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