Skip to content

Commit bf16de6

Browse files
committed
Remove undo/redo from graphical interface.
Undo and redo facility was not fully implemented and had unpredictable behaviour. Closes #505.
1 parent f91c054 commit bf16de6

File tree

6 files changed

+7
-121
lines changed

6 files changed

+7
-121
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
terminal Nash profile correctly. (#172)
88
- Improved sizing of list of logit profiles computed for normal form games.
99

10+
### Removed
11+
- Undo and redo have been removed from the graphical interface. (These were meant to be
12+
removed previously as they did not work properly and gave unpredictable behaviour.) (#505)
13+
1014

1115
## [16.3.1] - 2025-08-18
1216

src/gui/efgdisplay.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,6 @@ gbtEfgDisplay::gbtEfgDisplay(wxWindow *p_parent, gbtGameDocument *p_doc)
335335
void gbtEfgDisplay::MakeMenus()
336336
{
337337
m_nodeMenu = new wxMenu;
338-
339-
m_nodeMenu->Append(wxID_UNDO, _("&Undo\tCtrl-Z"), _("Undo the last change"));
340-
m_nodeMenu->Append(wxID_REDO, _("&Redo\tCtrl-Y"), _("Redo the last undone change"));
341-
m_nodeMenu->AppendSeparator();
342-
343338
m_nodeMenu->Append(GBT_MENU_EDIT_INSERT_MOVE, _("&Insert move"), _("Insert a move"));
344339
m_nodeMenu->Append(GBT_MENU_EDIT_INSERT_ACTION, _("Insert &action"),
345340
_("Insert an action at the current move"));
@@ -590,8 +585,6 @@ void gbtEfgDisplay::OnUpdate()
590585

591586
Gambit::GameNode selectNode = m_doc->GetSelectNode();
592587

593-
m_nodeMenu->Enable(wxID_UNDO, m_doc->CanUndo());
594-
m_nodeMenu->Enable(wxID_REDO, m_doc->CanRedo());
595588
m_nodeMenu->Enable(GBT_MENU_EDIT_INSERT_MOVE, selectNode);
596589
m_nodeMenu->Enable(GBT_MENU_EDIT_INSERT_ACTION, selectNode && selectNode->GetInfoset());
597590
m_nodeMenu->Enable(GBT_MENU_EDIT_REVEAL, selectNode && selectNode->GetInfoset());

src/gui/gamedoc.cc

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ gbtGameDocument::gbtGameDocument(Gambit::Game p_game)
184184

185185
std::ostringstream s;
186186
SaveDocument(s);
187-
m_undoList.push_back(s.str());
188187
}
189188

190189
gbtGameDocument::~gbtGameDocument() { wxGetApp().RemoveDocument(this); }
@@ -300,7 +299,6 @@ bool gbtGameDocument::LoadDocument(const wxString &p_filename, bool p_saveUndo)
300299
if (p_saveUndo) {
301300
std::ostringstream s;
302301
SaveDocument(s);
303-
m_undoList.push_back(s.str());
304302
}
305303

306304
return true;
@@ -348,11 +346,8 @@ void gbtGameDocument::UpdateViews(gbtGameModificationType p_modifications)
348346
{
349347
if (p_modifications != GBT_DOC_MODIFIED_NONE) {
350348
m_modified = true;
351-
m_redoList = std::list<std::string>();
352-
353349
std::ostringstream s;
354350
SaveDocument(s);
355-
m_undoList.push_back(s.str());
356351
}
357352

358353
if (p_modifications == GBT_DOC_MODIFIED_GAME || p_modifications == GBT_DOC_MODIFIED_PAYOFFS) {
@@ -395,65 +390,6 @@ void gbtGameDocument::SetStyle(const gbtStyle &p_style)
395390
UpdateViews(GBT_DOC_MODIFIED_VIEWS);
396391
}
397392

398-
//
399-
// A word about the undo and redo features:
400-
// We store a list of the textual representation of games. We don't
401-
// store other aspects of the state (e.g., profiles) as yet.
402-
// The "undo" list includes the representation of the current state
403-
// of the game (hence, CanUndo() only returns true when the list has
404-
// more than one element.
405-
//
406-
void gbtGameDocument::Undo()
407-
{
408-
// The current game is at the end of the undo list; move it to the redo list
409-
m_redoList.push_back(m_undoList.back());
410-
m_undoList.pop_back();
411-
412-
m_game = nullptr;
413-
414-
while (!m_profiles.empty()) {
415-
delete m_profiles.back();
416-
m_profiles.pop_back();
417-
}
418-
m_currentProfileList = 0;
419-
420-
wxString tempfile = wxFileName::CreateTempFileName(wxT("gambit"));
421-
std::ofstream f((const char *)tempfile.mb_str());
422-
f << m_undoList.back() << std::endl;
423-
f.close();
424-
425-
LoadDocument(tempfile, false);
426-
wxRemoveFile(tempfile);
427-
428-
for (int i = 1; i <= m_views.size(); m_views[i++]->OnUpdate())
429-
;
430-
}
431-
432-
void gbtGameDocument::Redo()
433-
{
434-
m_undoList.push_back(m_redoList.back());
435-
m_redoList.pop_back();
436-
437-
m_game = nullptr;
438-
439-
while (!m_profiles.empty()) {
440-
delete m_profiles.back();
441-
m_profiles.pop_back();
442-
}
443-
m_currentProfileList = 0;
444-
445-
wxString tempfile = wxFileName::CreateTempFileName(wxT("gambit"));
446-
std::ofstream f((const char *)tempfile.mb_str());
447-
f << m_undoList.back() << std::endl;
448-
f.close();
449-
450-
LoadDocument(tempfile, false);
451-
wxRemoveFile(tempfile);
452-
453-
for (int i = 1; i <= m_views.size(); m_views[i++]->OnUpdate())
454-
;
455-
}
456-
457393
void gbtGameDocument::SetCurrentProfile(int p_profile)
458394
{
459395
m_profiles[m_currentProfileList]->SetCurrent(p_profile);

src/gui/gamedoc.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ class gbtGameDocument {
235235
Gambit::Array<gbtAnalysisOutput *> m_profiles;
236236
int m_currentProfileList;
237237

238-
std::list<std::string> m_undoList, m_redoList;
239-
240238
void UpdateViews(gbtGameModificationType p_modifications);
241239

242240
public:
@@ -269,17 +267,6 @@ class gbtGameDocument {
269267
bool IsConstSum() const { return m_game->IsConstSum(); }
270268
bool IsTree() const { return m_game->IsTree(); }
271269

272-
//!
273-
//! @name Handling of undo/redo features
274-
//!
275-
//@{
276-
bool CanUndo() const { return (m_undoList.size() > 1); }
277-
void Undo();
278-
279-
bool CanRedo() const { return (m_redoList.size() > 0); }
280-
void Redo();
281-
//@}
282-
283270
//!
284271
//! @name Handling of list of computed profiles
285272
//!

src/gui/gameframe.cc

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ EVT_MENU(wxID_PREVIEW, gbtGameFrame::OnFilePrintPreview)
198198
EVT_MENU(wxID_PRINT, gbtGameFrame::OnFilePrint)
199199
EVT_MENU(wxID_EXIT, gbtGameFrame::OnFileExit)
200200
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, gbtGameFrame::OnFileMRUFile)
201-
EVT_MENU(wxID_UNDO, gbtGameFrame::OnEditUndo)
202-
EVT_MENU(wxID_REDO, gbtGameFrame::OnEditRedo)
203201
EVT_MENU(GBT_MENU_EDIT_INSERT_MOVE, gbtGameFrame::OnEditInsertMove)
204202
EVT_MENU(GBT_MENU_EDIT_INSERT_ACTION, gbtGameFrame::OnEditInsertAction)
205203
EVT_MENU(GBT_MENU_EDIT_DELETE_TREE, gbtGameFrame::OnEditDeleteTree)
@@ -246,19 +244,15 @@ gbtGameFrame::gbtGameFrame(wxWindow *p_parent, gbtGameDocument *p_doc)
246244
MakeMenus();
247245
MakeToolbar();
248246

249-
wxAcceleratorEntry entries[10];
247+
wxAcceleratorEntry entries[8];
250248
entries[0].Set(wxACCEL_CTRL, (int)'o', wxID_OPEN);
251249
entries[1].Set(wxACCEL_CTRL, (int)'s', wxID_SAVE);
252250
entries[2].Set(wxACCEL_CTRL | wxACCEL_SHIFT, (int)'s', wxID_SAVEAS);
253251
entries[3].Set(wxACCEL_CTRL, (int)'p', wxID_PRINT);
254252
entries[4].Set(wxACCEL_CTRL, (int)'w', wxID_CLOSE);
255253
entries[5].Set(wxACCEL_CTRL, (int)'x', wxID_EXIT);
256-
entries[6].Set(wxACCEL_CTRL, (int)'z', wxID_UNDO);
257-
entries[7].Set(wxACCEL_CTRL, (int)'y', wxID_REDO);
258-
// entries[8].Set(wxACCEL_NORMAL, WXK_DELETE, GBT_MENU_EDIT_DELETE_TREE);
259-
// entries[9].Set(wxACCEL_NORMAL, WXK_BACK, GBT_MENU_EDIT_DELETE_PARENT);
260-
entries[8].Set(wxACCEL_CTRL, (int)'+', GBT_MENU_VIEW_ZOOMIN);
261-
entries[9].Set(wxACCEL_CTRL, (int)'-', GBT_MENU_VIEW_ZOOMOUT);
254+
entries[6].Set(wxACCEL_CTRL, (int)'+', GBT_MENU_VIEW_ZOOMIN);
255+
entries[7].Set(wxACCEL_CTRL, (int)'-', GBT_MENU_VIEW_ZOOMOUT);
262256
wxAcceleratorTable accel(10, entries);
263257
SetAcceleratorTable(accel);
264258

@@ -325,10 +319,6 @@ void gbtGameFrame::OnUpdate()
325319

326320
menuBar->Enable(GBT_MENU_FILE_EXPORT_EFG, m_doc->IsTree());
327321

328-
menuBar->Enable(wxID_UNDO, m_doc->CanUndo());
329-
GetToolBar()->EnableTool(wxID_UNDO, m_doc->CanUndo());
330-
menuBar->Enable(wxID_REDO, m_doc->CanRedo());
331-
GetToolBar()->EnableTool(wxID_REDO, m_doc->CanRedo());
332322
menuBar->Enable(GBT_MENU_EDIT_INSERT_MOVE, selectNode != nullptr);
333323
menuBar->Enable(GBT_MENU_EDIT_INSERT_ACTION, selectNode && selectNode->GetInfoset());
334324
menuBar->Enable(GBT_MENU_EDIT_REVEAL, selectNode && selectNode->GetInfoset());
@@ -456,13 +446,6 @@ void gbtGameFrame::MakeMenus()
456446
AppendBitmapItem(fileMenu, wxID_EXIT, _("E&xit\tCtrl-Q"), _("Exit Gambit"), wxBitmap(exit_xpm));
457447

458448
auto *editMenu = new wxMenu;
459-
460-
AppendBitmapItem(editMenu, wxID_UNDO, _("&Undo\tCtrl-Z"), _("Undo the last change"),
461-
wxBitmap(undo_xpm));
462-
AppendBitmapItem(editMenu, wxID_REDO, _("&Redo\tCtrl-Y"), _("Redo the last undone change"),
463-
wxBitmap(redo_xpm));
464-
465-
editMenu->AppendSeparator();
466449
AppendBitmapItem(editMenu, GBT_MENU_EDIT_NEWPLAYER, _("Add p&layer"),
467450
_("Add a new player to the game"), wxBitmap(newplayer_xpm));
468451

@@ -931,20 +914,6 @@ void gbtGameFrame::OnFileMRUFile(wxCommandEvent &p_event)
931914
// gbtGameFrame: Menu handlers - Edit menu
932915
//----------------------------------------------------------------------
933916

934-
void gbtGameFrame::OnEditUndo(wxCommandEvent &)
935-
{
936-
if (m_doc->CanUndo()) {
937-
m_doc->Undo();
938-
}
939-
}
940-
941-
void gbtGameFrame::OnEditRedo(wxCommandEvent &)
942-
{
943-
if (m_doc->CanRedo()) {
944-
m_doc->Redo();
945-
}
946-
}
947-
948917
void gbtGameFrame::OnEditInsertMove(wxCommandEvent &)
949918
{
950919
gbtInsertMoveDialog dialog(this, m_doc);

src/gui/gameframe.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ class gbtGameFrame : public wxFrame, public gbtGameView {
6868
void OnFileExit(wxCommandEvent &);
6969
void OnFileMRUFile(wxCommandEvent &);
7070

71-
void OnEditUndo(wxCommandEvent &);
72-
void OnEditRedo(wxCommandEvent &);
73-
7471
void OnEditInsertMove(wxCommandEvent &);
7572
void OnEditInsertAction(wxCommandEvent &);
7673
void OnEditDeleteTree(wxCommandEvent &);

0 commit comments

Comments
 (0)