diff --git a/src/game.cpp b/src/game.cpp index 02886fde..a4fa6be6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -43,27 +43,19 @@ namespace fs = boost::filesystem; namespace boss { - void DetectGames(std::vector& detected, std::vector& undetected) { + std::vector DetectGames() { + vector detected; if (Game(GAME_TES4, false).IsInstalled()) //Look for Oblivion. detected.push_back(GAME_TES4); - else - undetected.push_back(GAME_TES4); if (Game(GAME_NEHRIM, false).IsInstalled()) //Look for Nehrim. detected.push_back(GAME_NEHRIM); - else - undetected.push_back(GAME_NEHRIM); if (Game(GAME_TES5, false).IsInstalled()) //Look for Skyrim. detected.push_back(GAME_TES5); - else - undetected.push_back(GAME_TES5); if (Game(GAME_FO3, false).IsInstalled()) //Look for Fallout 3. detected.push_back(GAME_FO3); - else - undetected.push_back(GAME_FO3); if (Game(GAME_FONV, false).IsInstalled()) //Look for Fallout New Vegas. detected.push_back(GAME_FONV); - else - undetected.push_back(GAME_FONV); + return detected; } Game::Game() {} diff --git a/src/game.h b/src/game.h index 29e8a531..347fb7d3 100644 --- a/src/game.h +++ b/src/game.h @@ -40,7 +40,7 @@ namespace boss { class Plugin; - void DetectGames(std::vector& detected, std::vector& undetected); + std::vector DetectGames(); class Game { public: diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index e0a00b99..69ae97ec 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -37,7 +37,7 @@ END_EVENT_TABLE() using namespace std; -Editor::Editor(const wxString title, wxFrame *parent) : wxFrame(parent, wxID_ANY, title) { +Editor::Editor(wxWindow *parent, const wxString& title) : wxFrame(parent, wxID_ANY, title) { //Initialise child windows. listBook = new wxNotebook(this, BOOK_Lists); @@ -156,6 +156,7 @@ Editor::Editor(const wxString title, wxFrame *parent) : wxFrame(parent, wxID_ANY bigBox->Add(mainBox, 2, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 10); SetBackgroundColour(wxColour(255,255,255)); + SetIcon(wxIconLocation("BOSS.exe")); SetSizerAndFit(bigBox); } @@ -349,3 +350,45 @@ void Editor::ApplyCurrentPluginEdits() { else _editedPlugins.push_back(diff); } + +FileEditDialog::FileEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title) { + +} + +void FileEditDialog::SetValues(const std::string& name, const std::string& display, const std::string& condition) { + +} + +std::vector FileEditDialog::GetValues() const { + vector values; + + return values; +} + +MessageEditDialog::MessageEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title) { + +} + +void MessageEditDialog::SetValues(const std::string& type, const std::string& content, const std::string& condition, const std::string& language) { + +} + +std::vector MessageEditDialog::GetValues() const { + vector values; + + return values; +} + +TagEditDialog::TagEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title) { + +} + +void TagEditDialog::SetValues(const std::string& addRemove, const std::string& name, const std::string& condition) { + +} + +std::vector TagEditDialog::GetValues() const { + vector values; + + return values; +} diff --git a/src/gui/editor.h b/src/gui/editor.h index 5d6a99fa..be9033cf 100644 --- a/src/gui/editor.h +++ b/src/gui/editor.h @@ -34,7 +34,7 @@ class Editor : public wxFrame { public: - Editor(const wxString title, wxFrame *parent); + Editor(wxWindow *parent, const wxString& title); void SetList(const std::vector& basePlugins, const std::vector& editedPlugins); void IsSorted(bool sorted); @@ -71,6 +71,46 @@ private: std::vector _basePlugins, _editedPlugins; boss::Plugin currentPlugin; + + //boss::Game& _game; + // YAML::Node& _settings; //BOSS Settings. +}; + +class FileEditDialog : public wxDialog { +public: + FileEditDialog(wxWindow *parent, const wxString& title); + + void SetValues(const std::string& name, const std::string& display, const std::string& condition); + std::vector GetValues() const; +private: + wxTextCtrl * _name; + wxTextCtrl * _display; + wxTextCtrl * _condition; +}; + +class MessageEditDialog : public wxDialog { +public: + MessageEditDialog(wxWindow *parent, const wxString& title); + + void SetValues(const std::string& type, const std::string& content, const std::string& condition, const std::string& language); + std::vector GetValues() const; +private: + wxChoice * _type; + wxTextCtrl * _content; + wxTextCtrl * _condition; + wxChoice * _language; +}; + +class TagEditDialog : public wxDialog { +public: + TagEditDialog(wxWindow *parent, const wxString& title); + + void SetValues(const std::string& addRemove, const std::string& name, const std::string& condition); + std::vector GetValues() const; +private: + wxChoice * _addRemove; + wxTextCtrl * _name; + wxTextCtrl * _condition; }; #endif diff --git a/src/gui/main.cpp b/src/gui/main.cpp index d72eb2ca..39f590aa 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -88,10 +88,9 @@ bool BossGUI::OnInit() { } //Load settings. - YAML::Node settings; if (fs::exists(settings_path)) { try { - settings = YAML::LoadFile(settings_path.string()); + _settings = YAML::LoadFile(settings_path.string()); } catch (YAML::ParserException& e) { //LOG_ERROR("Error: %s", e.getString().c_str()); wxMessageBox( @@ -115,10 +114,10 @@ bool BossGUI::OnInit() { gen.add_messages_domain("messages"); //Set the locale to get encoding and language conversions working correctly. - if (settings["Language"]) { + if (_settings["Language"]) { string localeId = ""; wxLanguage lang; - if (settings["Language"].as() == "eng") { + if (_settings["Language"].as() == "eng") { localeId = "en.UTF-8"; lang = wxLANGUAGE_ENGLISH; } @@ -146,9 +145,8 @@ bool BossGUI::OnInit() { } //Detect installed games. - vector detected, undetected; - DetectGames(detected, undetected); - if (detected.empty()) + _detectedGames = DetectGames(); + if (_detectedGames.empty()) wxMessageBox( translate("Error: None of the supported games were detected."), translate("BOSS: Error"), @@ -156,37 +154,40 @@ bool BossGUI::OnInit() { NULL); string target; - unsigned int targetGame; - if (settings["Game"] && settings["Game"].as() != "auto") - target = settings["Game"].as(); - else if (settings["Last Game"] && settings["Last Game"].as() != "auto") - target = settings["Last Game"].as(); + unsigned int targetGame = GAME_AUTODETECT; + if (_settings["Game"] && _settings["Game"].as() != "auto") + target = _settings["Game"].as(); + else if (_settings["Last Game"] && _settings["Last Game"].as() != "auto") + target = _settings["Last Game"].as(); if (!target.empty()) { - for (size_t i=0, max=detected.size(); i < max; ++i) { - if (target == "oblivion" && detected[i] == GAME_TES4) { + for (size_t i=0, max=_detectedGames.size(); i < max; ++i) { + if (target == "oblivion" && _detectedGames[i] == GAME_TES4) { targetGame = GAME_TES4; break; - } else if (target == "nehrim" && detected[i] == GAME_NEHRIM) { + } else if (target == "nehrim" && _detectedGames[i] == GAME_NEHRIM) { targetGame = GAME_NEHRIM; break; - } else if (target == "skyrim" && detected[i] == GAME_TES5) { + } else if (target == "skyrim" && _detectedGames[i] == GAME_TES5) { targetGame = GAME_TES5; break; - } else if (target == "fallout3" && detected[i] == GAME_FO3) { + } else if (target == "fallout3" && _detectedGames[i] == GAME_FO3) { targetGame = GAME_FO3; break; - } else if (target == "falloutnv" && detected[i] == GAME_FONV) { + } else if (target == "falloutnv" && _detectedGames[i] == GAME_FONV) { targetGame = GAME_FONV; break; } } + if (targetGame == GAME_AUTODETECT) + targetGame = _detectedGames[0]; } else - targetGame = detected[0]; - Game game(targetGame); + targetGame = _detectedGames[0]; + + _game = Game(targetGame); //Create launcher window. - Launcher * launcher = new Launcher(wxT("BOSS"), settings, game, detected); + Launcher * launcher = new Launcher(wxT("BOSS"), _settings, _game, _detectedGames); launcher->SetIcon(wxIconLocation("BOSS.exe")); launcher->Show(); @@ -195,7 +196,7 @@ bool BossGUI::OnInit() { return true; } -Launcher::Launcher(const wxChar *title, const YAML::Node& settings, const Game& game, const vector& detectedGames) : wxFrame(NULL, wxID_ANY, title), _game(game), _detectedGames(detectedGames), _settings(settings) { +Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, const vector& detectedGames) : wxFrame(NULL, wxID_ANY, title), _game(game), _detectedGames(detectedGames), _settings(settings) { //Initialise menu items. wxMenuBar * MenuBar = new wxMenuBar(); @@ -267,6 +268,15 @@ Launcher::Launcher(const wxChar *title, const YAML::Node& settings, const Game& //Called when the frame exits. void Launcher::OnQuit(wxCommandEvent& event) { + //Save settings. + YAML::Emitter yout; + yout.SetIndent(2); + yout << _settings; + + ofstream out(boss::settings_path.string().c_str()); + out << yout.c_str(); + out.close(); + Close(true); // Tells the OS to quit running this process } @@ -482,8 +492,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { progDia->Destroy(); //Create editor window. - Editor *editor = new Editor(translate("BOSS: Metadata Editor"), this); - editor->SetIcon(wxIconLocation("BOSS.exe")); + Editor *editor = new Editor(this, translate("BOSS: Metadata Editor")); //The 'plugins' list contains the merged plugin info, but we want to pass a vector of plugins with only masterlist info in its place, so have to construct that. vector pluginVec; @@ -572,9 +581,8 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { std::sort(ulist_plugins.begin(), ulist_plugins.end(), AlphaSortPlugins); //Create editor window. - Editor *editor = new Editor(translate("BOSS: Metadata Editor"), this); - editor->SetIcon(wxIconLocation("BOSS.exe")); - + Editor *editor = new Editor(this, translate("BOSS: Metadata Editor")); + //Pass plugin lists to editor window. editor->SetList(plugins, ulist_plugins); @@ -589,8 +597,7 @@ void Launcher::OnViewLastReport(wxCommandEvent& event) { } void Launcher::OnOpenSettings(wxCommandEvent& event) { - SettingsFrame *settings = new SettingsFrame(translate("BOSS: Settings"), this, _settings); - settings->SetIcon(wxIconLocation("BOSS.exe")); + SettingsFrame *settings = new SettingsFrame(this, translate("BOSS: Settings"), _settings); settings->Show(); } diff --git a/src/gui/main.h b/src/gui/main.h index c6d9fd20..5bdbcc0c 100644 --- a/src/gui/main.h +++ b/src/gui/main.h @@ -36,11 +36,15 @@ public: bool OnInit(); //Load settings, apply logging and language settings, check if BOSS is already running, detect games, set game to last game or to first detected game if auto, create launcher window. private: wxLocale * wxLoc; + + boss::Game _game; + YAML::Node _settings; + std::vector _detectedGames; }; class Launcher : public wxFrame { public: - Launcher(const wxChar *title, const YAML::Node& settings, const boss::Game& inGame, const std::vector& inGames); + Launcher(const wxChar *title, YAML::Node& settings, boss::Game& inGame, const std::vector& detectedGames); void OnSortPlugins(wxCommandEvent& event); void OnEditMetadata(wxCommandEvent& event); @@ -57,9 +61,9 @@ private: wxMenu * GameMenu; wxButton * ViewButton; - std::vector _detectedGames; - boss::Game _game; - YAML::Node _settings; //BOSS Settings. + boss::Game& _game; + YAML::Node& _settings; //BOSS Settings. + const std::vector& _detectedGames; void DisableUndetectedGames(); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index c83a2b15..4372f3fd 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -32,7 +32,7 @@ END_EVENT_TABLE() using namespace std; -SettingsFrame::SettingsFrame(const wxString title, wxFrame *parent, YAML::Node& settings) : wxFrame(parent, wxID_ANY, title), _settings(settings) { +SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings) : wxFrame(parent, wxID_ANY, title), _settings(settings) { //Initialise drop-down list contents. wxString DebugVerbosity[] = { @@ -122,7 +122,7 @@ SettingsFrame::SettingsFrame(const wxString title, wxFrame *parent, YAML::Node& bigBox->AddStretchSpacer(1); - bigBox->Add(new wxStaticText(this, wxID_ANY, translate("Settings will be applied after BOSS is restarted.")), wholeItem); + bigBox->Add(new wxStaticText(this, wxID_ANY, translate("Language changes will be applied after BOSS is restarted.")), wholeItem); //Need to add 'OK' and 'Cancel' buttons. wxBoxSizer * hbox = new wxBoxSizer(wxHORIZONTAL); @@ -142,6 +142,7 @@ SettingsFrame::SettingsFrame(const wxString title, wxFrame *parent, YAML::Node& //Now set the layout and sizes. SetBackgroundColour(wxColour(255,255,255)); + SetIcon(wxIconLocation("BOSS.exe")); SetSizerAndFit(bigBox); } diff --git a/src/gui/settings.h b/src/gui/settings.h index addff22a..fa586599 100644 --- a/src/gui/settings.h +++ b/src/gui/settings.h @@ -30,7 +30,7 @@ class SettingsFrame : public wxFrame { public: - SettingsFrame(const wxString title, wxFrame *parent, YAML::Node& settings); + SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings); void OnQuit(wxCommandEvent& event); void SetDefaultValues(); DECLARE_EVENT_TABLE() @@ -45,6 +45,6 @@ private: wxTextCtrl *FO3URL; wxTextCtrl *FONVURL; - YAML::Node _settings; + YAML::Node& _settings; }; #endif