def runGame(self, id_, random=None): self.top.connectApp(self) # create game instance g = self.getGameClass(id_) if g is None: id_ = 2 # start Klondike as default game random = None g = self.getGameClass(id_) if g is None: # start first available game id_ = self.gdb.getGamesIdSortedByName()[0] g = self.getGameClass(id_) gi = self.getGameInfo(id_) assert gi is not None and gi.id == id_ self.game = self.constructGame(id_) self.gdb.setSelected(id_) self.game.busy = 1 # create stacks and layout self.game.create(self) # connect with game self.menubar.connectGame(self.game) if self.toolbar: # ~ self.toolbar.connectGame(self.game) self.game.updateStatus(player=self.opt.player) # update "Recent games" menubar entry if id_ in self.opt.recent_gameid: self.opt.recent_gameid.remove(id_) self.opt.recent_gameid.insert(0, id_) del self.opt.recent_gameid[self.opt.num_recent_games:] self.menubar.updateRecentGamesMenu(self.opt.recent_gameid) self.menubar.updateFavoriteGamesMenu() # hide/show "Shuffle" button self.toolbar.config( 'shuffle', self.opt.toolbar_vars['shuffle'] and self.game.canShuffle()) # delete intro progress bar if self.intro.progress: self.intro.progress.destroy() destruct(self.intro.progress) self.intro.progress = None # prepare game autoplay = 0 if self.nextgame.loadedgame is not None: self.stats.gameid_balance = 0 self.game.restoreGame(self.nextgame.loadedgame) destruct(self.nextgame.loadedgame) elif self.nextgame.bookmark is not None: self.game.restoreGameFromBookmark(self.nextgame.bookmark) else: self.stats.gameid_balance = 0 self.game.newGame(random=random, autoplay=0) autoplay = 1 self.nextgame.loadedgame = None self.nextgame.bookmark = None # splash screen if self.opt.splashscreen and self.splashscreen > 0: status = help_about(self, timeout=20000, sound=0) if status == 2: # timeout - start a demo if autoplay: self.nextgame.startdemo = 1 self.splashscreen = 0 # start demo/autoplay if self.nextgame.startdemo: self.nextgame.startdemo = 0 self.game.startDemo() self.game.createDemoInfoText() elif autoplay: self.game.autoPlay() self.game.stats.player_moves = 0 # enter the Tk mainloop self.game.busy = 0 self.top.mainloop()
def mHelpAbout(self, *args): if self._cancelDrag(break_pause=False): return help_about(self.app)
def mHelpAbout(self, *args): if self._cancelDrag(break_pause=False): return help_about(self.app)