improved live display with colors

Sat, 17 Dec 2011 15:12:19 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sat, 17 Dec 2011 15:12:19 +0100
changeset 93
ee4f9b8a36e9
parent 92
c57f43f25a5c
child 94
c7ff8cde6b1e

improved live display with colors

slotUI/SlotCli.py file | annotate | diff | comparison | revisions
--- a/slotUI/SlotCli.py	Sat Dec 17 14:37:55 2011 +0100
+++ b/slotUI/SlotCli.py	Sat Dec 17 15:12:19 2011 +0100
@@ -35,6 +35,10 @@
         "pitlane_enter":   os.path.abspath(SOUNDPREFIX + "sound/pitlane_enter.mp3"),
         "pitlane_exit":    os.path.abspath(SOUNDPREFIX + "sound/pitlane_exit.mp3"),
         "data_error":      os.path.abspath(SOUNDPREFIX + "sound/data_error.mp3"),
+        "panic":           os.path.abspath(SOUNDPREFIX + "sound/panic.mp3"),
+        "panic_shortcut":  os.path.abspath(SOUNDPREFIX + "sound/panic_shortcut.mp3"),
+        "resume":          os.path.abspath(SOUNDPREFIX + "sound/resume.mp3"),
+
     }
 
 def trigger_sound(what):
@@ -78,7 +82,7 @@
             slt["laps"] = 0
             slt["last"] = 0.00
             slt["best"] = 0.00
-            slt["fuel"] = 0
+            slt["fuel"] = 100
             slt["fuel_last"] = 0
             slt["position"] = idx
             slt["car"] = idx # used for sort order calculation
@@ -100,9 +104,14 @@
     def render_slots(self):
         self.update_positions()
         self.scr.addstr(3,0,
-            "Pos | #/Name            | Laps | Best     | Last     | Fuel | Status    ",
+            #"Pos | #/Name            | Laps | Best     | Last     | Fuel | Status    ",
+            "Pos | #/Name                                                            ",
+            curses.color_pair(2))
+        self.scr.addstr(4,4,
+            "  Laps | Best     | Last     | Fuel | Status                        ",
             curses.color_pair(2))
         for idx in range(MAXSLOTS):
+            """
             self.scr.addstr((3 + (self.slot[idx]["position"] * 2)), 0,
                 "%3i | %i %15s | %4i | %7.2fs | %7.2fs | %3i%% | %10s" % (
                 self.slot[idx]["position"],
@@ -112,7 +121,26 @@
                 self.slot[idx]["last"],
                 self.slot[idx]["fuel"],
                 self.slot[idx]["status"],
-                ) )
+                ),
+                curses.color_pair(11 + idx) )
+            """
+            self.scr.addstr((3 + (self.slot[idx]["position"] * 2)), 0,
+                "%3i | %i %15s %48s" % (
+                self.slot[idx]["position"],
+                self.slot[idx]["car"] + 1, self.slot[idx]["name"],
+                "",
+                ),
+                curses.color_pair(11 + idx) )
+            self.scr.addstr((4 + (self.slot[idx]["position"] * 2)), 4,
+                "  %4i | %7.2fs | %7.2fs | %3i%% | %10s %19s" % (
+                self.slot[idx]["laps"],
+                self.slot[idx]["best"],
+                self.slot[idx]["last"],
+                self.slot[idx]["fuel"],
+                self.slot[idx]["status"],
+                ""
+                ),
+                curses.color_pair(11 + idx) )
 
     def cleartop(self):
         self.scr.addstr(0,0, "%80s" % "Live monitor running, press keys to control or (q)uit")
@@ -154,6 +182,12 @@
         curses.start_color()
         curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) # standard text
         curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLUE) # label
+        curses.init_pair(11, curses.COLOR_BLACK, curses.COLOR_YELLOW) # player 1 slot
+        curses.init_pair(12, curses.COLOR_BLACK, curses.COLOR_GREEN) # player 2 slot
+        curses.init_pair(13, curses.COLOR_BLACK, curses.COLOR_RED) # player 3 slot
+        curses.init_pair(14, curses.COLOR_BLACK, curses.COLOR_MAGENTA) # player 4 slot
+        curses.init_pair(15, curses.COLOR_WHITE, curses.COLOR_BLACK) # player 5 slot
+        curses.init_pair(16, curses.COLOR_WHITE, curses.COLOR_BLACK) # player 6 slot
         curses.noecho() # disable key echo
         curses.cbreak() # do not buffer keypresses
         self.scr.keypad(1) # enable special keys
@@ -296,7 +330,7 @@
 
                     if rx == "!SHORTCUT":
                         # panic mode
-                        trigger_sound("panic_shortcircuit")
+                        trigger_sound("panic_shortcut")
 
                     if rx == "!RESUME":
                         # panic mode

mercurial