From fb46f504c7f12941360d14a661a1122a0d9c618d Mon Sep 17 00:00:00 2001 From: Pio Date: Sun, 11 Nov 2018 23:06:43 +0100 Subject: [PATCH] Ensure playfield window is restored after menu, help and especially aborted loading. --- gbg.bas | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/gbg.bas b/gbg.bas index b8a697a..3385a05 100644 --- a/gbg.bas +++ b/gbg.bas @@ -701,6 +701,17 @@ Sub quit() End Sub +Sub openwindow(s As Sub) + Dim As Integer w,h + ScreenInfo(w,h) + + s() + + ScreenRes w,h,16,2',&h08 + drawplayfield() +End Sub + + Function openloader(directory As String) As String ScreenRes 300,150,16,1',&h08 @@ -736,9 +747,6 @@ End Function Sub openhelp() - Dim As Integer w,h - ScreenInfo(w,h) - ScreenRes 300,150,16,1',&h08 Print "Help for " + title @@ -753,8 +761,6 @@ Sub openhelp() Do keypress=InKey Loop Until keypress <> "" - ScreenRes w,h,16,2',&h08 - drawplayfield() End Sub @@ -762,9 +768,6 @@ Sub openmenu() Dim e As EVENT Dim As Integer x, y, pressed - Dim As Integer w,h - ScreenInfo(w,h) - Dim menuimg As Any Ptr ScreenRes 150,150,16,1',&h08 menuimg = ImageCreate(150,150) @@ -820,7 +823,7 @@ Sub openmenu() ImageDestroy(menuimg) Exit Sub Case chr(255)+";" 'F1 - openhelp() + openwindow(@openhelp) Case chr(255)+"<" 'F2 gameRestart() Exit Do @@ -833,9 +836,6 @@ Sub openmenu() Loop Until keypress <> "" ImageDestroy(menuimg) - - ScreenRes w,h,16,2',&h08 - drawplayfield() End Sub Sub windowmouse @@ -846,7 +846,7 @@ Sub windowmouse Select Case e.type Case EVENT_MOUSE_BUTTON_PRESS pressed = e.button=1 - If e.button=2 Then openmenu() + If e.button=2 Then openwindow(@openmenu) Case EVENT_MOUSE_BUTTON_RELEASE pressed = 0 Case EVENT_MOUSE_MOVE @@ -946,14 +946,15 @@ do togglescore() ElseIf keypress="l" Or keypress="L" then 'load loadgame(openloader(VARPATH)) + loadTiles(0) 'restore resolution ElseIf keypress=chr(255)+";" then 'F1 - openhelp() + openwindow(@openhelp) ElseIf keypress=chr(255)+"<" then 'F2 gameRestart() ElseIf keypress="+" Then 'speed+ speed=speed/1.5 ElseIf keypress=chr(27) Then 'Esc - openmenu() + openwindow(@openmenu) EndIf if gravity And timer-tim>speed then speed=speed/1.003 -- 2.11.4.GIT