Abfragedialog J/N eingebaut. Für Rennabbruch Tracker.
This commit is contained in:
parent
bcbaa25cf5
commit
84a99a747e
Binary file not shown.
After Width: | Height: | Size: 233 B |
|
@ -84,6 +84,7 @@ class Page():
|
|||
self.sym_lock = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "lock.png"))
|
||||
self.sym_swipe = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "swipe3.png"))
|
||||
self.sym_exclamation = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "exclamation.png"))
|
||||
self.sym_question = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "question.png"))
|
||||
self.buttonlabel = {
|
||||
1: '',
|
||||
2: '',
|
||||
|
@ -229,6 +230,46 @@ class Page():
|
|||
ctx.show_text(text)
|
||||
ctx.stroke()
|
||||
|
||||
def draw_query(self, ctx, title, message):
|
||||
x, y, w, h = (50, 80, 300, 150)
|
||||
ctx.save()
|
||||
ctx.select_font_face("AtariST8x16SystemFont")
|
||||
ctx.set_font_size(16)
|
||||
# Dialogbox mit Rahmen
|
||||
ctx.set_line_width(1)
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ctx.rectangle(x + 0.5, y + 0.5, w, h)
|
||||
ctx.stroke()
|
||||
ctx.set_source_rgb(*self.bgcolor)
|
||||
ctx.rectangle(x + 1, y + 1, w - 1, h - 1)
|
||||
ctx.fill()
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ctx.set_line_width(2)
|
||||
ctx.rectangle(x + 3, y + 3, w - 5, h - 5)
|
||||
ctx.clip_preserve()
|
||||
ctx.stroke()
|
||||
# Symbol
|
||||
ctx.save()
|
||||
ctx.set_source_surface(self.sym_question, x + 16, y + 16)
|
||||
ctx.paint()
|
||||
ctx.restore()
|
||||
# Titel
|
||||
ctx.move_to(x + 64, y + 30)
|
||||
ctx.show_text(title)
|
||||
ctx.move_to(x + 64, y + 48)
|
||||
# Meldung, umgebrochen
|
||||
n = 0
|
||||
for l in wordwrap(message, (w - 16 - 8) / 8):
|
||||
ctx.move_to(x + 16, y + 70 + n)
|
||||
ctx.show_text(l)
|
||||
n += 16
|
||||
if n > 64:
|
||||
break
|
||||
# Auswahlmöglichkeiten
|
||||
self.draw_button(ctx, x + 16, y + h - 32, "YES")
|
||||
self.draw_button(ctx, x + w - 96, y + h - 32, "NO")
|
||||
ctx.restore()
|
||||
|
||||
def draw_alarm(self, ctx, source, alarmid, message):
|
||||
x, y, w, h = (50, 100, 300, 150)
|
||||
ctx.select_font_face("AtariST8x16SystemFont")
|
||||
|
@ -360,6 +401,21 @@ class Page():
|
|||
ctx.stroke()
|
||||
ctx.restore()
|
||||
|
||||
def draw_button(self, ctx, x, y, label):
|
||||
ctx.save()
|
||||
ctx.select_font_face("AtariST8x16SystemFont")
|
||||
ctx.set_font_size(16)
|
||||
ctx.set_line_width(3)
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ext = ctx.text_extents(label)
|
||||
w = max(ext.width, 80)
|
||||
h = 24
|
||||
ctx.rectangle(x + 0.5, y + 0.5, w, h)
|
||||
ctx.stroke()
|
||||
ctx.move_to(x + (w - ext.width) / 2.0, y + h - 5)
|
||||
ctx.show_text(label)
|
||||
ctx.restore()
|
||||
|
||||
def wordwrap(text, wrap):
|
||||
# Wrap long line to multiple lines, monospaced character set
|
||||
# e.g. used for alarm dialog boxes
|
||||
|
|
|
@ -39,6 +39,8 @@ class RaceTracker(Page):
|
|||
self.buttonlabel[2] = 'INFO'
|
||||
self.buttonlabel[5] = 'ABORT'
|
||||
self.mode = 'N' # (N)ormal, (C)onfiguration, (M)itteilung
|
||||
self.query_active = False
|
||||
self.savebuttons = None
|
||||
|
||||
# Flaggengröße: 96 x 64 Pixel
|
||||
self.flagpos = ((208, 140), (308, 140), (208, 210), (308, 210))
|
||||
|
@ -74,6 +76,15 @@ class RaceTracker(Page):
|
|||
self.sym_flag[f] = cairo.ImageSurface.create_from_png(flagfile)
|
||||
|
||||
def handle_key(self, buttonid):
|
||||
if self.query_active:
|
||||
if buttonid == 2:
|
||||
self.query_active = False
|
||||
self.app.track.hero_giveup()
|
||||
self.buttonlabel = self.savebuttons.copy()
|
||||
elif buttonid == 5:
|
||||
self.query_active = False
|
||||
self.buttonlabel = self.savebuttons.copy()
|
||||
return True
|
||||
if buttonid == 1:
|
||||
# Modus umschalten
|
||||
if self.mode == 'N':
|
||||
|
@ -122,7 +133,17 @@ class RaceTracker(Page):
|
|||
print(f"Selected race '{self.raceid}'")
|
||||
return True
|
||||
elif buttonid == 5:
|
||||
if self.mode == 'C':
|
||||
if self.mode == 'N':
|
||||
self.query_active = True;
|
||||
self.savebuttons = self.buttonlabel.copy()
|
||||
self.buttonlabel[1] = ""
|
||||
self.buttonlabel[2] = "YES"
|
||||
self.buttonlabel[3] = ""
|
||||
self.buttonlabel[4] = ""
|
||||
self.buttonlabel[5] = "NO"
|
||||
self.buttonlabel[6] = ""
|
||||
# Taste 2 = JA, Taste 5 = NEIN
|
||||
elif self.mode == 'C':
|
||||
# Tracking ein/-ausschalten
|
||||
if self.app.track.is_active():
|
||||
self.app.track.set_active(False)
|
||||
|
@ -220,6 +241,8 @@ class RaceTracker(Page):
|
|||
ctx.paint()
|
||||
ctx.restore()
|
||||
pos += 1
|
||||
if self.query_active:
|
||||
self.draw_query(ctx, "A B O R T R A C E", "Are you sure to abort the current race? This cannot be undone. Are you sure?")
|
||||
|
||||
|
||||
def draw_config(self, ctx):
|
||||
|
|
|
@ -93,6 +93,7 @@ class Tracker():
|
|||
self.hero_orgstatus = None
|
||||
self.hero_racestatus = None
|
||||
self.hero_timedelta = 0 # Zeitdifferenz zum Server in sec
|
||||
self.hero_givenup = False
|
||||
|
||||
# Hole erste Daten vom Server
|
||||
self.hero_query_org()
|
||||
|
@ -166,6 +167,12 @@ class Tracker():
|
|||
|
||||
"""
|
||||
|
||||
def hero_giveup(self):
|
||||
# TODO nach Aufgabe noch ein paar Pakete senden bis dier
|
||||
# Tracker dann abgestellt wird.
|
||||
self.hero_givenup = True
|
||||
|
||||
|
||||
def hero_play_audio(self, event, lang='de'):
|
||||
"""
|
||||
Ein Event ist mit einer Audiodatei gekoppelt. Das Event trägt
|
||||
|
|
Loading…
Reference in New Issue