diff --git a/pysollib/actions.py b/pysollib/actions.py index 3ea9f165..34734c90 100644 --- a/pysollib/actions.py +++ b/pysollib/actions.py @@ -41,7 +41,7 @@ import os, locale from mfxutil import SubclassResponsibility from mfxutil import Struct, openURL from pysolrandom import constructRandom -from settings import PACKAGE, PACKAGE_URL +from settings import TITLE, PACKAGE_URL from settings import TOP_TITLE from settings import DEBUG from gamedb import GI @@ -406,7 +406,7 @@ class PysolMenubarActions: def mQuit(self, *args): if self._cancelDrag(): return if self.changed(): - if not self.game.areYouSure(_("Quit ") + PACKAGE): return + if not self.game.areYouSure(_("Quit ") + TITLE): return self.game.endGame() self.game.quitGame() @@ -543,7 +543,7 @@ class PysolMenubarActions: text=_("Error while writing to file")) else: if fd: fd.close() - d = MfxMessageDialog(self.top, title=PACKAGE+_(" Info"), bitmap="info", + d = MfxMessageDialog(self.top, title=TITLE+_(" Info"), bitmap="info", text=_("Comments were appended to\n\n") + fn) self._setCommentMenu(bool(game.gsaveinfo.comment)) @@ -571,7 +571,7 @@ class PysolMenubarActions: text=_("Error while writing to file")) else: if file: file.close() - d = MfxMessageDialog(self.top, title=PACKAGE+_(" Info"), bitmap="info", + d = MfxMessageDialog(self.top, title=TITLE+_(" Info"), bitmap="info", text=text + _(" were appended to\n\n") + filename) @@ -587,7 +587,7 @@ class PysolMenubarActions: d = Struct(status=-1, button=-1) if demo: player = None - p0, p1, p2 = PACKAGE+_(" Demo"), PACKAGE+_(" Demo "), "" + p0, p1, p2 = TITLE+_(" Demo"), TITLE+_(" Demo "), "" else: player = self.app.opt.player p0, p1, p2 = player, "", _(" for ") + player diff --git a/pysollib/game.py b/pysollib/game.py index 8f72e0fe..267d0b5a 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -46,8 +46,8 @@ from mfxutil import Image, ImageTk from mfxutil import destruct, Struct, SubclassResponsibility from mfxutil import uclock, usleep from mfxutil import format_time -from settings import PACKAGE, TOOLKIT, TOP_TITLE -from settings import VERSION, VERSION_TUPLE, FC_VERSION +from settings import PACKAGE, TITLE, TOOLKIT, TOP_TITLE +from settings import VERSION, VERSION_TUPLE from settings import DEBUG from gamedb import GI from pysolrandom import PysolRandom, LCRandom31 @@ -154,8 +154,8 @@ class Game: self.__createCommon(app) self.setCursor(cursor=CURSOR_WATCH) #print 'gameid:', self.id - self.top.wm_title(PACKAGE + " - " + self.getTitleName()) - self.top.wm_iconname(PACKAGE + " - " + self.getTitleName()) + self.top.wm_title(TITLE + " - " + self.getTitleName()) + self.top.wm_iconname(TITLE + " - " + self.getTitleName()) # create the game if self.app.intro.progress: self.app.intro.progress.update(step=1) self.createGame() @@ -1009,7 +1009,7 @@ class Game: if confirm < 0: confirm = self.app.opt.confirm if confirm: - if not title: title = PACKAGE + if not title: title = TITLE if not text: text = _("Discard current game ?") self.playSample("areyousure") d = MfxMessageDialog(self.top, title=title, text=text, @@ -2282,7 +2282,7 @@ for %d moves. self.playSample("autopilotwon", priority=1000) s = self.app.miscrandom.choice((_("&Great"), _("&Cool"), _("&Yeah"), _("&Wow"))) - d = MfxMessageDialog(self.top, title=PACKAGE+_(" Autopilot"), + d = MfxMessageDialog(self.top, title=TITLE+_(" Autopilot"), text=_("\nGame solved in %d moves.\n") % self.moves.index, image=self.app.gimages.logos[4], @@ -2296,7 +2296,7 @@ for %d moves. text = _("\nGame finished\n") if DEBUG: text += "\nplayer_moves: %d\ndemo_moves: %d\n" % (self.stats.player_moves, self.stats.demo_moves) - d = MfxMessageDialog(self.top, title=PACKAGE+_(" Autopilot"), + d = MfxMessageDialog(self.top, title=TITLE+_(" Autopilot"), text=text, bitmap=bitmap, strings=(s,), padx=30, timeout=timeout) status = d.status @@ -2308,7 +2308,7 @@ for %d moves. if player_moves == 0: self.playSample("autopilotlost", priority=1000) s = self.app.miscrandom.choice((_("&Oh well"), _("&That's life"), _("&Hmm"))) # ??? accelerators - d = MfxMessageDialog(self.top, title=PACKAGE+_(" Autopilot"), + d = MfxMessageDialog(self.top, title=TITLE+_(" Autopilot"), text=_("\nThis won't come out...\n"), bitmap=bitmap, strings=(s,), padx=30, timeout=timeout) @@ -2823,7 +2823,7 @@ Error while loading game. Probably the game file is damaged, but this could also be a bug you might want to report.""")) traceback.print_exc() - except (Exception, UnpicklingError), ex: + except UnpicklingError, ex: self.updateMenus() self.setCursor(cursor=self.app.top_cursor) d = MfxExceptionDialog(self.top, ex, title=_("Load game error"), @@ -2894,34 +2894,36 @@ Please report this bug.""")) if isinstance(t, type): assert isinstance(obj, t), err_txt return obj + def validate(v, txt): + if not v: + raise UnpicklingError(txt) # package = pload(str) - assert package == PACKAGE, err_txt + validate(package == PACKAGE, err_txt) version = pload(str) - #assert isinstance(version, str) and len(version) <= 20, err_txt + #validate(isinstance(version, str) and len(version) <= 20, err_txt) version_tuple = pload(tuple) - if version_tuple < (10,): - raise UnpicklingError(_('''\ + validate(version_tuple >= (1,0), _('''\ Cannot load games saved with %s version %s''') % (PACKAGE, version)) game_version = 1 bookmark = pload(int) - assert 0 <= bookmark <= 2, err_txt + validate(0 <= bookmark <= 2, err_txt) game_version = pload(int) - assert game_version > 0, err_txt + validate(game_version > 0, err_txt) # id = pload(int) - assert id > 0, err_txt + validate(id > 0, err_txt) if id not in GI.PROTECTED_GAMES: game = app.constructGame(id) if game: if not game.canLoadGame(version_tuple, game_version): destruct(game) game = None - assert game is not None, _('''\ + validate(game is not None, _('''\ Cannot load this game from version %s as the game rules have changed -in the current implementation.''') % version +in the current implementation.''') % version) game.version = version game.version_tuple = version_tuple # @@ -2937,18 +2939,18 @@ in the current implementation.''') % version game.loadinfo.stacks = [] game.loadinfo.ncards = 0 nstacks = pload(int) - assert 1 <= nstacks, err_txt + validate(1 <= nstacks, err_txt) for i in range(nstacks): stack = [] ncards = pload(int) - assert 0 <= ncards <= 1024, err_txt + validate(0 <= ncards <= 1024, err_txt) for j in range(ncards): card_id = pload(int) face_up = pload(int) stack.append((card_id, face_up)) game.loadinfo.stacks.append(stack) game.loadinfo.ncards = game.loadinfo.ncards + ncards - assert game.loadinfo.ncards == game.gameinfo.ncards, err_txt + validate(game.loadinfo.ncards == game.gameinfo.ncards, err_txt) game.loadinfo.talon_round = pload() game.finished = pload() if 0 <= bookmark <= 1: @@ -2967,7 +2969,7 @@ in the current implementation.''') % version game.stats.__dict__.update(stats.__dict__) game._loadGameHook(p) dummy = pload(str) - assert dummy == "EOF", err_txt + validate(dummy == "EOF", err_txt) if bookmark == 2: # copy back all variables that are not saved game.stats = self.stats @@ -2991,7 +2993,7 @@ in the current implementation.''') % version self.updateTime() assert 0 <= bookmark <= 2 p.dump(PACKAGE) - p.dump(FC_VERSION) + p.dump(VERSION) p.dump(VERSION_TUPLE) p.dump(bookmark) p.dump(self.GAME_VERSION) diff --git a/pysollib/games/fan.py b/pysollib/games/fan.py index 72ee542d..994e2c93 100644 --- a/pysollib/games/fan.py +++ b/pysollib/games/fan.py @@ -784,6 +784,135 @@ class School(Fan): return card1.rank == card2.rank +# /*********************************************************************** +# // Forest Glade +# ************************************************************************/ + +class ForestGlade_Talon(DealRowRedealTalonStack): + + def _redeal(self, rows=None, frames=0): + # move all cards to the talon + num_cards = 0 + if rows is None: + rows = self.game.s.rows + for r in rows: + for i in range(len(r.cards)): + num_cards += 1 + self.game.moveMove(1, r, self, frames=frames, shadow=0) + if self.cards[-1].face_up: + self.game.flipMove(self) + return num_cards + + def canDealCards(self): + if self.round == self.max_rounds: + if not self.cards: + return False + for r in self.game.s.rows: + if not r.cards: + return True + return False + return True + + def dealCards(self, sound=0): + rows = [r for r in self.game.s.rows if not r.cards] + if not rows or not self.cards: + if sound and self.game.app.opt.animations: + self.game.startDealSample() + # move all cards to the talon + ncards = self._redeal(frames=4) + # shuffle + self.game.shuffleStackMove(self) + # deal + if self.cards: + for r in self.game.s.rows: + for i in range(3): + if not self.cards: + break + ncards += self.dealRowAvail(rows=[r], frames=4) + # + self.game.nextRoundMove(self) + if sound: + self.game.stopSamples() + return ncards + # + if sound and self.game.app.opt.animations: + self.game.startDealSample() + ncards = 0 + for r in rows: + for i in range(3): + if not self.cards: + break + ncards += self.dealRowAvail(rows=[r], sound=0) + if sound: + self.game.stopSamples() + return ncards + + +class ForestGlade(Game): + Hint_Class = CautiousDefaultHint + + def createGame(self): + + l, s = Layout(self), self.s + playcards = 7 + w0 = l.XS+(playcards-1)*l.XOFFSET + w, h = l.XM + 3*w0 + 4*l.XS, l.YM+6*l.YS + self.setSize(w, h) + + x1, x2 = l.XM, self.width - 2*l.XS + for i in range(2): + y = l.YM + for j in range(4): + s.foundations.append(SS_FoundationStack(x1, y, self, + suit=j, dir=2, max_cards=7)) + s.foundations.append(SS_FoundationStack(x2, y, self, + base_rank=1, suit=j, dir=2, max_cards=6)) + y += l.YS + x1 += l.XS + x2 += l.XS + + x, y = l.XM + 3*l.XS, l.YM + for i in (0, 1): + stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) + stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 + s.rows.append(stack) + x += w0 + y = l.YM+l.YS + for i in range(4): + x = l.XM + 2*l.XS + for j in range(3): + stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) + stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 + s.rows.append(stack) + x += w0 + y += l.YS + x, y = l.XM + 3*l.XS, l.YM + 5*l.YS + for i in (0, 1): + stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) + stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 + s.rows.append(stack) + x += w0 + + x, y = l.XM, self.height - l.YS + s.talon = ForestGlade_Talon(x, y, self, max_rounds=3) + l.createText(s.talon, 'ne') + tx, ty, ta, tf = l.getTextAttr(s.talon, 'se') + font=self.app.getFont('canvas_default') + s.talon.texts.rounds = MfxCanvasText(self.canvas, tx, ty, + anchor=ta, font=font) + + l.defaultStackGroups() + + + def startGame(self): + for i in range(2): + self.s.talon.dealRow(frames=0) + self.startDealSample() + self.s.talon.dealRow() + + shallHighlightMatch = Game._shallHighlightMatch_SS + + # register the game registerGame(GameInfo(56, FanGame, "Fan", @@ -828,4 +957,6 @@ registerGame(GameInfo(714, ShamrocksII, "Shamrocks II", GI.GT_FAN_TYPE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(719, School, "School", GI.GT_FAN_TYPE, 1, 2, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(739, ForestGlade, "Forest Glade", + GI.GT_FAN_TYPE, 2, 2, GI.SL_MOSTLY_SKILL)) diff --git a/pysollib/help.py b/pysollib/help.py index e3c689e8..a79dd043 100644 --- a/pysollib/help.py +++ b/pysollib/help.py @@ -37,7 +37,7 @@ # imports # PySol imports -from settings import PACKAGE, PACKAGE_URL, TOOLKIT, FC_VERSION +from settings import TITLE, PACKAGE_URL, TOOLKIT, VERSION from pysoltk import make_help_toplevel from pysoltk import MfxMessageDialog from pysoltk import PysolAboutDialog @@ -57,8 +57,8 @@ def help_about(app, timeout=0, sound=1): strings=(_("&Nice"), _("&Credits...")) if timeout: strings=(_("&Enjoy"),) - version = _("Version %s") % FC_VERSION - d = PysolAboutDialog(app, app.top, title=_("About ") + PACKAGE, + version = _("Version %s") % VERSION + d = PysolAboutDialog(app, app.top, title=_("About ") + TITLE, timeout=timeout, text=_('''PySol Fan Club edition %s%s @@ -91,7 +91,7 @@ def help_credits(app, timeout=0, sound=1): elif TOOLKIT == "kde": t = "pyKDE" elif TOOLKIT == "wx" : t = "wxPython" d = MfxMessageDialog(app.top, title=_("Credits"), timeout=timeout, - text=PACKAGE+_(''' credits go to: + text=TITLE+_(''' credits go to: Volker Weidner for getting me into Solitaire Guido van Rossum for the initial example program @@ -126,7 +126,7 @@ def help_html(app, document, dir_, top=None): document, dir_ = "index.html", "html" help_html_index = app.dataloader.findFile(document, dir_) except EnvironmentError: - d = MfxMessageDialog(app.top, title=PACKAGE + _(" HTML Problem"), + d = MfxMessageDialog(app.top, title=TITLE + _(" HTML Problem"), text=_("Cannot find help document\n") + document, bitmap="warning") return None @@ -140,7 +140,7 @@ def help_html(app, document, dir_, top=None): viewer.display(doc, relpath=0) except: ##traceback.print_exc() - top = make_help_toplevel(app, title=PACKAGE+_(" Help")) + top = make_help_toplevel(app, title=TITLE+_(" Help")) if top.winfo_screenwidth() < 800 or top.winfo_screenheight() < 600: #maximized = 1 top.wm_minsize(300, 150) diff --git a/pysollib/init.py b/pysollib/init.py index e724da53..ae2d8db3 100644 --- a/pysollib/init.py +++ b/pysollib/init.py @@ -110,12 +110,12 @@ def init(): sys.argv.remove('--tile') if settings.TOOLKIT == 'tk': import Tkinter - root = Tkinter.Tk(className=settings.PACKAGE) + root = Tkinter.Tk(className=settings.TITLE) root.withdraw() if Tkinter.TkVersion < 8.4: # we need unicode support sys.exit("%s needs Tcl/Tk 8.4 or better (you have %s)" % - (settings.PACKAGE, str(Tkinter.TkVersion))) + (settings.TITLE, str(Tkinter.TkVersion))) settings.WIN_SYSTEM = root.tk.call('tk', 'windowingsystem') if settings.WIN_SYSTEM == 'aqua': # TkAqua displays the console automatically in application diff --git a/pysollib/main.py b/pysollib/main.py index 9ed1d80a..4ff93d36 100644 --- a/pysollib/main.py +++ b/pysollib/main.py @@ -46,7 +46,7 @@ from resource import Tile from app import Application from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient -from settings import PACKAGE, SOUND_MOD +from settings import TITLE, SOUND_MOD from winsystems import init_root_window # Toolkit imports @@ -62,14 +62,14 @@ from pysoltk import PysolProgressBar def fatal_no_cardsets(app): app.wm_withdraw() - d = MfxMessageDialog(app.top, title=_("%s installation error") % PACKAGE, + d = MfxMessageDialog(app.top, title=_("%s installation error") % TITLE, text=_('''No cardsets were found !!! Main data directory is: %s Please check your %s installation. -''') % (app.dataloader.dir, PACKAGE), +''') % (app.dataloader.dir, TITLE), bitmap="error", strings=(_("&Quit"),)) @@ -203,7 +203,7 @@ def pysol_init(app, args): pass # init toolkit 1) - top = MfxRoot(className=PACKAGE) + top = MfxRoot(className=TITLE) app.top = top app.top_bg = top.cget("bg") app.top_cursor = top.cget("cursor") @@ -255,7 +255,7 @@ def pysol_init(app, args): # check games if len(app.gdb.getGamesIdSortedByName()) == 0: app.wm_withdraw() - d = MfxMessageDialog(top, title=_("%s installation error") % PACKAGE, + d = MfxMessageDialog(top, title=_("%s installation error") % TITLE, text=_(''' No games were found !!! @@ -263,7 +263,7 @@ Main data directory is: %s Please check your %s installation. -''') % (app.dataloader.dir, PACKAGE), bitmap="error", strings=(_("&Quit"),)) +''') % (app.dataloader.dir, TITLE), bitmap="error", strings=(_("&Quit"),)) return 1 # init cardsets @@ -325,7 +325,7 @@ Please check your %s installation. app.wm_withdraw() # create the progress bar - title = _("Welcome to %s") % PACKAGE + title = _("Welcome to %s") % TITLE color = app.opt.colors['table'] if app.tabletile_index > 0: color = "#008200" diff --git a/pysollib/pysolgtk/menubar.py b/pysollib/pysolgtk/menubar.py index 4013e17d..eb01fe61 100644 --- a/pysollib/pysolgtk/menubar.py +++ b/pysollib/pysolgtk/menubar.py @@ -39,7 +39,7 @@ from gtk import gdk # PySol imports from pysollib.gamedb import GI from pysollib.actions import PysolMenubarActions -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE # toolkit imports from tkutil import setTransient @@ -229,7 +229,7 @@ class PysolMenubar(PysolMenubarActions): ltk2gtk('&Contents'), 'F1', None, self.mHelp), ('aboutpysol', None, - ltk2gtk('&About ')+PACKAGE+'...', + ltk2gtk('&About ')+TITLE+'...', None,None,self.mHelpAbout), ('updateall', None, 'Redraw Game', 'L', diff --git a/pysollib/pysolgtk/tkhtml.py b/pysollib/pysolgtk/tkhtml.py index 82e1aa29..13dcdadd 100644 --- a/pysollib/pysolgtk/tkhtml.py +++ b/pysollib/pysolgtk/tkhtml.py @@ -51,7 +51,7 @@ if __name__ == '__main__': # PySol imports from pysollib.mfxutil import Struct, openURL -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE # Toolkit imports from tkutil import bind, unbind_destroy, loadImage @@ -444,7 +444,7 @@ class HTMLViewer: for p in REMOTE_PROTOCOLS: if url.startswith(p): if not openURL(url): - self.errorDialog(PACKAGE + _('''HTML limitation: + self.errorDialog(TITLE + _('''HTML limitation: The %s protocol is not supported yet. Please use your standard web browser @@ -544,7 +544,7 @@ to open the following URL: self.display(self.home, relpath=0) def errorDialog(self, msg): - d = MfxMessageDialog(self.parent, title=PACKAGE+' HTML Problem', + d = MfxMessageDialog(self.parent, title=TITLE+' HTML Problem', text=msg, bitmap='warning', strings=(_('&OK'),), default=0) diff --git a/pysollib/pysolgtk/tkstats.py b/pysollib/pysolgtk/tkstats.py index 285a058c..bee2c3a9 100644 --- a/pysollib/pysolgtk/tkstats.py +++ b/pysollib/pysolgtk/tkstats.py @@ -27,7 +27,7 @@ import gtk.glade # PySol imports from pysollib.mfxutil import format_time -from pysollib.settings import TOP_TITLE, PACKAGE +from pysollib.settings import TOP_TITLE, TITLE from pysollib.stats import PysolStatsFormatter # Toolkit imports @@ -166,7 +166,7 @@ class Game_StatsDialog: dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) dialog.set_transient_for(parent) dialog.resize(500, 340) - dialog.set_title(PACKAGE+' - '+_("Statistics")) + dialog.set_title(TITLE+' - '+_("Statistics")) # dialog.run() self.status = -1 diff --git a/pysollib/pysolgtk/tkwrap.py b/pysollib/pysolgtk/tkwrap.py index f7724ab1..1a0d2e84 100644 --- a/pysollib/pysolgtk/tkwrap.py +++ b/pysollib/pysolgtk/tkwrap.py @@ -38,7 +38,7 @@ from gtk import gdk # PySol imports ## from pysollib.images import Images -from pysollib.settings import PACKAGE, VERSION +from pysollib.settings import TITLE, VERSION # Toolkit imports from tkutil import makeToplevel, loadImage @@ -236,8 +236,8 @@ class MfxRoot(_MfxToplevel): def initToolkit(self, app, fg=None, bg=None, font=None, theme=None): sw, sh, sd = self.winfo_screenwidth(), self.winfo_screenheight(), self.winfo_screendepth() ##self.wm_group(self) - self.wm_title(PACKAGE + ' ' + VERSION) - ##self.wm_iconname(PACKAGE + ' ' + VERSION) + self.wm_title(TITLE + ' ' + VERSION) + ##self.wm_iconname(TITLE + ' ' + VERSION) if sw < 640 or sh < 480: self.wm_minsize(400, 300) else: diff --git a/pysollib/settings.py b/pysollib/settings.py index cc9a9147..4c29ebce 100644 --- a/pysollib/settings.py +++ b/pysollib/settings.py @@ -24,16 +24,15 @@ import os n_ = lambda x: x # for gettext -#PACKAGE = 'PySolFC' -PACKAGE = 'PySol' -#PACKAGE_URL = 'http://pysolfc/sourceforge.net/' +PACKAGE = 'PySolFC' +TITLE = 'PySol' +#PACKAGE_URL = 'http://pysolfc.sourceforge.net/' PACKAGE_URL = 'http://sourceforge.net/projects/pysolfc/' -VERSION = '4.82' -FC_VERSION = '1.0.1' -VERSION_TUPLE = (10, 0, 1) +VERSION = '1.0.1' +VERSION_TUPLE = (1, 0, 1) -# Tk windowing system (auto determine in init.py) +# Tk windowing system (auto set up in init.py) WIN_SYSTEM = 'x11' # win32, x11, aqua, classic # toolkit diff --git a/pysollib/tile/findcarddialog.py b/pysollib/tile/findcarddialog.py index 53252932..5a12bdff 100644 --- a/pysollib/tile/findcarddialog.py +++ b/pysollib/tile/findcarddialog.py @@ -33,7 +33,7 @@ from tkutil import after, after_cancel from tkutil import bind, unbind_destroy, makeImage from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE # /*********************************************************************** @@ -130,7 +130,7 @@ class FindCardDialog(Tkinter.Toplevel): i += 1 w, h = dx*j+2, dy*i+2 self.canvas.config(width=w, height=h) - self.wm_iconname(PACKAGE + " - " + game.getTitleName()) + self.wm_iconname(TITLE + " - " + game.getTitleName()) self.wm_geometry('') # cancel user-specified geometry def enterEvent(self, suit, rank, rect, group): diff --git a/pysollib/tile/menubar.py b/pysollib/tile/menubar.py index ebfc44c2..1486bb63 100644 --- a/pysollib/tile/menubar.py +++ b/pysollib/tile/menubar.py @@ -46,7 +46,7 @@ import tkFileDialog from pysollib.mfxutil import Struct, kwdefault from pysollib.mfxutil import Image from pysollib.util import CARDSET -from pysollib.settings import PACKAGE, WIN_SYSTEM +from pysollib.settings import TITLE, WIN_SYSTEM from pysollib.settings import SELECT_GAME_MENU from pysollib.settings import USE_FREECELL_SOLVER from pysollib.settings import DEBUG @@ -347,7 +347,7 @@ class PysolMenubar(PysolMenubarActions): if WIN_SYSTEM == "aqua": applemenu=MfxMenu(self.__menubar, "apple") - applemenu.add_command(label=_("&About ")+PACKAGE, command=self.mHelpAbout) + applemenu.add_command(label=_("&About ")+TITLE, command=self.mHelpAbout) menu = MfxMenu(self.__menubar, n_("&File")) menu.add_command(label=n_("&New game"), command=self.mNewGame, accelerator="N") @@ -517,7 +517,7 @@ class PysolMenubar(PysolMenubarActions): ##menu.add_command(label=n_("What's &new ?"), command=self.mHelpNews) if WIN_SYSTEM != "aqua": menu.add_separator() - menu.add_command(label=n_("&About ")+PACKAGE+"...", command=self.mHelpAbout) + menu.add_command(label=n_("&About ")+TITLE+"...", command=self.mHelpAbout) MfxMenubar.addPath = None @@ -973,7 +973,7 @@ class PysolMenubar(PysolMenubarActions): # DEFAULTEXTENSION = ".pso" - FILETYPES = ((PACKAGE+" files", "*"+DEFAULTEXTENSION), ("All files", "*")) + FILETYPES = ((TITLE+" files", "*"+DEFAULTEXTENSION), ("All files", "*")) def mAddFavor(self, *event): gameid = self.app.game.id @@ -1346,7 +1346,7 @@ class PysolMenubar(PysolMenubarActions): d = MfxMessageDialog(self.top, title=_("Change theme"), text=_("""\ This settings will take effect -the next time you restart """)+PACKAGE, +the next time you restart """)+TITLE, bitmap="warning", default=0, strings=(_("&OK"),)) diff --git a/pysollib/tile/solverdialog.py b/pysollib/tile/solverdialog.py index 3c78d6ab..547d6e77 100644 --- a/pysollib/tile/solverdialog.py +++ b/pysollib/tile/solverdialog.py @@ -32,7 +32,7 @@ import Tkinter import Tile # PySol imports -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE from pysollib.mfxutil import KwStruct # Toolkit imports @@ -50,7 +50,7 @@ class SolverDialog(MfxDialog): def __init__(self, parent, app, **kw): self.parent = parent self.app = app - title = PACKAGE+' - FreeCell Solver' + title = TITLE+' - FreeCell Solver' kw = self.initKw(kw) MfxDialog.__init__(self, parent, title, kw.resizable, kw.default) top_frame, bottom_frame = self.createFrames(kw) diff --git a/pysollib/tile/soundoptionsdialog.py b/pysollib/tile/soundoptionsdialog.py index ba836d16..e45f05d7 100644 --- a/pysollib/tile/soundoptionsdialog.py +++ b/pysollib/tile/soundoptionsdialog.py @@ -42,7 +42,7 @@ import Tile # PySol imports from pysollib.mfxutil import KwStruct -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE from pysollib.pysolaudio import pysolsoundserver # Toolkit imports @@ -201,7 +201,7 @@ class SoundOptionsDialog(MfxDialog): d = MfxMessageDialog(self.top, title=_("Sound preferences info"), text=_("""\ Changing DirectX settings will take effect -the next time you restart """)+PACKAGE, +the next time you restart """)+TITLE, bitmap="warning", default=0, strings=(_("&OK"),)) diff --git a/pysollib/tile/tkhtml.py b/pysollib/tile/tkhtml.py index 961e912f..4d9e3c40 100644 --- a/pysollib/tile/tkhtml.py +++ b/pysollib/tile/tkhtml.py @@ -49,7 +49,7 @@ if __name__ == '__main__': # PySol imports from pysollib.mfxutil import Struct, openURL -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE # Toolkit imports from tkutil import bind, unbind_destroy @@ -388,7 +388,7 @@ class HTMLViewer: for p in REMOTE_PROTOCOLS: if url.startswith(p): if not openURL(url): - self.errorDialog(PACKAGE + _('''HTML limitation: + self.errorDialog(TITLE + _('''HTML limitation: The %s protocol is not supported yet. Please use your standard web browser @@ -500,7 +500,7 @@ to open the following URL: self.display(self.home, relpath=0) def errorDialog(self, msg): - d = MfxMessageDialog(self.parent, title=PACKAGE+" HTML Problem", + d = MfxMessageDialog(self.parent, title=TITLE+" HTML Problem", text=msg, ##bitmap="warning", # FIXME: this interp don't have images strings=(_("&OK"),), default=0) diff --git a/pysollib/tile/tkutil.py b/pysollib/tile/tkutil.py index a3429d87..e5368daa 100644 --- a/pysollib/tile/tkutil.py +++ b/pysollib/tile/tkutil.py @@ -62,7 +62,7 @@ from tkFont import Font # PySol imports from pysollib.mfxutil import Image, ImageTk, ImageOps -from pysollib.settings import PACKAGE, WIN_SYSTEM +from pysollib.settings import TITLE, WIN_SYSTEM # /*********************************************************************** @@ -125,7 +125,7 @@ def makeToplevel(parent, title=None): # # This is a shortcut for a Toplevel() instantiation plus calls to # set the title and icon name of the window. - window = Tkinter.Toplevel(parent) #, class_=PACKAGE) + window = Tkinter.Toplevel(parent) #, class_=TITLE) ##window.wm_group(parent) ##window.wm_command("") if WIN_SYSTEM == "x11": @@ -139,7 +139,7 @@ def makeToplevel(parent, title=None): def make_help_toplevel(app, title=None): # Create an independent Toplevel window. from pysollib.winsystems import init_root_window - window = Tkinter.Tk(className=PACKAGE) + window = Tkinter.Tk(className=TITLE) init_root_window(window, app) return window diff --git a/pysollib/tile/toolbar.py b/pysollib/tile/toolbar.py index ec4c40cb..4d8a6fc2 100644 --- a/pysollib/tile/toolbar.py +++ b/pysollib/tile/toolbar.py @@ -44,7 +44,7 @@ import Tile from pysollib.mfxutil import destruct from pysollib.mfxutil import Image, ImageTk from pysollib.util import IMAGE_EXTENSIONS -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE from pysollib.actions import PysolToolbarActions from pysollib.winsystems import TkSettings @@ -200,7 +200,7 @@ class PysolToolbar(PysolToolbarActions): (n_("Statistics"), self.mPlayerStats, _("View statistics")), (n_("Rules"), self.mHelpRules, _("Rules for this game")), (None, None, None), - (n_("Quit"), self.mQuit, _("Quit ")+PACKAGE), + (n_("Quit"), self.mQuit, _("Quit ")+TITLE), ): if l is None: sep = self._createSeparator() diff --git a/pysollib/tk/findcarddialog.py b/pysollib/tk/findcarddialog.py index 4cfa4b99..2643ae8e 100644 --- a/pysollib/tk/findcarddialog.py +++ b/pysollib/tk/findcarddialog.py @@ -36,7 +36,7 @@ from tkutil import after, after_cancel from tkutil import bind, unbind_destroy, makeImage from tkcanvas import MfxCanvas, MfxCanvasGroup, MfxCanvasImage, MfxCanvasRectangle -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE # /*********************************************************************** @@ -133,7 +133,7 @@ class FindCardDialog(Tkinter.Toplevel): i += 1 w, h = dx*j+2, dy*i+2 self.canvas.config(width=w, height=h) - self.wm_iconname(PACKAGE + " - " + game.getTitleName()) + self.wm_iconname(TITLE + " - " + game.getTitleName()) self.wm_geometry('') # cancel user-specified geometry def enterEvent(self, suit, rank, rect, group): diff --git a/pysollib/tk/menubar.py b/pysollib/tk/menubar.py index ee74e595..8caa070d 100644 --- a/pysollib/tk/menubar.py +++ b/pysollib/tk/menubar.py @@ -45,7 +45,7 @@ import Tkinter, tkFileDialog from pysollib.mfxutil import Struct, kwdefault from pysollib.mfxutil import Image from pysollib.util import CARDSET -from pysollib.settings import PACKAGE, WIN_SYSTEM +from pysollib.settings import TITLE, WIN_SYSTEM from pysollib.settings import TOP_TITLE from pysollib.settings import SELECT_GAME_MENU from pysollib.settings import USE_FREECELL_SOLVER @@ -344,7 +344,7 @@ class PysolMenubar(PysolMenubarActions): if WIN_SYSTEM == "aqua": applemenu=MfxMenu(self.__menubar, "apple") - applemenu.add_command(label=_("&About ")+PACKAGE, command=self.mHelpAbout) + applemenu.add_command(label=_("&About ")+TITLE, command=self.mHelpAbout) menu = MfxMenu(self.__menubar, n_("&File")) menu.add_command(label=n_("&New game"), command=self.mNewGame, accelerator="N") @@ -521,7 +521,7 @@ class PysolMenubar(PysolMenubarActions): ##menu.add_command(label=n_("What's &new ?"), command=self.mHelpNews) if WIN_SYSTEM != "aqua": menu.add_separator() - menu.add_command(label=n_("&About ")+PACKAGE+"...", command=self.mHelpAbout) + menu.add_command(label=n_("&About ")+TITLE+"...", command=self.mHelpAbout) MfxMenubar.addPath = None @@ -977,7 +977,7 @@ class PysolMenubar(PysolMenubarActions): # DEFAULTEXTENSION = ".pso" - FILETYPES = ((PACKAGE+" files", "*"+DEFAULTEXTENSION), ("All files", "*")) + FILETYPES = ((TITLE+" files", "*"+DEFAULTEXTENSION), ("All files", "*")) def mAddFavor(self, *event): gameid = self.app.game.id diff --git a/pysollib/tk/solverdialog.py b/pysollib/tk/solverdialog.py index f40be95b..ff2d5876 100644 --- a/pysollib/tk/solverdialog.py +++ b/pysollib/tk/solverdialog.py @@ -33,7 +33,7 @@ import Tkinter # PySol imports from pysollib.mfxutil import KwStruct -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE # Toolkit imports from tkconst import EVENT_HANDLED @@ -49,7 +49,7 @@ class SolverDialog(MfxDialog): def __init__(self, parent, app, **kw): self.parent = parent self.app = app - title = PACKAGE+' - FreeCell Solver' + title = TITLE+' - FreeCell Solver' kw = self.initKw(kw) MfxDialog.__init__(self, parent, title, kw.resizable, kw.default) top_frame, bottom_frame = self.createFrames(kw) diff --git a/pysollib/tk/soundoptionsdialog.py b/pysollib/tk/soundoptionsdialog.py index a1fc0c97..0a2b3205 100644 --- a/pysollib/tk/soundoptionsdialog.py +++ b/pysollib/tk/soundoptionsdialog.py @@ -41,7 +41,7 @@ import Tkinter # PySol imports from pysollib.mfxutil import KwStruct -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE from pysollib.pysolaudio import pysolsoundserver # Toolkit imports @@ -201,7 +201,7 @@ class SoundOptionsDialog(MfxDialog): d = MfxMessageDialog(self.top, title=_("Sound preferences info"), text=_("""\ Changing DirectX settings will take effect -the next time you restart """)+PACKAGE, +the next time you restart """)+TITLE, bitmap="warning", default=0, strings=(_("&OK"),)) diff --git a/pysollib/tk/tkhtml.py b/pysollib/tk/tkhtml.py index 59b27730..a5be8340 100644 --- a/pysollib/tk/tkhtml.py +++ b/pysollib/tk/tkhtml.py @@ -48,7 +48,7 @@ if __name__ == '__main__': # PySol imports from pysollib.mfxutil import Struct, openURL -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE # Toolkit imports from tkutil import bind, unbind_destroy @@ -383,7 +383,7 @@ class HTMLViewer: for p in REMOTE_PROTOCOLS: if url.startswith(p): if not openURL(url): - self.errorDialog(PACKAGE + _('''HTML limitation: + self.errorDialog(TITLE + _('''HTML limitation: The %s protocol is not supported yet. Please use your standard web browser @@ -495,7 +495,7 @@ to open the following URL: self.display(self.home, relpath=0) def errorDialog(self, msg): - d = MfxMessageDialog(self.parent, title=PACKAGE+" HTML Problem", + d = MfxMessageDialog(self.parent, title=TITLE+" HTML Problem", text=msg, ##bitmap="warning", # FIXME: this interp don't have images strings=(_("&OK"),), default=0) diff --git a/pysollib/tk/tkutil.py b/pysollib/tk/tkutil.py index a3429d87..e5368daa 100644 --- a/pysollib/tk/tkutil.py +++ b/pysollib/tk/tkutil.py @@ -62,7 +62,7 @@ from tkFont import Font # PySol imports from pysollib.mfxutil import Image, ImageTk, ImageOps -from pysollib.settings import PACKAGE, WIN_SYSTEM +from pysollib.settings import TITLE, WIN_SYSTEM # /*********************************************************************** @@ -125,7 +125,7 @@ def makeToplevel(parent, title=None): # # This is a shortcut for a Toplevel() instantiation plus calls to # set the title and icon name of the window. - window = Tkinter.Toplevel(parent) #, class_=PACKAGE) + window = Tkinter.Toplevel(parent) #, class_=TITLE) ##window.wm_group(parent) ##window.wm_command("") if WIN_SYSTEM == "x11": @@ -139,7 +139,7 @@ def makeToplevel(parent, title=None): def make_help_toplevel(app, title=None): # Create an independent Toplevel window. from pysollib.winsystems import init_root_window - window = Tkinter.Tk(className=PACKAGE) + window = Tkinter.Tk(className=TITLE) init_root_window(window, app) return window diff --git a/pysollib/tk/toolbar.py b/pysollib/tk/toolbar.py index bb3db84b..497cbd1f 100644 --- a/pysollib/tk/toolbar.py +++ b/pysollib/tk/toolbar.py @@ -43,7 +43,7 @@ import Tkinter from pysollib.mfxutil import destruct from pysollib.mfxutil import Image, ImageTk from pysollib.util import IMAGE_EXTENSIONS -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE from pysollib.actions import PysolToolbarActions from pysollib.winsystems import TkSettings @@ -200,7 +200,7 @@ class PysolToolbar(PysolToolbarActions): (n_("Statistics"), self.mPlayerStats, _("View statistics")), (n_("Rules"), self.mHelpRules, _("Rules for this game")), (None, None, None), - (n_("Quit"), self.mQuit, _("Quit ")+PACKAGE), + (n_("Quit"), self.mQuit, _("Quit ")+TITLE), ): if l is None: sep = self._createSeparator() diff --git a/pysollib/winsystems/common.py b/pysollib/winsystems/common.py index 2ea66363..9d38ef89 100644 --- a/pysollib/winsystems/common.py +++ b/pysollib/winsystems/common.py @@ -21,8 +21,8 @@ import sys, os, traceback -from pysollib.settings import PACKAGE -from pysollib.settings import FC_VERSION as VERSION +from pysollib.settings import TITLE +from pysollib.settings import VERSION from pysollib.settings import TOOLKIT, USE_TILE from pysollib.settings import DEBUG from pysollib.mfxutil import print_err @@ -87,8 +87,8 @@ def get_font_name(font): def base_init_root_window(root, app): #root.wm_group(root) - root.wm_title(PACKAGE + ' ' + VERSION) - root.wm_iconname(PACKAGE + ' ' + VERSION) + root.wm_title(TITLE + ' ' + VERSION) + root.wm_iconname(TITLE + ' ' + VERSION) # set minsize sw, sh, sd = (root.winfo_screenwidth(), root.winfo_screenheight(), diff --git a/pysollib/winsystems/x11.py b/pysollib/winsystems/x11.py index 812a6700..b8e2033f 100644 --- a/pysollib/winsystems/x11.py +++ b/pysollib/winsystems/x11.py @@ -24,7 +24,7 @@ import sys, os, traceback import Tkinter import tkFont -from pysollib.settings import PACKAGE +from pysollib.settings import TITLE from pysollib.settings import TOOLKIT, USE_TILE from pysollib.tile import Tile @@ -106,7 +106,7 @@ def init_root_window(root, app): root.option_add('*selectBorderWidth', 0, 60) - font = root.option_get('font', PACKAGE) + font = root.option_get('font', TITLE) if font: # use font from xrdb fn = get_font_name(font) @@ -150,7 +150,7 @@ def init_root_window(root, app): root.option_add('*Menu.activeBorderWidth', 1, 60) #root.option_add('*Button.HighlightBackground', '#595d59') #root.option_add('*Button.HighlightThickness', '1') - font = root.option_get('font', PACKAGE) + font = root.option_get('font', TITLE) if font: fn = get_font_name(font) app.opt.fonts['default'] = fn diff --git a/setup.py b/setup.py index 15f92790..366f7d5f 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os from distutils.core import setup -from pysollib.settings import FC_VERSION as VERSION +from pysollib.settings import VERSION from pysollib.settings import PACKAGE_URL if os.name == 'nt': import py2exe