The only bit of the UI that is explicitly dependent on any game details now are the masterlist update paths settings. The backend for TC support will probably change though, and a UI for editing TCs supported is yet to be implemented.

This commit is contained in:
WrinklyNinja
2013-05-14 14:59:14 +01:00
parent 59c4a90499
commit bf58ae2d80
10 changed files with 61 additions and 78 deletions
-1
View File
@@ -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
+6 -15
View File
@@ -27,16 +27,8 @@
#include "error.h"
#include "metadata.h"
#include <stdexcept>
#include <boost/algorithm/string.hpp>
#if _WIN32 || _WIN64
# include <windows.h>
# include <shlobj.h>
#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 {
+2 -2
View File
@@ -64,7 +64,7 @@ wxString State[2] = {
translate("Remove")
};
Editor::Editor(wxWindow *parent, const wxString& title, const boss::Game& game, const std::vector<boss::Plugin>& basePlugins, std::vector<boss::Plugin>& 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<boss::Plugin>& basePlugins, std::vector<boss::Plugin>& 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();
}
+2 -2
View File
@@ -34,7 +34,7 @@
class Editor : public wxFrame {
public:
Editor(wxWindow *parent, const wxString& title, const boss::Game& game, const std::vector<boss::Plugin>& basePlugins, std::vector<boss::Plugin>& editedPlugins);
Editor(wxWindow *parent, const wxString& title, const char * userlistPath, const std::vector<boss::Plugin>& basePlugins, std::vector<boss::Plugin>& 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<boss::Plugin> _basePlugins;
std::vector<boss::Plugin> _editedPlugins;
+21 -10
View File
@@ -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<boss::Game>& detectedGames, const vector<boss::Game>& undetectedGames) : wxFrame(NULL, wxID_ANY, title), _game(game), _settings(settings), _detectedGames(detectedGames) {
Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, const vector<boss::Game>& detectedGames, const vector<boss::Game>& 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<boss::Game> games = _detectedGames;
games.insert(games.end(), _undetectedGames.begin(), _undetectedGames.end());
SettingsFrame *settings = new SettingsFrame(this, translate("BOSS: Settings"), _settings, games);
settings->ShowModal();
}
+3
View File
@@ -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<boss::Game>& _detectedGames;
const std::vector<boss::Game>& _undetectedGames;
static bool AlphaSortPlugins(const boss::Plugin& lhs, const boss::Plugin& rhs);
};
+18 -42
View File
@@ -24,6 +24,7 @@
#include "settings.h"
#include "../globals.h"
#include <fstream>
#include <boost/algorithm/string.hpp>
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<boss::Game>& 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<string>();
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);
+4 -1
View File
@@ -25,12 +25,14 @@
#define __BOSS_GUI_SETTINGS__
#include "ids.h"
#include "../game.h"
#include <yaml-cpp/yaml.h>
#include <wx/listctrl.h>
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<boss::Game>& games);
void OnQuit(wxCommandEvent& event);
void SetDefaultValues();
DECLARE_EVENT_TABLE()
@@ -46,5 +48,6 @@ private:
wxTextCtrl *FONVURL;
YAML::Node& _settings;
std::vector<boss::Game> _games;
};
#endif
+4 -4
View File
@@ -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);
+1 -1
View File
@@ -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