mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
* improved solitaire wizard
git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@159 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
parent
4147a1ce20
commit
bc4d344348
9 changed files with 207 additions and 134 deletions
|
@ -43,10 +43,12 @@ class CustomGame(Game):
|
||||||
for w in WizardWidgets:
|
for w in WizardWidgets:
|
||||||
if isinstance(w, basestring):
|
if isinstance(w, basestring):
|
||||||
continue
|
continue
|
||||||
if w.widget == 'menu':
|
if w.var_name in ss:
|
||||||
v = dict(w.values_map)[ss[w.var_name]]
|
|
||||||
else:
|
|
||||||
v = ss[w.var_name]
|
v = ss[w.var_name]
|
||||||
|
else:
|
||||||
|
v = w.default
|
||||||
|
if w.widget == 'menu':
|
||||||
|
v = dict(w.values_map)[v]
|
||||||
s[w.var_name] = v
|
s[w.var_name] = v
|
||||||
##from pprint import pprint; pprint(s)
|
##from pprint import pprint; pprint(s)
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ class CustomGame(Game):
|
||||||
kw = {
|
kw = {
|
||||||
'dir': s['found_dir'],
|
'dir': s['found_dir'],
|
||||||
'base_rank': s['found_base_card'],
|
'base_rank': s['found_base_card'],
|
||||||
|
'mod': 13,
|
||||||
}
|
}
|
||||||
if s['found_type'] not in (Spider_SS_Foundation,
|
if s['found_type'] not in (Spider_SS_Foundation,
|
||||||
Spider_AC_Foundation,):
|
Spider_AC_Foundation,):
|
||||||
|
@ -64,8 +67,6 @@ class CustomGame(Game):
|
||||||
kw['base_rank'] = ACE
|
kw['base_rank'] = ACE
|
||||||
elif s['found_base_card'] == ACE:
|
elif s['found_base_card'] == ACE:
|
||||||
kw['base_rank'] = KING
|
kw['base_rank'] = KING
|
||||||
if s['found_wrap']:
|
|
||||||
kw['mod'] = 13
|
|
||||||
foundation = StackWrapper(s['found_type'], **kw)
|
foundation = StackWrapper(s['found_type'], **kw)
|
||||||
|
|
||||||
# talon
|
# talon
|
||||||
|
@ -74,6 +75,8 @@ class CustomGame(Game):
|
||||||
}
|
}
|
||||||
if s['redeals'] >= 0:
|
if s['redeals'] >= 0:
|
||||||
kw['max_rounds'] += 1
|
kw['max_rounds'] += 1
|
||||||
|
if s['talon'] is WasteTalonStack:
|
||||||
|
kw['num_deal'] = s['deal_to_waste']
|
||||||
talon = StackWrapper(s['talon'], **kw)
|
talon = StackWrapper(s['talon'], **kw)
|
||||||
|
|
||||||
# rows
|
# rows
|
||||||
|
@ -84,20 +87,24 @@ class CustomGame(Game):
|
||||||
}
|
}
|
||||||
if s['rows_wrap']:
|
if s['rows_wrap']:
|
||||||
kw['mod'] = 13
|
kw['mod'] = 13
|
||||||
|
if s['rows_type'] in (UD_SS_RowStack, UD_AC_RowStack,
|
||||||
|
UD_RK_RowStack, UD_SC_RowStack):
|
||||||
|
kw['max_move'] = 1
|
||||||
row = StackWrapper(s['rows_type'], **kw)
|
row = StackWrapper(s['rows_type'], **kw)
|
||||||
|
|
||||||
# layout
|
# layout
|
||||||
layout_kw = {'rows' : s['rows_num'],
|
layout_kw = {
|
||||||
'waste' : False,
|
'rows' : s['rows_num'],
|
||||||
'texts' : True,
|
'reserves' : s['reserves_num'],
|
||||||
}
|
'waste' : False,
|
||||||
|
'texts' : True,
|
||||||
|
}
|
||||||
if s['talon'] is InitialDealTalonStack:
|
if s['talon'] is InitialDealTalonStack:
|
||||||
layout_kw['texts'] = False
|
layout_kw['texts'] = False
|
||||||
layout_kw['playcards'] = 12+s['deal_to_rows']
|
layout_kw['playcards'] = 12+s['deal_to_rows']
|
||||||
|
|
||||||
# reserves
|
# reserves
|
||||||
if s['reserves_num']:
|
if s['reserves_num']:
|
||||||
layout_kw['reserves'] = s['reserves_num']
|
|
||||||
kw = {
|
kw = {
|
||||||
'max_accept': s['reserves_max_accept'],
|
'max_accept': s['reserves_max_accept'],
|
||||||
}
|
}
|
||||||
|
@ -156,10 +163,11 @@ class CustomGame(Game):
|
||||||
for stack in self.s.rows:
|
for stack in self.s.rows:
|
||||||
stack.canDropCards = stack.spiderCanDropCards
|
stack.canDropCards = stack.spiderCanDropCards
|
||||||
|
|
||||||
if s['found_base_card'] == ANY_RANK:
|
# acceptsCards
|
||||||
|
if s['found_base_card'] == ANY_RANK and s['found_equal']:
|
||||||
for stack in self.s.foundations:
|
for stack in self.s.foundations:
|
||||||
stack.acceptsCards = stack.varyAcceptsCards
|
stack.acceptsCards = stack.varyAcceptsCards
|
||||||
stack.getBaseCard = stack.getVaryBaseCard
|
stack.getBaseCard = stack.varyGetBaseCard
|
||||||
|
|
||||||
|
|
||||||
def startGame(self):
|
def startGame(self):
|
||||||
|
@ -213,17 +221,16 @@ class CustomGame(Game):
|
||||||
def registerCustomGame(gameclass):
|
def registerCustomGame(gameclass):
|
||||||
|
|
||||||
s = gameclass.SETTINGS
|
s = gameclass.SETTINGS
|
||||||
|
|
||||||
for w in WizardWidgets:
|
for w in WizardWidgets:
|
||||||
if isinstance(w, basestring):
|
if isinstance(w, basestring):
|
||||||
continue
|
continue
|
||||||
if w.var_name == 'decks':
|
if w.var_name == 'decks':
|
||||||
v = s['decks']
|
v = s['decks']
|
||||||
decks = dict(w.values_map)[v]
|
decks = dict(w.values_map)[v]
|
||||||
if w.var_name == 'redeals':
|
elif w.var_name == 'redeals':
|
||||||
v = s['redeals']
|
v = s['redeals']
|
||||||
redeals = dict(w.values_map)[v]
|
redeals = dict(w.values_map)[v]
|
||||||
if w.var_name == 'skill_level':
|
elif w.var_name == 'skill_level':
|
||||||
v = s['skill_level']
|
v = s['skill_level']
|
||||||
skill_level = dict(w.values_map)[v]
|
skill_level = dict(w.values_map)[v]
|
||||||
gameid = s['gameid']
|
gameid = s['gameid']
|
||||||
|
|
|
@ -174,7 +174,6 @@ class GI:
|
||||||
(n_("Two-Deck games"),lambda gi, gt=GT_2DECK_TYPE: gi.si.game_type == gt),
|
(n_("Two-Deck games"),lambda gi, gt=GT_2DECK_TYPE: gi.si.game_type == gt),
|
||||||
(n_("Three-Deck games"),lambda gi, gt=GT_3DECK_TYPE: gi.si.game_type == gt),
|
(n_("Three-Deck games"),lambda gi, gt=GT_3DECK_TYPE: gi.si.game_type == gt),
|
||||||
(n_("Four-Deck games"),lambda gi, gt=GT_4DECK_TYPE: gi.si.game_type == gt),
|
(n_("Four-Deck games"),lambda gi, gt=GT_4DECK_TYPE: gi.si.game_type == gt),
|
||||||
(n_("Cusom games"), lambda gi, gt=GT_CUSTOM: gi.si.game_type == gt),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SELECT_ORIGINAL_GAME_BY_TYPE = (
|
SELECT_ORIGINAL_GAME_BY_TYPE = (
|
||||||
|
|
|
@ -314,7 +314,7 @@ class Layout:
|
||||||
for suit in range(suits):
|
for suit in range(suits):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
self.s.foundations.append(S(x+i*XS, y, suit=suit))
|
self.s.foundations.append(S(x+i*XS, y, suit=suit))
|
||||||
y = y + YS
|
y += YS
|
||||||
|
|
||||||
# create talon
|
# create talon
|
||||||
h = YM + 2*h
|
h = YM + 2*h
|
||||||
|
@ -341,7 +341,9 @@ class Layout:
|
||||||
|
|
||||||
decks = self.game.gameinfo.decks
|
decks = self.game.gameinfo.decks
|
||||||
suits = len(self.game.gameinfo.suits) + bool(self.game.gameinfo.trumps)
|
suits = len(self.game.gameinfo.suits) + bool(self.game.gameinfo.trumps)
|
||||||
toprows = reserves + 1 + suits*decks
|
toprows = suits*decks
|
||||||
|
if reserves:
|
||||||
|
toprows += reserves+1
|
||||||
maxrows = max(rows, toprows)
|
maxrows = max(rows, toprows)
|
||||||
|
|
||||||
w = XM + maxrows*XS
|
w = XM + maxrows*XS
|
||||||
|
@ -352,19 +354,21 @@ class Layout:
|
||||||
|
|
||||||
# create reserves & foundations
|
# create reserves & foundations
|
||||||
x, y = (w - (toprows*XS - XM))/2, YM
|
x, y = (w - (toprows*XS - XM))/2, YM
|
||||||
for i in range(reserves):
|
if reserves:
|
||||||
self.s.reserves.append(S(x, y))
|
for i in range(reserves):
|
||||||
x = x + XS
|
self.s.reserves.append(S(x, y))
|
||||||
|
x += XS
|
||||||
|
x += XS
|
||||||
for suit in range(suits):
|
for suit in range(suits):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
x = x + XS
|
|
||||||
self.s.foundations.append(S(x, y, suit=suit))
|
self.s.foundations.append(S(x, y, suit=suit))
|
||||||
|
x += XS
|
||||||
|
|
||||||
# create rows
|
# create rows
|
||||||
x, y = (w - (rows*XS - XM))/2, YM + YS
|
x, y = (w - (rows*XS - XM))/2, YM + YS
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
self.setRegion(self.s.rows, (-999, y - CH / 2, 999999, 999999))
|
self.setRegion(self.s.rows, (-999, y - CH / 2, 999999, 999999))
|
||||||
|
|
||||||
# create talon
|
# create talon
|
||||||
|
@ -416,7 +420,7 @@ class Layout:
|
||||||
x, y = XM, YM
|
x, y = XM, YM
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
self.setRegion(self.s.rows, (-999, -999, x - CW / 2, 999999))
|
self.setRegion(self.s.rows, (-999, -999, x - CW / 2, 999999))
|
||||||
|
|
||||||
# create foundations
|
# create foundations
|
||||||
|
@ -424,18 +428,18 @@ class Layout:
|
||||||
for suit in range(suits):
|
for suit in range(suits):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
self.s.foundations.append(S(x+i*XS, y, suit=suit))
|
self.s.foundations.append(S(x+i*XS, y, suit=suit))
|
||||||
y = y + YS
|
y += YS
|
||||||
|
|
||||||
# create talon and waste
|
# create talon and waste
|
||||||
x, y = x + (decks-1)*XS, h - YS
|
x, y = x + (decks-1)*XS, h - YS
|
||||||
if texts:
|
if texts:
|
||||||
x = x - XS/2
|
x -= XS/2
|
||||||
self.s.talon = s = S(x, y)
|
self.s.talon = s = S(x, y)
|
||||||
if texts:
|
if texts:
|
||||||
# place text right of stack
|
# place text right of stack
|
||||||
self._setText(s, anchor="se")
|
self._setText(s, anchor="se")
|
||||||
if waste:
|
if waste:
|
||||||
x = x - XS
|
x -= XS
|
||||||
self.s.waste = s = S(x, y)
|
self.s.waste = s = S(x, y)
|
||||||
if texts:
|
if texts:
|
||||||
# place text left of stack
|
# place text left of stack
|
||||||
|
@ -495,7 +499,7 @@ class Layout:
|
||||||
for suit in range(suits):
|
for suit in range(suits):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
self.s.foundations.append(S(x, y, suit=suit))
|
self.s.foundations.append(S(x, y, suit=suit))
|
||||||
x = x + XS
|
x += XS
|
||||||
if waste:
|
if waste:
|
||||||
x = w - 2*XS
|
x = w - 2*XS
|
||||||
self.s.waste = s = S(x, y)
|
self.s.waste = s = S(x, y)
|
||||||
|
@ -550,7 +554,7 @@ class Layout:
|
||||||
# place text right of stack
|
# place text right of stack
|
||||||
self._setText(s, 'ne')
|
self._setText(s, 'ne')
|
||||||
if waste:
|
if waste:
|
||||||
x = x + XS
|
x += XS
|
||||||
self.s.waste = s = S(x, y)
|
self.s.waste = s = S(x, y)
|
||||||
if texts:
|
if texts:
|
||||||
# place text below stack
|
# place text below stack
|
||||||
|
@ -565,8 +569,8 @@ class Layout:
|
||||||
for suit in range(suits / foundrows):
|
for suit in range(suits / foundrows):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
self.s.foundations.append(S(x, y, suit=suit + (row * (suits / 2))))
|
self.s.foundations.append(S(x, y, suit=suit + (row * (suits / 2))))
|
||||||
x = x + XS
|
x += XS
|
||||||
y = y + YS
|
y += YS
|
||||||
|
|
||||||
# below
|
# below
|
||||||
x = XM
|
x = XM
|
||||||
|
@ -576,7 +580,7 @@ class Layout:
|
||||||
self.setRegion(self.s.rows, (-999, y-CH/2, 999999, 999999))
|
self.setRegion(self.s.rows, (-999, y-CH/2, 999999, 999999))
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
|
|
||||||
# bottom
|
# bottom
|
||||||
if reserves:
|
if reserves:
|
||||||
|
@ -615,14 +619,14 @@ class Layout:
|
||||||
x, y = XM, YM
|
x, y = XM, YM
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
self.setRegion(self.s.rows, (-999, -999, x - CW / 2, 999999))
|
self.setRegion(self.s.rows, (-999, -999, x - CW / 2, 999999))
|
||||||
|
|
||||||
# create foundations
|
# create foundations
|
||||||
for suit in range(suits):
|
for suit in range(suits):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
self.s.foundations.append(S(x+i*XS, y, suit=suit))
|
self.s.foundations.append(S(x+i*XS, y, suit=suit))
|
||||||
y = y + YS
|
y += YS
|
||||||
|
|
||||||
# create talon
|
# create talon
|
||||||
x, y = XM, h - YS
|
x, y = XM, h - YS
|
||||||
|
@ -670,7 +674,7 @@ class Layout:
|
||||||
# place text right of stack
|
# place text right of stack
|
||||||
self._setText(s, 'ne')
|
self._setText(s, 'ne')
|
||||||
if waste:
|
if waste:
|
||||||
x = x + XS
|
x += XS
|
||||||
self.s.waste = s = S(x, y)
|
self.s.waste = s = S(x, y)
|
||||||
if texts:
|
if texts:
|
||||||
# place text below stack
|
# place text below stack
|
||||||
|
@ -684,7 +688,7 @@ class Layout:
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
for rank in range(ranks):
|
for rank in range(ranks):
|
||||||
self.s.foundations.append(S(x0, y0, suit=rank))
|
self.s.foundations.append(S(x0, y0, suit=rank))
|
||||||
x0 = x0 + XS
|
x0 += XS
|
||||||
if i == 1 and decks > 2:
|
if i == 1 and decks > 2:
|
||||||
x0, y0 = x, y + YS
|
x0, y0 = x, y + YS
|
||||||
y = y0
|
y = y0
|
||||||
|
@ -694,7 +698,7 @@ class Layout:
|
||||||
self.setRegion(self.s.rows, (-999, y - YM / 2, 999999, 999999))
|
self.setRegion(self.s.rows, (-999, y - YM / 2, 999999, 999999))
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
|
|
||||||
# set window
|
# set window
|
||||||
self.size = (XM + maxrows * XS, YM + YS + yextra + h)
|
self.size = (XM + maxrows * XS, YM + YS + yextra + h)
|
||||||
|
@ -735,7 +739,7 @@ class Layout:
|
||||||
# place text right of stack
|
# place text right of stack
|
||||||
self._setText(s, 'ne')
|
self._setText(s, 'ne')
|
||||||
if waste:
|
if waste:
|
||||||
x = x + XS
|
x += XS
|
||||||
self.s.waste = s = S(x, y)
|
self.s.waste = s = S(x, y)
|
||||||
if texts:
|
if texts:
|
||||||
# place text below stack
|
# place text below stack
|
||||||
|
@ -751,14 +755,14 @@ class Layout:
|
||||||
if i == decks - 1 and suit == 5:
|
if i == decks - 1 and suit == 5:
|
||||||
x0, y0 = x + XS * (toprows - decks), YM
|
x0, y0 = x + XS * (toprows - decks), YM
|
||||||
d, x, y = -1, x0, y0
|
d, x, y = -1, x0, y0
|
||||||
d = d + 1
|
d += 1
|
||||||
|
|
||||||
# top center
|
# top center
|
||||||
x, y = XM + XS * decks, YM
|
x, y = XM + XS * decks, YM
|
||||||
self.setRegion(self.s.rows, (x - XM / 2, 0, x + XS * rows, 999999))
|
self.setRegion(self.s.rows, (x - XM / 2, 0, x + XS * rows, 999999))
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
|
|
||||||
# set window
|
# set window
|
||||||
self.size = (XM + toprows * XS, YM + YS + yextra + h)
|
self.size = (XM + toprows * XS, YM + YS + yextra + h)
|
||||||
|
@ -793,25 +797,25 @@ class Layout:
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
for suit in range(12):
|
for suit in range(12):
|
||||||
self.s.foundations.append(S(x, y, suit=suit))
|
self.s.foundations.append(S(x, y, suit=suit))
|
||||||
x = x + XS
|
x += XS
|
||||||
x, y = XM, y + YS
|
x, y = XM, y + YS
|
||||||
|
|
||||||
# create rows
|
# create rows
|
||||||
x, y = XM + XS * ((toprows - rows) / 2), YM + YS * decks
|
x, y = XM + XS * ((toprows - rows) / 2), YM + YS * decks
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
self.setRegion(self.s.rows, (XS + XM / 2, YS * decks + YM / 2, XS * 11 - XM / 2, 999999))
|
self.setRegion(self.s.rows, (XS + XM / 2, YS * decks + YM / 2, XS * 11 - XM / 2, 999999))
|
||||||
|
|
||||||
# create reserves
|
# create reserves
|
||||||
x, y = XM, YM + YS * decks
|
x, y = XM, YM + YS * decks
|
||||||
for i in range(reserves / 2):
|
for i in range(reserves / 2):
|
||||||
self.s.reserves.append(S(x, y))
|
self.s.reserves.append(S(x, y))
|
||||||
y = y + YS
|
y += YS
|
||||||
x, y = w - XS, YM + YS * decks
|
x, y = w - XS, YM + YS * decks
|
||||||
for i in range(reserves / 2):
|
for i in range(reserves / 2):
|
||||||
self.s.reserves.append(S(x, y))
|
self.s.reserves.append(S(x, y))
|
||||||
y = y + YS
|
y += YS
|
||||||
|
|
||||||
# create talon
|
# create talon
|
||||||
x, y = XM, h + YM
|
x, y = XM, h + YM
|
||||||
|
@ -853,18 +857,18 @@ class Layout:
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
for rank in range(ranks):
|
for rank in range(ranks):
|
||||||
self.s.foundations.append(S(x, y, suit=rank))
|
self.s.foundations.append(S(x, y, suit=rank))
|
||||||
y = y + YS
|
y += YS
|
||||||
x, y = x + XS, YM
|
x, y = x + XS, YM
|
||||||
|
|
||||||
# create rows
|
# create rows
|
||||||
x, y = XM, YM
|
x, y = XM, YM
|
||||||
for i in range(rows / 2):
|
for i in range(rows / 2):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
x, y = XM, (YS + h) / 2
|
x, y = XM, (YS + h) / 2
|
||||||
for i in range(rows / 2):
|
for i in range(rows / 2):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
self.setRegion(self.s.rows, (0, 0, XS * rows / 2 + XM / 2, 999999))
|
self.setRegion(self.s.rows, (0, 0, XS * rows / 2 + XM / 2, 999999))
|
||||||
|
|
||||||
# create reserves
|
# create reserves
|
||||||
|
@ -872,7 +876,7 @@ class Layout:
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
for i in range(reserves / decks):
|
for i in range(reserves / decks):
|
||||||
self.s.reserves.append(S(x, y))
|
self.s.reserves.append(S(x, y))
|
||||||
y = y + YS
|
y += YS
|
||||||
x, y = x + XS, YM + YS * 4
|
x, y = x + XS, YM + YS * 4
|
||||||
|
|
||||||
# create talon
|
# create talon
|
||||||
|
@ -919,11 +923,11 @@ class Layout:
|
||||||
x, y = XS + XM * 3, YM
|
x, y = XS + XM * 3, YM
|
||||||
for i in range(rows / 2):
|
for i in range(rows / 2):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS + XM
|
x += XS + XM
|
||||||
x, y = XS + XM * 3, (YS + h) / 2
|
x, y = XS + XM * 3, (YS + h) / 2
|
||||||
for i in range(rows / 2):
|
for i in range(rows / 2):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS + XM
|
x += XS + XM
|
||||||
self.setRegion(self.s.rows, (XS + XM, -999, 999999, 999999))
|
self.setRegion(self.s.rows, (XS + XM, -999, 999999, 999999))
|
||||||
|
|
||||||
# create reserves
|
# create reserves
|
||||||
|
@ -931,7 +935,7 @@ class Layout:
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
for i in range(reserves / decks):
|
for i in range(reserves / decks):
|
||||||
self.s.reserves.append(S(x, y))
|
self.s.reserves.append(S(x, y))
|
||||||
y = y + YS
|
y += YS
|
||||||
x, y = x + XS, YM + YS * 4
|
x, y = x + XS, YM + YS * 4
|
||||||
|
|
||||||
# set window
|
# set window
|
||||||
|
@ -963,7 +967,7 @@ class Layout:
|
||||||
x, y = XM, YM
|
x, y = XM, YM
|
||||||
for i in range(suits):
|
for i in range(suits):
|
||||||
self.s.foundations.append(S(x, y, suit=i))
|
self.s.foundations.append(S(x, y, suit=i))
|
||||||
y = y + YS
|
y += YS
|
||||||
if i == suits / 2 - 1:
|
if i == suits / 2 - 1:
|
||||||
x, y = w - XS, YM
|
x, y = w - XS, YM
|
||||||
|
|
||||||
|
@ -1023,18 +1027,18 @@ class Layout:
|
||||||
for suit in range(suits / 2):
|
for suit in range(suits / 2):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
self.s.foundations.append(S(x, y, suit = suit))
|
self.s.foundations.append(S(x, y, suit = suit))
|
||||||
x = x + XS
|
x += XS
|
||||||
x = w - fspace - XS * frows / 2
|
x = w - fspace - XS * frows / 2
|
||||||
y = y + YS
|
y += YS
|
||||||
for suit in range(suits / 2):
|
for suit in range(suits / 2):
|
||||||
for i in range(decks):
|
for i in range(decks):
|
||||||
self.s.foundations.append(S(x, y, suit = suit + suits / 2))
|
self.s.foundations.append(S(x, y, suit = suit + suits / 2))
|
||||||
x = x + XS
|
x += XS
|
||||||
|
|
||||||
# bottom
|
# bottom
|
||||||
x, y = XM, YM * 2 + YS * 2
|
x, y = XM, YM * 2 + YS * 2
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
self.s.rows.append(S(x, y))
|
self.s.rows.append(S(x, y))
|
||||||
x = x + XS
|
x += XS
|
||||||
self.setRegion(self.s.rows, (-999, y - YM, 999999, 999999))
|
self.setRegion(self.s.rows, (-999, y - YM, 999999, 999999))
|
||||||
|
|
||||||
|
|
|
@ -2088,7 +2088,7 @@ class AbstractFoundationStack(OpenStack):
|
||||||
return base_card.rank == cards[0].rank
|
return base_card.rank == cards[0].rank
|
||||||
return True # all foundations is empty
|
return True # all foundations is empty
|
||||||
|
|
||||||
def getVaryBaseCard(self):
|
def varyGetBaseCard(self):
|
||||||
rank = None
|
rank = None
|
||||||
for s in self.game.s.foundations:
|
for s in self.game.s.foundations:
|
||||||
if s.cards:
|
if s.cards:
|
||||||
|
@ -2119,11 +2119,6 @@ class RK_FoundationStack(SS_FoundationStack):
|
||||||
def __init__(self, x, y, game, suit=ANY_SUIT, **cap):
|
def __init__(self, x, y, game, suit=ANY_SUIT, **cap):
|
||||||
SS_FoundationStack.__init__(self, x, y, game, ANY_SUIT, **cap)
|
SS_FoundationStack.__init__(self, x, y, game, ANY_SUIT, **cap)
|
||||||
|
|
||||||
def assertStack(self):
|
|
||||||
SS_FoundationStack.assertStack(self)
|
|
||||||
##assert self.cap.suit == ANY_SUIT
|
|
||||||
assert self.cap.color == ANY_COLOR
|
|
||||||
|
|
||||||
def getHelp(self):
|
def getHelp(self):
|
||||||
if self.cap.dir > 0: return _('Foundation. Build up regardless of suit.')
|
if self.cap.dir > 0: return _('Foundation. Build up regardless of suit.')
|
||||||
elif self.cap.dir < 0: return _('Foundation. Build down regardless of suit.')
|
elif self.cap.dir < 0: return _('Foundation. Build down regardless of suit.')
|
||||||
|
|
|
@ -653,7 +653,9 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
self._addSelectOrientalGameSubMenu(games, menu, self.mSelectGame,
|
self._addSelectOrientalGameSubMenu(games, menu, self.mSelectGame,
|
||||||
self.tkopt.gameid)
|
self.tkopt.gameid)
|
||||||
self._addSelectSpecialGameSubMenu(games, menu, self.mSelectGame,
|
self._addSelectSpecialGameSubMenu(games, menu, self.mSelectGame,
|
||||||
self.tkopt.gameid)
|
self.tkopt.gameid)
|
||||||
|
self._addSelectCustomGameSubMenu(games, menu, self.mSelectGame,
|
||||||
|
self.tkopt.gameid)
|
||||||
menu.add_separator()
|
menu.add_separator()
|
||||||
if self.progress: self.progress.update(step=1)
|
if self.progress: self.progress.update(step=1)
|
||||||
self._addSelectAllGameSubMenu(games, menu, self.mSelectGame,
|
self._addSelectAllGameSubMenu(games, menu, self.mSelectGame,
|
||||||
|
@ -755,6 +757,12 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
GI.SELECT_SPECIAL_GAME_BY_TYPE,
|
GI.SELECT_SPECIAL_GAME_BY_TYPE,
|
||||||
self.mSelectGame, self.tkopt.gameid)
|
self.mSelectGame, self.tkopt.gameid)
|
||||||
|
|
||||||
|
def _addSelectCustomGameSubMenu(self, games, menu, command, variable):
|
||||||
|
submenu = MfxMenu(menu, label=n_("&Cusom games"))
|
||||||
|
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
|
||||||
|
games = filter(select_func, games)
|
||||||
|
self.updateGamesMenu(submenu, games)
|
||||||
|
|
||||||
def _addSelectAllGameSubMenu(self, games, menu, command, variable):
|
def _addSelectAllGameSubMenu(self, games, menu, command, variable):
|
||||||
menu = MfxMenu(menu, label=n_("&All games by name"))
|
menu = MfxMenu(menu, label=n_("&All games by name"))
|
||||||
n, d = 0, self.__cb_max
|
n, d = 0, self.__cb_max
|
||||||
|
@ -797,6 +805,20 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
'value': gi.id,
|
'value': gi.id,
|
||||||
'label': label}))
|
'label': label}))
|
||||||
|
|
||||||
|
def updateGamesMenu(self, menu, games):
|
||||||
|
menu.delete(0, 'last')
|
||||||
|
if len(games) == 0:
|
||||||
|
menu.add_radiobutton(label='<none>', name=None, state='disabled')
|
||||||
|
elif len(games) > self.__cb_max*4:
|
||||||
|
games.sort(lambda a, b: cmp(gettext(a.name), gettext(b.name)))
|
||||||
|
self._addSelectAllGameSubMenu(games, menu,
|
||||||
|
command=self.mSelectGame,
|
||||||
|
variable=self.tkopt.gameid)
|
||||||
|
else:
|
||||||
|
self._addSelectGameSubSubMenu(games, menu,
|
||||||
|
command=self.mSelectGame,
|
||||||
|
variable=self.tkopt.gameid)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Select Game menu actions
|
# Select Game menu actions
|
||||||
#
|
#
|
||||||
|
@ -853,24 +875,13 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
|
|
||||||
def updateFavoriteGamesMenu(self):
|
def updateFavoriteGamesMenu(self):
|
||||||
gameids = self.app.opt.favorite_gameid
|
gameids = self.app.opt.favorite_gameid
|
||||||
# delete all entries
|
|
||||||
submenu = self.__menupath[".menubar.file.favoritegames"][2]
|
submenu = self.__menupath[".menubar.file.favoritegames"][2]
|
||||||
submenu.delete(0, "last")
|
|
||||||
# insert games
|
|
||||||
games = []
|
games = []
|
||||||
for id in gameids:
|
for id in gameids:
|
||||||
gi = self.app.getGameInfo(id)
|
gi = self.app.getGameInfo(id)
|
||||||
if gi:
|
if gi:
|
||||||
games.append(gi)
|
games.append(gi)
|
||||||
if len(games) > self.__cb_max*4:
|
self.updateGamesMenu(submenu, games)
|
||||||
games.sort(lambda a, b: cmp(gettext(a.name), gettext(b.name)))
|
|
||||||
self._addSelectAllGameSubMenu(games, submenu,
|
|
||||||
command=self.mSelectGame,
|
|
||||||
variable=self.tkopt.gameid)
|
|
||||||
else:
|
|
||||||
self._addSelectGameSubSubMenu(games, submenu,
|
|
||||||
command=self.mSelectGame,
|
|
||||||
variable=self.tkopt.gameid)
|
|
||||||
state = self._getEnabledState
|
state = self._getEnabledState
|
||||||
in_favor = self.app.game.id in gameids
|
in_favor = self.app.game.id in gameids
|
||||||
menu, index, submenu = self.__menupath[".menubar.file.addtofavorites"]
|
menu, index, submenu = self.__menupath[".menubar.file.addtofavorites"]
|
||||||
|
@ -1367,6 +1378,8 @@ the next time you restart """)+PACKAGE,
|
||||||
from pysollib.wizardutil import write_game, reset_wizard
|
from pysollib.wizardutil import write_game, reset_wizard
|
||||||
if edit:
|
if edit:
|
||||||
reset_wizard(self.game)
|
reset_wizard(self.game)
|
||||||
|
else:
|
||||||
|
reset_wizard(None)
|
||||||
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
||||||
if d.status == 0 and d.button == 0:
|
if d.status == 0 and d.button == 0:
|
||||||
try:
|
try:
|
||||||
|
@ -1385,13 +1398,15 @@ Error while saving game.
|
||||||
''') % str(err),
|
''') % str(err),
|
||||||
bitmap='error')
|
bitmap='error')
|
||||||
return
|
return
|
||||||
if SELECT_GAME_MENU and not edit:
|
|
||||||
gi = self.app.getGameInfo(gameid)
|
if SELECT_GAME_MENU:
|
||||||
label = gettext(gi.name)
|
menu = self.__menupath[".menubar.select.cusomgames"][2]
|
||||||
menu = self.__menupath[".menubar.select.frenchgames.cusomgames"][2]
|
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
|
||||||
menu.add_radiobutton(command=self.mSelectGame,
|
games = map(self.app.gdb.get,
|
||||||
variable=self.tkopt.gameid,
|
self.app.gdb.getGamesIdSortedByName())
|
||||||
value=gameid, label=label, name=None)
|
games = filter(select_func, games)
|
||||||
|
self.updateGamesMenu(menu, games)
|
||||||
|
|
||||||
self.tkopt.gameid.set(gameid)
|
self.tkopt.gameid.set(gameid)
|
||||||
self._mSelectGame(gameid, force=True)
|
self._mSelectGame(gameid, force=True)
|
||||||
|
|
||||||
|
@ -1404,5 +1419,3 @@ Error while saving game.
|
||||||
if self._cancelDrag(break_pause=False): return
|
if self._cancelDrag(break_pause=False): return
|
||||||
self.wizardDialog(edit=True)
|
self.wizardDialog(edit=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,31 +63,40 @@ class WizardDialog(MfxDialog):
|
||||||
Label(frame, text=w.label).grid(row=row, column=0)
|
Label(frame, text=w.label).grid(row=row, column=0)
|
||||||
|
|
||||||
if w.widget == 'entry':
|
if w.widget == 'entry':
|
||||||
w.variable = var = StringVar()
|
if w.variable is None:
|
||||||
en = Entry(frame, textvariable=var)
|
w.variable = StringVar()
|
||||||
|
en = Entry(frame, textvariable=w.variable)
|
||||||
en.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
en.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
||||||
elif w.widget == 'menu':
|
elif w.widget == 'menu':
|
||||||
w.variable = var = StringVar()
|
if w.variable is None:
|
||||||
cb = Combobox(frame, values=tuple(w.values), textvariable=var,
|
w.variable = StringVar()
|
||||||
|
cb = Combobox(frame, values=tuple(w.values),
|
||||||
|
textvariable=w.variable,
|
||||||
state='readonly', width=32)
|
state='readonly', width=32)
|
||||||
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
||||||
elif w.widget == 'spin':
|
elif w.widget == 'spin':
|
||||||
w.variable = var = IntVar()
|
if w.variable is None:
|
||||||
|
w.variable = IntVar()
|
||||||
|
else:
|
||||||
|
# delete all trace callbacks
|
||||||
|
for mod, cbname in w.variable.trace_vinfo():
|
||||||
|
w.variable.trace_vdelete(mod, cbname)
|
||||||
from_, to = w.values
|
from_, to = w.values
|
||||||
##s = Spinbox(frame, textvariable=var, from_=from_, to=to)
|
##s = Spinbox(frame, textvariable=w.variable, from_=from_, to=to)
|
||||||
s = PysolScale(frame, from_=from_, to=to, resolution=1,
|
s = PysolScale(frame, from_=from_, to=to, resolution=1,
|
||||||
orient='horizontal',
|
orient='horizontal',
|
||||||
variable=var)
|
variable=w.variable)
|
||||||
s.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
s.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
||||||
elif w.widget == 'check':
|
elif w.widget == 'check':
|
||||||
w.variable = var = BooleanVar()
|
if w.variable is None:
|
||||||
ch = Checkbutton(frame, variable=var, takefocus=False)
|
w.variable = BooleanVar()
|
||||||
|
ch = Checkbutton(frame, variable=w.variable, takefocus=False)
|
||||||
ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
||||||
|
|
||||||
if w.current_value is None:
|
if w.current_value is None:
|
||||||
var.set(w.default)
|
w.variable.set(w.default)
|
||||||
else:
|
else:
|
||||||
var.set(w.current_value)
|
w.variable.set(w.current_value)
|
||||||
|
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ from pysollib.settings import PACKAGE, WIN_SYSTEM
|
||||||
from pysollib.settings import TOP_TITLE
|
from pysollib.settings import TOP_TITLE
|
||||||
from pysollib.settings import SELECT_GAME_MENU
|
from pysollib.settings import SELECT_GAME_MENU
|
||||||
from pysollib.settings import USE_FREECELL_SOLVER
|
from pysollib.settings import USE_FREECELL_SOLVER
|
||||||
|
from pysollib.settings import DEBUG
|
||||||
from pysollib.gamedb import GI
|
from pysollib.gamedb import GI
|
||||||
from pysollib.actions import PysolMenubarActions
|
from pysollib.actions import PysolMenubarActions
|
||||||
|
|
||||||
|
@ -656,7 +657,9 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
self._addSelectOrientalGameSubMenu(games, menu, self.mSelectGame,
|
self._addSelectOrientalGameSubMenu(games, menu, self.mSelectGame,
|
||||||
self.tkopt.gameid)
|
self.tkopt.gameid)
|
||||||
self._addSelectSpecialGameSubMenu(games, menu, self.mSelectGame,
|
self._addSelectSpecialGameSubMenu(games, menu, self.mSelectGame,
|
||||||
self.tkopt.gameid)
|
self.tkopt.gameid)
|
||||||
|
self._addSelectCustomGameSubMenu(games, menu, self.mSelectGame,
|
||||||
|
self.tkopt.gameid)
|
||||||
menu.add_separator()
|
menu.add_separator()
|
||||||
if self.progress: self.progress.update(step=1)
|
if self.progress: self.progress.update(step=1)
|
||||||
self._addSelectAllGameSubMenu(games, menu, self.mSelectGame,
|
self._addSelectAllGameSubMenu(games, menu, self.mSelectGame,
|
||||||
|
@ -758,6 +761,12 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
GI.SELECT_SPECIAL_GAME_BY_TYPE,
|
GI.SELECT_SPECIAL_GAME_BY_TYPE,
|
||||||
self.mSelectGame, self.tkopt.gameid)
|
self.mSelectGame, self.tkopt.gameid)
|
||||||
|
|
||||||
|
def _addSelectCustomGameSubMenu(self, games, menu, command, variable):
|
||||||
|
submenu = MfxMenu(menu, label=n_("&Cusom games"))
|
||||||
|
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
|
||||||
|
games = filter(select_func, games)
|
||||||
|
self.updateGamesMenu(submenu, games)
|
||||||
|
|
||||||
def _addSelectAllGameSubMenu(self, games, menu, command, variable):
|
def _addSelectAllGameSubMenu(self, games, menu, command, variable):
|
||||||
menu = MfxMenu(menu, label=n_("&All games by name"))
|
menu = MfxMenu(menu, label=n_("&All games by name"))
|
||||||
n, d = 0, self.__cb_max
|
n, d = 0, self.__cb_max
|
||||||
|
@ -800,6 +809,20 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
'value': gi.id,
|
'value': gi.id,
|
||||||
'label': label}))
|
'label': label}))
|
||||||
|
|
||||||
|
def updateGamesMenu(self, menu, games):
|
||||||
|
menu.delete(0, 'last')
|
||||||
|
if len(games) == 0:
|
||||||
|
menu.add_radiobutton(label='<none>', name=None, state='disabled')
|
||||||
|
elif len(games) > self.__cb_max*4:
|
||||||
|
games.sort(lambda a, b: cmp(gettext(a.name), gettext(b.name)))
|
||||||
|
self._addSelectAllGameSubMenu(games, menu,
|
||||||
|
command=self.mSelectGame,
|
||||||
|
variable=self.tkopt.gameid)
|
||||||
|
else:
|
||||||
|
self._addSelectGameSubSubMenu(games, menu,
|
||||||
|
command=self.mSelectGame,
|
||||||
|
variable=self.tkopt.gameid)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Select Game menu actions
|
# Select Game menu actions
|
||||||
#
|
#
|
||||||
|
@ -856,24 +879,13 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
|
|
||||||
def updateFavoriteGamesMenu(self):
|
def updateFavoriteGamesMenu(self):
|
||||||
gameids = self.app.opt.favorite_gameid
|
gameids = self.app.opt.favorite_gameid
|
||||||
# delete all entries
|
|
||||||
submenu = self.__menupath[".menubar.file.favoritegames"][2]
|
submenu = self.__menupath[".menubar.file.favoritegames"][2]
|
||||||
submenu.delete(0, "last")
|
|
||||||
# insert games
|
|
||||||
games = []
|
games = []
|
||||||
for id in gameids:
|
for id in gameids:
|
||||||
gi = self.app.getGameInfo(id)
|
gi = self.app.getGameInfo(id)
|
||||||
if gi:
|
if gi:
|
||||||
games.append(gi)
|
games.append(gi)
|
||||||
if len(games) > self.__cb_max*4:
|
self.updateGamesMenu(submenu, games)
|
||||||
games.sort(lambda a, b: cmp(gettext(a.name), gettext(b.name)))
|
|
||||||
self._addSelectAllGameSubMenu(games, submenu,
|
|
||||||
command=self.mSelectGame,
|
|
||||||
variable=self.tkopt.gameid)
|
|
||||||
else:
|
|
||||||
self._addSelectGameSubSubMenu(games, submenu,
|
|
||||||
command=self.mSelectGame,
|
|
||||||
variable=self.tkopt.gameid)
|
|
||||||
state = self._getEnabledState
|
state = self._getEnabledState
|
||||||
in_favor = self.app.game.id in gameids
|
in_favor = self.app.game.id in gameids
|
||||||
menu, index, submenu = self.__menupath[".menubar.file.addtofavorites"]
|
menu, index, submenu = self.__menupath[".menubar.file.addtofavorites"]
|
||||||
|
@ -1351,6 +1363,8 @@ class PysolMenubar(PysolMenubarActions):
|
||||||
from pysollib.wizardutil import write_game, reset_wizard
|
from pysollib.wizardutil import write_game, reset_wizard
|
||||||
if edit:
|
if edit:
|
||||||
reset_wizard(self.game)
|
reset_wizard(self.game)
|
||||||
|
else:
|
||||||
|
reset_wizard(None)
|
||||||
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
d = WizardDialog(self.top, _('Solitaire Wizard'), self.app)
|
||||||
if d.status == 0 and d.button == 0:
|
if d.status == 0 and d.button == 0:
|
||||||
try:
|
try:
|
||||||
|
@ -1369,13 +1383,14 @@ Error while saving game.
|
||||||
''') % str(err),
|
''') % str(err),
|
||||||
bitmap='error')
|
bitmap='error')
|
||||||
return
|
return
|
||||||
if SELECT_GAME_MENU and not edit:
|
if SELECT_GAME_MENU:
|
||||||
gi = self.app.getGameInfo(gameid)
|
menu = self.__menupath[".menubar.select.cusomgames"][2]
|
||||||
label = gettext(gi.name)
|
select_func = lambda gi: gi.si.game_type == GI.GT_CUSTOM
|
||||||
menu = self.__menupath[".menubar.select.frenchgames.cusomgames"][2]
|
games = map(self.app.gdb.get,
|
||||||
menu.add_radiobutton(command=self.mSelectGame,
|
self.app.gdb.getGamesIdSortedByName())
|
||||||
variable=self.tkopt.gameid,
|
games = filter(select_func, games)
|
||||||
value=gameid, label=label, name=None)
|
self.updateGamesMenu(menu, games)
|
||||||
|
|
||||||
self.tkopt.gameid.set(gameid)
|
self.tkopt.gameid.set(gameid)
|
||||||
self._mSelectGame(gameid, force=True)
|
self._mSelectGame(gameid, force=True)
|
||||||
|
|
||||||
|
|
|
@ -64,30 +64,34 @@ class WizardDialog(MfxDialog):
|
||||||
Label(frame, text=w.label).grid(row=row, column=0, padx=2)
|
Label(frame, text=w.label).grid(row=row, column=0, padx=2)
|
||||||
|
|
||||||
if w.widget == 'entry':
|
if w.widget == 'entry':
|
||||||
w.variable = var = StringVar()
|
if w.variable is None:
|
||||||
en = Entry(frame, textvariable=var)
|
w.variable = StringVar()
|
||||||
|
en = Entry(frame, textvariable=w.variable)
|
||||||
en.grid(row=row, column=1, sticky='ew', padx=2)
|
en.grid(row=row, column=1, sticky='ew', padx=2)
|
||||||
elif w.widget == 'menu':
|
elif w.widget == 'menu':
|
||||||
w.variable = var = StringVar()
|
if w.variable is None:
|
||||||
om = OptionMenu(frame, var, *w.values)
|
w.variable = StringVar()
|
||||||
|
om = OptionMenu(frame, w.variable, *w.values)
|
||||||
om.grid(row=row, column=1, sticky='ew', padx=2)
|
om.grid(row=row, column=1, sticky='ew', padx=2)
|
||||||
elif w.widget == 'spin':
|
elif w.widget == 'spin':
|
||||||
w.variable = var = IntVar()
|
if w.variable is None:
|
||||||
|
w.variable = IntVar()
|
||||||
from_, to = w.values
|
from_, to = w.values
|
||||||
s = Scale(frame, from_=from_, to=to, resolution=1,
|
s = Scale(frame, from_=from_, to=to, resolution=1,
|
||||||
orient='horizontal',
|
orient='horizontal',
|
||||||
variable=var)
|
variable=w.variable)
|
||||||
s.grid(row=row, column=1, sticky='ew', padx=2)
|
s.grid(row=row, column=1, sticky='ew', padx=2)
|
||||||
elif w.widget == 'check':
|
elif w.widget == 'check':
|
||||||
w.variable = var = BooleanVar()
|
if w.variable is None:
|
||||||
ch = Checkbutton(frame, variable=var,
|
w.variable = BooleanVar()
|
||||||
|
ch = Checkbutton(frame, variable=w.variable,
|
||||||
takefocus=False, anchor='w')
|
takefocus=False, anchor='w')
|
||||||
ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
|
||||||
|
|
||||||
if w.current_value is None:
|
if w.current_value is None:
|
||||||
var.set(w.default)
|
w.variable.set(w.default)
|
||||||
else:
|
else:
|
||||||
var.set(w.current_value)
|
w.variable.set(w.current_value)
|
||||||
|
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
|
|
|
@ -103,19 +103,27 @@ TalonType = WizSetting(
|
||||||
(n_('Deal to rows'), DealRowTalonStack),
|
(n_('Deal to rows'), DealRowTalonStack),
|
||||||
),
|
),
|
||||||
default = n_('Initial dealing'),
|
default = n_('Initial dealing'),
|
||||||
label = _('Type of talon:'),
|
label = _('Type:'),
|
||||||
var_name = 'talon',
|
var_name = 'talon',
|
||||||
)
|
)
|
||||||
Redeals = WizSetting(
|
Redeals = WizSetting(
|
||||||
values_map = ((n_('No redeals'), 0),
|
values_map = ((n_('No redeals'), 0),
|
||||||
(n_('One redeal'), 1),
|
(n_('One redeal'), 1),
|
||||||
(n_('Two redeals'), 2),
|
(n_('Two redeals'), 2),
|
||||||
|
(n_('Three redeals'), 3),
|
||||||
(n_('Unlimited redeals'), -1),
|
(n_('Unlimited redeals'), -1),
|
||||||
),
|
),
|
||||||
default = n_('No redeals'),
|
default = n_('No redeals'),
|
||||||
label = _('Number of redeals:'),
|
label = _('Number of redeals:'),
|
||||||
var_name = 'redeals',
|
var_name = 'redeals',
|
||||||
)
|
)
|
||||||
|
DealToWaste = WizSetting(
|
||||||
|
values_map = (1, 5),
|
||||||
|
default = 1,
|
||||||
|
widget = 'spin',
|
||||||
|
label = _('Deal to waste:'),
|
||||||
|
var_name = 'deal_to_waste',
|
||||||
|
)
|
||||||
FoundType = WizSetting(
|
FoundType = WizSetting(
|
||||||
values_map = ((n_('Same suit'), SS_FoundationStack),
|
values_map = ((n_('Same suit'), SS_FoundationStack),
|
||||||
(n_('Alternate color'), AC_FoundationStack),
|
(n_('Alternate color'), AC_FoundationStack),
|
||||||
|
@ -144,8 +152,8 @@ FoundDir = WizSetting(
|
||||||
var_name = 'found_dir',
|
var_name = 'found_dir',
|
||||||
)
|
)
|
||||||
FoundWrap = WizSetting(
|
FoundWrap = WizSetting(
|
||||||
values_map = (True, False),
|
values_map = (0, 1),
|
||||||
default = False,
|
default = 0,
|
||||||
label = _('Wrapping:'),
|
label = _('Wrapping:'),
|
||||||
var_name = 'found_wrap',
|
var_name = 'found_wrap',
|
||||||
widget = 'check',
|
widget = 'check',
|
||||||
|
@ -156,6 +164,13 @@ FoundMaxMove = WizSetting(
|
||||||
label = _('Max move cards:'),
|
label = _('Max move cards:'),
|
||||||
var_name = 'found_max_move',
|
var_name = 'found_max_move',
|
||||||
)
|
)
|
||||||
|
FoundEqual = WizSetting(
|
||||||
|
values_map = (0, 1),
|
||||||
|
default = 1,
|
||||||
|
label = _('Equal base cards:'),
|
||||||
|
var_name = 'found_equal',
|
||||||
|
widget = 'check',
|
||||||
|
)
|
||||||
RowsNum = WizSetting(
|
RowsNum = WizSetting(
|
||||||
values_map = (1, 20),
|
values_map = (1, 20),
|
||||||
default = 8,
|
default = 8,
|
||||||
|
@ -261,19 +276,21 @@ WizardWidgets = (
|
||||||
_('Talon'),
|
_('Talon'),
|
||||||
TalonType,
|
TalonType,
|
||||||
Redeals,
|
Redeals,
|
||||||
|
DealToWaste,
|
||||||
_('Foundations'),
|
_('Foundations'),
|
||||||
FoundType,
|
FoundType,
|
||||||
FoundBaseCard,
|
FoundBaseCard,
|
||||||
FoundDir,
|
FoundDir,
|
||||||
FoundWrap,
|
##FoundWrap,
|
||||||
FoundMaxMove,
|
FoundMaxMove,
|
||||||
|
FoundEqual,
|
||||||
_('Tableau'),
|
_('Tableau'),
|
||||||
RowsNum,
|
RowsNum,
|
||||||
RowsType,
|
RowsType,
|
||||||
RowsBaseCard,
|
RowsBaseCard,
|
||||||
RowsDir,
|
RowsDir,
|
||||||
RowsWrap,
|
|
||||||
RowsMaxMove,
|
RowsMaxMove,
|
||||||
|
RowsWrap,
|
||||||
_('Reserves'),
|
_('Reserves'),
|
||||||
ReservesNum,
|
ReservesNum,
|
||||||
ReservesMaxAccept,
|
ReservesMaxAccept,
|
||||||
|
@ -332,8 +349,11 @@ class MyCustomGame(CustomGame):
|
||||||
if isinstance(v, int):
|
if isinstance(v, int):
|
||||||
fd.write(" '%s': %i,\n" % (w.var_name, v))
|
fd.write(" '%s': %i,\n" % (w.var_name, v))
|
||||||
else:
|
else:
|
||||||
if w.var_name == 'name' and not v:
|
if w.var_name == 'name':
|
||||||
v = 'Invalid Game Name'
|
v = v.replace('\\', '\\\\')
|
||||||
|
v = v.replace("'", "\\'")
|
||||||
|
if not v:
|
||||||
|
v = 'Invalid Game Name'
|
||||||
fd.write(" '%s': '%s',\n" % (w.var_name, v))
|
fd.write(" '%s': '%s',\n" % (w.var_name, v))
|
||||||
fd.write(" 'gameid': %i,\n" % gameid)
|
fd.write(" 'gameid': %i,\n" % gameid)
|
||||||
fd.write(" 'file': '%s',\n" % os.path.split(fn)[1])
|
fd.write(" 'file': '%s',\n" % os.path.split(fn)[1])
|
||||||
|
@ -350,11 +370,18 @@ registerCustomGame(MyCustomGame)
|
||||||
return gameid
|
return gameid
|
||||||
|
|
||||||
def reset_wizard(game):
|
def reset_wizard(game):
|
||||||
s = game.SETTINGS
|
|
||||||
for w in WizardWidgets:
|
for w in WizardWidgets:
|
||||||
if isinstance(w, basestring):
|
if isinstance(w, basestring):
|
||||||
continue
|
continue
|
||||||
v = s[w.var_name]
|
if game is None:
|
||||||
|
# set to default
|
||||||
|
v = w.default
|
||||||
|
else:
|
||||||
|
# set from current game
|
||||||
|
if w.var_name in game.SETTINGS:
|
||||||
|
v = game.SETTINGS[w.var_name]
|
||||||
|
else:
|
||||||
|
v = w.default
|
||||||
if w.widget == 'menu':
|
if w.widget == 'menu':
|
||||||
v = gettext(v)
|
v = gettext(v)
|
||||||
w.current_value = v
|
w.current_value = v
|
||||||
|
|
Loading…
Add table
Reference in a new issue