mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ 3 new games
* move poker.py to pysollib/games/special * improved menubar * updated translation git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@42 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
parent
cf72a6794a
commit
2632de3eab
20 changed files with 2866 additions and 1673 deletions
3
Makefile
3
Makefile
|
@ -4,8 +4,7 @@ override LANG=C
|
|||
|
||||
PYSOLLIB_FILES=pysollib/tk/*.py pysollib/*.py \
|
||||
pysollib/games/*.py pysollib/games/special/*.py \
|
||||
pysollib/games/contrib/*.py pysollib/games/ultra/*.py \
|
||||
pysollib/games/mahjongg/*.py
|
||||
pysollib/games/ultra/*.py pysollib/games/mahjongg/*.py
|
||||
|
||||
.PHONY : install dist all_games_html rules pot mo
|
||||
|
||||
|
|
445
po/games.pot
445
po/games.pot
File diff suppressed because it is too large
Load diff
1444
po/pysol.pot
1444
po/pysol.pot
File diff suppressed because it is too large
Load diff
732
po/ru_games.po
732
po/ru_games.po
File diff suppressed because it is too large
Load diff
1417
po/ru_pysol.po
1417
po/ru_pysol.po
File diff suppressed because it is too large
Load diff
|
@ -535,7 +535,9 @@ class GameManager:
|
|||
# access games database - we do not expose hidden games
|
||||
#
|
||||
|
||||
def getAllGames(self): return self.__all_games
|
||||
def getAllGames(self):
|
||||
##return self.__all_games
|
||||
return self.__games.values()
|
||||
|
||||
def getGamesIdSortedById(self):
|
||||
if self.__games_by_id is None:
|
||||
|
|
|
@ -42,7 +42,6 @@ import parallels
|
|||
import pasdedeux
|
||||
import picturegallery
|
||||
import pileon
|
||||
import poker
|
||||
import pushpin
|
||||
import pyramid
|
||||
import royalcotillion
|
||||
|
|
|
@ -138,5 +138,6 @@ class Doublets(Game):
|
|||
|
||||
# register the game
|
||||
registerGame(GameInfo(111, Doublets, "Doublets",
|
||||
GI.GT_1DECK_TYPE, 1, 2, GI.SL_MOSTLY_LUCK))
|
||||
GI.GT_1DECK_TYPE, 1, 2, GI.SL_MOSTLY_LUCK,
|
||||
altnames=('Double or Quits',) ))
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class Fan(Game):
|
|||
for r in range(reserves):
|
||||
s.reserves.append(self.ReserveStack_Class(x, y, self))
|
||||
x += l.XS
|
||||
x = (self.width - decks*4*l.XS - 2*l.XS) / 2
|
||||
x = (self.width - decks*4*l.XS) # - 2*l.XS) / 2
|
||||
dx = l.XS
|
||||
else:
|
||||
dx = (self.width - decks*4*l.XS)/(decks*4+1)
|
||||
|
@ -532,7 +532,7 @@ class CloverLeaf(Game):
|
|||
|
||||
class FreeFan(Fan):
|
||||
def createGame(self):
|
||||
Fan.createGame(self, reserves=2)
|
||||
Fan.createGame(self, reserves=2, playcards=8)
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
|
@ -640,6 +640,90 @@ class FascinationFan(Fan):
|
|||
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Crescent
|
||||
# ************************************************************************/
|
||||
|
||||
class Crescent_Talon(RedealTalonStack):
|
||||
|
||||
def dealCards(self, sound=0):
|
||||
old_state = self.game.enterState(self.game.S_DEAL)
|
||||
ncards = 0
|
||||
intern1, intern2 = self.game.s.internals
|
||||
if sound and self.game.app.opt.animations:
|
||||
self.game.startDealSample()
|
||||
for r in self.game.s.rows:
|
||||
if len(r.cards) <= 1:
|
||||
continue
|
||||
ncards += len(r.cards)
|
||||
# move cards to internal stacks
|
||||
while len(r.cards) != 1:
|
||||
self.game.moveMove(1, r, intern1, frames=4)
|
||||
self.game.moveMove(1, r, intern2, frames=4)
|
||||
# move back
|
||||
while intern1.cards:
|
||||
self.game.moveMove(1, intern1, r, frames=4)
|
||||
self.game.moveMove(1, intern2, r, frames=4)
|
||||
self.game.nextRoundMove(self)
|
||||
if sound:
|
||||
self.game.stopSamples()
|
||||
self.game.leaveState(old_state)
|
||||
return ncards
|
||||
|
||||
|
||||
class Crescent(Game):
|
||||
Hint_Class = CautiousDefaultHint
|
||||
|
||||
def createGame(self):
|
||||
l, s = Layout(self), self.s
|
||||
playcards = 10
|
||||
w0 = l.XS+(playcards-1)*l.XOFFSET
|
||||
w, h = l.XM+max(4*w0, 9*l.XS), l.YM+5*l.YS
|
||||
self.setSize(w, h)
|
||||
x, y = l.XM, l.YM
|
||||
s.talon = Crescent_Talon(x, y, self, max_rounds=4)
|
||||
tx, ty, ta, tf = l.getTextAttr(s.talon, 'ne')
|
||||
font=self.app.getFont("canvas_default")
|
||||
s.talon.texts.rounds = MfxCanvasText(self.canvas, tx, ty,
|
||||
anchor=ta, font=font)
|
||||
x, y = w-8*l.XS, l.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
|
||||
x += l.XS
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
|
||||
base_rank=KING, dir=-1))
|
||||
x += l.XS
|
||||
y = l.YM+l.YS
|
||||
for i in range(4):
|
||||
x = l.XM
|
||||
for j in range(4):
|
||||
stack = UD_SS_RowStack(x, y, self, base_rank=NO_RANK, mod=13)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
|
||||
x += w0
|
||||
y += l.YS
|
||||
self.s.internals.append(InvisibleStack(self))
|
||||
self.s.internals.append(InvisibleStack(self))
|
||||
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
return self._shuffleHookMoveToTop(cards,
|
||||
lambda c: (c.rank in (ACE, KING) and c.deck == 0,
|
||||
(c.rank, c.suit)))
|
||||
|
||||
def startGame(self):
|
||||
self.s.talon.dealRow(rows=self.s.foundations, frames=0)
|
||||
for i in range(5):
|
||||
self.s.talon.dealRow(frames=0)
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow()
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_SSW
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(56, Fan, "Fan",
|
||||
|
@ -678,4 +762,6 @@ registerGame(GameInfo(517, TroikaPlus, "Troika +",
|
|||
GI.GT_FAN_TYPE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(625, FascinationFan, "Fascination Fan",
|
||||
GI.GT_FAN_TYPE, 1, 6, GI.SL_BALANCED))
|
||||
registerGame(GameInfo(647, Crescent, "Crescent",
|
||||
GI.GT_FAN_TYPE, 2, 3, GI.SL_MOSTLY_SKILL))
|
||||
|
||||
|
|
|
@ -556,6 +556,56 @@ class KingCell(FreeCell):
|
|||
shallHighlightMatch = Game._shallHighlightMatch_RK
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Headquarters
|
||||
# ************************************************************************/
|
||||
|
||||
class Headquarters_Reserve(ReserveStack):
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if not ReserveStack.acceptsCards(self, from_stack, cards):
|
||||
return False
|
||||
return len(self.cards) == 0
|
||||
|
||||
|
||||
class Headquarters(Game):
|
||||
|
||||
def createGame(self, rows=8, reserves=6):
|
||||
l, s = Layout(self), self.s
|
||||
w, h = l.XM+(rows+reserves+1)*l.XS, l.YM+3*l.YS+16*l.YOFFSET
|
||||
self.setSize(w, h)
|
||||
x, y = l.XM+(rows+reserves+1-8)*l.XS/2, l.YM
|
||||
for i in range(8):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i%4))
|
||||
x += l.XS
|
||||
x, y = l.XM, l.YM+l.YS
|
||||
for i in range(reserves):
|
||||
stack = Headquarters_Reserve(x, y, self,
|
||||
max_cards=UNLIMITED_CARDS,
|
||||
max_accept=UNLIMITED_CARDS,
|
||||
max_move=UNLIMITED_CARDS)
|
||||
s.reserves.append(stack)
|
||||
stack.CARD_YOFFSET = l.YOFFSET
|
||||
x += l.XS
|
||||
x, y = l.XM+(reserves+1)*l.XS, l.YM+l.YS
|
||||
for j in range(rows):
|
||||
s.rows.append(AC_RowStack(x, y, self, base_rank=NO_RANK))
|
||||
x += l.XS
|
||||
x, y = w-l.XS, h-l.YS
|
||||
s.talon = InitialDealTalonStack(x, y, self)
|
||||
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def startGame(self):
|
||||
for i in range(12):
|
||||
self.s.talon.dealRow(frames=0)
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow()
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(5, RelaxedFreeCell, "Relaxed FreeCell",
|
||||
|
@ -600,4 +650,6 @@ registerGame(GameInfo(520, GermanFreeCell, "German FreeCell",
|
|||
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_SKILL))
|
||||
registerGame(GameInfo(542, KingCell, "KingCell",
|
||||
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(648, Headquarters, "Headquarters",
|
||||
GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ r(5235, "Kyodai 41", layout="0CaeCagCaivbevbgvbiCcdoceocgociCcjvddhdevdfhdgCdgvd
|
|||
r(5236, "Kyodai 42", layout="0oaboadCagoajoalhbahbcvbchbeobfvbgobhhbihbkvbkhbmacbacdacjaclhdbhddodevdfCdgvdhodihdjhdlaecaekhfchfeoffvfgofhhfihfkagdCggagjhhdhhfhhhhhjaieaiihjehjghjiakfCkgakhhlfvlghlhCmfamgomgCmhhnfvnghnhaogCoghpfhphCqcvqdoqeCqeaqgoqgoqiCqivqjCqkhrfhrhasgCsghtfvtghthCufaugougCuhhvfvvghvhawfCwgawhhxehxghxiayeayihzdhzfhzhhzjaAdCAgaAjhBchBeoBfvBgoBhhBihBkaCcaCkhDbhDdoDevDfCDgvDhoDihDjhDlaEbaEdaEjaElhFahFcvFchFeoFfvFgoFhhFihFkvFkhFmoGboGdCGgoGjoGl")
|
||||
r(5237, "Lattice", layout="0aaiacebciacmaecbeeaegbeiaekbemaeoagecgiagmaicbieaigciiaikbimaioakeckiakmamcbmebmgdmibmkbmmamoboeeoibomaqabqccqeeqgdqieqkcqmbqoaqqbseesibsmaucbuebugduibukbumauoawecwiawmaycbyeaygcyiaykbymayoaAecAiaAmaCcbCeaCgbCiaCkbCmaCoaEebEiaEmaGi")
|
||||
#
|
||||
r(5238, "Leo", layout="0aapabiablhbphcfacghchhclacnocpadjodladpvdpheeaefheiaelvelhepCepofihflCflafnofphgdagevgiagjoglagpvgphhiChiahlvhlhhpChphicaidoiihilCilainoipvjiajjojlajpvjpbkabkchkiCkiaklvklhkpCkpolbolihllalnolpbmabmcvmiamjomlampvmphnianlhnpooiholaonoophpfaphapjappaqfhqiaqlhqphrdarnasehsqhtcatpaudbumhuphvbcvgavqawccwlhwqhxbcxjaxpayccylhyphzbczgazqaAdbAmhAqhBcaBpaCehCphDeaDgaDohEgaEiaEmhEohFiaFkhFmhGk")
|
||||
#r(5238, "Leo", layout="0aapabiablhbphcfacghchhclacnocpadjodladpvdpheeaefheiaelvelhepCepofihflCflafnofphgdagevgiagjoglagpvgphhiChiahlvhlhhpChphicaidoiihilCilainoipvjiajjojlajpvjpbkabkchkiCkiaklvklhkpCkpolbolihllalnolpbmabmcvmiamjomlampvmphnianlhnpooiholaonoophpfaphapjappaqfhqiaqlhqphrdarnasehsqhtcatpaudbumhuphvbcvgavqawccwlhwqhxbcxjaxpayccylhyphzbczgazqaAdbAmhAqhBcaBpaCehCphDeaDgaDohEgaEiaEmhEohFiaFkhFmhGk")
|
||||
#
|
||||
r(5239, "Loose Ends", layout="0aaaoabaaioapaaqhbahbihbqacboccachociacjocoacphdbhdivdihdpaecoedaegaeioeiaekoenaeohfchfivfihfoagdogeaghogiagjogmagnhhdhhivhihhnaieoifaiioiioilaimhjfhjihjlakgokgakiakkokkhlholihljamahmbamcomchmdvmdameomehmfvmfamgvmhamiCmivmjamkhmlvmlammommhmnvmnamoomohmpamqhnhonihnjaogoogaoiaokookhpfhpihplaqeoqfaqioqioqlaqmhrdhrivrihrnasdoseashosiasjosmasnhtchtivtihtoaucoudaugauiouiaukounauohvbhvivvihvpawbowcawhowiawjowoawphxahxihxqayaoybayioypayq")
|
||||
r(5240, "Mini Traditional", ncards=48, layout="0aaeacdacfhdeaecaeeoeeaeghfdvfehffagbagdogeagfaghhhchhevhehhgaiaaicoicaieoieaigoigaiihjchjevjehjgakbakdokeakfakhhldvlehlfamcameomeamghneaodaofaqe")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import hanoi
|
||||
import memory
|
||||
import pegged
|
||||
import poker
|
||||
import tarock
|
||||
|
|
|
@ -909,6 +909,71 @@ class CircleEight(Game):
|
|||
shallHighlightMatch = Game._shallHighlightMatch_RKW
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Adela
|
||||
# ************************************************************************/
|
||||
|
||||
class Adela_Foundation(SS_FoundationStack):
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
|
||||
return False
|
||||
index = list(self.game.s.foundations).index(self)
|
||||
index = index%8
|
||||
return len(self.game.s.foundations[index].cards) > 0
|
||||
|
||||
|
||||
class Adela(Game):
|
||||
Hint_Class = CautiousDefaultHint
|
||||
|
||||
def createGame(self):
|
||||
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM+9.5*l.XS, l.YM+4*l.YS)
|
||||
|
||||
x, y = l.XM+l.XS, l.YM
|
||||
for i in range(8):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i%4,
|
||||
base_rank=JACK, dir=-1, max_cards=11))
|
||||
x += l.XS
|
||||
x, y = l.XM+l.XS, l.YM+l.YS
|
||||
for i in range(8):
|
||||
s.foundations.append(Adela_Foundation(x, y, self, suit=i%4,
|
||||
base_rank=QUEEN, max_cards=1))
|
||||
x += l.XS
|
||||
x, y = l.XM+l.XS, l.YM+2*l.YS
|
||||
for i in range(8):
|
||||
s.foundations.append(Adela_Foundation(x, y, self, suit=i%4,
|
||||
base_rank=KING, max_cards=1))
|
||||
x += l.XS
|
||||
x, y = l.XM, l.YM+l.YS
|
||||
s.talon = DealRowTalonStack(x, y, self)
|
||||
l.createText(s.talon, 'n')
|
||||
x, y = l.XM+l.XS/2, l.YM+3*l.YS
|
||||
for i in range(9):
|
||||
stack = SS_RowStack(x, y, self, max_move=1, dir=1)
|
||||
s.rows.append(stack)
|
||||
stack.CARD_YOFFSET = 0
|
||||
x += l.XS
|
||||
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def startGame(self):
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow()
|
||||
|
||||
def fillStack(self, stack):
|
||||
if stack in self.s.rows and not stack.cards:
|
||||
if self.s.talon.cards:
|
||||
old_state = self.enterState(self.S_FILL)
|
||||
self.flipMove(self.s.talon)
|
||||
self.moveMove(1, self.s.talon, stack)
|
||||
self.leaveState(old_state)
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_SS
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(330, Sultan, "Sultan",
|
||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK,
|
||||
|
@ -945,3 +1010,5 @@ registerGame(GameInfo(598, PicturePatience, "Picture Patience",
|
|||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK))
|
||||
registerGame(GameInfo(635, CircleEight, "Circle Eight",
|
||||
GI.GT_1DECK_TYPE, 1, 1, GI.SL_MOSTLY_LUCK))
|
||||
registerGame(GameInfo(646, Adela, "Adela",
|
||||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK))
|
||||
|
|
|
@ -505,7 +505,7 @@ class ASingleCardMove(AtomicMove):
|
|||
|
||||
|
||||
# /***********************************************************************
|
||||
# // AInnerMove - change position of single card in stack
|
||||
# // AInnerMove - change position of single card in stack (TODO)
|
||||
# ************************************************************************/
|
||||
|
||||
class AInnerMove(AtomicMove):
|
||||
|
@ -515,10 +515,10 @@ class AInnerMove(AtomicMove):
|
|||
self.from_pos, self.to_pos = from_pos, to_pos
|
||||
|
||||
def redo(self, game):
|
||||
pass
|
||||
stack = game.allstacks[self.stack_id]
|
||||
|
||||
def undo(self, game):
|
||||
pass
|
||||
stack = game.allstacks[self.stack_id]
|
||||
|
||||
def cmpForRedo(self, other):
|
||||
return cmp((self.stack_id, self.from_pos, self.to_pos),
|
||||
|
|
|
@ -298,7 +298,9 @@ class Stack:
|
|||
misc = None, # canvas item
|
||||
)
|
||||
view.top_bottom = None # the highest of all bottom items
|
||||
view.is_visible = view.x >= -100 and view.y >= -100
|
||||
cardw, cardh = game.app.images.CARDW, game.app.images.CARDH
|
||||
dx, dy = cardw+view.canvas.xmargin, cardh+view.canvas.ymargin
|
||||
view.is_visible = view.x >= -dx and view.y >= -dy
|
||||
view.is_open = -1
|
||||
view.can_hide_cards = -1
|
||||
view.max_shadow_cards = -1
|
||||
|
@ -2217,9 +2219,11 @@ class ReserveStack(OpenStack):
|
|||
|
||||
class InvisibleStack(Stack):
|
||||
def __init__(self, game, **cap):
|
||||
x, y = -500, -500 - len(game.allstacks)
|
||||
##x, y = -500, -500 - len(game.allstacks)
|
||||
cardw, cardh = game.app.images.CARDW, game.app.images.CARDH
|
||||
x, y = cardw+game.canvas.xmargin, cardh+game.canvas.ymargin
|
||||
kwdefault(cap, max_move=0, max_accept=0)
|
||||
Stack.__init__(self, x, y, game, cap=cap)
|
||||
Stack.__init__(self, -x-10, -y-10, game, cap=cap)
|
||||
|
||||
def assertStack(self):
|
||||
Stack.assertStack(self)
|
||||
|
|
|
@ -54,10 +54,10 @@ class FindCardDialog(Tkinter.Toplevel):
|
|||
#
|
||||
##self.images_dir = dir
|
||||
if size == 'large':
|
||||
self.images_dir = os.path.join(dir, 'large-emblems')
|
||||
self.images_dir = os.path.join(dir, 'large')
|
||||
self.label_width, self.label_height = LARGE_EMBLEMS_SIZE
|
||||
else:
|
||||
self.images_dir = os.path.join(dir, 'small-emblems')
|
||||
self.images_dir = os.path.join(dir, 'small')
|
||||
self.label_width, self.label_height = SMALL_EMBLEMS_SIZE
|
||||
self.canvas = MfxCanvas(self, bg='white')
|
||||
##self.canvas = MfxCanvas(self, bg='black')
|
||||
|
|
|
@ -518,34 +518,30 @@ class PysolMenubar(PysolMenubarActions):
|
|||
games = map(self.app.gdb.get, self.app.gdb.getGamesIdSortedByName())
|
||||
##games = tuple(games)
|
||||
###menu = MfxMenu(menu, label="Select &game")
|
||||
menu.add_command(label=n_("All &games..."), command=self.mSelectGameDialog, accelerator="G")
|
||||
menu.add_command(label=n_("Playable pre&view..."), command=self.mSelectGameDialogWithPreview, accelerator="V")
|
||||
menu.add_command(label=n_("All &games..."), accelerator="G",
|
||||
command=self.mSelectGameDialog)
|
||||
menu.add_command(label=n_("Playable pre&view..."), accelerator="V",
|
||||
command=self.mSelectGameDialogWithPreview)
|
||||
menu.add_separator()
|
||||
data = (n_("&Popular games"), lambda gi: gi.si.game_flags & GI.GT_POPULAR)
|
||||
self._addSelectGameSubMenu(menu, games, (data, ),
|
||||
self.mSelectGamePopular, self.tkopt.gameid_popular)
|
||||
submenu = MfxMenu(menu, label=n_("&French games"))
|
||||
self._addSelectGameSubMenu(submenu, games, GI.SELECT_GAME_BY_TYPE,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
self._addSelectPopularGameSubMenu(games, menu, self.mSelectGame,
|
||||
self.tkopt.gameid)
|
||||
self._addSelectFrenchGameSubMenu(games, menu, self.mSelectGame,
|
||||
self.tkopt.gameid)
|
||||
if self.progress: self.progress.update(step=1)
|
||||
submenu = MfxMenu(menu, label=n_("&Mahjongg games"))
|
||||
self._addSelectMahjonggGameSubMenu(submenu,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
submenu = MfxMenu(menu, label=n_("&Oriental games"))
|
||||
self._addSelectGameSubMenu(submenu, games,
|
||||
GI.SELECT_ORIENTAL_GAME_BY_TYPE,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
submenu = MfxMenu(menu, label=n_("&Special games"))
|
||||
self._addSelectGameSubMenu(submenu, games, GI.SELECT_SPECIAL_GAME_BY_TYPE,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
self._addSelectMahjonggGameSubMenu(games, menu, self.mSelectGame,
|
||||
self.tkopt.gameid)
|
||||
self._addSelectOrientalGameSubMenu(games, menu, self.mSelectGame,
|
||||
self.tkopt.gameid)
|
||||
self._addSelectSpecialGameSubMenu(games, menu, self.mSelectGame,
|
||||
self.tkopt.gameid)
|
||||
menu.add_separator()
|
||||
if self.progress: self.progress.update(step=1)
|
||||
submenu = MfxMenu(menu, label=n_("All games by name"))
|
||||
self._addSelectAllGameSubMenu(submenu, games,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
self._addSelectAllGameSubMenu(games, menu, self.mSelectGame,
|
||||
self.tkopt.gameid)
|
||||
|
||||
|
||||
def _addSelectGameSubMenu(self, menu, games, select_data, command, variable):
|
||||
def _addSelectGameSubMenu(self, games, menu, select_data,
|
||||
command, variable):
|
||||
##print select_data
|
||||
need_sep = 0
|
||||
for label, select_func in select_data:
|
||||
|
@ -559,104 +555,112 @@ class PysolMenubar(PysolMenubarActions):
|
|||
menu.add_separator()
|
||||
need_sep = 0
|
||||
submenu = MfxMenu(menu, label=label)
|
||||
self._addSelectGameSubSubMenu(submenu, g, command, variable)
|
||||
self._addSelectGameSubSubMenu(g, submenu, command, variable)
|
||||
|
||||
def _addSelectMahjonggGameSubMenu(self, menu, command, variable):
|
||||
## games = []
|
||||
## g = []
|
||||
## c0 = c1 = None
|
||||
## for i in self.app.gdb.getGamesIdSortedByShortName():
|
||||
## gi = self.app.gdb.get(i)
|
||||
## if gi.si.game_type == GI.GT_MAHJONGG:
|
||||
## c = gettext(gi.short_name).strip()[0]
|
||||
## if c0 is None:
|
||||
## c0 = c
|
||||
## elif c != c0:
|
||||
## if g:
|
||||
## games.append((c0, g))
|
||||
## g = []
|
||||
## c0 = c
|
||||
## #else:
|
||||
## #if g:
|
||||
## g.append(gi)
|
||||
## if g:
|
||||
## games.append((c0, g))
|
||||
## n = 0
|
||||
## gg = []
|
||||
## c0 = c1 = None
|
||||
## for c, g in games:
|
||||
## if c0 is None:
|
||||
## c0 = c
|
||||
## if len(gg) + len(g) > self.__cb_max:
|
||||
## if gg:
|
||||
## if c0 != c1:
|
||||
## label = c0+' - '+c1
|
||||
## else:
|
||||
## label = c1
|
||||
## c0 = c
|
||||
## submenu = MfxMenu(menu, label=label, name=None)
|
||||
## self._addSelectGameSubSubMenu(submenu, gg, command,
|
||||
## variable, short_name=True)
|
||||
## gg = []
|
||||
## c1 = c
|
||||
## gg += g
|
||||
## if gg:
|
||||
## label = c0+' - '+c
|
||||
## submenu = MfxMenu(menu, label=label, name=None)
|
||||
## self._addSelectGameSubSubMenu(submenu, gg, command,
|
||||
## variable, short_name=True)
|
||||
## return
|
||||
def _getNumGames(self, games, select_data):
|
||||
ngames = 0
|
||||
for label, select_func in select_data:
|
||||
ngames += len(filter(select_func, games))
|
||||
return ngames
|
||||
|
||||
def _addSelectMahjonggGameSubMenu(self, games, menu, command, variable):
|
||||
select_func = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
|
||||
mahjongg_games = filter(select_func, games)
|
||||
if len(mahjongg_games) == 0:
|
||||
return
|
||||
#
|
||||
menu = MfxMenu(menu, label=n_("&Mahjongg games"))
|
||||
|
||||
g = []
|
||||
c0 = c1 = None
|
||||
for i in self.app.gdb.getGamesIdSortedByShortName():
|
||||
gi = self.app.gdb.get(i)
|
||||
if gi.si.game_type == GI.GT_MAHJONGG:
|
||||
c = gettext(gi.short_name).strip()[0]
|
||||
if c0 is None:
|
||||
c0 = c
|
||||
if len(g) >= self.__cb_max and c != c1:
|
||||
label = c0 + ' - ' + c1
|
||||
if c0 == c1:
|
||||
label = c0
|
||||
submenu = MfxMenu(menu, label=label, name=None)
|
||||
self._addSelectGameSubSubMenu(submenu, g, command,
|
||||
variable, short_name=True)
|
||||
g = [gi]
|
||||
c0 = c
|
||||
else:
|
||||
g.append(gi)
|
||||
c1 = c
|
||||
if g:
|
||||
def add_menu(games, c0, c1, menu=menu,
|
||||
variable=variable, command=command):
|
||||
if not games:
|
||||
return
|
||||
label = c0 + ' - ' + c1
|
||||
if c0 == c1:
|
||||
label = c0
|
||||
submenu = MfxMenu(menu, label=label, name=None)
|
||||
self._addSelectGameSubSubMenu(submenu, g, command,
|
||||
self._addSelectGameSubSubMenu(games, submenu, command,
|
||||
variable, short_name=True)
|
||||
|
||||
def _addSelectAllGameSubMenu(self, menu, g, command, variable):
|
||||
games = {}
|
||||
for gi in mahjongg_games:
|
||||
c = gettext(gi.short_name).strip()[0]
|
||||
if games.has_key(c):
|
||||
games[c].append(gi)
|
||||
else:
|
||||
games[c] = [gi]
|
||||
games = games.items()
|
||||
games.sort()
|
||||
g0 = []
|
||||
c0 = c1 = games[0][0]
|
||||
for c, g1 in games:
|
||||
if len(g0)+len(g1) >= self.__cb_max:
|
||||
add_menu(g0, c0, c1)
|
||||
g0 = g1
|
||||
c0 = c1 = c
|
||||
else:
|
||||
g0 += g1
|
||||
c1 = c
|
||||
add_menu(g0, c0, c1)
|
||||
|
||||
def _addSelectPopularGameSubMenu(self, games, menu, command, variable):
|
||||
select_func = lambda gi: gi.si.game_flags & GI.GT_POPULAR
|
||||
if len(filter(select_func, games)) == 0:
|
||||
return
|
||||
data = (n_("&Popular games"), select_func)
|
||||
self._addSelectGameSubMenu(games, menu, (data, ),
|
||||
self.mSelectGamePopular,
|
||||
self.tkopt.gameid_popular)
|
||||
|
||||
def _addSelectFrenchGameSubMenu(self, games, menu, command, variable):
|
||||
if self._getNumGames(games, GI.SELECT_GAME_BY_TYPE) == 0:
|
||||
return
|
||||
submenu = MfxMenu(menu, label=n_("&French games"))
|
||||
self._addSelectGameSubMenu(games, submenu, GI.SELECT_GAME_BY_TYPE,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
|
||||
def _addSelectOrientalGameSubMenu(self, games, menu, command, variable):
|
||||
if self._getNumGames(games, GI.SELECT_ORIENTAL_GAME_BY_TYPE) == 0:
|
||||
return
|
||||
submenu = MfxMenu(menu, label=n_("&Oriental games"))
|
||||
self._addSelectGameSubMenu(games, submenu,
|
||||
GI.SELECT_ORIENTAL_GAME_BY_TYPE,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
|
||||
def _addSelectSpecialGameSubMenu(self, games, menu, command, variable):
|
||||
if self._getNumGames(games, GI.SELECT_ORIENTAL_GAME_BY_TYPE) == 0:
|
||||
return
|
||||
submenu = MfxMenu(menu, label=n_("&Special games"))
|
||||
self._addSelectGameSubMenu(games, submenu,
|
||||
GI.SELECT_SPECIAL_GAME_BY_TYPE,
|
||||
self.mSelectGame, self.tkopt.gameid)
|
||||
|
||||
def _addSelectAllGameSubMenu(self, games, menu, command, variable):
|
||||
menu = MfxMenu(menu, label=n_("All games by name"))
|
||||
n, d = 0, self.__cb_max
|
||||
i = 0
|
||||
while True:
|
||||
if self.progress: self.progress.update(step=1)
|
||||
columnbreak = i > 0 and (i % d) == 0
|
||||
i += 1
|
||||
if not g[n:n+d]:
|
||||
if not games[n:n+d]:
|
||||
break
|
||||
m = min(n+d-1, len(g)-1)
|
||||
label = gettext(g[n].name)[:3]+' - '+gettext(g[m].name)[:3]
|
||||
m = min(n+d-1, len(games)-1)
|
||||
label = gettext(games[n].name)[:3]+' - '+gettext(games[m].name)[:3]
|
||||
submenu = MfxMenu(menu, label=label, name=None)
|
||||
self._addSelectGameSubSubMenu(submenu, g[n:n+d], command, variable)
|
||||
self._addSelectGameSubSubMenu(games[n:n+d], submenu,
|
||||
command, variable)
|
||||
n += d
|
||||
if columnbreak:
|
||||
menu.entryconfigure(i, columnbreak=columnbreak)
|
||||
|
||||
def _addSelectGameSubSubMenu(self, menu, g, command, variable, short_name=False):
|
||||
def _addSelectGameSubSubMenu(self, games, menu, command, variable,
|
||||
short_name=False):
|
||||
##cb = (25, self.__cb_max) [ len(g) > 4 * 25 ]
|
||||
##cb = min(cb, self.__cb_max)
|
||||
cb = self.__cb_max
|
||||
for i in range(len(g)):
|
||||
gi = g[i]
|
||||
for i in range(len(games)):
|
||||
gi = games[i]
|
||||
columnbreak = i > 0 and (i % cb) == 0
|
||||
if short_name:
|
||||
label = gi.short_name
|
||||
|
@ -728,11 +732,11 @@ class PysolMenubar(PysolMenubarActions):
|
|||
games.append(gi)
|
||||
if len(games) > self.__cb_max*4:
|
||||
games.sort(lambda a, b: cmp(gettext(a.name), gettext(b.name)))
|
||||
self._addSelectAllGameSubMenu(submenu, games,
|
||||
self._addSelectAllGameSubMenu(games, submenu,
|
||||
command=self.mSelectGame,
|
||||
variable=self.tkopt.gameid)
|
||||
else:
|
||||
self._addSelectGameSubSubMenu(submenu, games,
|
||||
self._addSelectGameSubSubMenu(games, submenu,
|
||||
command=self.mSelectGame,
|
||||
variable=self.tkopt.gameid)
|
||||
state = self._getEnabledState
|
||||
|
|
|
@ -63,9 +63,9 @@ REMOTE_PROTOCOLS = ("ftp:", "gopher:", "http:", "mailto:", "news:", "telnet:")
|
|||
# //
|
||||
# ************************************************************************/
|
||||
|
||||
class tkHTMLWriter(formatter.DumbWriter):
|
||||
class tkHTMLWriter(formatter.NullWriter):
|
||||
def __init__(self, text, viewer, app):
|
||||
formatter.DumbWriter.__init__(self, self, maxcol=9999)
|
||||
formatter.NullWriter.__init__(self)
|
||||
|
||||
self.text = text
|
||||
self.viewer = viewer
|
||||
|
@ -113,12 +113,6 @@ class tkHTMLWriter(formatter.DumbWriter):
|
|||
return Functor(self.viewer, href)
|
||||
|
||||
def write(self, data):
|
||||
## FIXME
|
||||
##if self.col == 0 and self.atbreak == 0:
|
||||
## self.text.insert("insert", self.indent)
|
||||
self.text.insert("insert", data)
|
||||
|
||||
def __write(self, data):
|
||||
self.text.insert("insert", data)
|
||||
|
||||
def anchor_bgn(self, href, name, type):
|
||||
|
@ -131,14 +125,7 @@ class tkHTMLWriter(formatter.DumbWriter):
|
|||
if self.anchor:
|
||||
url = self.anchor[0]
|
||||
tag = "href_" + url
|
||||
anchor_mark = self.anchor_mark
|
||||
if self.text.get(anchor_mark) == ' ': # FIXME
|
||||
try:
|
||||
y, x = anchor_mark.split('.')
|
||||
anchor_mark = y+'.'+str(int(x)+1)
|
||||
except:
|
||||
pass
|
||||
self.text.tag_add(tag, anchor_mark, "insert")
|
||||
self.text.tag_add(tag, self.anchor_mark, "insert")
|
||||
self.text.tag_bind(tag, "<1>", self.createCallback(url))
|
||||
self.text.tag_bind(tag, "<Enter>", lambda e: self.anchor_enter(url))
|
||||
self.text.tag_bind(tag, "<Leave>", self.anchor_leave)
|
||||
|
@ -183,33 +170,35 @@ class tkHTMLWriter(formatter.DumbWriter):
|
|||
self.indent = " " * level
|
||||
|
||||
def send_label_data(self, data):
|
||||
##self.__write(self.indent + data + " ")
|
||||
self.__write(self.indent)
|
||||
##self.write(self.indent + data + " ")
|
||||
self.write(self.indent)
|
||||
if data == '*': # <li>
|
||||
img = self.viewer.symbols_img.get('disk')
|
||||
if img:
|
||||
self.text.image_create(index='insert', image=img,
|
||||
padx=0, pady=0)
|
||||
else:
|
||||
self.__write('*')
|
||||
self.write('*')
|
||||
else:
|
||||
self.__write(data)
|
||||
self.__write(' ')
|
||||
self.write(data)
|
||||
self.write(' ')
|
||||
|
||||
def send_paragraph(self, blankline):
|
||||
if self.col > 0:
|
||||
self.__write("\n")
|
||||
if blankline > 0:
|
||||
self.__write("\n" * blankline)
|
||||
self.col = 0
|
||||
self.atbreak = 0
|
||||
self.write('\n' * blankline)
|
||||
|
||||
def send_line_break(self):
|
||||
self.write('\n')
|
||||
|
||||
def send_hor_rule(self, *args):
|
||||
width = int(int(self.text["width"]) * 0.9)
|
||||
self.__write("_" * width)
|
||||
self.__write("\n")
|
||||
self.col = 0
|
||||
self.atbreak = 0
|
||||
self.write("_" * width)
|
||||
self.write("\n")
|
||||
|
||||
def send_literal_data(self, data):
|
||||
self.write(data)
|
||||
|
||||
def send_flowing_data(self, data):
|
||||
self.write(data)
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
|
@ -218,6 +207,7 @@ class tkHTMLWriter(formatter.DumbWriter):
|
|||
|
||||
class tkHTMLParser(htmllib.HTMLParser):
|
||||
def anchor_bgn(self, href, name, type):
|
||||
self.formatter.flush_softspace()
|
||||
htmllib.HTMLParser.anchor_bgn(self, href, name, type)
|
||||
self.formatter.writer.anchor_bgn(href, name, type)
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ VERSION_MAJOR = 4
|
|||
VERSION_MINOR = 82
|
||||
VERSION_TUPLE = (4, 82)
|
||||
|
||||
FC_VERSION = "0.9.2"
|
||||
FC_VERSION = "0.9.3"
|
||||
#FC_VERSION_TUPLE = (0, 4, 0)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue