Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/games/gamebagg.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class GameBAGGRep : public GameRep {
/// @name General data access
//@{
bool IsTree() const override { return false; }
virtual bool IsBagg() const { return true; }
bool IsAgg() const override { return true; }
bool IsPerfectRecall() const override { return true; }
bool IsConstSum() const override { throw UndefinedException(); }
/// Returns the smallest payoff to any player in any outcome of the game
Expand Down
17 changes: 11 additions & 6 deletions src/gui/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ AppLoadResult Application::LoadFile(const wxString &p_filename, wxWindow *p_pare
if (!infile.good()) {
wxMessageBox(_("Gambit could not open file for reading:\n") + p_filename,
_("Unable to open file"), wxOK | wxICON_ERROR, p_parent);
return GBT_APP_OPEN_FAILED;
return AppLoadResult::OpenFailed;
}

auto *doc = new GameDocument(NewTree());
Expand All @@ -135,24 +135,29 @@ AppLoadResult Application::LoadFile(const wxString &p_filename, wxWindow *p_pare
m_fileHistory.AddFileToHistory(p_filename);
m_fileHistory.Save(*wxConfigBase::Get());
(void)new GameFrame(nullptr, doc);
return GBT_APP_FILE_OK;
return AppLoadResult::Success;
}
delete doc;

try {
const Game nfg = ReadGame(infile);
const Game game = ReadGame(infile);
if (game->IsAgg()) {
wxMessageBox(_("Action graph games are not currently supported by the graphical interface"),
_("Unsupported game representation"), wxOK | wxICON_ERROR, p_parent);
return AppLoadResult::UnsupportedRepresentation;
}

m_fileHistory.AddFileToHistory(p_filename);
m_fileHistory.Save(*wxConfigBase::Get());
doc = new GameDocument(nfg);
doc = new GameDocument(game);
doc->SetFilename(p_filename);
(void)new GameFrame(nullptr, doc);
return GBT_APP_FILE_OK;
return AppLoadResult::Success;
}
catch (InvalidFileException &) {
wxMessageBox(_("File is not in a format Gambit recognizes:\n") + p_filename,
_("Unable to read file"), wxOK | wxICON_ERROR, p_parent);
return GBT_APP_PARSE_FAILED;
return AppLoadResult::ParseFailed;
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/gui/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ namespace Gambit::GUI {

class GameDocument;

enum AppLoadResult { GBT_APP_FILE_OK = 0, GBT_APP_OPEN_FAILED = 1, GBT_APP_PARSE_FAILED = 2 };
enum class AppLoadResult : unsigned int {
Success = 0,
OpenFailed = 1,
ParseFailed = 2,
UnsupportedRepresentation = 3
};

class Application final : public wxApp {
wxString m_currentDir; /* Current position in directory tree. */
Expand Down
Loading