mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-22 03:04:09 -04:00
Pause game when showing options/game selection dialogs
This commit is contained in:
parent
bdd3093a2b
commit
5b31861364
3 changed files with 67 additions and 0 deletions
|
@ -780,7 +780,14 @@ class PysolMenubar(PysolMenubarTk):
|
|||
def mOptPlayerOptions(self, *args):
|
||||
if self._cancelDrag(break_pause=False):
|
||||
return
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
d = PlayerOptionsDialog(self.top, _("Set player options"), self.app)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
if d.status == 0 and d.button == 0:
|
||||
self.app.opt.confirm = bool(d.confirm)
|
||||
self.app.opt.update_player_stats = bool(d.update_stats)
|
||||
|
@ -797,7 +804,14 @@ class PysolMenubar(PysolMenubarTk):
|
|||
def mOptColors(self, *args):
|
||||
if self._cancelDrag(break_pause=False):
|
||||
return
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
d = ColorsDialog(self.top, _("Set colors"), self.app)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
text_color = self.app.opt.colors['text']
|
||||
if d.status == 0 and d.button == 0:
|
||||
self.app.opt.colors['text'] = d.text_color
|
||||
|
@ -815,7 +829,14 @@ class PysolMenubar(PysolMenubarTk):
|
|||
def mOptFonts(self, *args):
|
||||
if self._cancelDrag(break_pause=False):
|
||||
return
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
d = FontsDialog(self.top, _("Set fonts"), self.app)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
if d.status == 0 and d.button == 0:
|
||||
self.app.opt.fonts.update(d.fonts)
|
||||
self._cancelDrag()
|
||||
|
@ -825,7 +846,14 @@ class PysolMenubar(PysolMenubarTk):
|
|||
def mOptTimeouts(self, *args):
|
||||
if self._cancelDrag(break_pause=False):
|
||||
return
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
d = TimeoutsDialog(self.top, _("Set timeouts"), self.app)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
if d.status == 0 and d.button == 0:
|
||||
self.app.opt.timeouts['demo'] = d.demo_timeout
|
||||
self.app.opt.timeouts['hint'] = d.hint_timeout
|
||||
|
|
|
@ -971,9 +971,16 @@ class Application:
|
|||
'correct_type': t[0]}, strings=(_("&OK"),), default=0)
|
||||
|
||||
def selectCardset(self, title, key):
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
d = SelectCardsetDialogWithPreview(
|
||||
self.top, title=title, app=self,
|
||||
manager=self.cardset_manager, key=key)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
cs = self.cardset_manager.get(d.key)
|
||||
if d.status != 0 or d.button != 0 or d.key < 0 or cs is None:
|
||||
return None
|
||||
|
|
|
@ -279,6 +279,9 @@ class PysolMenubarTkCommon:
|
|||
self._createMenubar()
|
||||
self.top = top
|
||||
|
||||
# Sometimes, this needs to be tracked between methods
|
||||
self.wasPaused = False
|
||||
|
||||
if self.progress:
|
||||
self.progress.update(step=1)
|
||||
|
||||
|
@ -1251,6 +1254,10 @@ class PysolMenubarTkCommon:
|
|||
self.tkopt.gameid_popular.set(self.game.id)
|
||||
|
||||
def _mSelectGameDialog(self, d):
|
||||
if self.game.pause:
|
||||
if self.wasPaused:
|
||||
self.game.resizeGame()
|
||||
self.game.doPause()
|
||||
if d.status == 0 and d.button == 0 and d.gameid != self.game.id:
|
||||
self.tkopt.gameid.set(d.gameid)
|
||||
self.tkopt.gameid_popular.set(d.gameid)
|
||||
|
@ -1287,6 +1294,10 @@ class PysolMenubarTkCommon:
|
|||
bookmark = self.game.gsaveinfo.bookmarks[-2][0]
|
||||
del self.game.gsaveinfo.bookmarks[-2]
|
||||
after_idle(self.top, self.__restoreCursor)
|
||||
self.wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
self.wasPaused = True
|
||||
d = self._calcSelectGameDialogWithPreview()(
|
||||
self.top, title=_("Select game"),
|
||||
app=self.app, gameid=self.game.id,
|
||||
|
@ -1594,8 +1605,15 @@ Unsupported game for import.
|
|||
def mOptSoundDialog(self, *args):
|
||||
if self._cancelDrag(break_pause=False):
|
||||
return
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
self._calcSoundOptionsDialog()(
|
||||
self.top, _("Sound settings"), self.app)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
self.tkopt.sound.set(self.app.opt.sound)
|
||||
|
||||
def mOptAutoFaceUp(self, *args):
|
||||
|
@ -1935,11 +1953,18 @@ Unsupported game for import.
|
|||
key = self.app.tabletile_index
|
||||
if key <= 0:
|
||||
key = self.app.opt.colors['table'] # .lower()
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
d = self._calcSelectTileDialogWithPreview()(
|
||||
self.top, app=self.app,
|
||||
title=_("Select table background"),
|
||||
manager=self.app.tabletile_manager,
|
||||
key=key)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
if d.status == 0 and d.button == 0:
|
||||
if isinstance(d.key, str):
|
||||
tile = self.app.tabletile_manager.get(0)
|
||||
|
@ -2169,6 +2194,10 @@ Unsupported game for import.
|
|||
self.game.quitGame(bookmark=1)
|
||||
|
||||
def wizardDialog(self, edit=False):
|
||||
wasPaused = False
|
||||
if not self.game.pause:
|
||||
self.game.doPause()
|
||||
wasPaused = True
|
||||
from pysollib.wizardutil import write_game, reset_wizard
|
||||
WizardDialog = self._calcWizardDialog()
|
||||
|
||||
|
@ -2177,6 +2206,9 @@ Unsupported game for import.
|
|||
else:
|
||||
reset_wizard(None)
|
||||
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
||||
if self.game.pause:
|
||||
if wasPaused:
|
||||
self.game.doPause()
|
||||
if d.status == 0 and d.button == 0:
|
||||
try:
|
||||
if edit:
|
||||
|
|
Loading…
Add table
Reference in a new issue