diff --git a/resources/settings.yaml b/resources/settings.yaml index 68b3359b..e9e41c26 100644 --- a/resources/settings.yaml +++ b/resources/settings.yaml @@ -11,7 +11,6 @@ View Report Externally: false Masterlist URLs: Oblivion: http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-oblivion/masterlist.yaml - Nehrim: http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-nehrim/masterlist.yaml Skyrim: http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-skyrim/masterlist.yaml Fallout 3: http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-fallout/masterlist.yaml Fallout New Vegas: http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-fallout-nv/masterlist.yaml diff --git a/src/game.cpp b/src/game.cpp index bb7e6555..696ef447 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -27,16 +27,8 @@ #include "error.h" #include "metadata.h" - -#include - #include -#if _WIN32 || _WIN64 -# include -# include -#endif - using namespace std; namespace fs = boost::filesystem; @@ -91,7 +83,7 @@ namespace boss { } } - Game::Game() {} + Game::Game() : id(0), isTC(false) {} Game::Game(const unsigned int gameCode) : id(gameCode), isTC(false) { @@ -100,28 +92,28 @@ namespace boss { _name = "TES IV: Oblivion"; registryKey = "Software\\Bethesda Softworks\\Oblivion"; registrySubKey = "Installed Path"; - bossFolderName = "oblivion"; + bossFolderName = "Oblivion"; _masterFile = "Oblivion.esm"; libespmGame = "Oblivion"; } else if (Id() == GAME_TES5) { _name = "TES V: Skyrim"; registryKey = "Software\\Bethesda Softworks\\Skyrim"; registrySubKey = "Installed Path"; - bossFolderName = "skyrim"; + bossFolderName = "Skyrim"; _masterFile = "Skyrim.esm"; libespmGame = "Skyrim"; } else if (Id() == GAME_FO3) { _name = "Fallout 3"; registryKey = "Software\\Bethesda Softworks\\Fallout3"; registrySubKey = "Installed Path"; - bossFolderName = "fallout3"; + bossFolderName = "Fallout3"; _masterFile = "Fallout3.esm"; libespmGame = "Skyrim"; } else if (Id() == GAME_FONV) { _name = "Fallout: New Vegas"; registryKey = "Software\\Bethesda Softworks\\FalloutNV"; registrySubKey = "Installed Path"; - bossFolderName = "falloutnv"; + bossFolderName = "FalloutNV"; _masterFile = "FalloutNV.esm"; libespmGame = "Skyrim"; } else @@ -172,8 +164,7 @@ namespace boss { bool Game::operator == (const Game& rhs) const { return (id == rhs.Id() && _name == rhs.Name() - && bossFolderName == rhs.FolderName() - && gamePath == rhs.GamePath()); + && bossFolderName == rhs.FolderName()); } unsigned int Game::Id() const { diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index 9c5e2d02..4657bb4e 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -64,7 +64,7 @@ wxString State[2] = { translate("Remove") }; -Editor::Editor(wxWindow *parent, const wxString& title, const boss::Game& game, const std::vector& basePlugins, std::vector& editedPlugins) : wxFrame(parent, wxID_ANY, title), _game(game), _basePlugins(basePlugins), _editedPlugins(editedPlugins) { +Editor::Editor(wxWindow *parent, const wxString& title, const char * userlistPath, const std::vector& basePlugins, std::vector& editedPlugins) : wxFrame(parent, wxID_ANY, title), _userlistPath(userlistPath), _basePlugins(basePlugins), _editedPlugins(editedPlugins) { //Initialise child windows. listBook = new wxNotebook(this, BOOK_Lists); @@ -634,7 +634,7 @@ void Editor::OnQuit(wxCommandEvent& event) { << YAML::Key << "plugins" << YAML::Value << _editedPlugins << YAML::EndMap; - ofstream out(_game.UserlistPath().string().c_str()); + ofstream out(_userlistPath); out << yout.c_str(); out.close(); } diff --git a/src/gui/editor.h b/src/gui/editor.h index 5e0f42cf..c87617fe 100644 --- a/src/gui/editor.h +++ b/src/gui/editor.h @@ -34,7 +34,7 @@ class Editor : public wxFrame { public: - Editor(wxWindow *parent, const wxString& title, const boss::Game& game, const std::vector& basePlugins, std::vector& editedPlugins); + Editor(wxWindow *parent, const wxString& title, const char * userlistPath, const std::vector& basePlugins, std::vector& editedPlugins); void OnPluginSelect(wxListEvent& event); void OnEnabledToggle(wxCommandEvent& event); @@ -65,7 +65,7 @@ private: wxSpinCtrl * prioritySpin; wxStaticText * pluginText; - const boss::Game& _game; + const char * _userlistPath; const std::vector _basePlugins; std::vector _editedPlugins; diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 039779b6..ca75a2b8 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -167,10 +167,10 @@ bool BossGUI::OnInit() { if (!target.empty()) { for (size_t i=0, max=_detectedGames.size(); i < max; ++i) { - if (boost::iequals(target, _detectedGames[i].Name())) + if (boost::iequals(target, _detectedGames[i].FolderName())) _game = _detectedGames[i]; } - if (_game.Id() == GAME_AUTODETECT) + if (_game == Game()) _game = _detectedGames[0]; } else _game = _detectedGames[0]; @@ -188,7 +188,7 @@ bool BossGUI::OnInit() { return true; } -Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, const vector& detectedGames, const vector& undetectedGames) : wxFrame(NULL, wxID_ANY, title), _game(game), _settings(settings), _detectedGames(detectedGames) { +Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, const vector& detectedGames, const vector& undetectedGames) : wxFrame(NULL, wxID_ANY, title), _game(game), _settings(settings), _detectedGames(detectedGames), _undetectedGames(undetectedGames) { //Initialise menu items. wxMenuBar * MenuBar = new wxMenuBar(); @@ -220,7 +220,6 @@ Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, const item->Check(); Bind(wxEVT_COMMAND_MENU_SELECTED, &Launcher::OnGameChange, this, MENU_LowestDynamicGameID + i); } - GameMenu->AppendSeparator(); for (size_t i=0,max=undetectedGames.size(); i < max; ++i) { GameMenu->AppendRadioItem(wxID_ANY, FromUTF8(undetectedGames[i].Name()))->Enable(false); } @@ -248,6 +247,7 @@ Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, const Bind(wxEVT_COMMAND_BUTTON_CLICKED, &Launcher::OnSortPlugins, this, OPTION_SortPlugins); Bind(wxEVT_COMMAND_BUTTON_CLICKED, &Launcher::OnEditMetadata, this, OPTION_EditMetadata); Bind(wxEVT_COMMAND_BUTTON_CLICKED, &Launcher::OnViewLastReport, this, OPTION_ViewLastReport); + Bind(wxEVT_CLOSE_WINDOW, &Launcher::OnClose, this); //Set up initial state. SortButton->SetDefault(); @@ -267,6 +267,15 @@ Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, const //Called when the frame exits. void Launcher::OnQuit(wxCommandEvent& event) { + + Close(true); // Tells the OS to quit running this process +} + +void Launcher::OnClose(wxCloseEvent& event) { + + + _settings["Last Game"] = _game.FolderName(); + //Save settings. YAML::Emitter yout; yout.SetIndent(2); @@ -275,8 +284,8 @@ void Launcher::OnQuit(wxCommandEvent& event) { ofstream out(boss::settings_path.string().c_str()); out << yout.c_str(); out.close(); - - Close(true); // Tells the OS to quit running this process + + Destroy(); } void Launcher::OnSortPlugins(wxCommandEvent& event) { @@ -520,7 +529,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { wxLaunchDefaultApplication(_game.ReportPath().string()); } else { //Create viewer window. - Viewer *viewer = new Viewer(this, translate("BOSS: Report Viewer"), _game); + Viewer *viewer = new Viewer(this, translate("BOSS: Report Viewer"), _game.ReportPath().string()); viewer->Show(); } } @@ -605,7 +614,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { progDia->Pulse(); //Create editor window. - Editor *editor = new Editor(this, translate("BOSS: Metadata Editor"), _game, installed, ulist_plugins); + Editor *editor = new Editor(this, translate("BOSS: Metadata Editor"), _game.UserlistPath().string().c_str(), installed, ulist_plugins); progDia->Destroy(); @@ -617,13 +626,15 @@ void Launcher::OnViewLastReport(wxCommandEvent& event) { wxLaunchDefaultApplication(_game.ReportPath().string()); } else { //Create viewer window. - Viewer *viewer = new Viewer(this, translate("BOSS: Report Viewer"), _game); + Viewer *viewer = new Viewer(this, translate("BOSS: Report Viewer"), _game.ReportPath().string()); viewer->Show(); } } void Launcher::OnOpenSettings(wxCommandEvent& event) { - SettingsFrame *settings = new SettingsFrame(this, translate("BOSS: Settings"), _settings); + vector games = _detectedGames; + games.insert(games.end(), _undetectedGames.begin(), _undetectedGames.end()); + SettingsFrame *settings = new SettingsFrame(this, translate("BOSS: Settings"), _settings, games); settings->ShowModal(); } diff --git a/src/gui/main.h b/src/gui/main.h index aecf6b4c..c317fd52 100644 --- a/src/gui/main.h +++ b/src/gui/main.h @@ -55,6 +55,8 @@ public: void OnHelp(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); + + void OnClose(wxCloseEvent& event); private: wxMenu * GameMenu; wxButton * ViewButton; @@ -62,6 +64,7 @@ private: boss::Game& _game; YAML::Node& _settings; //BOSS Settings. const std::vector& _detectedGames; + const std::vector& _undetectedGames; static bool AlphaSortPlugins(const boss::Plugin& lhs, const boss::Plugin& rhs); }; diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 65062938..1e20bf68 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -24,6 +24,7 @@ #include "settings.h" #include "../globals.h" #include +#include BEGIN_EVENT_TABLE ( SettingsFrame, wxDialog ) EVT_BUTTON ( wxID_OK, SettingsFrame::OnQuit) @@ -31,7 +32,7 @@ END_EVENT_TABLE() using namespace std; -SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), _settings(settings) { +SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, const std::vector& games) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), _settings(settings), _games(games) { //Initialise drop-down list contents. wxString DebugVerbosity[] = { @@ -41,13 +42,11 @@ SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node translate("High") }; - wxString Game[] = { - translate("Autodetect"), - wxT("Oblivion"), - wxT("Skyrim"), - wxT("Fallout 3"), - wxT("Fallout: New Vegas"), - }; + wxArrayString Games; + Games.Add(translate("Autodetect")); + for (size_t i=0,max=_games.size(); i < max; ++i) { + Games.Add(FromUTF8(_games[i].Name())); + } wxString Language[] = { wxT("English"), @@ -58,7 +57,7 @@ SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node }; //Initialise controls. - GameChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 5, Game); + GameChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Games); LanguageChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 1, Language); DebugVerbosityChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, DebugVerbosity); @@ -148,16 +147,14 @@ void SettingsFrame::SetDefaultValues() { if (_settings["Game"]) { string game = _settings["Game"].as(); - if (game == "auto") + if (boost::iequals(game, "auto")) GameChoice->SetSelection(0); - else if (game == "oblivion") - GameChoice->SetSelection(1); - else if (game == "skyrim") - GameChoice->SetSelection(2); - else if (game == "fallout3") - GameChoice->SetSelection(3); - else if (game == "falloutnv") - GameChoice->SetSelection(4); + else { + for (size_t i=0,max=_games.size(); i < max; ++i) { + if (boost::iequals(game, _games[i].FolderName())) + GameChoice->SetSelection(i+1); + } + } } if (_settings["Debug Verbosity"]) { @@ -195,23 +192,10 @@ void SettingsFrame::SetDefaultValues() { void SettingsFrame::OnQuit(wxCommandEvent& event) { if (event.GetId() == wxID_OK) { - switch (GameChoice->GetSelection()) { - case 0: + if (GameChoice->GetSelection() == 0) _settings["Game"] = "auto"; - break; - case 1: - _settings["Game"] = "oblivion"; - break; - case 2: - _settings["Game"] = "skyrim"; - break; - case 3: - _settings["Game"] = "fallout3"; - break; - case 4: - _settings["Game"] = "falloutnv"; - break; - } + else + _settings["Game"] = _games[GameChoice->GetSelection() - 1].FolderName(); switch (LanguageChoice->GetSelection()) { case 0: @@ -232,14 +216,6 @@ void SettingsFrame::OnQuit(wxCommandEvent& event) { _settings["Masterlist URLs"]["Fallout 3"] = string(FO3URL->GetValue().ToUTF8()); _settings["Masterlist URLs"]["Fallout New Vegas"] = string(FONVURL->GetValue().ToUTF8()); - - YAML::Emitter yout; - yout.SetIndent(2); - yout << _settings; - - ofstream out(boss::settings_path.string().c_str()); - out << yout.c_str(); - out.close(); } EndModal(0); diff --git a/src/gui/settings.h b/src/gui/settings.h index a12c3699..b927e665 100644 --- a/src/gui/settings.h +++ b/src/gui/settings.h @@ -25,12 +25,14 @@ #define __BOSS_GUI_SETTINGS__ #include "ids.h" +#include "../game.h" + #include #include class SettingsFrame : public wxDialog { public: - SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings); + SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, const std::vector& games); void OnQuit(wxCommandEvent& event); void SetDefaultValues(); DECLARE_EVENT_TABLE() @@ -46,5 +48,6 @@ private: wxTextCtrl *FONVURL; YAML::Node& _settings; + std::vector _games; }; #endif diff --git a/src/gui/viewer.cpp b/src/gui/viewer.cpp index 91e9925b..d76137fe 100644 --- a/src/gui/viewer.cpp +++ b/src/gui/viewer.cpp @@ -28,11 +28,11 @@ namespace fs = boost::filesystem; -Viewer::Viewer(wxWindow *parent, const wxString& title, const boss::Game& game) : wxFrame(parent, wxID_ANY, title) { - if (!fs::exists(fs::absolute(game.ReportPath()))) - throw boss::error(ERROR_PATH_NOT_FOUND, "The path \"" + game.ReportPath().string() + "\" could not be found."); +Viewer::Viewer(wxWindow *parent, const wxString& title, const std::string& path) : wxFrame(parent, wxID_ANY, title) { + if (!fs::exists(fs::absolute(path))) + throw boss::error(ERROR_PATH_NOT_FOUND, "The path \"" + path + "\" could not be found."); - wxWebView * web = wxWebView::New(this, wxID_ANY, "file://" + fs::absolute(game.ReportPath()).string()); + wxWebView * web = wxWebView::New(this, wxID_ANY, "file://" + fs::absolute(path).string()); wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/viewer.h b/src/gui/viewer.h index cee84443..5eddffe6 100644 --- a/src/gui/viewer.h +++ b/src/gui/viewer.h @@ -29,7 +29,7 @@ class Viewer : public wxFrame { public: - Viewer(wxWindow *parent, const wxString& title, const boss::Game& game); + Viewer(wxWindow *parent, const wxString& title, const std::string& path); }; #endif