diff --git a/po/de_pysol.po b/po/de_pysol.po index 703106d8..69568725 100644 --- a/po/de_pysol.po +++ b/po/de_pysol.po @@ -4669,6 +4669,9 @@ msgstr "Zu&fallsspiel auswählen" msgid "&All games" msgstr "&Alle Spiele" +msgid "&Games played" +msgstr "&Gespielte Spiele" + #: pysollib/ui/tktile/menubar.py:309 msgid "Games played and &won" msgstr "Gespielt: ge&wonnen/verloren" diff --git a/po/fr_pysol.po b/po/fr_pysol.po index 21b11231..7ae2aa3b 100644 --- a/po/fr_pysol.po +++ b/po/fr_pysol.po @@ -4721,6 +4721,9 @@ msgstr "Jeu au hasa&rd" msgid "&All games" msgstr "&Tous les jeux" +msgid "&Games played" +msgstr "J&eux joués" + #: pysollib/ui/tktile/menubar.py:309 msgid "Games played and &won" msgstr "Jeux finis et &gagnés" diff --git a/po/it_pysol.po b/po/it_pysol.po index c180b32a..393162d7 100644 --- a/po/it_pysol.po +++ b/po/it_pysol.po @@ -4786,6 +4786,9 @@ msgstr "Un gioco a &caso" msgid "&All games" msgstr "&Tutti i giochi" +msgid "&Games played" +msgstr "&Giocati" + #: pysollib/ui/tktile/menubar.py:309 msgid "Games played and &won" msgstr "Giocati e &vinti" diff --git a/po/pl_pysol.po b/po/pl_pysol.po index 5e1c2a56..6b0220e1 100644 --- a/po/pl_pysol.po +++ b/po/pl_pysol.po @@ -4844,6 +4844,9 @@ msgstr "Wybie&rz grę losowo" msgid "&All games" msgstr "Wszystkie gry" +msgid "&Games played" +msgstr "&Gry rozegrane" + #: pysollib/ui/tktile/menubar.py:309 msgid "Games played and &won" msgstr "Gry rozegrane i &wygrane" diff --git a/po/pysol.pot b/po/pysol.pot index 8ad0bfca..f21bf55b 100644 --- a/po/pysol.pot +++ b/po/pysol.pot @@ -4476,6 +4476,9 @@ msgstr "" msgid "&All games" msgstr "" +msgid "&Games played" +msgstr "" + #: pysollib/ui/tktile/menubar.py:309 msgid "Games played and &won" msgstr "" diff --git a/po/ru_pysol.po b/po/ru_pysol.po index aaf8b06e..321a19e4 100644 --- a/po/ru_pysol.po +++ b/po/ru_pysol.po @@ -4810,6 +4810,9 @@ msgstr "С&лучайная игра" msgid "&All games" msgstr "&Все игры" +msgid "&Games played" +msgstr "&Играли игры" + #: pysollib/ui/tktile/menubar.py:309 msgid "Games played and &won" msgstr "&Выигранные игры" diff --git a/pysollib/actions.py b/pysollib/actions.py index 1d5c2392..e720c5a0 100644 --- a/pysollib/actions.py +++ b/pysollib/actions.py @@ -65,6 +65,10 @@ class PysolMenubar(PysolMenubarTk): save=0, save_as=0, hold_and_quit=0, + rndplayed=0, + rndwon=0, + rndnotwon=0, + rndnotplayed=0, undo=0, redo=0, restart=0, @@ -123,6 +127,10 @@ class PysolMenubar(PysolMenubarTk): opt = self.app.opt ms = self.menustate # 0 = DISABLED, 1 = ENABLED + ms.rndplayed = len(self._mGetPossibleRandomGames("played")) > 0 + ms.rndwon = len(self._mGetPossibleRandomGames("won")) > 0 + ms.rndnotwon = len(self._mGetPossibleRandomGames("not won")) > 0 + ms.rndnotplayed = len(self._mGetPossibleRandomGames("not played")) > 0 ms.save_as = game.canSaveGame() ms.hold_and_quit = ms.save_as if game.filename and ms.save_as: @@ -174,6 +182,12 @@ class PysolMenubar(PysolMenubarTk): # File menu self.setMenuState(ms.save, "file.save") self.setMenuState(ms.save_as, "file.saveas") + self.setMenuState(ms.rndplayed, "file.selectrandomgame.gamesplayed") + self.setMenuState(ms.rndwon, "file.selectrandomgame.gamesplayedandwon") + self.setMenuState(ms.rndnotwon, + "file.selectrandomgame.gamesplayedandnotwon") + self.setMenuState(ms.rndnotplayed, + "file.selectrandomgame.gamesnotplayed") self.setMenuState(ms.hold_and_quit, "file.holdandquit") # Edit menu self.setMenuState(ms.undo, "edit.undo") @@ -325,6 +339,14 @@ class PysolMenubar(PysolMenubarTk): if not self.game.areYouSure(_("Select random game")): return game_id = None + games = self._mGetPossibleRandomGames(type) + if games: + game_id = self.app.chooseRandomOutOfGames(games) + if game_id and game_id != self.game.id: + self.game.endGame() + self.game.quitGame(game_id) + + def _mGetPossibleRandomGames(self, type='all'): games = [] for g in self.app.gdb.getGamesIdSortedById(): gi = self.app.getGameInfo(g) @@ -337,17 +359,15 @@ class PysolMenubar(PysolMenubarTk): won, lost = self.app.stats.getStats(self.app.opt.player, gi.id) if type == 'all': games.append(gi.id) + elif type == 'played' and won + lost > 0: + games.append(gi.id) elif type == 'won' and won > 0: games.append(gi.id) elif type == 'not won' and won == 0 and lost > 0: games.append(gi.id) - elif type == 'not played' and won+lost == 0: + elif type == 'not played' and won + lost == 0: games.append(gi.id) - if games: - game_id = self.app.chooseRandomOutOfGames(games) - if game_id and game_id != self.game.id: - self.game.endGame() - self.game.quitGame(game_id) + return games def _mSelectNextGameFromList(self, gl, step): if self._cancelDrag(): @@ -747,6 +767,7 @@ class PysolMenubar(PysolMenubarTk): self.game.updateStatus(player=self.app.opt.player) self.game.updateStatus(stats=self.app.stats.getStats( self.app.opt.player, self.game.id)) + self.updateMenus() def mOptColors(self, *args): if self._cancelDrag(break_pause=False): diff --git a/pysollib/ui/tktile/menubar.py b/pysollib/ui/tktile/menubar.py index 2498456c..d1757562 100644 --- a/pysollib/ui/tktile/menubar.py +++ b/pysollib/ui/tktile/menubar.py @@ -383,6 +383,10 @@ class PysolMenubarTkCommon: submenu.add_command( label=n_("&All games"), command=lambda: self.mSelectRandomGame('all'), accelerator=m+"R") + submenu.add_separator() + submenu.add_command( + label=n_("&Games played"), + command=lambda: self.mSelectRandomGame('played')) submenu.add_command( label=n_("Games played and &won"), command=lambda: self.mSelectRandomGame('won'))