mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added show full picture option for puzzle type games.
This commit is contained in:
parent
0112e831ff
commit
a28aaeeb4f
19 changed files with 388 additions and 6 deletions
|
@ -63,3 +63,9 @@ moved as a unit. Using this does not disqualify you from getting a perfect game
|
|||
<p>
|
||||
The find card feature will locate and highlight any face-up instances of the chosen
|
||||
card. Using this does not disqualify you from getting a perfect game.
|
||||
|
||||
<h2>Show Full Picture</h2>
|
||||
<p>
|
||||
In puzzle type games, the show full picture option will give you an image of what the
|
||||
puzzle looks like when it's completed. Using this does not disqualify you from
|
||||
getting a perfect game.
|
||||
|
|
|
@ -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: 2023-09-22 21:55-0400\n"
|
||||
"PO-Revision-Date: 2023-09-27 20:03-0400\n"
|
||||
"Last-Translator: H. Schaekel <Holger.Schaekel@web.de>\n"
|
||||
"Language-Team: German\n"
|
||||
"Language: de\n"
|
||||
|
@ -4836,6 +4836,9 @@ msgstr "Keine passenden hervorheben:"
|
|||
msgid "Find card"
|
||||
msgstr "Karte suchen"
|
||||
|
||||
msgid "Full picture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Icon Style"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5044,6 +5047,9 @@ msgstr "Sp&ielfeldstapel hervorheben:"
|
|||
msgid "&Find card..."
|
||||
msgstr "Karte suchen (&F)"
|
||||
|
||||
msgid "Sh&ow full picture..."
|
||||
msgstr ""
|
||||
|
||||
#: pysollib/ui/tktile/menubar.py:442
|
||||
msgid "&Demo"
|
||||
msgstr "&Demo"
|
||||
|
|
|
@ -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: 2023-09-22 21:54-0400\n"
|
||||
"PO-Revision-Date: 2023-09-27 20:02-0400\n"
|
||||
"Last-Translator: Eric Rausch <neelix570@gmail.com>\n"
|
||||
"Language-Team: French\n"
|
||||
"Language: fr\n"
|
||||
|
@ -4886,6 +4886,9 @@ msgstr "Sans correspondance:"
|
|||
msgid "Find card"
|
||||
msgstr "Trouver carte"
|
||||
|
||||
msgid "Full picture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Icon Style"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5094,6 +5097,9 @@ msgstr "Surbrillance p&iles"
|
|||
msgid "&Find card..."
|
||||
msgstr "&Trouver carte..."
|
||||
|
||||
msgid "Sh&ow full picture..."
|
||||
msgstr ""
|
||||
|
||||
#: pysollib/ui/tktile/menubar.py:442
|
||||
msgid "&Demo"
|
||||
msgstr "&Démo"
|
||||
|
|
|
@ -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: 2023-09-22 21:54-0400\n"
|
||||
"PO-Revision-Date: 2023-09-27 20:02-0400\n"
|
||||
"Last-Translator: Giuliano Colla <giuliano.colla@gmail.com>\n"
|
||||
"Language-Team: Italiano <it@li.org>\n"
|
||||
"Language: it\n"
|
||||
|
@ -4951,6 +4951,9 @@ msgstr "Evidenzia non corrispondenti:"
|
|||
msgid "Find card"
|
||||
msgstr "Trova carta"
|
||||
|
||||
msgid "Full picture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Icon Style"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5160,6 +5163,9 @@ msgstr "Evidenzia p&ile"
|
|||
msgid "&Find card..."
|
||||
msgstr "&Trova carta..."
|
||||
|
||||
msgid "Sh&ow full picture..."
|
||||
msgstr ""
|
||||
|
||||
#: pysollib/ui/tktile/menubar.py:442
|
||||
msgid "&Demo"
|
||||
msgstr "&Demo"
|
||||
|
|
|
@ -8,7 +8,7 @@ msgstr ""
|
|||
"Project-Id-Version: PySolFC\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-12-10 10:19-0500\n"
|
||||
"PO-Revision-Date: 2023-09-22 21:55-0400\n"
|
||||
"PO-Revision-Date: 2023-09-27 20:01-0400\n"
|
||||
"Last-Translator: Jerzy Trzeciak <artusek@wp.pl>\n"
|
||||
"Language-Team: Polish <pl@li.org>\n"
|
||||
"Language: pl\n"
|
||||
|
@ -4906,6 +4906,9 @@ msgstr "Podświetlenie niepasujących:"
|
|||
msgid "Find card"
|
||||
msgstr "Znajdź kartę"
|
||||
|
||||
msgid "Full picture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Icon Style"
|
||||
msgstr "Wygląd ikon"
|
||||
|
||||
|
@ -5114,6 +5117,9 @@ msgstr "Podśw&ietl stosy"
|
|||
msgid "&Find card..."
|
||||
msgstr "Znajdź kartę..."
|
||||
|
||||
msgid "Sh&ow full picture..."
|
||||
msgstr ""
|
||||
|
||||
#: pysollib/ui/tktile/menubar.py:442
|
||||
msgid "&Demo"
|
||||
msgstr "&Demo"
|
||||
|
|
|
@ -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: 2023-09-22 21:52-0400\n"
|
||||
"PO-Revision-Date: 2023-09-27 20:02-0400\n"
|
||||
"Last-Translator: Matheus Knack <mtknack555@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: pt_BR\n"
|
||||
|
@ -4908,6 +4908,9 @@ msgstr "Sem correspondência:"
|
|||
msgid "Find card"
|
||||
msgstr "Encontrar carta"
|
||||
|
||||
msgid "Full picture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Icon Style"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5116,6 +5119,9 @@ msgstr "Surbrillance pilhas"
|
|||
msgid "&Find card..."
|
||||
msgstr "&Encontrar carta..."
|
||||
|
||||
msgid "Sh&ow full picture..."
|
||||
msgstr ""
|
||||
|
||||
#: pysollib/ui/tktile/menubar.py:442
|
||||
msgid "&Demo"
|
||||
msgstr "&Demonstração"
|
||||
|
|
|
@ -4639,6 +4639,9 @@ msgstr ""
|
|||
msgid "Find card"
|
||||
msgstr ""
|
||||
|
||||
msgid "Full picture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Icon Style"
|
||||
msgstr ""
|
||||
|
||||
|
@ -4847,6 +4850,9 @@ msgstr ""
|
|||
msgid "&Find card..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Sh&ow full picture..."
|
||||
msgstr ""
|
||||
|
||||
#: pysollib/ui/tktile/menubar.py:442
|
||||
msgid "&Demo"
|
||||
msgstr ""
|
||||
|
|
|
@ -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: 2023-09-22 21:52-0400\n"
|
||||
"PO-Revision-Date: 2023-09-27 20:02-0400\n"
|
||||
"Last-Translator: Skomoroh <skomoroh@gmail.com>\n"
|
||||
"Language-Team: Russian <ru@li.org>\n"
|
||||
"Language: ru\n"
|
||||
|
@ -4975,6 +4975,9 @@ msgstr "Подсветка отсутствия совпадения:"
|
|||
msgid "Find card"
|
||||
msgstr "Найти карту"
|
||||
|
||||
msgid "Full picture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Icon Style"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5183,6 +5186,9 @@ msgstr "П&оказать группы"
|
|||
msgid "&Find card..."
|
||||
msgstr "&Найти карту..."
|
||||
|
||||
msgid "Sh&ow full picture..."
|
||||
msgstr ""
|
||||
|
||||
#: pysollib/ui/tktile/menubar.py:442
|
||||
msgid "&Demo"
|
||||
msgstr "&Демо"
|
||||
|
|
|
@ -44,6 +44,7 @@ from pysollib.pysoltk import PysolMenubarTk, PysolToolbarTk
|
|||
from pysollib.pysoltk import Status_StatsDialog, Top_StatsDialog
|
||||
from pysollib.pysoltk import TimeoutsDialog
|
||||
from pysollib.pysoltk import create_find_card_dialog
|
||||
from pysollib.pysoltk import create_full_picture_dialog
|
||||
from pysollib.pysoltk import create_solver_dialog
|
||||
from pysollib.settings import DEBUG
|
||||
from pysollib.settings import PACKAGE_URL, TITLE
|
||||
|
@ -83,6 +84,7 @@ class PysolMenubar(PysolMenubarTk):
|
|||
highlight_piles=0,
|
||||
autoscale=0,
|
||||
find_card=0,
|
||||
full_picture=0,
|
||||
rules=0,
|
||||
pause=0,
|
||||
custom_game=0,
|
||||
|
@ -164,6 +166,8 @@ class PysolMenubar(PysolMenubarTk):
|
|||
ms.autoscale = 1
|
||||
if game.canFindCard():
|
||||
ms.find_card = 1
|
||||
if game.canShowFullPicture():
|
||||
ms.full_picture = 1
|
||||
if game.app.getGameRulesFilename(game.id): # note: this may return ""
|
||||
ms.rules = 1
|
||||
if not game.finished:
|
||||
|
@ -206,6 +210,7 @@ class PysolMenubar(PysolMenubarTk):
|
|||
self.setMenuState(ms.hint, "assist.hint")
|
||||
self.setMenuState(ms.highlight_piles, "assist.highlightpiles")
|
||||
self.setMenuState(ms.find_card, "assist.findcard")
|
||||
self.setMenuState(ms.full_picture, "assist.showfullpicture")
|
||||
self.setMenuState(ms.demo, "assist.demo")
|
||||
self.setMenuState(ms.demo, "assist.demoallgames")
|
||||
# Options menu
|
||||
|
@ -528,6 +533,10 @@ class PysolMenubar(PysolMenubarTk):
|
|||
create_find_card_dialog(self.game.top, self.game,
|
||||
self.app.getFindCardImagesDir())
|
||||
|
||||
def mFullPicture(self, *args):
|
||||
if self.game.canShowFullPicture():
|
||||
create_full_picture_dialog(self.game.top, self.game)
|
||||
|
||||
def mSolver(self, *args):
|
||||
create_solver_dialog(self.game.top, self.app)
|
||||
|
||||
|
|
|
@ -3483,6 +3483,9 @@ class Game(object):
|
|||
def canFindCard(self):
|
||||
return self.gameinfo.category not in (GI.GC_MATCHING, GI.GC_PUZZLE)
|
||||
|
||||
def canShowFullPicture(self):
|
||||
return self.gameinfo.category == GI.GC_PUZZLE
|
||||
|
||||
#
|
||||
# subclass hooks
|
||||
#
|
||||
|
|
83
pysollib/kivy/fullpicturedialog.py
Normal file
83
pysollib/kivy/fullpicturedialog.py
Normal file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
# ---------------------------------------------------------------------------#
|
||||
#
|
||||
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||
# Copyright (C) 2005-2009 Skomoroh
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# ---------------------------------------------------------------------------#
|
||||
|
||||
# imports
|
||||
# import os
|
||||
# import traceback
|
||||
|
||||
# PySol imports
|
||||
|
||||
# Toolkit imports
|
||||
# from tkutil import after, after_cancel
|
||||
# from tkutil import bind, unbind_destroy, makeImage
|
||||
# from tkcanvas import MfxCanvas, MfxCanvasGroup
|
||||
# from tkcanvas import MfxCanvasImage, MfxCanvasRectangle
|
||||
|
||||
# from pysollib.settings import TITLE
|
||||
|
||||
# ************************************************************************
|
||||
# *
|
||||
# ************************************************************************
|
||||
|
||||
|
||||
full_picture_dialog = None
|
||||
|
||||
|
||||
def create_full_picture_dialog(parent, game):
|
||||
pass
|
||||
'''
|
||||
global full_picture_dialog
|
||||
try:
|
||||
full_picture_dialog.wm_deiconify()
|
||||
full_picture_dialog.tkraise()
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
full_picture_dialog = FullPictureDialog(parent, game)
|
||||
'''
|
||||
|
||||
|
||||
def connect_game_full_picture_dialog(game):
|
||||
pass
|
||||
'''
|
||||
try:
|
||||
full_picture_dialog.connectGame(game)
|
||||
except Exception:
|
||||
pass
|
||||
'''
|
||||
|
||||
|
||||
def destroy_full_picture_dialog():
|
||||
pass
|
||||
'''
|
||||
global full_picture_dialog
|
||||
try:
|
||||
full_picture_dialog.destroy()
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
pass
|
||||
full_picture_dialog = None
|
||||
'''
|
||||
|
||||
|
||||
'''
|
||||
'''
|
|
@ -39,6 +39,7 @@ from pysollib.kivy.LApp import LTopLevel
|
|||
from pysollib.kivy.LApp import LTreeNode
|
||||
from pysollib.kivy.LApp import LTreeRoot
|
||||
from pysollib.kivy.findcarddialog import destroy_find_card_dialog
|
||||
from pysollib.kivy.fullpicturedialog import destroy_full_picture_dialog
|
||||
from pysollib.kivy.selectcardset import SelectCardsetDialogWithPreview
|
||||
from pysollib.kivy.selectgame import SelectGameDialog
|
||||
from pysollib.kivy.solverdialog import connect_game_solver_dialog
|
||||
|
@ -50,6 +51,7 @@ from pysollib.mfxutil import Struct
|
|||
from pysollib.mygettext import _
|
||||
from pysollib.pysoltk import MfxMessageDialog
|
||||
from pysollib.pysoltk import connect_game_find_card_dialog
|
||||
from pysollib.pysoltk import connect_game_full_picture_dialog
|
||||
from pysollib.settings import SELECT_GAME_MENU
|
||||
from pysollib.settings import TITLE
|
||||
|
||||
|
@ -1465,6 +1467,10 @@ class PysolMenubarTk:
|
|||
connect_game_find_card_dialog(game)
|
||||
else:
|
||||
destroy_find_card_dialog()
|
||||
if game.canShowFullPicture():
|
||||
connect_game_full_picture_dialog(game)
|
||||
else:
|
||||
destroy_full_picture_dialog()
|
||||
connect_game_solver_dialog(game)
|
||||
|
||||
# create a GTK-like path
|
||||
|
|
54
pysollib/pysolgtk/fullpicturedialog.py
Normal file
54
pysollib/pysolgtk/fullpicturedialog.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||
# Copyright (C) 2005-2009 Skomoroh
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# imports
|
||||
# import os
|
||||
# from six.moves import tkinter
|
||||
# import traceback
|
||||
|
||||
# # PySol imports
|
||||
|
||||
# # Toolkit imports
|
||||
# from tkutil import after, after_cancel
|
||||
# from tkutil import bind, unbind_destroy, makeImage
|
||||
# from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, \
|
||||
# MfxCanvasRectangle
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
# *
|
||||
# ************************************************************************
|
||||
|
||||
full_picture_dialog = None
|
||||
|
||||
|
||||
def create_full_picture_dialog(parent, game):
|
||||
pass
|
||||
|
||||
|
||||
def connect_game_full_picture_dialog(game):
|
||||
pass
|
||||
|
||||
|
||||
def destroy_full_picture_dialog():
|
||||
pass
|
|
@ -28,6 +28,8 @@ import re
|
|||
|
||||
from findcarddialog import connect_game_find_card_dialog, \
|
||||
destroy_find_card_dialog
|
||||
from fullpicturedialog import connect_game_full_picture_dialog, \
|
||||
destroy_full_picture_dialog
|
||||
|
||||
import gtk
|
||||
from gtk import gdk
|
||||
|
@ -81,6 +83,10 @@ class PysolMenubarTk:
|
|||
connect_game_find_card_dialog(game)
|
||||
else:
|
||||
destroy_find_card_dialog()
|
||||
if game.canShowFullPicture():
|
||||
connect_game_full_picture_dialog(game)
|
||||
else:
|
||||
destroy_full_picture_dialog()
|
||||
|
||||
#
|
||||
# create menubar
|
||||
|
|
|
@ -30,6 +30,7 @@ if TOOLKIT == 'tk':
|
|||
from pysollib.ui.tktile.tkcanvas import * # noqa: F401,F403
|
||||
from pysollib.ui.tktile.tkwrap import * # noqa: F401,F403
|
||||
from pysollib.ui.tktile.findcarddialog import * # noqa: F401,F403
|
||||
from pysollib.ui.tktile.fullpicturedialog import * # noqa: F401,F403
|
||||
if USE_TILE:
|
||||
from pysollib.tile.tkwidget import * # noqa: F401,F403
|
||||
from pysollib.tile.tkhtml import * # noqa: F401,F403
|
||||
|
@ -74,6 +75,7 @@ elif TOOLKIT == 'kivy':
|
|||
from pysollib.kivy.tkcanvas import * # noqa: F401,F403
|
||||
from pysollib.kivy.tkwrap import * # noqa: F401,F403
|
||||
from pysollib.kivy.findcarddialog import * # noqa: F401,F403
|
||||
from pysollib.kivy.fullpicturedialog import * # noqa: F401,F403
|
||||
from pysollib.kivy.tkwidget import * # noqa: F401,F403
|
||||
from pysollib.kivy.tkhtml import * # noqa: F401,F403
|
||||
from pysollib.kivy.edittextdialog import * # noqa: F401,F403
|
||||
|
@ -107,6 +109,7 @@ else: # gtk
|
|||
from pysollib.pysolgtk.colorsdialog import * # noqa: F401,F403
|
||||
from pysollib.pysolgtk.fontsdialog import * # noqa: F401,F403
|
||||
from pysollib.pysolgtk.findcarddialog import * # noqa: F401,F403
|
||||
from pysollib.pysolgtk.fullpicturedialog import * # noqa: F401,F403
|
||||
from pysollib.pysolgtk.solverdialog import * # noqa: F401,F403
|
||||
from pysollib.pysolgtk.gameinfodialog import * # noqa: F401,F403
|
||||
from pysollib.pysolgtk.toolbar import * # noqa: F401,F403
|
||||
|
|
|
@ -25,6 +25,9 @@ from pysollib.mygettext import _, n_
|
|||
from pysollib.settings import TITLE
|
||||
from pysollib.ui.tktile.findcarddialog import connect_game_find_card_dialog
|
||||
from pysollib.ui.tktile.findcarddialog import destroy_find_card_dialog
|
||||
from pysollib.ui.tktile.fullpicturedialog import \
|
||||
connect_game_full_picture_dialog
|
||||
from pysollib.ui.tktile.fullpicturedialog import destroy_full_picture_dialog
|
||||
from pysollib.ui.tktile.menubar import MfxMenu, PysolMenubarTkCommon
|
||||
from pysollib.ui.tktile.solverdialog import connect_game_solver_dialog
|
||||
from pysollib.util import CARDSET
|
||||
|
@ -58,6 +61,12 @@ class PysolMenubarTk(PysolMenubarTkCommon):
|
|||
def _destroy_find_card_dialog(self):
|
||||
return destroy_find_card_dialog()
|
||||
|
||||
def _connect_game_full_picture_dialog(self, game):
|
||||
return connect_game_full_picture_dialog(game)
|
||||
|
||||
def _destroy_full_picture_dialog(self):
|
||||
return destroy_full_picture_dialog()
|
||||
|
||||
def _connect_game_solver_dialog(self, game):
|
||||
return connect_game_solver_dialog(game)
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ from pysollib.mygettext import _
|
|||
from pysollib.ui.tktile.findcarddialog import \
|
||||
connect_game_find_card_dialog, \
|
||||
destroy_find_card_dialog
|
||||
from pysollib.ui.tktile.fullpicturedialog import \
|
||||
connect_game_full_picture_dialog, \
|
||||
destroy_full_picture_dialog
|
||||
from pysollib.ui.tktile.menubar import PysolMenubarTkCommon
|
||||
from pysollib.ui.tktile.solverdialog import connect_game_solver_dialog
|
||||
from pysollib.util import CARDSET
|
||||
|
@ -53,6 +56,12 @@ class PysolMenubarTk(PysolMenubarTkCommon):
|
|||
def _destroy_find_card_dialog(self):
|
||||
return destroy_find_card_dialog()
|
||||
|
||||
def _connect_game_full_picture_dialog(self, game):
|
||||
return connect_game_full_picture_dialog(game)
|
||||
|
||||
def _destroy_full_picture_dialog(self):
|
||||
return destroy_full_picture_dialog()
|
||||
|
||||
def _connect_game_solver_dialog(self, game):
|
||||
return connect_game_solver_dialog(game)
|
||||
|
||||
|
|
145
pysollib/ui/tktile/fullpicturedialog.py
Normal file
145
pysollib/ui/tktile/fullpicturedialog.py
Normal file
|
@ -0,0 +1,145 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||
# Copyright (C) 2005-2009 Skomoroh
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
from pysollib.mygettext import _
|
||||
from pysollib.settings import TITLE
|
||||
from pysollib.ui.tktile.tkcanvas import MfxCanvas, MfxCanvasGroup
|
||||
from pysollib.ui.tktile.tkcanvas import MfxCanvasImage
|
||||
from pysollib.ui.tktile.tkutil import bind, unbind_destroy
|
||||
|
||||
from six.moves import tkinter
|
||||
|
||||
|
||||
class FullPictureDialog(tkinter.Toplevel):
|
||||
CARD_IMAGES = {} # key: (type, rank, suit)
|
||||
|
||||
def __init__(self, parent, game):
|
||||
tkinter.Toplevel.__init__(self)
|
||||
title = TITLE + ' - ' + _('Full picture')
|
||||
self.title(title)
|
||||
self.wm_resizable(False, False)
|
||||
self.cardsettype = ''
|
||||
self.images = {}
|
||||
self.label_width = 0
|
||||
self.label_height = 0
|
||||
|
||||
# if size == 'large':
|
||||
# self.images_dir = os.path.join(dir, 'large', cs_type)
|
||||
# self.label_width, self.label_height = LARGE_EMBLEMS_SIZE
|
||||
# else:
|
||||
# self.images_dir = os.path.join(dir, 'small')
|
||||
# self.label_width, self.label_height = SMALL_EMBLEMS_SIZE
|
||||
|
||||
self.canvas = MfxCanvas(self, bg='white')
|
||||
# self.canvas = MfxCanvas(self, bg='black')
|
||||
self.canvas.pack(expand=True, fill='both')
|
||||
#
|
||||
self.groups = []
|
||||
self.highlight_items = None
|
||||
self.busy = False
|
||||
self.connectGame(game)
|
||||
#
|
||||
bind(self, "WM_DELETE_WINDOW", self.destroy)
|
||||
bind(self, "<Escape>", self.destroy)
|
||||
#
|
||||
|
||||
def createCardLabel(self, suit, rank, x0, y0):
|
||||
canvas = self.canvas
|
||||
group = MfxCanvasGroup(canvas)
|
||||
#
|
||||
im = self.images.getFace(0, 0, rank)
|
||||
FullPictureDialog.CARD_IMAGES[rank] = im
|
||||
cim = MfxCanvasImage(canvas, x0, y0, image=im, anchor='nw')
|
||||
cim.addtag(group)
|
||||
cim.lower()
|
||||
|
||||
self.groups.append(group)
|
||||
|
||||
def connectGame(self, game):
|
||||
self.images = game.app.subsampled_images
|
||||
#
|
||||
# self.images_dir = dir
|
||||
self.label_width = self.images.CARDW
|
||||
self.label_height = self.images.CARDH
|
||||
self.cardsettype = game.gameinfo.subcategory
|
||||
#
|
||||
# self.images_dir = dir
|
||||
self.canvas.delete('all')
|
||||
self.game = game
|
||||
cards = game.gameinfo.trumps
|
||||
|
||||
dx, dy = self.label_width, self.label_height
|
||||
i = 0
|
||||
k = 0
|
||||
|
||||
for card in cards:
|
||||
x, y = dx * k + 2, dy * i + 2
|
||||
self.createCardLabel(suit=0, rank=card, x0=x, y0=y)
|
||||
k += 1
|
||||
if k >= self.cardsettype:
|
||||
k = 0
|
||||
i += 1
|
||||
if k > 0:
|
||||
i += 1
|
||||
|
||||
w, h = dx*self.cardsettype+2, dy*i+2
|
||||
self.canvas.config(width=w, height=h)
|
||||
self.wm_iconname(TITLE + " - " + game.getTitleName())
|
||||
self.wm_geometry('') # cancel user-specified geometry
|
||||
|
||||
def destroy(self, *args):
|
||||
for group in self.groups:
|
||||
unbind_destroy(group)
|
||||
unbind_destroy(self)
|
||||
self.wm_withdraw()
|
||||
tkinter.Toplevel.destroy(self)
|
||||
|
||||
|
||||
full_picture_dialog = None
|
||||
|
||||
|
||||
def create_full_picture_dialog(parent, game):
|
||||
global full_picture_dialog
|
||||
try:
|
||||
full_picture_dialog.wm_deiconify()
|
||||
full_picture_dialog.tkraise()
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
full_picture_dialog = FullPictureDialog(parent, game)
|
||||
|
||||
|
||||
def connect_game_full_picture_dialog(game):
|
||||
try:
|
||||
full_picture_dialog.connectGame(game)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def destroy_full_picture_dialog():
|
||||
global full_picture_dialog
|
||||
try:
|
||||
full_picture_dialog.destroy()
|
||||
except Exception:
|
||||
# traceback.print_exc()
|
||||
pass
|
||||
full_picture_dialog = None
|
|
@ -347,6 +347,10 @@ class PysolMenubarTkCommon:
|
|||
self._connect_game_find_card_dialog(game)
|
||||
else:
|
||||
self._destroy_find_card_dialog()
|
||||
if game.canShowFullPicture():
|
||||
self._connect_game_full_picture_dialog(game)
|
||||
else:
|
||||
self._destroy_full_picture_dialog()
|
||||
self._connect_game_solver_dialog(game)
|
||||
|
||||
# create a GTK-like path
|
||||
|
@ -534,6 +538,9 @@ class PysolMenubarTkCommon:
|
|||
menu.add_command(
|
||||
label=n_("&Find card..."),
|
||||
command=self.mFindCard, accelerator="F3")
|
||||
menu.add_command(
|
||||
label=n_("Sh&ow full picture..."),
|
||||
command=self.mFullPicture)
|
||||
menu.add_separator()
|
||||
menu.add_command(
|
||||
label=n_("&Demo"),
|
||||
|
|
Loading…
Add table
Reference in a new issue