Skip to content

Commit

Permalink
The way window is resized was changed as it was reloading the screen …
Browse files Browse the repository at this point in the history
…every frame whilst resizing which proved problematic on some systems.
  • Loading branch information
imiolek-ireneusz committed Nov 17, 2020
1 parent 91a3ea1 commit a41c84e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion classes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, android):
self.fs_height = 768
self.debug_screen_size = None # [900,600]
# size_limits - don't let window resizing get out of hand [min_w, min_h, max_w, max_h]
self.size_limits = [838, 570, 2000, 2000]
self.size_limits = [838, 570, 4000, 2000]
# [670,480,2000,2000] #800 - minimum to fit all buttons, 2000 - with over 2000 pixels each way pygame is not redrawing very well
# set total size of OS panels and window decorations on both sides - used in windowed version. Not so much important now with resizing enabled.
# this will not be auto-detected
Expand Down
2 changes: 1 addition & 1 deletion classes/cversion.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ver = "4.20.08"
ver = "4.20.11"
31 changes: 27 additions & 4 deletions eduactiv8.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,17 @@ def run(self):
icon = pygame.image.load(os.path.join('res', 'icon', 'ico256.png'))
pygame.display.set_icon(icon)

new_size = self.size[:]
resizing = False
frames_since_resize = 0

# -------- Main Program Loop ----------- #
wait = False
while self.done is False:
# uncomment the following line to test all activities across multiple languages as specified in the stresstest.py
# stresstest.step(self)

resizing_this_frame = False
if android is not None:
if android.check_pause():
wait = True
Expand Down Expand Up @@ -498,13 +504,20 @@ def run(self):
for event in pygame.event.get():
if event.type == pygame.QUIT or (
event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
self.dialog.show_dialog(0, self.lang.d["Do you want to exit the game?"])
self.done = True
self.done4good = True
# don't show dialog if closing with window manager or ESC
# self.dialog.show_dialog(0, self.lang.d["Do you want to exit the game?"])
elif event.type == pygame.VIDEORESIZE:
if not self.config.fullscreen:
self.on_resize(list(event.size), info)
new_size = list(event.size)
resizing = True
resizing_this_frame = True
elif event.type == pygame.KEYDOWN and event.key == pygame.K_f and (
event.mod & pygame.KMOD_LCTRL):
self.fullscreen_toggle(info)
# eduActiv8 crashes in fullscreen mode in pygame 2 so temporarily not available
if pygame.version.vernum[0] < 2:
self.fullscreen_toggle(info)
elif event.type == pygame.KEYDOWN and event.key == pygame.K_F5: # refresh - reload level
self.game_board.level.load_level()
elif event.type == pygame.KEYDOWN and event.key == pygame.K_F8:
Expand Down Expand Up @@ -577,9 +590,19 @@ def run(self):
else:
# let the game handle other events
self.game_board.handle(event)
if resizing:
# changed the window resizing behaviour:
# only resize contents 15 frames after the user stopped resizing
if not resizing_this_frame:
frames_since_resize += 1
if frames_since_resize > 15:
self.on_resize(new_size, info)
resizing = False
frames_since_resize = 0
else:
frames_since_resize = 0

# checking if any of the subsurfaces need updating and updating them if needed

if self.redraw_needed[1]:
info.draw(self.info_bar)
self.redraw_needed[1] = False
Expand Down

0 comments on commit a41c84e

Please sign in to comment.