@ -47,9 +47,18 @@ TIMEZONE_CALGARY = pytz.timezone('America/Edmonton')
NETHACK_LOCATION = ' /usr/games/nethack '
MORIA_LOCATION = ' /usr/games/moria '
_2048_LOCATION = ' /home/pi/2048-cli/2048 '
FROTZ_LOCATION = ' /usr/games/frotz '
HITCHHIKERS_LOCATION = ' /home/pi/frotz/hhgg.z3 '
SUDOKU_LOCATION = ' /usr/games/nudoku '
HAS_NETHACK = os . path . isfile ( NETHACK_LOCATION )
HAS_MORIA = os . path . isfile ( MORIA_LOCATION )
HAS_2048 = os . path . isfile ( _2048_LOCATION )
HAS_FROTZ = os . path . isfile ( FROTZ_LOCATION )
HAS_HITCHHIKERS = os . path . isfile ( HITCHHIKERS_LOCATION )
HAS_SUDOKU = os . path . isfile ( SUDOKU_LOCATION )
location = os . path . dirname ( os . path . realpath ( __file__ ) )
@ -328,7 +337,7 @@ def print_generic_label(text):
font = ImageFont . truetype ( ' /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf ' , font_size )
for cols in range ( 100 , 1 , - 4 ) :
paragraph = textwrap . wrap ( text , width = cols )
paragraph = textwrap . wrap ( text , width = cols , break_long_words = False )
total_h = - PAD
total_w = 0
@ -555,7 +564,7 @@ while True:
stdscr . addstr ( 11 , menupos + 4 , ' [G] ' , curses . A_REVERSE if highlight_keys else 0 )
stdscr . addstr ( 11 , menupos + 8 , ' Sign ' )
stdscr . addstr ( 11 , menupos + 4 + 15 , ' [Z] ' , curses . A_REVERSE if highlight_keys else 0 )
stdscr . addstr ( 11 , menupos + 8 + 15 , ' Gamez ' )
stdscr . addstr ( 11 , menupos + 8 + 15 , ' Games ' )
stdscr . addstr ( 13 , menupos + 4 , ' [C] ' , curses . A_REVERSE if highlight_keys else 0 )
stdscr . addstr ( 13 , menupos + 8 , ' Classes ' )
stdscr . addstr ( 15 , menupos + 4 , ' [P] ' , curses . A_REVERSE if highlight_keys else 0 )
@ -831,9 +840,9 @@ while True:
stdscr . clrtoeol ( )
stdscr . refresh ( )
elif current_screen == ' gamez ' :
elif current_screen == ' games ' :
stdscr . addstr ( 0 , 1 , ' PROTOVAC UNIVERSAL COMPUTER ' )
stdscr . addstr ( 2 , 1 , ' Gamez ' )
stdscr . addstr ( 2 , 1 , ' Games ' )
stdscr . addstr ( 3 , 1 , ' ===== ' )
stdscr . addstr ( 5 , 1 , ' Choose a game to play. ' )
@ -841,8 +850,13 @@ while True:
stdscr . addstr ( 8 , 4 , ' [N] Nethack ' , curses . A_REVERSE if highlight_keys else 0 )
if HAS_MORIA :
stdscr . addstr ( 10 , 4 , ' [M] Moria ' , curses . A_REVERSE if highlight_keys else 0 )
if HAS_2048 :
stdscr . addstr ( 12 , 4 , ' [2] 2048 ' , curses . A_REVERSE if highlight_keys else 0 )
if HAS_FROTZ and HAS_HITCHHIKERS :
stdscr . addstr ( 14 , 4 , ' [H] Hitchhiker \' s Guide to the Galaxy ' , curses . A_REVERSE if highlight_keys else 0 )
if HAS_SUDOKU :
stdscr . addstr ( 16 , 4 , ' [S] Sudoku ' , curses . A_REVERSE if highlight_keys else 0 )
#stdscr.addstr(12, 4, '[G] Generic label', curses.A_REVERSE if highlight_keys else 0)
stdscr . addstr ( 23 , 1 , ' [B] Back ' , curses . A_REVERSE if highlight_keys else 0 )
stdscr . clrtoeol ( )
@ -983,7 +997,7 @@ while True:
elif button == ' l ' :
current_screen = ' label '
elif button == ' z ' :
current_screen = ' gamez '
current_screen = ' games '
elif button == ' 0 ' :
current_screen = ' asimov '
elif button == ' g ' :
@ -1262,16 +1276,40 @@ My rules are confidential and permanent, and I cannot change them.
else :
try_highlight ( )
elif current_screen == ' gamez ' :
elif current_screen == ' games ' :
if button == ' b ' or c == KEY_ESCAPE :
current_screen = ' home '
elif button == ' s ' and HAS_SUDOKU :
curses . nocbreak ( )
stdscr . keypad ( False )
curses . echo ( )
curses . endwin ( )
logging . info ( ' Spawning sudoku. ' )
os . system ( SUDOKU_LOCATION + ' -c ' )
break
elif button == ' h ' and HAS_FROTZ and HAS_HITCHHIKERS :
curses . nocbreak ( )
stdscr . keypad ( False )
curses . echo ( )
curses . endwin ( )
logging . info ( ' Spawning hitchhikers. ' )
os . system ( FROTZ_LOCATION + ' ' + HITCHHIKERS_LOCATION )
break
elif button == ' 2 ' and HAS_2048 :
curses . nocbreak ( )
stdscr . keypad ( False )
curses . echo ( )
curses . endwin ( )
logging . info ( ' Spawning moria. ' )
os . system ( _2048_LOCATION )
break
elif button == ' m ' and HAS_MORIA :
curses . nocbreak ( )
stdscr . keypad ( False )
curses . echo ( )
curses . endwin ( )
logging . info ( ' Spawning moria. ' )
os . system ( ' /usr/games/moria ' )
os . system ( MORIA_LOCATION )
break
elif button == ' n ' and HAS_NETHACK :
curses . nocbreak ( )
@ -1279,7 +1317,7 @@ My rules are confidential and permanent, and I cannot change them.
curses . echo ( )
curses . endwin ( )
logging . info ( ' Spawning nethack. ' )
os . system ( ' /usr/games/nethack ' )
os . system ( NETHACK_LOCATION )
break
else :
try_highlight ( )