From 02e62afb164516229b7ab422e039d12eb3207113 Mon Sep 17 00:00:00 2001 From: Joe R Date: Thu, 28 Jul 2022 18:56:41 -0400 Subject: [PATCH] Stuck notification option. --- po/de_pysol.po | 16 +++++++++++++++- po/fr_pysol.po | 16 +++++++++++++++- po/it_pysol.po | 16 +++++++++++++++- po/pl_pysol.po | 16 +++++++++++++++- po/pysol.pot | 14 ++++++++++++++ po/ru_pysol.po | 16 +++++++++++++++- pysollib/game/__init__.py | 23 +++++++++++++++++++++++ pysollib/games/special/lightsout.py | 1 + pysollib/kivy/menubar.py | 13 +++++++++++++ pysollib/options.py | 3 +++ pysollib/ui/tktile/menubar.py | 12 ++++++++++++ 11 files changed, 141 insertions(+), 5 deletions(-) diff --git a/po/de_pysol.po b/po/de_pysol.po index 14669003..f8a57fae 100644 --- a/po/de_pysol.po +++ b/po/de_pysol.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: PySol 0.0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-07-17 09:21-0400\n" +"PO-Revision-Date: 2022-07-28 18:52-0400\n" "Last-Translator: H. Schaekel \n" "Language-Team: German\n" "Language: de\n" @@ -1964,6 +1964,14 @@ msgid "" "Game finished, but not without my help...\n" msgstr "" +msgid "You are Stuck" +msgstr "" + +msgid "" +"\n" +"There are no moves left...\n" +msgstr "" + #: pysollib/game/__init__.py:2046 msgid "&Restart" msgstr "Neusta&rt" @@ -2445,6 +2453,9 @@ msgstr "Gleichen Rang hervorheben" msgid "Highlight no matching" msgstr "Nicht passende hervorheben" +msgid "Stuck notification" +msgstr "" + #: pysollib/kivy/menubar.py:583 msgid "Show removed tiles (in Mahjongg games)" msgstr "Zeige entfernte Steine (in Mahjongg)" @@ -4829,6 +4840,9 @@ msgstr "Gleichen Rang hervorheben:" msgid "Highlight &no matching" msgstr "Keine passenden hervorheben:" +msgid "Stuc&k notification" +msgstr "" + #: pysollib/ui/tktile/menubar.py:508 msgid "&Show removed tiles (in Mahjongg games)" msgstr "" diff --git a/po/fr_pysol.po b/po/fr_pysol.po index 3ecf1486..be46f4df 100644 --- a/po/fr_pysol.po +++ b/po/fr_pysol.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: 1.02\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-07-17 09:19-0400\n" +"PO-Revision-Date: 2022-07-28 18:52-0400\n" "Last-Translator: Eric Rausch \n" "Language-Team: French\n" "Language: fr\n" @@ -1996,6 +1996,14 @@ msgstr "" "\n" "Jeu terminé, mais pas sans mon aide...\n" +msgid "You are Stuck" +msgstr "" + +msgid "" +"\n" +"There are no moves left...\n" +msgstr "" + #: pysollib/game/__init__.py:2046 msgid "&Restart" msgstr "&Redémarrer" @@ -2487,6 +2495,9 @@ msgstr "Surbrillance des équivalents" msgid "Highlight no matching" msgstr "Surbrillance sans correspondance" +msgid "Stuck notification" +msgstr "" + #: pysollib/kivy/menubar.py:583 msgid "Show removed tiles (in Mahjongg games)" msgstr "Montrer tuiles retirées (Mahjongg)" @@ -4874,6 +4885,9 @@ msgstr "Surbrillance des &équivalents" msgid "Highlight &no matching" msgstr "Surbrilla&nce incorrectes" +msgid "Stuc&k notification" +msgstr "" + #: pysollib/ui/tktile/menubar.py:508 msgid "&Show removed tiles (in Mahjongg games)" msgstr "Montrer tuiles retirées (Mahjongg)" diff --git a/po/it_pysol.po b/po/it_pysol.po index 01074655..9049fd63 100644 --- a/po/it_pysol.po +++ b/po/it_pysol.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: it_pysol\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-07-17 09:19-0400\n" +"PO-Revision-Date: 2022-07-28 18:52-0400\n" "Last-Translator: Giuliano Colla \n" "Language-Team: Italiano \n" "Language: it\n" @@ -2004,6 +2004,14 @@ msgstr "" "\n" "Gioco terminato, ma non senza il mio aiuto...\n" +msgid "You are Stuck" +msgstr "" + +msgid "" +"\n" +"There are no moves left...\n" +msgstr "" + #: pysollib/game/__init__.py:2046 msgid "&Restart" msgstr "&Ricomincia" @@ -2504,6 +2512,9 @@ msgstr "Abilita evidenzia stesso valo&re" msgid "Highlight no matching" msgstr "Abilita non corrispondenti" +msgid "Stuck notification" +msgstr "" + #: pysollib/kivy/menubar.py:583 #, fuzzy msgid "Show removed tiles (in Mahjongg games)" @@ -4940,6 +4951,9 @@ msgstr "Abilita evidenzia stesso valo&re" msgid "Highlight &no matching" msgstr "Abilita non corrispondenti" +msgid "Stuc&k notification" +msgstr "" + #: pysollib/ui/tktile/menubar.py:508 msgid "&Show removed tiles (in Mahjongg games)" msgstr "Mo&stra tessere tolte (in Mahjongg)" diff --git a/po/pl_pysol.po b/po/pl_pysol.po index 85e9fd10..5cd150dc 100644 --- a/po/pl_pysol.po +++ b/po/pl_pysol.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-07-17 09:19-0400\n" +"PO-Revision-Date: 2022-07-28 18:53-0400\n" "Last-Translator: Jerzy Trzeciak \n" "Language-Team: Polish \n" "Language: pl\n" @@ -2017,6 +2017,14 @@ msgstr "" "\n" "Gra zakończona, ale nie bez mojej pomocy...\n" +msgid "You are Stuck" +msgstr "" + +msgid "" +"\n" +"There are no moves left...\n" +msgstr "" + #: pysollib/game/__init__.py:2046 msgid "&Restart" msgstr "U&ruchom ponownie" @@ -2541,6 +2549,9 @@ msgstr "Podświetlaj karty o jednakowej sile" msgid "Highlight no matching" msgstr "Podświetlaj brak dopasowa&nia" +msgid "Stuck notification" +msgstr "" + #: pysollib/kivy/menubar.py:583 #, fuzzy msgid "Show removed tiles (in Mahjongg games)" @@ -5000,6 +5011,9 @@ msgstr "Podświetlaj karty o jednakowej sile" msgid "Highlight &no matching" msgstr "Podświetlaj brak dopasowa&nia" +msgid "Stuc&k notification" +msgstr "" + #: pysollib/ui/tktile/menubar.py:508 msgid "&Show removed tiles (in Mahjongg games)" msgstr "Pokaż u&sunięte klocki (w grach Mahjongg)" diff --git a/po/pysol.pot b/po/pysol.pot index 41e6527c..e488497a 100644 --- a/po/pysol.pot +++ b/po/pysol.pot @@ -1870,6 +1870,14 @@ msgid "" "Game finished, but not without my help...\n" msgstr "" +msgid "You are Stuck" +msgstr "" + +msgid "" +"\n" +"There are no moves left...\n" +msgstr "" + #: pysollib/game/__init__.py:2046 msgid "&Restart" msgstr "" @@ -2322,6 +2330,9 @@ msgstr "" msgid "Highlight no matching" msgstr "" +msgid "Stuck notification" +msgstr "" + #: pysollib/kivy/menubar.py:583 msgid "Show removed tiles (in Mahjongg games)" msgstr "" @@ -4629,6 +4640,9 @@ msgstr "" msgid "Highlight &no matching" msgstr "" +msgid "Stuc&k notification" +msgstr "" + #: pysollib/ui/tktile/menubar.py:508 msgid "&Show removed tiles (in Mahjongg games)" msgstr "" diff --git a/po/ru_pysol.po b/po/ru_pysol.po index 8086bdc6..b074c26e 100644 --- a/po/ru_pysol.po +++ b/po/ru_pysol.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-10 10:19-0500\n" -"PO-Revision-Date: 2022-07-17 09:18-0400\n" +"PO-Revision-Date: 2022-07-28 18:53-0400\n" "Last-Translator: Skomoroh \n" "Language-Team: Russian \n" "Language: ru\n" @@ -2003,6 +2003,14 @@ msgstr "" "\n" "Игра закончена, но не без моей помощи...\n" +msgid "You are Stuck" +msgstr "" + +msgid "" +"\n" +"There are no moves left...\n" +msgstr "" + #: pysollib/game/__init__.py:2046 msgid "&Restart" msgstr "&Начало" @@ -2517,6 +2525,9 @@ msgstr "Разрешить показывать карты &одного дос msgid "Highlight no matching" msgstr "Подсветка отсутствия &совпадения" +msgid "Stuck notification" +msgstr "" + #: pysollib/kivy/menubar.py:583 #, fuzzy msgid "Show removed tiles (in Mahjongg games)" @@ -4964,6 +4975,9 @@ msgstr "Разрешить показывать карты &одного дос msgid "Highlight &no matching" msgstr "Подсветка отсутствия &совпадения" +msgid "Stuc&k notification" +msgstr "" + #: pysollib/ui/tktile/menubar.py:508 msgid "&Show removed tiles (in Mahjongg games)" msgstr "Показывать удалённые (в Маджонг)" diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index 929757db..5f1ae9a2 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -517,6 +517,7 @@ class Game(object): self.busy = 0 self.pause = False self.finished = False + self.stuck = False self.version = VERSION self.version_tuple = VERSION_TUPLE self.cards = [] @@ -780,6 +781,7 @@ class Game(object): def newGame(self, random=None, restart=0, autoplay=1, shuffle=True, dealer=None): self.finished = False + self.stuck = False old_busy, self.busy = self.busy, 1 self.setCursor(cursor=CURSOR_WATCH) self.stopWinAnimation() @@ -2855,8 +2857,29 @@ class Game(object): return if self.getStuck(): text = '' + self.stuck = False else: text = 'x' + if (not self.stuck and not self.demo and + self.app.opt.stuck_notification): + self.playSample("gamelost", priority=1000) + self.updateStatus(stuck='x') + d = MfxMessageDialog( + self.top, title=_("You are Stuck"), bitmap="info", + text=_("\nThere are no moves left...\n"), + strings=(_("&New game"), _("&Restart"), None, + _("&Cancel"))) + if TOOLKIT != 'kivy': + if d.status == 0 and d.button == 0: + # new game + self.endGame() + self.newGame() + return + elif d.status == 0 and d.button == 1: + # restart game + self.restartGame() + return + self.stuck = True # self.playSample("autopilotlost", priority=1000) self.updateStatus(stuck=text) diff --git a/pysollib/games/special/lightsout.py b/pysollib/games/special/lightsout.py index 32b18178..8e418f4c 100644 --- a/pysollib/games/special/lightsout.py +++ b/pysollib/games/special/lightsout.py @@ -114,6 +114,7 @@ class LightsOut_Talon(InitialDealTalonStack): # ************************************************************************ class LightsOut(Game): + Hint_Class = None # # Game layout diff --git a/pysollib/kivy/menubar.py b/pysollib/kivy/menubar.py index 6332c54a..f721a3ad 100644 --- a/pysollib/kivy/menubar.py +++ b/pysollib/kivy/menubar.py @@ -582,6 +582,11 @@ class OptionsMenuDialog(LMenuDialog): self.menubar.tkopt.highlight_not_matching, self.menubar.mOptEnableHighlightNotMatching) + self.addCheckNode(tv, rg, + _('Stuck notification'), + self.menubar.tkopt.stuck_notification, + self.menubar.mOptEnableStuckNotification) + # submenu.add_separator() self.addCheckNode(tv, rg, @@ -1261,6 +1266,7 @@ class PysolMenubarTk: highlight_cards=BooleanVar(), highlight_samerank=BooleanVar(), highlight_not_matching=BooleanVar(), + stuck_notification=BooleanVar(), mahjongg_show_removed=BooleanVar(), shisen_show_hint=BooleanVar(), accordion_deal_all=BooleanVar(), @@ -1323,6 +1329,7 @@ class PysolMenubarTk: tkopt.highlight_cards.set(opt.highlight_cards) tkopt.highlight_samerank.set(opt.highlight_samerank) tkopt.highlight_not_matching.set(opt.highlight_not_matching) + tkopt.stuck_notification.set(opt.stuck_notification) tkopt.shrink_face_down.set(opt.shrink_face_down) tkopt.shade_filled_stacks.set(opt.shade_filled_stacks) tkopt.mahjongg_show_removed.set(opt.mahjongg_show_removed) @@ -2071,6 +2078,12 @@ the next time you restart the %(app)s""") % {'app': TITLE}) self.tkopt.highlight_not_matching.get() # self.game.updateMenus() + def mOptEnableStuckNotification(self, *args): + if self._cancelDrag(break_pause=False): + return + self.app.opt.stuck_notification = self.tkopt.stuck_notification.get() + # self.game.updateMenus() + def mOptAnimations(self, *args): if self._cancelDrag(break_pause=False): return diff --git a/pysollib/options.py b/pysollib/options.py index 34595ceb..d9438cc5 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -77,6 +77,7 @@ highlight_piles = boolean highlight_cards = boolean highlight_samerank = boolean highlight_not_matching = boolean +stuck_notification = boolean mahjongg_show_removed = boolean mahjongg_create_solvable = integer(0, 2) shisen_show_hint = boolean @@ -227,6 +228,7 @@ class Options: ('highlight_cards', 'bool'), ('highlight_samerank', 'bool'), ('highlight_not_matching', 'bool'), + ('stuck_notification', 'bool'), ('mahjongg_show_removed', 'bool'), ('mahjongg_create_solvable', 'int'), ('shisen_show_hint', 'bool'), @@ -316,6 +318,7 @@ class Options: self.highlight_cards = True self.highlight_samerank = True self.highlight_not_matching = True + self.stuck_notification = False self.mahjongg_show_removed = False self.mahjongg_create_solvable = 2 # 0 - none, 1 - easy, 2 - hard self.accordion_deal_all = True diff --git a/pysollib/ui/tktile/menubar.py b/pysollib/ui/tktile/menubar.py index 64a7cd3a..84f99e2a 100644 --- a/pysollib/ui/tktile/menubar.py +++ b/pysollib/ui/tktile/menubar.py @@ -222,6 +222,7 @@ class PysolMenubarTkCommon: highlight_cards=tkinter.BooleanVar(), highlight_samerank=tkinter.BooleanVar(), highlight_not_matching=tkinter.BooleanVar(), + stuck_notification=tkinter.BooleanVar(), mahjongg_show_removed=tkinter.BooleanVar(), shisen_show_hint=tkinter.BooleanVar(), accordion_deal_all=tkinter.BooleanVar(), @@ -282,6 +283,7 @@ class PysolMenubarTkCommon: tkopt.highlight_cards.set(opt.highlight_cards) tkopt.highlight_samerank.set(opt.highlight_samerank) tkopt.highlight_not_matching.set(opt.highlight_not_matching) + tkopt.stuck_notification.set(opt.stuck_notification) tkopt.shrink_face_down.set(opt.shrink_face_down) tkopt.shade_filled_stacks.set(opt.shade_filled_stacks) tkopt.randomize_place.set(opt.randomize_place) @@ -588,6 +590,10 @@ class PysolMenubarTkCommon: label=n_("Highlight &no matching"), variable=self.tkopt.highlight_not_matching, command=self.mOptEnableHighlightNotMatching) + submenu.add_checkbutton( + label=n_("Stuc&k notification"), + variable=self.tkopt.stuck_notification, + command=self.mOptEnableStuckNotification) submenu.add_separator() submenu.add_checkbutton( label=n_("&Show removed tiles (in Mahjongg games)"), @@ -1506,6 +1512,12 @@ Unsupported game for import. self.tkopt.highlight_not_matching.get() # self.game.updateMenus() + def mOptEnableStuckNotification(self, *args): + if self._cancelDrag(break_pause=False): + return + self.app.opt.stuck_notification = self.tkopt.stuck_notification.get() + # self.game.updateMenus() + def mOptAnimations(self, *args): if self._cancelDrag(break_pause=False): return