mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Add option to replay a specific game/deal from the log
This commit is contained in:
parent
a0ea7a3870
commit
792fbca78a
2 changed files with 49 additions and 16 deletions
|
@ -606,6 +606,7 @@ class PysolMenubar(PysolMenubarTk):
|
||||||
mode = kw.get("mode", 101)
|
mode = kw.get("mode", 101)
|
||||||
demo = 0
|
demo = 0
|
||||||
gameid = None
|
gameid = None
|
||||||
|
gamenum = None
|
||||||
while mode > 0:
|
while mode > 0:
|
||||||
if mode > 1000:
|
if mode > 1000:
|
||||||
demo = not demo
|
demo = not demo
|
||||||
|
@ -640,10 +641,14 @@ class PysolMenubar(PysolMenubarTk):
|
||||||
header = (_("%(app)s Demo Full log") if demo
|
header = (_("%(app)s Demo Full log") if demo
|
||||||
else _("Full log for %(player)s")) % transkw
|
else _("Full log for %(player)s")) % transkw
|
||||||
d = FullLog_StatsDialog(self.top, header, self.app, player)
|
d = FullLog_StatsDialog(self.top, header, self.app, player)
|
||||||
|
gameid = d.selected_game
|
||||||
|
gamenum = d.selected_game_num
|
||||||
elif mode == 104:
|
elif mode == 104:
|
||||||
header = (_("%(app)s Demo Session log") if demo
|
header = (_("%(app)s Demo Session log") if demo
|
||||||
else _("Session log for %(player)s")) % transkw
|
else _("Session log for %(player)s")) % transkw
|
||||||
d = SessionLog_StatsDialog(self.top, header, self.app, player)
|
d = SessionLog_StatsDialog(self.top, header, self.app, player)
|
||||||
|
gameid = d.selected_game
|
||||||
|
gamenum = d.selected_game_num
|
||||||
elif mode == 105:
|
elif mode == 105:
|
||||||
# TRANSLATORS: eg. top 10 or top 5 results for a certain game
|
# TRANSLATORS: eg. top 10 or top 5 results for a certain game
|
||||||
header = (_("%(app)s Demo Top %(tops)d for %(game)s") if demo
|
header = (_("%(app)s Demo Top %(tops)d for %(game)s") if demo
|
||||||
|
@ -698,8 +703,12 @@ class PysolMenubar(PysolMenubarTk):
|
||||||
self.game.quitGame(gameid)
|
self.game.quitGame(gameid)
|
||||||
elif mode == 402:
|
elif mode == 402:
|
||||||
# start a new game with a gameid / gamenumber
|
# start a new game with a gameid / gamenumber
|
||||||
# TODO
|
if (gameid and gamenum and
|
||||||
pass
|
(gameid != self.game.id or
|
||||||
|
gamenum != self.game.getGameNumber(format=0))):
|
||||||
|
self.game.endGame()
|
||||||
|
self.game.quitGame(gameid,
|
||||||
|
random=construct_random(gamenum))
|
||||||
else:
|
else:
|
||||||
print_err("stats problem: %s %s %s" % (mode, demo, player))
|
print_err("stats problem: %s %s %s" % (mode, demo, player))
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -383,6 +383,7 @@ class TreeFormatter(PysolStatsFormatter):
|
||||||
t1, t2, t3, t4, t5, t6 = result
|
t1, t2, t3, t4, t5, t6 = result
|
||||||
id = self.tree.insert("", "end", text=t1, values=(t2, t3, t4))
|
id = self.tree.insert("", "end", text=t1, values=(t2, t3, t4))
|
||||||
self.parent_window.tree_items.append(id)
|
self.parent_window.tree_items.append(id)
|
||||||
|
self.parent_window.games[id] = (t6, t2)
|
||||||
num_rows += 1
|
num_rows += 1
|
||||||
if num_rows > self.MAX_ROWS:
|
if num_rows > self.MAX_ROWS:
|
||||||
break
|
break
|
||||||
|
@ -512,7 +513,8 @@ class LogDialog(MfxDialog):
|
||||||
title = _('Log')
|
title = _('Log')
|
||||||
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
|
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
|
||||||
|
|
||||||
# self.selected_game = None
|
self.selected_game = None
|
||||||
|
self.selected_game_num = None
|
||||||
|
|
||||||
top_frame, bottom_frame = self.createFrames(kw)
|
top_frame, bottom_frame = self.createFrames(kw)
|
||||||
notebook = ttk.Notebook(top_frame)
|
notebook = ttk.Notebook(top_frame)
|
||||||
|
@ -522,24 +524,40 @@ class LogDialog(MfxDialog):
|
||||||
|
|
||||||
full_frame = FullLogFrame(self, notebook, app, player)
|
full_frame = FullLogFrame(self, notebook, app, player)
|
||||||
notebook.add(full_frame, text=_('Full log'))
|
notebook.add(full_frame, text=_('Full log'))
|
||||||
|
self.full_log_frame = full_frame
|
||||||
self.notebook_tabs.append(full_frame._w)
|
self.notebook_tabs.append(full_frame._w)
|
||||||
|
|
||||||
session_frame = SessionLogFrame(self, notebook, app, player)
|
session_frame = SessionLogFrame(self, notebook, app, player)
|
||||||
notebook.add(session_frame, text=_('Session log'))
|
notebook.add(session_frame, text=_('Session log'))
|
||||||
|
self.session_log_frame = session_frame
|
||||||
self.notebook_tabs.append(session_frame._w)
|
self.notebook_tabs.append(session_frame._w)
|
||||||
|
|
||||||
notebook.select(LogDialog.SELECTED_TAB)
|
notebook.select(LogDialog.SELECTED_TAB)
|
||||||
# bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)
|
bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)
|
||||||
|
|
||||||
self.notebook = notebook
|
self.notebook = notebook
|
||||||
|
|
||||||
focus = self.createButtons(bottom_frame, kw)
|
focus = self.createButtons(bottom_frame, kw)
|
||||||
# self.tabChanged() # configure buttons state
|
self.tabChanged() # configure buttons state
|
||||||
self.mainloop(focus, kw.timeout)
|
self.mainloop(focus, kw.timeout)
|
||||||
|
|
||||||
|
def tabChanged(self, *args):
|
||||||
|
w = self.notebook.select()
|
||||||
|
run_button = self.buttons[0]
|
||||||
|
indx = self.notebook_tabs.index(w)
|
||||||
|
if indx == 0:
|
||||||
|
g = self.full_log_frame.getSelectedGame()
|
||||||
|
else:
|
||||||
|
g = self.session_log_frame.getSelectedGame()
|
||||||
|
if g[0] is None:
|
||||||
|
run_button.config(state='disabled')
|
||||||
|
else:
|
||||||
|
run_button.config(state='normal')
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(kw,
|
||||||
strings=(_("&OK"),
|
strings=((_("&Play this game"), 402),
|
||||||
|
"sep", _("&OK"),
|
||||||
(_("&Save to file"), 500)),
|
(_("&Save to file"), 500)),
|
||||||
default=0,
|
default=0,
|
||||||
width=76*self.CHAR_W,
|
width=76*self.CHAR_W,
|
||||||
|
@ -548,16 +566,17 @@ class LogDialog(MfxDialog):
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
|
||||||
def mDone(self, button):
|
def mDone(self, button):
|
||||||
# self.selected_game = self.all_games_frame.getSelectedGame()
|
|
||||||
w = self.notebook.select()
|
w = self.notebook.select()
|
||||||
indx = self.notebook_tabs.index(w)
|
indx = self.notebook_tabs.index(w)
|
||||||
LogDialog.SELECTED_TAB = indx
|
LogDialog.SELECTED_TAB = indx
|
||||||
if button == 500: # "Save to file"
|
if indx == 0:
|
||||||
assert indx in (0, 1)
|
self.selected_game, self.selected_game_num \
|
||||||
if indx == 0: # "Full log"
|
= self.full_log_frame.getSelectedGame()
|
||||||
button = 203
|
else:
|
||||||
else: # "Session log"
|
self.selected_game, self.selected_game_num \
|
||||||
button = 204
|
= self.session_log_frame.getSelectedGame()
|
||||||
|
|
||||||
MfxDialog.mDone(self, button)
|
MfxDialog.mDone(self, button)
|
||||||
|
|
||||||
|
|
||||||
|
@ -576,6 +595,7 @@ class FullLogFrame(AllGamesFrame):
|
||||||
AllGamesFrame.__init__(self, dialog, parent, app, player, **kw)
|
AllGamesFrame.__init__(self, dialog, parent, app, player, **kw)
|
||||||
header = ('', '99999999999999999999', '9999-99-99 99:99',
|
header = ('', '99999999999999999999', '9999-99-99 99:99',
|
||||||
'XXXXXXXXXXXX')
|
'XXXXXXXXXXXX')
|
||||||
|
self.games = {}
|
||||||
self.formatter.resizeHeader(player, header)
|
self.formatter.resizeHeader(player, header)
|
||||||
|
|
||||||
def createHeader(self, player):
|
def createHeader(self, player):
|
||||||
|
@ -587,12 +607,16 @@ class FullLogFrame(AllGamesFrame):
|
||||||
return
|
return
|
||||||
self.formatter.writeFullLog(player)
|
self.formatter.writeFullLog(player)
|
||||||
|
|
||||||
def treeviewSelected(self, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def headerClick(self, column):
|
def headerClick(self, column):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def getSelectedGame(self):
|
||||||
|
sel = self.tree.selection()
|
||||||
|
if sel and len(sel) == 1:
|
||||||
|
if sel[0] in self.games:
|
||||||
|
return self.games[sel[0]]
|
||||||
|
return (None, None)
|
||||||
|
|
||||||
|
|
||||||
class SessionLogFrame(FullLogFrame):
|
class SessionLogFrame(FullLogFrame):
|
||||||
def fillTreeview(self, player):
|
def fillTreeview(self, player):
|
||||||
|
|
Loading…
Add table
Reference in a new issue