Skip to content

Commit

Permalink
Improvement to fs.sh window manager
Browse files Browse the repository at this point in the history
Don't clear screen before and after launching emulators
  • Loading branch information
10yard committed Jul 20, 2021
1 parent cf743dc commit 616a64f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
12 changes: 5 additions & 7 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def check_patches_available():
y_offset += 9
if y_offset > 220:
x_offset, y_offset = 120, 24
flash_message("ALL GOOD!", x=8, y=232, clear=False, cycles=4)
flash_message("ALL GOOD!", x=8, y=232, cycles=4, clear=False)
jump_to_continue()


Expand All @@ -103,7 +103,7 @@ def check_roms_available():

def jump_to_continue():
# Show Jump to continue message at foot of screen and wait for button press
flash_message("PRESS JUMP TO CONTINUE", x=8, y=242, clear=False, cycles=8)
flash_message("PRESS JUMP TO CONTINUE", x=8, y=242, cycles=8, clear=False)
while True:
check_for_input(force_exit=True)
if _g.jump or _g.start:
Expand All @@ -128,7 +128,7 @@ def write_text(text=None, font=pl_font, x=0, y=0, fg=WHITE, bg=None, bubble=Fals
pygame.draw.lines(_g.screen, fg, False, [(_x - 2, y + 2), (_x - 6, y + 3), (_x - 2, y + 4)], 1)


def flash_message(message, x, y, clear=True, bright=False, cycles=6, delay_ms=40):
def flash_message(message, x, y, bright=False, cycles=6, delay_ms=40, clear=True):
if clear:
clear_screen()
for i in (0, 1, 2) * cycles:
Expand Down Expand Up @@ -564,7 +564,7 @@ def save_menu_settings():
else:
f_out.write(line)
write_text(text=" Changes have been saved ", font=dk_font, x=0, y=232, fg=PINK, bg=RED)
update_screen(delay_ms=1000)
update_screen(delay_ms=750)


def set_basic(_, setting_value):
Expand Down Expand Up @@ -647,23 +647,21 @@ def launch_rom(info, override_emu=None):
if FREE_PLAY or BASIC_MODE or _g.score >= PLAY_COST:
_g.score = _g.score - (PLAY_COST, 0)[int(FREE_PLAY or BASIC_MODE)] # Deduct coins if not freeplay
play_sound_effect("sounds/coin.wav")
clear_screen()
if not competing and "-record" in launch_command:
flash_message("R E C O R D I N G", x=40, y=120) # Gameplay recording (i.e. Wolfmame)

clear_awarded_coin_status(_g.coins)
reset_all_inputs()
if os.path.exists(launch_directory):
os.chdir(launch_directory)
clear_screen()
if EMU_ENTER:
# Optional command to issue before launching the emulator
Popen(EMU_ENTER.replace("<ROOT>", ROOT_DIR), shell=False)
if EMU_EXIT:
# Optional command to issue when exiting emulator
launch_command += f"; {EMU_EXIT} "
os.system(launch_command)
clear_screen(and_reset_display=True)
# clear_screen(and_reset_display=True)
pygame.time.delay(50) # debounce
_g.lastexit = _g.timer.duration
os.chdir(ROOT_DIR)
Expand Down
18 changes: 11 additions & 7 deletions rpi4/fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
# DKAFE by Jon Wilson
# Switch to fullscreen when wmctrl detects MAME window.
# Use this line in your settings.txt to enable it i.e.
# EMU_ENTER = nohup ./fs.sh

DELAY=0.2
REPEATS=10
# EMU_ENTER = <ROOT>/fs.sh

i=0
while [ $i -lt $REPEATS ]
while [ $i -lt 20 ]
do
sleep $DELAY
wmctrl -a MAME: -b add,fullscreen
# Keep focus on DKAFE until MAME starts
wmctrl -Fa DKAFE
if wmctrl -l | grep -q MAME:; then
# Switch focus to MAME
sleep 0.25
wmctrl -a MAME: -b add,fullscreen
break
fi
sleep 0.1
i=$[$i+1]
done

0 comments on commit 616a64f

Please sign in to comment.