mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ human readable config file (~/.PySolFC/options.cfg; options.dat is gone)
+ added `custom games' node to select games dialog * cleanup code git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@170 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
parent
20674666f8
commit
db52c78437
17 changed files with 487 additions and 241 deletions
|
@ -10,8 +10,9 @@ pysollib_dir = '../'
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
import gettext
|
import __builtin__
|
||||||
gettext.install('pysol', 'locale', unicode=True)
|
__builtin__._ = lambda x: x
|
||||||
|
__builtin__.n_ = lambda x: x
|
||||||
|
|
||||||
try: os.mkdir('html')
|
try: os.mkdir('html')
|
||||||
except: pass
|
except: pass
|
||||||
|
|
|
@ -17,9 +17,14 @@
|
||||||
<p>
|
<p>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<p> Visit the official <a href="http://pysolfc.sourceforge.net/">PySolFC Home
|
||||||
|
Page</a>.
|
||||||
<!--
|
<!--
|
||||||
<p> Visit the official <a href="http://www.oberhumer.com/pysol">PySol Home Page</a>
|
<p>
|
||||||
<p>Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by <a href="mailto:markus@oberhumer.com">Markus F.X.J. Oberhumer</a>.<br>
|
Copyright (C) 1998-2003 by <a href="mailto:markus@oberhumer.com">Markus
|
||||||
|
F.X.J. Oberhumer</a>.<br>
|
||||||
|
Copyright (C) 2003 by Mt. Hood Playing Card Co.<br>
|
||||||
|
Copyright (C) 2005 by <a href="mailto:skomoroh@gmail.com">Skomoroh</a>.<br>
|
||||||
All Rights Reserved.
|
All Rights Reserved.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
import os, locale
|
import os, locale
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from mfxutil import EnvError, SubclassResponsibility
|
from mfxutil import SubclassResponsibility
|
||||||
from mfxutil import Struct, openURL
|
from mfxutil import Struct, openURL
|
||||||
from pysolrandom import constructRandom
|
from pysolrandom import constructRandom
|
||||||
from settings import PACKAGE, PACKAGE_URL
|
from settings import PACKAGE, PACKAGE_URL
|
||||||
|
@ -565,7 +565,7 @@ class PysolMenubarActions:
|
||||||
file = open(filename, "a")
|
file = open(filename, "a")
|
||||||
a = FileStatsFormatter(self.app, file)
|
a = FileStatsFormatter(self.app, file)
|
||||||
write_method(a, player)
|
write_method(a, player)
|
||||||
except EnvError, ex:
|
except EnvironmentError, ex:
|
||||||
if file: file.close()
|
if file: file.close()
|
||||||
d = MfxExceptionDialog(self.top, ex,
|
d = MfxExceptionDialog(self.top, ex,
|
||||||
text=_("Error while writing to file"))
|
text=_("Error while writing to file"))
|
||||||
|
@ -756,18 +756,6 @@ class PysolMenubarActions:
|
||||||
self.app.opt.timeouts['highlight_cards'] = d.highlight_cards_timeout
|
self.app.opt.timeouts['highlight_cards'] = d.highlight_cards_timeout
|
||||||
self.app.opt.timeouts['highlight_samerank'] = d.highlight_samerank_timeout
|
self.app.opt.timeouts['highlight_samerank'] = d.highlight_samerank_timeout
|
||||||
|
|
||||||
## def mOptSave(self, *args):
|
|
||||||
## if self._cancelDrag(break_pause=False): return
|
|
||||||
## try:
|
|
||||||
## self.app.saveOptions()
|
|
||||||
## except Exception, ex:
|
|
||||||
## d = MfxExceptionDialog(self.top, ex,
|
|
||||||
## text=_("Error while saving options"))
|
|
||||||
## else:
|
|
||||||
## # tell the player where their config files reside
|
|
||||||
## d = MfxMessageDialog(self.top, title=PACKAGE+_(" Info"), bitmap="info",
|
|
||||||
## text=_("Options were saved to\n\n") + self.app.fn.opt)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Help menu
|
# Help menu
|
||||||
|
|
335
pysollib/app.py
335
pysollib/app.py
|
@ -37,16 +37,15 @@
|
||||||
# imports
|
# imports
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
import traceback
|
import traceback
|
||||||
|
import ConfigParser
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from mfxutil import destruct, Struct
|
from mfxutil import destruct, Struct
|
||||||
from mfxutil import pickle, unpickle, UnpicklingError
|
from mfxutil import pickle, unpickle, UnpicklingError
|
||||||
from mfxutil import getusername, gethomedir, getprefdir, EnvError
|
from mfxutil import getusername, gethomedir, getprefdir
|
||||||
from mfxutil import latin1_to_ascii, print_err
|
from mfxutil import latin1_to_ascii, print_err
|
||||||
from mfxutil import Image
|
|
||||||
from util import Timer
|
|
||||||
from util import CARDSET, IMAGE_EXTENSIONS
|
from util import CARDSET, IMAGE_EXTENSIONS
|
||||||
from settings import PACKAGE, VERSION, VERSION_TUPLE, WIN_SYSTEM
|
from settings import PACKAGE, VERSION_TUPLE, WIN_SYSTEM
|
||||||
from resource import CSI, CardsetConfig, Cardset, CardsetManager
|
from resource import CSI, CardsetConfig, Cardset, CardsetManager
|
||||||
from resource import Tile, TileManager
|
from resource import Tile, TileManager
|
||||||
from resource import Sample, SampleManager
|
from resource import Sample, SampleManager
|
||||||
|
@ -72,7 +71,6 @@ from pysoltk import HTMLViewer
|
||||||
from pysoltk import TOOLBAR_BUTTONS
|
from pysoltk import TOOLBAR_BUTTONS
|
||||||
from pysoltk import destroy_find_card_dialog
|
from pysoltk import destroy_find_card_dialog
|
||||||
from pysoltk import destroy_solver_dialog
|
from pysoltk import destroy_solver_dialog
|
||||||
from pysoltk import connect_game_solver_dialog
|
|
||||||
from help import help_about, destroy_help_html
|
from help import help_about, destroy_help_html
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,9 +80,80 @@ from help import help_about, destroy_help_html
|
||||||
|
|
||||||
|
|
||||||
class Options:
|
class Options:
|
||||||
|
GENERAL_OPTIONS = [
|
||||||
|
('player', 'str'),
|
||||||
|
('confirm', 'bool'),
|
||||||
|
('update_player_stats', 'bool'),
|
||||||
|
('autofaceup', 'bool'),
|
||||||
|
('autodrop', 'bool'),
|
||||||
|
('autodeal', 'bool'),
|
||||||
|
('quickplay', 'bool'),
|
||||||
|
('undo', 'bool'),
|
||||||
|
('bookmarks', 'bool'),
|
||||||
|
('hint', 'bool'),
|
||||||
|
('highlight_piles', 'bool'),
|
||||||
|
('highlight_cards', 'bool'),
|
||||||
|
('highlight_samerank', 'bool'),
|
||||||
|
('highlight_not_matching', 'bool'),
|
||||||
|
('mahjongg_show_removed', 'bool'),
|
||||||
|
('mahjongg_create_solvable', 'int'),
|
||||||
|
('shisen_show_hint', 'bool'),
|
||||||
|
('animations', 'int'),
|
||||||
|
('redeal_animation', 'bool'),
|
||||||
|
('win_animation', 'bool'),
|
||||||
|
('shadow', 'bool'),
|
||||||
|
('shade', 'bool'),
|
||||||
|
('shrink_face_down', 'bool'),
|
||||||
|
('shade_filled_stacks', 'bool'),
|
||||||
|
('demo_logo', 'bool'),
|
||||||
|
('tile_theme', 'str'),
|
||||||
|
('default_tile_theme', 'str'),
|
||||||
|
('toolbar', 'int'),
|
||||||
|
('toolbar_style', 'str'),
|
||||||
|
('toolbar_relief', 'str'),
|
||||||
|
('toolbar_compound', 'str'),
|
||||||
|
('toolbar_size', 'int'),
|
||||||
|
('statusbar', 'bool'),
|
||||||
|
('num_cards', 'bool'),
|
||||||
|
('helpbar', 'bool'),
|
||||||
|
('num_recent_games', 'int'),
|
||||||
|
('last_gameid', 'int'),
|
||||||
|
('game_holded', 'int'),
|
||||||
|
('wm_maximized', 'bool'),
|
||||||
|
('splashscreen', 'bool'),
|
||||||
|
('mouse_type', 'str'),
|
||||||
|
('mouse_undo', 'bool'),
|
||||||
|
('negative_bottom', 'bool'),
|
||||||
|
('randomize_place', 'bool'),
|
||||||
|
('save_cardsets', 'bool'),
|
||||||
|
('dragcursor', 'bool'),
|
||||||
|
('save_games_geometry', 'bool'),
|
||||||
|
('sound', 'bool'),
|
||||||
|
('sound_mode', 'int'),
|
||||||
|
('sound_sample_volume', 'int'),
|
||||||
|
('sound_music_volume', 'int'),
|
||||||
|
('tabletile_name', 'str'),
|
||||||
|
#('toolbar_vars', 'list'),
|
||||||
|
#('recent_gameid', 'list'),
|
||||||
|
#('favorite_gameid', 'list'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.version_tuple = VERSION_TUPLE
|
config = self._config = ConfigParser.ConfigParser()
|
||||||
self.saved = 0
|
for section in (
|
||||||
|
'general',
|
||||||
|
'sound_samples',
|
||||||
|
'fonts',
|
||||||
|
'colors',
|
||||||
|
'timeouts',
|
||||||
|
'cardsets',
|
||||||
|
'games_geometry',
|
||||||
|
):
|
||||||
|
config.add_section(section)
|
||||||
|
|
||||||
|
self.version_tuple = VERSION_TUPLE # XXX
|
||||||
|
self.saved = 0 # XXX
|
||||||
# options menu:
|
# options menu:
|
||||||
self.player = _("Unknown")
|
self.player = _("Unknown")
|
||||||
self.confirm = True
|
self.confirm = True
|
||||||
|
@ -112,20 +181,10 @@ class Options:
|
||||||
self.shade_filled_stacks = True
|
self.shade_filled_stacks = True
|
||||||
self.demo_logo = True
|
self.demo_logo = True
|
||||||
self.tile_theme = 'default'
|
self.tile_theme = 'default'
|
||||||
if WIN_SYSTEM == 'win32':
|
|
||||||
self.tile_theme = self.default_tile_theme = 'winnative'
|
|
||||||
if sys.getwindowsversion() >= (5, 1): # xp
|
|
||||||
self.tile_theme = 'xpnative'
|
|
||||||
elif WIN_SYSTEM == 'x11':
|
|
||||||
self.tile_theme = 'clam'
|
|
||||||
self.default_tile_theme = 'default'
|
self.default_tile_theme = 'default'
|
||||||
elif WIN_SYSTEM == 'aqua':
|
|
||||||
self.tile_theme = self.default_tile_theme = 'aqua'
|
|
||||||
self.toolbar = 1 # 0 == hide, 1,2,3,4 == top, bottom, lef, right
|
self.toolbar = 1 # 0 == hide, 1,2,3,4 == top, bottom, lef, right
|
||||||
##self.toolbar_style = 'default'
|
##self.toolbar_style = 'default'
|
||||||
self.toolbar_style = 'bluecurve'
|
self.toolbar_style = 'bluecurve'
|
||||||
if WIN_SYSTEM == 'win32':
|
|
||||||
self.toolbar_style = 'crystal'
|
|
||||||
self.toolbar_relief = 'flat'
|
self.toolbar_relief = 'flat'
|
||||||
self.toolbar_compound = 'none' # icons only
|
self.toolbar_compound = 'none' # icons only
|
||||||
self.toolbar_size = 0
|
self.toolbar_size = 0
|
||||||
|
@ -135,6 +194,10 @@ class Options:
|
||||||
self.statusbar = True
|
self.statusbar = True
|
||||||
self.num_cards = False
|
self.num_cards = False
|
||||||
self.helpbar = False
|
self.helpbar = False
|
||||||
|
self.splashscreen = True
|
||||||
|
self.mouse_type = 'drag-n-drop' # or 'sticky-mouse' or 'point-n-click'
|
||||||
|
self.mouse_undo = False # use mouse for undo/redo
|
||||||
|
self.negative_bottom = True
|
||||||
# sound
|
# sound
|
||||||
self.sound = True
|
self.sound = True
|
||||||
self.sound_mode = 1
|
self.sound_mode = 1
|
||||||
|
@ -164,7 +227,8 @@ class Options:
|
||||||
'gamewon' : False,
|
'gamewon' : False,
|
||||||
}
|
}
|
||||||
# fonts
|
# fonts
|
||||||
self.fonts = {"default" : None,
|
self.fonts = {
|
||||||
|
"default" : None,
|
||||||
#"default" : ("helvetica", 12),
|
#"default" : ("helvetica", 12),
|
||||||
"sans" : ("times", 12), # for html
|
"sans" : ("times", 12), # for html
|
||||||
"fixed" : ("courier", 12), # for html & log
|
"fixed" : ("courier", 12), # for html & log
|
||||||
|
@ -175,11 +239,6 @@ class Options:
|
||||||
"canvas_large" : ("helvetica", 16),
|
"canvas_large" : ("helvetica", 16),
|
||||||
"canvas_small" : ("helvetica", 10),
|
"canvas_small" : ("helvetica", 10),
|
||||||
}
|
}
|
||||||
if WIN_SYSTEM == 'win32':
|
|
||||||
self.fonts["sans"] = ("times new roman", 12)
|
|
||||||
self.fonts["fixed"] = ("courier new", 10)
|
|
||||||
elif WIN_SYSTEM == 'x11':
|
|
||||||
self.fonts["sans"] = ("helvetica", 12)
|
|
||||||
# colors
|
# colors
|
||||||
self.colors = {
|
self.colors = {
|
||||||
'table': '#008200',
|
'table': '#008200',
|
||||||
|
@ -206,37 +265,56 @@ class Options:
|
||||||
self.recent_gameid = []
|
self.recent_gameid = []
|
||||||
self.favorite_gameid = []
|
self.favorite_gameid = []
|
||||||
self.last_gameid = 0 # last game played
|
self.last_gameid = 0 # last game played
|
||||||
#self.last_player = None # last player
|
self.game_holded = 0 # gameid or 0
|
||||||
#self.last_save_dir = None # last directory for load/save
|
|
||||||
self.game_holded = 0
|
|
||||||
self.wm_maximized = 0
|
self.wm_maximized = 0
|
||||||
self.save_games_geometry = False
|
self.save_games_geometry = False
|
||||||
self.games_geometry = {} # saved games geometry (gameid: (width, height))
|
self.games_geometry = {} # saved games geometry (gameid: (width, height))
|
||||||
#
|
#
|
||||||
self.splashscreen = True
|
|
||||||
self.mouse_type = 'drag-n-drop' # or 'sticky-mouse' or 'point-n-click'
|
|
||||||
self.mouse_undo = False # use mouse for undo/redo
|
|
||||||
self.negative_bottom = True
|
|
||||||
self.randomize_place = False
|
self.randomize_place = False
|
||||||
self.save_cardsets = True
|
self.save_cardsets = True
|
||||||
|
self.dragcursor = True
|
||||||
# defaults & constants
|
# defaults & constants
|
||||||
self.setDefaults()
|
self.setDefaults()
|
||||||
self.setConstants()
|
self.setConstants()
|
||||||
|
|
||||||
def setDefaults(self, top=None):
|
def setDefaults(self, top=None):
|
||||||
|
# toolbar
|
||||||
|
if WIN_SYSTEM == 'win32':
|
||||||
|
self.toolbar_style = 'crystal'
|
||||||
|
# fonts
|
||||||
|
if WIN_SYSTEM == 'win32':
|
||||||
|
self.fonts["sans"] = ("times new roman", 12)
|
||||||
|
self.fonts["fixed"] = ("courier new", 10)
|
||||||
|
elif WIN_SYSTEM == 'x11':
|
||||||
|
self.fonts["sans"] = ("helvetica", 12)
|
||||||
|
# tile theme
|
||||||
|
if WIN_SYSTEM == 'win32':
|
||||||
|
self.tile_theme = self.default_tile_theme = 'winnative'
|
||||||
|
if sys.getwindowsversion() >= (5, 1): # xp
|
||||||
|
self.tile_theme = 'xpnative'
|
||||||
|
elif WIN_SYSTEM == 'x11':
|
||||||
|
self.tile_theme = 'clam'
|
||||||
|
self.default_tile_theme = 'default'
|
||||||
|
elif WIN_SYSTEM == 'aqua':
|
||||||
|
self.tile_theme = self.default_tile_theme = 'aqua'
|
||||||
|
# cardsets
|
||||||
sw, sh, sd = 0, 0, 8
|
sw, sh, sd = 0, 0, 8
|
||||||
if top:
|
if top:
|
||||||
sw, sh, sd = top.winfo_screenwidth(), top.winfo_screenheight(), top.winfo_screendepth()
|
sw, sh, sd = (top.winfo_screenwidth(),
|
||||||
|
top.winfo_screenheight(),
|
||||||
|
top.winfo_screendepth())
|
||||||
if sd > 8:
|
if sd > 8:
|
||||||
self.tabletile_name = "Nostalgy.gif" # basename
|
self.tabletile_name = "Nostalgy.gif" # basename
|
||||||
else:
|
else:
|
||||||
self.tabletile_name = None
|
self.tabletile_name = None
|
||||||
#
|
#
|
||||||
#c = "Oxymoron"
|
|
||||||
c = "Standard"
|
c = "Standard"
|
||||||
if sw < 800 or sh < 600:
|
if sw < 800 or sh < 600:
|
||||||
c = "2000"
|
c = "2000"
|
||||||
|
#if sw > 1024 and sh > 768:
|
||||||
|
# c = 'Dondorf'
|
||||||
self.cardset = {
|
self.cardset = {
|
||||||
|
# game_type: (cardset_name, back_file)
|
||||||
0: (c, ""),
|
0: (c, ""),
|
||||||
CSI.TYPE_FRENCH: (c, ""),
|
CSI.TYPE_FRENCH: (c, ""),
|
||||||
CSI.TYPE_HANAFUDA: ("Kintengu", ""),
|
CSI.TYPE_HANAFUDA: ("Kintengu", ""),
|
||||||
|
@ -252,9 +330,9 @@ class Options:
|
||||||
|
|
||||||
# not changeable options
|
# not changeable options
|
||||||
def setConstants(self):
|
def setConstants(self):
|
||||||
self.dragcursor = True
|
## self.dragcursor = True
|
||||||
self.randomize_place = False
|
## self.randomize_place = False
|
||||||
self.mahjongg_create_solvable = 2
|
pass
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
opt = Options()
|
opt = Options()
|
||||||
|
@ -262,6 +340,165 @@ class Options:
|
||||||
opt.setConstants()
|
opt.setConstants()
|
||||||
return opt
|
return opt
|
||||||
|
|
||||||
|
def save(self, filename):
|
||||||
|
config = self._config
|
||||||
|
|
||||||
|
# general
|
||||||
|
for key, t in self.GENERAL_OPTIONS:
|
||||||
|
val = getattr(self, key)
|
||||||
|
config.set('general', key, val)
|
||||||
|
|
||||||
|
recent_gameid = ' '.join([str(i) for i in self.recent_gameid])
|
||||||
|
config.set('general', 'recent_gameid', recent_gameid)
|
||||||
|
|
||||||
|
favorite_gameid = ' '.join([str(i) for i in self.favorite_gameid])
|
||||||
|
config.set('general', 'favorite_gameid', favorite_gameid)
|
||||||
|
|
||||||
|
visible_buttons = [b for b in self.toolbar_vars
|
||||||
|
if self.toolbar_vars[b]]
|
||||||
|
visible_buttons = ' '.join(visible_buttons)
|
||||||
|
config.set('general', 'visible_buttons', visible_buttons)
|
||||||
|
|
||||||
|
# sound_samples
|
||||||
|
for key, val in self.sound_samples.items():
|
||||||
|
config.set('sound_samples', key, val)
|
||||||
|
|
||||||
|
# fonts
|
||||||
|
for key, val in self.fonts.items():
|
||||||
|
if val is None:
|
||||||
|
continue
|
||||||
|
val = list(val)
|
||||||
|
val[0] = val[0].replace(' ', '_') # XXX: hack
|
||||||
|
val = ' '.join([str(i) for i in val])
|
||||||
|
config.set('fonts', key, val)
|
||||||
|
|
||||||
|
# colors
|
||||||
|
for key, val in self.colors.items():
|
||||||
|
config.set('colors', key, val)
|
||||||
|
|
||||||
|
# timeouts
|
||||||
|
for key, val in self.timeouts.items():
|
||||||
|
config.set('timeouts', key, val)
|
||||||
|
|
||||||
|
# cardsets
|
||||||
|
for key, val in self.cardset.items():
|
||||||
|
val = list(val)
|
||||||
|
if val[1] == '':
|
||||||
|
val[1] = 'none'
|
||||||
|
val = ' '.join(val)
|
||||||
|
config.set('cardsets', str(key), val)
|
||||||
|
|
||||||
|
# games_geometry
|
||||||
|
for key, val in self.games_geometry.items():
|
||||||
|
val = ' '.join(val)
|
||||||
|
config.set('games_geometry', str(key), val)
|
||||||
|
|
||||||
|
config.write(file(filename, 'w'))
|
||||||
|
#config.write(sys.stdout)
|
||||||
|
|
||||||
|
def _getOption(self, section, key, t):
|
||||||
|
config = self._config
|
||||||
|
try:
|
||||||
|
if t == 'bool':
|
||||||
|
val = config.getboolean(section, key)
|
||||||
|
elif t == 'int':
|
||||||
|
val = config.getint(section, key)
|
||||||
|
elif t == 'float':
|
||||||
|
val = config.getfloat(section, key)
|
||||||
|
else:
|
||||||
|
val = config.get(section, key)
|
||||||
|
except ConfigParser.NoOptionError:
|
||||||
|
val = None
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
val = None
|
||||||
|
return val
|
||||||
|
|
||||||
|
def load(self, filename):
|
||||||
|
config = self._config
|
||||||
|
config.read(filename)
|
||||||
|
|
||||||
|
# general
|
||||||
|
for key, t in self.GENERAL_OPTIONS:
|
||||||
|
val = self._getOption('general', key, t)
|
||||||
|
if val is not None:
|
||||||
|
setattr(self, key, val)
|
||||||
|
|
||||||
|
recent_gameid = self._getOption('general', 'recent_gameid', 'str')
|
||||||
|
if recent_gameid is not None:
|
||||||
|
try:
|
||||||
|
self.recent_gameid = [int(i) for i in recent_gameid.split()]
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
favorite_gameid = self._getOption('general', 'favorite_gameid', 'str')
|
||||||
|
if favorite_gameid is not None:
|
||||||
|
try:
|
||||||
|
self.favorite_gameid = [int(i) for i in favorite_gameid.split()]
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
visible_buttons = self._getOption('general', 'visible_buttons', 'str')
|
||||||
|
if visible_buttons is not None:
|
||||||
|
visible_buttons = visible_buttons.split()
|
||||||
|
for key in self.toolbar_vars:
|
||||||
|
self.toolbar_vars[key] = (key in visible_buttons)
|
||||||
|
|
||||||
|
# sound_samples
|
||||||
|
for key in self.sound_samples:
|
||||||
|
val = self._getOption('sound_samples', key, 'bool')
|
||||||
|
if val is not None:
|
||||||
|
self.sound_samples[key] = val
|
||||||
|
|
||||||
|
# fonts
|
||||||
|
for key in self.fonts:
|
||||||
|
val = self._getOption('fonts', key, 'str')
|
||||||
|
if val is not None:
|
||||||
|
val = val.split()
|
||||||
|
try:
|
||||||
|
val[0] = val[0].replace('_', ' ')
|
||||||
|
val[1] = int(val[1])
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
else:
|
||||||
|
val = tuple(val)
|
||||||
|
self.fonts[key] = val
|
||||||
|
|
||||||
|
# colors
|
||||||
|
for key in self.colors:
|
||||||
|
val = self._getOption('colors', key, 'str')
|
||||||
|
if val is not None:
|
||||||
|
self.colors[key] = val
|
||||||
|
|
||||||
|
# timeouts
|
||||||
|
for key in self.timeouts:
|
||||||
|
val = self._getOption('timeouts', key, 'float')
|
||||||
|
if val is not None:
|
||||||
|
self.timeouts[key] = val
|
||||||
|
|
||||||
|
# cardsets
|
||||||
|
for key in self.cardset:
|
||||||
|
val = self._getOption('cardsets', str(key), 'str')
|
||||||
|
if val is not None:
|
||||||
|
try:
|
||||||
|
i = val.rindex(' ')
|
||||||
|
if val[i+1:] == 'none':
|
||||||
|
val = (val[:i], '')
|
||||||
|
else:
|
||||||
|
val = [val[:i], val[i+1:]]
|
||||||
|
self.cardset[int(key)] = val
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
# games_geometry
|
||||||
|
for key, val in config.items('games_geometry'):
|
||||||
|
try:
|
||||||
|
val = [int(i) for i in val.split()]
|
||||||
|
assert len(val) == 2
|
||||||
|
self.games_geometry[int(key)] = val
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# // Statistics
|
# // Statistics
|
||||||
|
@ -519,7 +756,6 @@ class Comments:
|
||||||
|
|
||||||
class Application:
|
class Application:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
##self.starttimer = Timer("Application.__init__")
|
|
||||||
self.gdb = GAME_DB
|
self.gdb = GAME_DB
|
||||||
self.opt = Options()
|
self.opt = Options()
|
||||||
self.startup_opt = self.opt.copy()
|
self.startup_opt = self.opt.copy()
|
||||||
|
@ -581,7 +817,7 @@ class Application:
|
||||||
# file names
|
# file names
|
||||||
self.fn = Struct(
|
self.fn = Struct(
|
||||||
opt = os.path.join(self.dn.config, "options.dat"),
|
opt = os.path.join(self.dn.config, "options.dat"),
|
||||||
opt_conf = os.path.join(self.dn.config, "options.conf"),
|
opt_cfg = os.path.join(self.dn.config, "options.cfg"),
|
||||||
stats = os.path.join(self.dn.config, "statistics.dat"),
|
stats = os.path.join(self.dn.config, "statistics.dat"),
|
||||||
holdgame = os.path.join(self.dn.config, "holdgame.dat"),
|
holdgame = os.path.join(self.dn.config, "holdgame.dat"),
|
||||||
comments = os.path.join(self.dn.config, "comments.dat"),
|
comments = os.path.join(self.dn.config, "comments.dat"),
|
||||||
|
@ -867,9 +1103,9 @@ class Application:
|
||||||
s = self.top.wm_state()
|
s = self.top.wm_state()
|
||||||
##print "wm_save_state", s
|
##print "wm_save_state", s
|
||||||
if s == "zoomed": # Windows only
|
if s == "zoomed": # Windows only
|
||||||
self.opt.wm_maximized = 1
|
self.opt.wm_maximized = True
|
||||||
elif s == "normal":
|
elif s == "normal":
|
||||||
self.opt.wm_maximized = 0
|
self.opt.wm_maximized = False
|
||||||
|
|
||||||
def wm_withdraw(self):
|
def wm_withdraw(self):
|
||||||
if self.intro.progress:
|
if self.intro.progress:
|
||||||
|
@ -1217,16 +1453,9 @@ Please select a %s type %s.
|
||||||
|
|
||||||
def loadOptions(self):
|
def loadOptions(self):
|
||||||
self.opt.setDefaults(self.top)
|
self.opt.setDefaults(self.top)
|
||||||
if not os.path.exists(self.fn.opt):
|
if not os.path.exists(self.fn.opt_cfg):
|
||||||
return
|
return
|
||||||
opt = unpickle(self.fn.opt)
|
self.opt.load(self.fn.opt_cfg)
|
||||||
if opt:
|
|
||||||
if DEBUG >= 6:
|
|
||||||
import pprint
|
|
||||||
print '======== options ========'
|
|
||||||
pprint.pprint(opt.__dict__)
|
|
||||||
print '========================='
|
|
||||||
self.opt.__dict__.update(opt.__dict__)
|
|
||||||
self.opt.setConstants()
|
self.opt.setConstants()
|
||||||
|
|
||||||
def loadStatistics(self):
|
def loadStatistics(self):
|
||||||
|
@ -1247,11 +1476,11 @@ Please select a %s type %s.
|
||||||
|
|
||||||
def __saveObject(self, obj, fn):
|
def __saveObject(self, obj, fn):
|
||||||
obj.version_tuple = VERSION_TUPLE
|
obj.version_tuple = VERSION_TUPLE
|
||||||
obj.saved = obj.saved + 1
|
obj.saved += 1
|
||||||
pickle(obj, fn, protocol=-1)
|
pickle(obj, fn, protocol=-1)
|
||||||
|
|
||||||
def saveOptions(self):
|
def saveOptions(self):
|
||||||
self.__saveObject(self.opt, self.fn.opt)
|
self.opt.save(self.fn.opt_cfg)
|
||||||
|
|
||||||
def saveStatistics(self):
|
def saveStatistics(self):
|
||||||
self.__saveObject(self.stats, self.fn.stats)
|
self.__saveObject(self.stats, self.fn.stats)
|
||||||
|
@ -1596,7 +1825,7 @@ Please select a %s type %s.
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
##traceback.print_exc()
|
##traceback.print_exc()
|
||||||
pass
|
pass
|
||||||
except EnvError, ex:
|
except EnvironmentError, ex:
|
||||||
pass
|
pass
|
||||||
# register cardsets
|
# register cardsets
|
||||||
for obj in found:
|
for obj in found:
|
||||||
|
@ -1645,7 +1874,7 @@ Please select a %s type %s.
|
||||||
if key not in t:
|
if key not in t:
|
||||||
t[key] = 1
|
t[key] = 1
|
||||||
found.append((n, tile))
|
found.append((n, tile))
|
||||||
except EnvError, ex:
|
except EnvironmentError, ex:
|
||||||
pass
|
pass
|
||||||
# register tiles
|
# register tiles
|
||||||
found.sort()
|
found.sort()
|
||||||
|
@ -1686,7 +1915,7 @@ Please select a %s type %s.
|
||||||
if key not in t:
|
if key not in t:
|
||||||
t[key] = 1
|
t[key] = 1
|
||||||
found.append((n, obj))
|
found.append((n, obj))
|
||||||
except EnvError, ex:
|
except EnvironmentError, ex:
|
||||||
pass
|
pass
|
||||||
# register songs
|
# register songs
|
||||||
found.sort()
|
found.sort()
|
||||||
|
|
|
@ -47,7 +47,6 @@ from mfxutil import Image, ImageTk
|
||||||
from mfxutil import destruct, Struct, SubclassResponsibility
|
from mfxutil import destruct, Struct, SubclassResponsibility
|
||||||
from mfxutil import uclock, usleep
|
from mfxutil import uclock, usleep
|
||||||
from mfxutil import format_time
|
from mfxutil import format_time
|
||||||
from util import Timer
|
|
||||||
from settings import PACKAGE, TOOLKIT, TOP_TITLE
|
from settings import PACKAGE, TOOLKIT, TOP_TITLE
|
||||||
from settings import VERSION, VERSION_TUPLE, FC_VERSION
|
from settings import VERSION, VERSION_TUPLE, FC_VERSION
|
||||||
from settings import DEBUG
|
from settings import DEBUG
|
||||||
|
@ -152,7 +151,6 @@ class Game:
|
||||||
|
|
||||||
# main constructor
|
# main constructor
|
||||||
def create(self, app):
|
def create(self, app):
|
||||||
##timer = Timer("Game.create")
|
|
||||||
old_busy = self.busy
|
old_busy = self.busy
|
||||||
self.__createCommon(app)
|
self.__createCommon(app)
|
||||||
self.setCursor(cursor=CURSOR_WATCH)
|
self.setCursor(cursor=CURSOR_WATCH)
|
||||||
|
@ -161,9 +159,7 @@ class Game:
|
||||||
self.top.wm_iconname(PACKAGE + " - " + self.getTitleName())
|
self.top.wm_iconname(PACKAGE + " - " + self.getTitleName())
|
||||||
# create the game
|
# create the game
|
||||||
if self.app.intro.progress: self.app.intro.progress.update(step=1)
|
if self.app.intro.progress: self.app.intro.progress.update(step=1)
|
||||||
##print timer
|
|
||||||
self.createGame()
|
self.createGame()
|
||||||
##print timer
|
|
||||||
# set some defaults
|
# set some defaults
|
||||||
self.sg.openstacks = filter(lambda s: s.cap.max_accept >= s.cap.min_accept, self.sg.openstacks)
|
self.sg.openstacks = filter(lambda s: s.cap.max_accept >= s.cap.min_accept, self.sg.openstacks)
|
||||||
self.sg.hp_stacks = filter(lambda s: s.cap.max_move >= 2, self.sg.dropstacks)
|
self.sg.hp_stacks = filter(lambda s: s.cap.max_move >= 2, self.sg.dropstacks)
|
||||||
|
@ -191,13 +187,11 @@ class Game:
|
||||||
# optimize regions
|
# optimize regions
|
||||||
self.optimizeRegions()
|
self.optimizeRegions()
|
||||||
# create cards
|
# create cards
|
||||||
##print timer
|
|
||||||
if not self.cards:
|
if not self.cards:
|
||||||
self.cards = self.createCards(progress=self.app.intro.progress)
|
self.cards = self.createCards(progress=self.app.intro.progress)
|
||||||
self.initBindings()
|
self.initBindings()
|
||||||
##self.top.bind('<ButtonPress>', self.top._sleepEvent)
|
##self.top.bind('<ButtonPress>', self.top._sleepEvent)
|
||||||
##self.top.bind('<3>', self.top._sleepEvent)
|
##self.top.bind('<3>', self.top._sleepEvent)
|
||||||
##print timer
|
|
||||||
# update display properties
|
# update display properties
|
||||||
self.top.wm_geometry("") # cancel user-specified geometry
|
self.top.wm_geometry("") # cancel user-specified geometry
|
||||||
self.canvas.setInitialSize(self.width, self.height)
|
self.canvas.setInitialSize(self.width, self.height)
|
||||||
|
@ -213,7 +207,6 @@ class Game:
|
||||||
#
|
#
|
||||||
self.stats.update_time = time.time()
|
self.stats.update_time = time.time()
|
||||||
self.busy = old_busy
|
self.busy = old_busy
|
||||||
##print timer
|
|
||||||
self.showHelp() # just in case
|
self.showHelp() # just in case
|
||||||
##self.reallocateStacks()
|
##self.reallocateStacks()
|
||||||
|
|
||||||
|
@ -298,13 +291,11 @@ class Game:
|
||||||
)
|
)
|
||||||
|
|
||||||
def createPreview(self, app):
|
def createPreview(self, app):
|
||||||
##timer = Timer("Game.createPreview")
|
|
||||||
old_busy = self.busy
|
old_busy = self.busy
|
||||||
self.__createCommon(app)
|
self.__createCommon(app)
|
||||||
self.preview = max(1, self.canvas.preview)
|
self.preview = max(1, self.canvas.preview)
|
||||||
# create game
|
# create game
|
||||||
self.createGame()
|
self.createGame()
|
||||||
##print timer
|
|
||||||
# set some defaults
|
# set some defaults
|
||||||
self.sg.openstacks = filter(lambda s: s.cap.max_accept >= s.cap.min_accept, self.sg.openstacks)
|
self.sg.openstacks = filter(lambda s: s.cap.max_accept >= s.cap.min_accept, self.sg.openstacks)
|
||||||
self.sg.hp_stacks = filter(lambda s: s.cap.max_move >= 2, self.sg.dropstacks)
|
self.sg.hp_stacks = filter(lambda s: s.cap.max_move >= 2, self.sg.dropstacks)
|
||||||
|
@ -437,7 +428,6 @@ class Game:
|
||||||
##print self.random, self.random.__dict__
|
##print self.random, self.random.__dict__
|
||||||
self.shuffle()
|
self.shuffle()
|
||||||
assert len(self.s.talon.cards) == self.gameinfo.ncards
|
assert len(self.s.talon.cards) == self.gameinfo.ncards
|
||||||
##print self.app.starttimer
|
|
||||||
for stack in self.allstacks:
|
for stack in self.allstacks:
|
||||||
stack.updateText()
|
stack.updateText()
|
||||||
self.updateText()
|
self.updateText()
|
||||||
|
@ -725,7 +715,6 @@ class Game:
|
||||||
|
|
||||||
# Create all cards for the game.
|
# Create all cards for the game.
|
||||||
def createCards(self, progress=None):
|
def createCards(self, progress=None):
|
||||||
##timer = Timer("Game.createCards")
|
|
||||||
gi = self.gameinfo
|
gi = self.gameinfo
|
||||||
pstep = 0
|
pstep = 0
|
||||||
if progress:
|
if progress:
|
||||||
|
@ -752,7 +741,6 @@ class Game:
|
||||||
if progress: progress.update(step=pstep)
|
if progress: progress.update(step=pstep)
|
||||||
if progress: progress.update(percent=100)
|
if progress: progress.update(percent=100)
|
||||||
assert len(cards) == gi.ncards
|
assert len(cards) == gi.ncards
|
||||||
##print timer
|
|
||||||
return cards
|
return cards
|
||||||
|
|
||||||
def _createCard(self, id, deck, suit, rank, x, y):
|
def _createCard(self, id, deck, suit, rank, x, y):
|
||||||
|
|
|
@ -392,8 +392,9 @@ class AbstractMahjonggGame(Game):
|
||||||
left_margin = l.XM + 4*cardw+fdxx+d_x + l.XM
|
left_margin = l.XM + 4*cardw+fdxx+d_x + l.XM
|
||||||
else:
|
else:
|
||||||
left_margin = l.XM
|
left_margin = l.XM
|
||||||
w = left_margin + (max_tx+2)*cardw/2+dxx+d_x + l.XM+ti_width+l.XM
|
tableau_width = (max_tx+2)*cardw/2+dxx+d_x
|
||||||
# left margin | tiles | right margin
|
right_margin = l.XM+ti_width+l.XM
|
||||||
|
w = left_margin + tableau_width + right_margin
|
||||||
h = l.YM + dyy + (max_ty + 2) * cardh / 2 + d_y + l.YM
|
h = l.YM + dyy + (max_ty + 2) * cardh / 2 + d_y + l.YM
|
||||||
if show_removed:
|
if show_removed:
|
||||||
h = max(h, l.YM+fdyy+cardh*9+d_y+l.YM)
|
h = max(h, l.YM+fdyy+cardh*9+d_y+l.YM)
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
# imports
|
# imports
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from mfxutil import EnvError
|
|
||||||
from settings import PACKAGE, PACKAGE_URL, TOOLKIT, FC_VERSION
|
from settings import PACKAGE, PACKAGE_URL, TOOLKIT, FC_VERSION
|
||||||
from pysoltk import make_help_toplevel
|
from pysoltk import make_help_toplevel
|
||||||
from pysoltk import MfxMessageDialog
|
from pysoltk import MfxMessageDialog
|
||||||
|
@ -130,7 +129,7 @@ def help_html(app, document, dir_, top=None):
|
||||||
if help_html_index is None:
|
if help_html_index is None:
|
||||||
document, dir_ = "index.html", "html"
|
document, dir_ = "index.html", "html"
|
||||||
help_html_index = app.dataloader.findFile(document, dir_)
|
help_html_index = app.dataloader.findFile(document, dir_)
|
||||||
except EnvError:
|
except EnvironmentError:
|
||||||
d = MfxMessageDialog(app.top, title=PACKAGE + _(" HTML Problem"),
|
d = MfxMessageDialog(app.top, title=PACKAGE + _(" HTML Problem"),
|
||||||
text=_("Cannot find help document\n") + document,
|
text=_("Cannot find help document\n") + document,
|
||||||
bitmap="warning")
|
bitmap="warning")
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
|
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
import os, sys
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from settings import DEBUG, USE_FREECELL_SOLVER, FCS_COMMAND
|
from settings import DEBUG, FCS_COMMAND
|
||||||
from mfxutil import destruct
|
from mfxutil import destruct
|
||||||
from util import KING
|
from util import KING
|
||||||
|
|
||||||
|
@ -253,17 +253,17 @@ class AbstractHint(HintInterface):
|
||||||
def _canDropAllCards(self, from_stack, stacks, stackcards):
|
def _canDropAllCards(self, from_stack, stacks, stackcards):
|
||||||
assert from_stack not in stacks
|
assert from_stack not in stacks
|
||||||
return 0
|
return 0
|
||||||
# FIXME: this does not account for cards which are dropped herein
|
## # FIXME: this does not account for cards which are dropped herein
|
||||||
cards = pile[:]
|
## cards = pile[:]
|
||||||
cards.reverse()
|
## cards.reverse()
|
||||||
for card in cards:
|
## for card in cards:
|
||||||
for s in stacks:
|
## for s in stacks:
|
||||||
if s is not from_stack:
|
## if s is not from_stack:
|
||||||
if s.acceptsCards(from_stack, [card]):
|
## if s.acceptsCards(from_stack, [card]):
|
||||||
break
|
## break
|
||||||
else:
|
## else:
|
||||||
return 0
|
## return 0
|
||||||
return 1
|
## return 1
|
||||||
|
|
||||||
#
|
#
|
||||||
# misc. constants
|
# misc. constants
|
||||||
|
|
|
@ -65,21 +65,13 @@ if TOOLKIT == 'tk':
|
||||||
import JpegImagePlugin
|
import JpegImagePlugin
|
||||||
import BmpImagePlugin
|
import BmpImagePlugin
|
||||||
import PpmImagePlugin
|
import PpmImagePlugin
|
||||||
Image._initialized=2
|
Image._initialized = 2
|
||||||
|
|
||||||
if os.name == "mac":
|
|
||||||
# macfs module is deprecated, consider using Carbon.File or Carbon.Folder
|
|
||||||
import macfs, MACFS
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# // exceptions
|
# // exceptions
|
||||||
# ************************************************************************/
|
# ************************************************************************/
|
||||||
|
|
||||||
# work around a Mac problem
|
|
||||||
##EnvError = EnvironmentError
|
|
||||||
EnvError = (IOError, OSError, os.error,)
|
|
||||||
|
|
||||||
|
|
||||||
class SubclassResponsibility(Exception):
|
class SubclassResponsibility(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -143,10 +135,6 @@ def gethomedir():
|
||||||
def getprefdir(package, home=None):
|
def getprefdir(package, home=None):
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
return win32_getprefdir(package)
|
return win32_getprefdir(package)
|
||||||
if os.name == "mac":
|
|
||||||
vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kPreferencesFolderType, 0)
|
|
||||||
fss = macfs.FSSpec((vrefnum, dirid, ":" + "PySolFC"))
|
|
||||||
return fss.as_pathname()
|
|
||||||
if home is None:
|
if home is None:
|
||||||
home = gethomedir()
|
home = gethomedir()
|
||||||
return os.path.join(home, ".PySolFC")
|
return os.path.join(home, ".PySolFC")
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
import os, glob
|
import os, glob
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from mfxutil import Struct, KwStruct, EnvError
|
from mfxutil import Struct, KwStruct
|
||||||
from settings import DEBUG
|
from settings import DEBUG
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class ResourceManager:
|
||||||
dir = os.path.normpath(dir)
|
dir = os.path.normpath(dir)
|
||||||
if dir and os.path.isdir(dir) and dir not in result:
|
if dir and os.path.isdir(dir) and dir not in result:
|
||||||
result.append(dir)
|
result.append(dir)
|
||||||
except EnvError, ex:
|
except EnvironmentError, ex:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getSearchDirs(self, app, search, env=None):
|
def getSearchDirs(self, app, search, env=None):
|
||||||
|
@ -156,7 +156,7 @@ class ResourceManager:
|
||||||
self._addDir(result, d)
|
self._addDir(result, d)
|
||||||
else:
|
else:
|
||||||
self._addDir(result, os.path.join(dir, s))
|
self._addDir(result, os.path.join(dir, s))
|
||||||
except EnvError, ex:
|
except EnvironmentError, ex:
|
||||||
pass
|
pass
|
||||||
if DEBUG >= 6:
|
if DEBUG >= 6:
|
||||||
print "getSearchDirs", env, search, "->", result
|
print "getSearchDirs", env, search, "->", result
|
||||||
|
|
|
@ -66,8 +66,6 @@ if os.name == 'posix':
|
||||||
]
|
]
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
pass
|
pass
|
||||||
if os.name == 'mac':
|
|
||||||
pass
|
|
||||||
|
|
||||||
TOP_SIZE = 10
|
TOP_SIZE = 10
|
||||||
TOP_TITLE = n_('Top 10')
|
TOP_TITLE = n_('Top 10')
|
||||||
|
|
|
@ -108,7 +108,7 @@ import types
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from mfxutil import Struct, kwdefault, SubclassResponsibility
|
from mfxutil import Struct, kwdefault, SubclassResponsibility
|
||||||
from mfxutil import Image, ImageTk, ImageOps
|
from mfxutil import Image, ImageTk
|
||||||
from util import ACE, KING
|
from util import ACE, KING
|
||||||
from util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK
|
from util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK
|
||||||
from pysoltk import EVENT_HANDLED, EVENT_PROPAGATE
|
from pysoltk import EVENT_HANDLED, EVENT_PROPAGATE
|
||||||
|
|
|
@ -118,16 +118,21 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
|
select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
|
||||||
gg = None
|
gg = None
|
||||||
if filter(select_mahjongg_game, self.all_games_gi):
|
if filter(select_mahjongg_game, self.all_games_gi):
|
||||||
gg = SelectGameNode(None, _("Mahjongg Games"), select_mahjongg_game)
|
gg = SelectGameNode(None, _("Mahjongg Games"),
|
||||||
|
select_mahjongg_game)
|
||||||
g.append(gg)
|
g.append(gg)
|
||||||
if g[0]:
|
if g[0]:
|
||||||
s_by_type = SelectGameNode(None, _("French games"), tuple(g[0]), expanded=1)
|
s_by_type = SelectGameNode(None, _("French games"),
|
||||||
|
tuple(g[0]), expanded=1)
|
||||||
if g[1]:
|
if g[1]:
|
||||||
s_oriental = SelectGameNode(None, _("Oriental Games"), tuple(g[1]))
|
s_oriental = SelectGameNode(None, _("Oriental Games"),
|
||||||
|
tuple(g[1]))
|
||||||
if g[2]:
|
if g[2]:
|
||||||
s_special = SelectGameNode(None, _("Special Games"), tuple(g[2]))
|
s_special = SelectGameNode(None, _("Special Games"),
|
||||||
|
tuple(g[2]))
|
||||||
if g[3]:
|
if g[3]:
|
||||||
s_original = SelectGameNode(None, _("Original Games"), tuple(g[3]))
|
s_original = SelectGameNode(None, _("Original Games"),
|
||||||
|
tuple(g[3]))
|
||||||
## if g[4]:
|
## if g[4]:
|
||||||
## s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4]))
|
## s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4]))
|
||||||
if g[5]:
|
if g[5]:
|
||||||
|
@ -141,8 +146,8 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
name = _(name)
|
name = _(name)
|
||||||
gg.append(SelectGameNode(None, name, select_func))
|
gg.append(SelectGameNode(None, name, select_func))
|
||||||
if 1 and gg:
|
if 1 and gg:
|
||||||
s_by_compatibility = SelectGameNode(None, _("by Compatibility"), tuple(gg))
|
s_by_compatibility = SelectGameNode(None, _("by Compatibility"),
|
||||||
pass
|
tuple(gg))
|
||||||
#
|
#
|
||||||
s_by_pysol_version, gg = None, []
|
s_by_pysol_version, gg = None, []
|
||||||
for name, games in GI.GAMES_BY_PYSOL_VERSION:
|
for name, games in GI.GAMES_BY_PYSOL_VERSION:
|
||||||
|
@ -152,62 +157,93 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
name = _("New games in v. ") + name
|
name = _("New games in v. ") + name
|
||||||
gg.append(SelectGameNode(None, name, select_func))
|
gg.append(SelectGameNode(None, name, select_func))
|
||||||
if 1 and gg:
|
if 1 and gg:
|
||||||
s_by_pysol_version = SelectGameNode(None, _("by PySol version"), tuple(gg))
|
s_by_pysol_version = SelectGameNode(None, _("by PySol version"),
|
||||||
pass
|
tuple(gg))
|
||||||
#
|
#
|
||||||
ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
||||||
#
|
#
|
||||||
self.rootnodes = filter(None, (
|
self.rootnodes = filter(None, (
|
||||||
#SelectGameNode(None, "All Games", lambda gi: 1, expanded=0),
|
|
||||||
SelectGameNode(None, _("All Games"), None, expanded=0),
|
SelectGameNode(None, _("All Games"), None, expanded=0),
|
||||||
SelectGameNode(None, _("Alternate Names"), ul_alternate_names),
|
SelectGameNode(None, _("Alternate Names"), ul_alternate_names),
|
||||||
SelectGameNode(None, _("Popular Games"), lambda gi: gi.si.game_flags & GI.GT_POPULAR, expanded=0),
|
SelectGameNode(None, _("Popular Games"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_POPULAR),
|
||||||
|
s_by_type,
|
||||||
s_mahjongg,
|
s_mahjongg,
|
||||||
s_oriental,
|
s_oriental,
|
||||||
s_special,
|
s_special,
|
||||||
s_by_type,
|
SelectGameNode(None, _("Custom Games"),
|
||||||
|
lambda gi: gi.si.game_type == GI.GT_CUSTOM),
|
||||||
SelectGameNode(None, _('by Skill Level'), (
|
SelectGameNode(None, _('by Skill Level'), (
|
||||||
SelectGameNode(None, _('Luck only'), lambda gi: gi.skill_level == GI.SL_LUCK),
|
SelectGameNode(None, _('Luck only'),
|
||||||
SelectGameNode(None, _('Mostly luck'), lambda gi: gi.skill_level == GI.SL_MOSTLY_LUCK),
|
lambda gi: gi.skill_level == GI.SL_LUCK),
|
||||||
SelectGameNode(None, _('Balanced'), lambda gi: gi.skill_level == GI.SL_BALANCED),
|
SelectGameNode(None, _('Mostly luck'),
|
||||||
SelectGameNode(None, _('Mostly skill'), lambda gi: gi.skill_level == GI.SL_MOSTLY_SKILL),
|
lambda gi: gi.skill_level == GI.SL_MOSTLY_LUCK),
|
||||||
SelectGameNode(None, _('Skill only'), lambda gi: gi.skill_level == GI.SL_SKILL),
|
SelectGameNode(None, _('Balanced'),
|
||||||
|
lambda gi: gi.skill_level == GI.SL_BALANCED),
|
||||||
|
SelectGameNode(None, _('Mostly skill'),
|
||||||
|
lambda gi: gi.skill_level == GI.SL_MOSTLY_SKILL),
|
||||||
|
SelectGameNode(None, _('Skill only'),
|
||||||
|
lambda gi: gi.skill_level == GI.SL_SKILL),
|
||||||
)),
|
)),
|
||||||
SelectGameNode(None, _("by Game Feature"), (
|
SelectGameNode(None, _("by Game Feature"), (
|
||||||
SelectGameNode(None, _("by Number of Cards"), (
|
SelectGameNode(None, _("by Number of Cards"), (
|
||||||
SelectGameNode(None, _("32 cards"), lambda gi: gi.si.ncards == 32),
|
SelectGameNode(None, _("32 cards"),
|
||||||
SelectGameNode(None, _("48 cards"), lambda gi: gi.si.ncards == 48),
|
lambda gi: gi.si.ncards == 32),
|
||||||
SelectGameNode(None, _("52 cards"), lambda gi: gi.si.ncards == 52),
|
SelectGameNode(None, _("48 cards"),
|
||||||
SelectGameNode(None, _("64 cards"), lambda gi: gi.si.ncards == 64),
|
lambda gi: gi.si.ncards == 48),
|
||||||
SelectGameNode(None, _("78 cards"), lambda gi: gi.si.ncards == 78),
|
SelectGameNode(None, _("52 cards"),
|
||||||
SelectGameNode(None, _("104 cards"), lambda gi: gi.si.ncards == 104),
|
lambda gi: gi.si.ncards == 52),
|
||||||
SelectGameNode(None, _("144 cards"), lambda gi: gi.si.ncards == 144),
|
SelectGameNode(None, _("64 cards"),
|
||||||
SelectGameNode(None, _("Other number"), lambda gi: gi.si.ncards not in (32, 48, 52, 64, 78, 104, 144)),
|
lambda gi: gi.si.ncards == 64),
|
||||||
|
SelectGameNode(None, _("78 cards"),
|
||||||
|
lambda gi: gi.si.ncards == 78),
|
||||||
|
SelectGameNode(None, _("104 cards"),
|
||||||
|
lambda gi: gi.si.ncards == 104),
|
||||||
|
SelectGameNode(None, _("144 cards"),
|
||||||
|
lambda gi: gi.si.ncards == 144),
|
||||||
|
SelectGameNode(None, _("Other number"),
|
||||||
|
lambda gi: gi.si.ncards not in (32, 48, 52, 64, 78, 104, 144)),
|
||||||
)),
|
)),
|
||||||
SelectGameNode(None, _("by Number of Decks"), (
|
SelectGameNode(None, _("by Number of Decks"), (
|
||||||
SelectGameNode(None, _("1 deck games"), lambda gi: gi.si.decks == 1),
|
SelectGameNode(None, _("1 deck games"),
|
||||||
SelectGameNode(None, _("2 deck games"), lambda gi: gi.si.decks == 2),
|
lambda gi: gi.si.decks == 1),
|
||||||
SelectGameNode(None, _("3 deck games"), lambda gi: gi.si.decks == 3),
|
SelectGameNode(None, _("2 deck games"),
|
||||||
SelectGameNode(None, _("4 deck games"), lambda gi: gi.si.decks == 4),
|
lambda gi: gi.si.decks == 2),
|
||||||
|
SelectGameNode(None, _("3 deck games"),
|
||||||
|
lambda gi: gi.si.decks == 3),
|
||||||
|
SelectGameNode(None, _("4 deck games"),
|
||||||
|
lambda gi: gi.si.decks == 4),
|
||||||
)),
|
)),
|
||||||
SelectGameNode(None, _("by Number of Redeals"), (
|
SelectGameNode(None, _("by Number of Redeals"), (
|
||||||
SelectGameNode(None, _("No redeal"), lambda gi: gi.si.redeals == 0),
|
SelectGameNode(None, _("No redeal"),
|
||||||
SelectGameNode(None, _("1 redeal"), lambda gi: gi.si.redeals == 1),
|
lambda gi: gi.si.redeals == 0),
|
||||||
SelectGameNode(None, _("2 redeals"), lambda gi: gi.si.redeals == 2),
|
SelectGameNode(None, _("1 redeal"),
|
||||||
SelectGameNode(None, _("3 redeals"), lambda gi: gi.si.redeals == 3),
|
lambda gi: gi.si.redeals == 1),
|
||||||
SelectGameNode(None, _("Unlimited redeals"), lambda gi: gi.si.redeals == -1),
|
SelectGameNode(None, _("2 redeals"),
|
||||||
## SelectGameNode(None, "Variable redeals", lambda gi: gi.si.redeals == -2),
|
lambda gi: gi.si.redeals == 2),
|
||||||
SelectGameNode(None, _("Other number of redeals"), lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
SelectGameNode(None, _("3 redeals"),
|
||||||
|
lambda gi: gi.si.redeals == 3),
|
||||||
|
SelectGameNode(None, _("Unlimited redeals"),
|
||||||
|
lambda gi: gi.si.redeals == -1),
|
||||||
|
## SelectGameNode(None, "Variable redeals",
|
||||||
|
## lambda gi: gi.si.redeals == -2),
|
||||||
|
SelectGameNode(None, _("Other number of redeals"),
|
||||||
|
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
||||||
)),
|
)),
|
||||||
s_by_compatibility,
|
s_by_compatibility,
|
||||||
)),
|
)),
|
||||||
s_by_pysol_version,
|
s_by_pysol_version,
|
||||||
SelectGameNode(None, _("Other Categories"), (
|
SelectGameNode(None, _("Other Categories"), (
|
||||||
SelectGameNode(None, _("Games for Children (very easy)"), lambda gi: gi.si.game_flags & GI.GT_CHILDREN),
|
SelectGameNode(None, _("Games for Children (very easy)"),
|
||||||
SelectGameNode(None, _("Games with Scoring"), lambda gi: gi.si.game_flags & GI.GT_SCORE),
|
lambda gi: gi.si.game_flags & GI.GT_CHILDREN),
|
||||||
SelectGameNode(None, _("Games with Separate Decks"), lambda gi: gi.si.game_flags & GI.GT_SEPARATE_DECKS),
|
SelectGameNode(None, _("Games with Scoring"),
|
||||||
SelectGameNode(None, _("Open Games (all cards visible)"), lambda gi: gi.si.game_flags & GI.GT_OPEN),
|
lambda gi: gi.si.game_flags & GI.GT_SCORE),
|
||||||
SelectGameNode(None, _("Relaxed Variants"), lambda gi: gi.si.game_flags & GI.GT_RELAXED),
|
SelectGameNode(None, _("Games with Separate Decks"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_SEPARATE_DECKS),
|
||||||
|
SelectGameNode(None, _("Open Games (all cards visible)"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_OPEN),
|
||||||
|
SelectGameNode(None, _("Relaxed Variants"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_RELAXED),
|
||||||
)),
|
)),
|
||||||
s_original,
|
s_original,
|
||||||
s_contrib,
|
s_contrib,
|
||||||
|
|
|
@ -117,16 +117,21 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
|
select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
|
||||||
gg = None
|
gg = None
|
||||||
if filter(select_mahjongg_game, self.all_games_gi):
|
if filter(select_mahjongg_game, self.all_games_gi):
|
||||||
gg = SelectGameNode(None, _("Mahjongg Games"), select_mahjongg_game)
|
gg = SelectGameNode(None, _("Mahjongg Games"),
|
||||||
|
select_mahjongg_game)
|
||||||
g.append(gg)
|
g.append(gg)
|
||||||
if g[0]:
|
if g[0]:
|
||||||
s_by_type = SelectGameNode(None, _("French games"), tuple(g[0]), expanded=1)
|
s_by_type = SelectGameNode(None, _("French games"),
|
||||||
|
tuple(g[0]), expanded=1)
|
||||||
if g[1]:
|
if g[1]:
|
||||||
s_oriental = SelectGameNode(None, _("Oriental Games"), tuple(g[1]))
|
s_oriental = SelectGameNode(None, _("Oriental Games"),
|
||||||
|
tuple(g[1]))
|
||||||
if g[2]:
|
if g[2]:
|
||||||
s_special = SelectGameNode(None, _("Special Games"), tuple(g[2]))
|
s_special = SelectGameNode(None, _("Special Games"),
|
||||||
|
tuple(g[2]))
|
||||||
if g[3]:
|
if g[3]:
|
||||||
s_original = SelectGameNode(None, _("Original Games"), tuple(g[3]))
|
s_original = SelectGameNode(None, _("Original Games"),
|
||||||
|
tuple(g[3]))
|
||||||
## if g[4]:
|
## if g[4]:
|
||||||
## s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4]))
|
## s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4]))
|
||||||
if g[5]:
|
if g[5]:
|
||||||
|
@ -140,7 +145,8 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
name = _(name)
|
name = _(name)
|
||||||
gg.append(SelectGameNode(None, name, select_func))
|
gg.append(SelectGameNode(None, name, select_func))
|
||||||
if 1 and gg:
|
if 1 and gg:
|
||||||
s_by_compatibility = SelectGameNode(None, _("by Compatibility"), tuple(gg))
|
s_by_compatibility = SelectGameNode(None, _("by Compatibility"),
|
||||||
|
tuple(gg))
|
||||||
pass
|
pass
|
||||||
#
|
#
|
||||||
s_by_pysol_version, gg = None, []
|
s_by_pysol_version, gg = None, []
|
||||||
|
@ -151,62 +157,94 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
name = _("New games in v. ") + name
|
name = _("New games in v. ") + name
|
||||||
gg.append(SelectGameNode(None, name, select_func))
|
gg.append(SelectGameNode(None, name, select_func))
|
||||||
if 1 and gg:
|
if 1 and gg:
|
||||||
s_by_pysol_version = SelectGameNode(None, _("by PySol version"), tuple(gg))
|
s_by_pysol_version = SelectGameNode(None, _("by PySol version"),
|
||||||
|
tuple(gg))
|
||||||
pass
|
pass
|
||||||
#
|
#
|
||||||
ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
||||||
#
|
#
|
||||||
self.rootnodes = filter(None, (
|
self.rootnodes = filter(None, (
|
||||||
#SelectGameNode(None, "All Games", lambda gi: 1, expanded=0),
|
SelectGameNode(None, _("All Games"), None),
|
||||||
SelectGameNode(None, _("All Games"), None, expanded=0),
|
|
||||||
SelectGameNode(None, _("Alternate Names"), ul_alternate_names),
|
SelectGameNode(None, _("Alternate Names"), ul_alternate_names),
|
||||||
SelectGameNode(None, _("Popular Games"), lambda gi: gi.si.game_flags & GI.GT_POPULAR, expanded=0),
|
SelectGameNode(None, _("Popular Games"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_POPULAR),
|
||||||
s_mahjongg,
|
s_mahjongg,
|
||||||
s_oriental,
|
s_oriental,
|
||||||
s_special,
|
s_special,
|
||||||
|
SelectGameNode(None, _("Custom Games"),
|
||||||
|
lambda gi: gi.si.game_type == GI.GT_CUSTOM),
|
||||||
s_by_type,
|
s_by_type,
|
||||||
SelectGameNode(None, _('by Skill Level'), (
|
SelectGameNode(None, _('by Skill Level'), (
|
||||||
SelectGameNode(None, _('Luck only'), lambda gi: gi.skill_level == GI.SL_LUCK),
|
SelectGameNode(None, _('Luck only'),
|
||||||
SelectGameNode(None, _('Mostly luck'), lambda gi: gi.skill_level == GI.SL_MOSTLY_LUCK),
|
lambda gi: gi.skill_level == GI.SL_LUCK),
|
||||||
SelectGameNode(None, _('Balanced'), lambda gi: gi.skill_level == GI.SL_BALANCED),
|
SelectGameNode(None, _('Mostly luck'),
|
||||||
SelectGameNode(None, _('Mostly skill'), lambda gi: gi.skill_level == GI.SL_MOSTLY_SKILL),
|
lambda gi: gi.skill_level == GI.SL_MOSTLY_LUCK),
|
||||||
SelectGameNode(None, _('Skill only'), lambda gi: gi.skill_level == GI.SL_SKILL),
|
SelectGameNode(None, _('Balanced'),
|
||||||
|
lambda gi: gi.skill_level == GI.SL_BALANCED),
|
||||||
|
SelectGameNode(None, _('Mostly skill'),
|
||||||
|
lambda gi: gi.skill_level == GI.SL_MOSTLY_SKILL),
|
||||||
|
SelectGameNode(None, _('Skill only'),
|
||||||
|
lambda gi: gi.skill_level == GI.SL_SKILL),
|
||||||
)),
|
)),
|
||||||
SelectGameNode(None, _("by Game Feature"), (
|
SelectGameNode(None, _("by Game Feature"), (
|
||||||
SelectGameNode(None, _("by Number of Cards"), (
|
SelectGameNode(None, _("by Number of Cards"), (
|
||||||
SelectGameNode(None, _("32 cards"), lambda gi: gi.si.ncards == 32),
|
SelectGameNode(None, _("32 cards"),
|
||||||
SelectGameNode(None, _("48 cards"), lambda gi: gi.si.ncards == 48),
|
lambda gi: gi.si.ncards == 32),
|
||||||
SelectGameNode(None, _("52 cards"), lambda gi: gi.si.ncards == 52),
|
SelectGameNode(None, _("48 cards"),
|
||||||
SelectGameNode(None, _("64 cards"), lambda gi: gi.si.ncards == 64),
|
lambda gi: gi.si.ncards == 48),
|
||||||
SelectGameNode(None, _("78 cards"), lambda gi: gi.si.ncards == 78),
|
SelectGameNode(None, _("52 cards"),
|
||||||
SelectGameNode(None, _("104 cards"), lambda gi: gi.si.ncards == 104),
|
lambda gi: gi.si.ncards == 52),
|
||||||
SelectGameNode(None, _("144 cards"), lambda gi: gi.si.ncards == 144),
|
SelectGameNode(None, _("64 cards"),
|
||||||
SelectGameNode(None, _("Other number"), lambda gi: gi.si.ncards not in (32, 48, 52, 64, 78, 104, 144)),
|
lambda gi: gi.si.ncards == 64),
|
||||||
|
SelectGameNode(None, _("78 cards"),
|
||||||
|
lambda gi: gi.si.ncards == 78),
|
||||||
|
SelectGameNode(None, _("104 cards"),
|
||||||
|
lambda gi: gi.si.ncards == 104),
|
||||||
|
SelectGameNode(None, _("144 cards"),
|
||||||
|
lambda gi: gi.si.ncards == 144),
|
||||||
|
SelectGameNode(None, _("Other number"),
|
||||||
|
lambda gi: gi.si.ncards not in (32, 48, 52, 64, 78, 104, 144)),
|
||||||
)),
|
)),
|
||||||
SelectGameNode(None, _("by Number of Decks"), (
|
SelectGameNode(None, _("by Number of Decks"), (
|
||||||
SelectGameNode(None, _("1 deck games"), lambda gi: gi.si.decks == 1),
|
SelectGameNode(None, _("1 deck games"),
|
||||||
SelectGameNode(None, _("2 deck games"), lambda gi: gi.si.decks == 2),
|
lambda gi: gi.si.decks == 1),
|
||||||
SelectGameNode(None, _("3 deck games"), lambda gi: gi.si.decks == 3),
|
SelectGameNode(None, _("2 deck games"),
|
||||||
SelectGameNode(None, _("4 deck games"), lambda gi: gi.si.decks == 4),
|
lambda gi: gi.si.decks == 2),
|
||||||
|
SelectGameNode(None, _("3 deck games"),
|
||||||
|
lambda gi: gi.si.decks == 3),
|
||||||
|
SelectGameNode(None, _("4 deck games"),
|
||||||
|
lambda gi: gi.si.decks == 4),
|
||||||
)),
|
)),
|
||||||
SelectGameNode(None, _("by Number of Redeals"), (
|
SelectGameNode(None, _("by Number of Redeals"), (
|
||||||
SelectGameNode(None, _("No redeal"), lambda gi: gi.si.redeals == 0),
|
SelectGameNode(None, _("No redeal"),
|
||||||
SelectGameNode(None, _("1 redeal"), lambda gi: gi.si.redeals == 1),
|
lambda gi: gi.si.redeals == 0),
|
||||||
SelectGameNode(None, _("2 redeals"), lambda gi: gi.si.redeals == 2),
|
SelectGameNode(None, _("1 redeal"),
|
||||||
SelectGameNode(None, _("3 redeals"), lambda gi: gi.si.redeals == 3),
|
lambda gi: gi.si.redeals == 1),
|
||||||
SelectGameNode(None, _("Unlimited redeals"), lambda gi: gi.si.redeals == -1),
|
SelectGameNode(None, _("2 redeals"),
|
||||||
## SelectGameNode(None, "Variable redeals", lambda gi: gi.si.redeals == -2),
|
lambda gi: gi.si.redeals == 2),
|
||||||
SelectGameNode(None, _("Other number of redeals"), lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
SelectGameNode(None, _("3 redeals"),
|
||||||
|
lambda gi: gi.si.redeals == 3),
|
||||||
|
SelectGameNode(None, _("Unlimited redeals"),
|
||||||
|
lambda gi: gi.si.redeals == -1),
|
||||||
|
SelectGameNode(None, "Variable redeals",
|
||||||
|
lambda gi: gi.si.redeals == -2),
|
||||||
|
SelectGameNode(None, _("Other number of redeals"),
|
||||||
|
lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)),
|
||||||
)),
|
)),
|
||||||
s_by_compatibility,
|
s_by_compatibility,
|
||||||
)),
|
)),
|
||||||
s_by_pysol_version,
|
s_by_pysol_version,
|
||||||
SelectGameNode(None, _("Other Categories"), (
|
SelectGameNode(None, _("Other Categories"), (
|
||||||
SelectGameNode(None, _("Games for Children (very easy)"), lambda gi: gi.si.game_flags & GI.GT_CHILDREN),
|
SelectGameNode(None, _("Games for Children (very easy)"),
|
||||||
SelectGameNode(None, _("Games with Scoring"), lambda gi: gi.si.game_flags & GI.GT_SCORE),
|
lambda gi: gi.si.game_flags & GI.GT_CHILDREN),
|
||||||
SelectGameNode(None, _("Games with Separate Decks"), lambda gi: gi.si.game_flags & GI.GT_SEPARATE_DECKS),
|
SelectGameNode(None, _("Games with Scoring"),
|
||||||
SelectGameNode(None, _("Open Games (all cards visible)"), lambda gi: gi.si.game_flags & GI.GT_OPEN),
|
lambda gi: gi.si.game_flags & GI.GT_SCORE),
|
||||||
SelectGameNode(None, _("Relaxed Variants"), lambda gi: gi.si.game_flags & GI.GT_RELAXED),
|
SelectGameNode(None, _("Games with Separate Decks"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_SEPARATE_DECKS),
|
||||||
|
SelectGameNode(None, _("Open Games (all cards visible)"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_OPEN),
|
||||||
|
SelectGameNode(None, _("Relaxed Variants"),
|
||||||
|
lambda gi: gi.si.game_flags & GI.GT_RELAXED),
|
||||||
)),
|
)),
|
||||||
s_original,
|
s_original,
|
||||||
s_contrib,
|
s_contrib,
|
||||||
|
|
|
@ -73,8 +73,6 @@ class MfxStatusbar:
|
||||||
self.frame.grid(row=self._row, column=self._column,
|
self.frame.grid(row=self._row, column=self._column,
|
||||||
columnspan=self._columnspan, sticky='ew',
|
columnspan=self._columnspan, sticky='ew',
|
||||||
padx=1, pady=1)
|
padx=1, pady=1)
|
||||||
#if os.name == "mac":
|
|
||||||
# Tkinter.Label(self.frame, width=2).pack(side='right')
|
|
||||||
if WIN_SYSTEM == 'win32':
|
if WIN_SYSTEM == 'win32':
|
||||||
self.frame.config(relief='raised')
|
self.frame.config(relief='raised')
|
||||||
self.padx = 0
|
self.padx = 0
|
||||||
|
|
|
@ -457,10 +457,7 @@ class AllGames_StatsDialogScrolledCanvas(MfxScrolledCanvas):
|
||||||
|
|
||||||
|
|
||||||
class AllGames_StatsDialog(MfxDialog):
|
class AllGames_StatsDialog(MfxDialog):
|
||||||
# for font "canvas_fixed"
|
|
||||||
#CHAR_W, CHAR_H = 7, 16
|
|
||||||
#if os.name == "mac": CHAR_W = 6
|
|
||||||
#
|
|
||||||
YVIEW = 0
|
YVIEW = 0
|
||||||
FONT_TYPE = "default"
|
FONT_TYPE = "default"
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,11 @@ __all__ = ['SUITS',
|
||||||
'VARIABLE_REDEALS',
|
'VARIABLE_REDEALS',
|
||||||
'CARDSET',
|
'CARDSET',
|
||||||
'IMAGE_EXTENSIONS',
|
'IMAGE_EXTENSIONS',
|
||||||
'Timer',
|
|
||||||
'DataLoader',
|
'DataLoader',
|
||||||
]
|
]
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
import sys, os, re, time
|
import sys, os
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from settings import DATA_DIRS, TOOLKIT
|
from settings import DATA_DIRS, TOOLKIT
|
||||||
|
@ -116,25 +115,6 @@ if Image:
|
||||||
IMAGE_EXTENSIONS = (".png", ".gif", ".jpg", ".ppm", ".bmp")
|
IMAGE_EXTENSIONS = (".png", ".gif", ".jpg", ".ppm", ".bmp")
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
|
||||||
# // simple benchmarking
|
|
||||||
# ************************************************************************/
|
|
||||||
|
|
||||||
class Timer:
|
|
||||||
def __init__(self, msg = ""):
|
|
||||||
self.msg = msg
|
|
||||||
self.clock = time.time
|
|
||||||
if os.name == "nt":
|
|
||||||
self.clock = time.clock
|
|
||||||
self.start = self.clock()
|
|
||||||
def reset(self):
|
|
||||||
self.start = self.clock()
|
|
||||||
def get(self):
|
|
||||||
return self.clock() - self.start
|
|
||||||
def __repr__(self):
|
|
||||||
return "%-20s %6.3f seconds" % (self.msg, self.clock() - self.start)
|
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# // DataLoader
|
# // DataLoader
|
||||||
# ************************************************************************/
|
# ************************************************************************/
|
||||||
|
|
Loading…
Add table
Reference in a new issue