Fixed/Tidied up unicode support, translation support. Swapped out some menu entries for their standard equivalents and replaced all the different readme links with just one item that opens the main readme.

This commit is contained in:
WrinklyNinja
2013-05-09 20:16:35 +01:00
parent 9f3ea84ebe
commit 4c97ff63b5
7 changed files with 97 additions and 101 deletions
+55 -43
View File
@@ -166,7 +166,7 @@ void Editor::SetList(const std::vector<boss::Plugin>& basePlugins, const std::ve
//Fill pluginList with the contents of basePlugins.
for (int i=0, max=_basePlugins.size(); i < max; ++i) {
pluginList->InsertItem(i, _basePlugins[i].Name());
pluginList->InsertItem(i, FromUTF8(_basePlugins[i].Name()));
}
pluginList->SetColumnWidth(0, wxLIST_AUTOSIZE);
Layout();
@@ -174,10 +174,10 @@ void Editor::SetList(const std::vector<boss::Plugin>& basePlugins, const std::ve
void Editor::IsSorted(bool sorted) {
if (sorted) {
applyBtn->SetLabel("Apply Load Order");
applyBtn->SetLabel(translate("Apply Load Order"));
} else {
recalcBtn->Show(false);
applyBtn->SetLabel("Save Changes");
applyBtn->SetLabel(translate("Save Changes"));
}
Layout();
}
@@ -189,22 +189,13 @@ void Editor::OnPluginSelect(wxListEvent& event) {
//Check if the selected plugin is the same as the current plugin.
if (currentPlugin != plugin) {
//Check if there are edits made to the current plugin compared to its original.
if (IsCurrentPluginEdited()) {
//Save changes.
boss::Plugin diff = currentPlugin.DiffMetadata(GetOriginal(currentPlugin, false));
vector<boss::Plugin>::iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff);
if (it != _editedPlugins.end())
*it = diff;
else
_editedPlugins.push_back(diff);
}
if (IsCurrentPluginEdited())
ApplyCurrentPluginEdits();
plugin = GetOriginal(plugin, true);
//Now fill editor fields with new plugin's info.
pluginText->SetLabelText(wxString(plugin.Name().c_str(), wxConvUTF8));
pluginText->SetLabelText(FromUTF8(plugin.Name()));
prioritySpin->SetValue(plugin.Priority());
@@ -219,37 +210,37 @@ void Editor::OnPluginSelect(wxListEvent& event) {
set<boss::File> files = plugin.LoadAfter();
int i=0;
for (set<boss::File>::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) {
loadAfterList->InsertItem(i, wxString(it->Name().c_str(), wxConvUTF8));
loadAfterList->SetItem(i, 1, wxString(it->DisplayName().c_str(), wxConvUTF8));
loadAfterList->SetItem(i, 2, wxString(it->Condition().c_str(), wxConvUTF8));
loadAfterList->InsertItem(i, FromUTF8(it->Name()));
loadAfterList->SetItem(i, 1, FromUTF8(it->DisplayName()));
loadAfterList->SetItem(i, 2, FromUTF8(it->Condition()));
++i;
}
files = plugin.Reqs();
i=0;
for (set<boss::File>::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) {
reqsList->InsertItem(i, wxString(it->Name().c_str(), wxConvUTF8));
reqsList->SetItem(i, 1, wxString(it->DisplayName().c_str(), wxConvUTF8));
reqsList->SetItem(i, 2, wxString(it->Condition().c_str(), wxConvUTF8));
reqsList->InsertItem(i, FromUTF8(it->Name()));
reqsList->SetItem(i, 1, FromUTF8(it->DisplayName()));
reqsList->SetItem(i, 2, FromUTF8(it->Condition()));
++i;
}
files = plugin.Incs();
i=0;
for (set<boss::File>::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) {
incsList->InsertItem(i, wxString(it->Name().c_str(), wxConvUTF8));
incsList->SetItem(i, 1, wxString(it->DisplayName().c_str(), wxConvUTF8));
incsList->SetItem(i, 2, wxString(it->Condition().c_str(), wxConvUTF8));
incsList->InsertItem(i, FromUTF8(it->Name()));
incsList->SetItem(i, 1, FromUTF8(it->DisplayName()));
incsList->SetItem(i, 2, FromUTF8(it->Condition()));
++i;
}
list<boss::Message> messages = plugin.Messages();
i=0;
for (list<boss::Message>::const_iterator it=messages.begin(), endit=messages.end(); it != endit; ++it) {
messageList->InsertItem(i, wxString(it->Type().c_str(), wxConvUTF8));
messageList->SetItem(i, 1, wxString(it->Content().c_str(), wxConvUTF8));
messageList->SetItem(i, 2, wxString(it->Condition().c_str(), wxConvUTF8));
messageList->SetItem(i, 2, wxString(it->Language().c_str(), wxConvUTF8));
messageList->InsertItem(i, FromUTF8(it->Type()));
messageList->SetItem(i, 1, FromUTF8(it->Content()));
messageList->SetItem(i, 2, FromUTF8(it->Condition()));
messageList->SetItem(i, 2, FromUTF8(it->Language()));
++i;
}
@@ -260,8 +251,8 @@ void Editor::OnPluginSelect(wxListEvent& event) {
tagsList->InsertItem(i, translate("Add"));
else
tagsList->InsertItem(i, translate("Remove"));
tagsList->SetItem(i, 1, wxString(it->Name().c_str(), wxConvUTF8));
tagsList->SetItem(i, 2, wxString(it->Condition().c_str(), wxConvUTF8));
tagsList->SetItem(i, 1, FromUTF8(it->Name()));
tagsList->SetItem(i, 2, FromUTF8(it->Condition()));
++i;
}
@@ -275,21 +266,21 @@ void Editor::OnPriorityChange(wxSpinEvent& event) {
void Editor::OnListBookChange(wxBookCtrlEvent& event) {
if (event.GetSelection() == 0 || event.GetSelection() == 1) {
addBtn->SetLabel("Add File");
editBtn->SetLabel("Edit File");
removeBtn->SetLabel("Remove File");
addBtn->SetLabel(translate("Add File"));
editBtn->SetLabel(translate("Edit File"));
removeBtn->SetLabel(translate("Remove File"));
} else if (event.GetSelection() == 2) {
addBtn->SetLabel("Add Plugin");
editBtn->SetLabel("Edit Plugin");
removeBtn->SetLabel("Remove Plugin");
addBtn->SetLabel(translate("Add Plugin"));
editBtn->SetLabel(translate("Edit Plugin"));
removeBtn->SetLabel(translate("Remove Plugin"));
} else if (event.GetSelection() == 3) {
addBtn->SetLabel("Add Message");
editBtn->SetLabel("Edit Message");
removeBtn->SetLabel("Remove Message");
addBtn->SetLabel(translate("Add Message"));
editBtn->SetLabel(translate("Edit Message"));
removeBtn->SetLabel(translate("Remove Message"));
} else if (event.GetSelection() == 4) {
addBtn->SetLabel("Add Bash Tag");
editBtn->SetLabel("Edit Bash Tag");
removeBtn->SetLabel("Remove Bash Tag");
addBtn->SetLabel(translate("Add Bash Tag"));
editBtn->SetLabel(translate("Edit Bash Tag"));
removeBtn->SetLabel(translate("Remove Bash Tag"));
}
Layout();
}
@@ -300,10 +291,20 @@ void Editor::OnEnabledToggle(wxCommandEvent& event) {
void Editor::OnQuit(wxCommandEvent& event) {
if (event.GetId() == BUTTON_Apply) {
//Save edits to userlist.
/* YAML::Emitter yout;
yout.SetIndent(2);
yout << YAML::BeginMap
<< YAML::Key << "plugins" << YAML::Value << _editedPlugins
<< YAML::EndMap;
ofstream out(game.UserlistPath().string().c_str());
out << yout.c_str();
out.close();
*/
if (recalcBtn->IsShown()) {
//Signal that the load order should be written.
}
//Save edits to userlist.
}
Close();
}
@@ -337,3 +338,14 @@ boss::Plugin Editor::GetOriginal(const boss::Plugin& plugin, bool withEdits) con
return p;
}
void Editor::ApplyCurrentPluginEdits() {
boss::Plugin diff = currentPlugin.DiffMetadata(GetOriginal(currentPlugin, false));
vector<boss::Plugin>::iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff);
if (it != _editedPlugins.end())
*it = diff;
else
_editedPlugins.push_back(diff);
}
+2
View File
@@ -26,6 +26,7 @@
#include "ids.h"
#include "../metadata.h"
#include <string>
#include <vector>
#include <wx/spinctrl.h>
#include <wx/notebook.h>
@@ -48,6 +49,7 @@ private:
bool IsCurrentPluginEdited() const;
boss::Plugin GetOriginal(const boss::Plugin& plugin, bool withEdits) const;
void ApplyCurrentPluginEdits();
wxButton * addBtn;
wxButton * editBtn;
+2 -2
View File
@@ -26,11 +26,11 @@
#include <boost/locale.hpp>
wxString translate(const std::string& str) {
return wxString(boost::locale::translate(str).str().c_str(), wxConvUTF8);
return wxString::FromUTF8(boost::locale::translate(str).str().c_str());
}
wxString FromUTF8(const std::string& str) {
return wxString(str.c_str(), wxConvUTF8);
return wxString::FromUTF8(str.c_str());
}
wxString FromUTF8(const boost::format& f) {
-7
View File
@@ -38,13 +38,6 @@ enum {
OPTION_EditMetadata = wxID_HIGHEST + 1, // declares an id which will be used to call our button
OPTION_ViewLastReport,
OPTION_SortPlugins,
MENU_Quit,
MENU_OpenMainReadMe,
MENU_OpenSyntaxReadMe,
MENU_OpenAPIReadMe,
MENU_OpenVersionHistory,
MENU_OpenLicenses,
MENU_ShowAbout,
MENU_ShowSettings,
MENU_Oblivion,
MENU_Nehrim,
+29 -40
View File
@@ -48,16 +48,12 @@
#include <wx/progdlg.h>
BEGIN_EVENT_TABLE ( Launcher, wxFrame )
EVT_MENU ( MENU_Quit, Launcher::OnQuit )
EVT_MENU ( wxID_EXIT, Launcher::OnQuit )
EVT_MENU ( OPTION_EditMetadata, Launcher::OnEditMetadata )
EVT_MENU ( OPTION_ViewLastReport, Launcher::OnViewLastReport )
EVT_MENU ( OPTION_SortPlugins, Launcher::OnSortPlugins )
EVT_MENU ( MENU_OpenMainReadMe, Launcher::OnOpenFile )
EVT_MENU ( MENU_OpenSyntaxReadMe, Launcher::OnOpenFile )
EVT_MENU ( MENU_OpenAPIReadMe, Launcher::OnOpenFile )
EVT_MENU ( MENU_OpenVersionHistory, Launcher::OnOpenFile )
EVT_MENU ( MENU_OpenLicenses, Launcher::OnOpenFile )
EVT_MENU ( MENU_ShowAbout, Launcher::OnAbout )
EVT_MENU ( wxID_HELP, Launcher::OnHelp )
EVT_MENU ( wxID_ABOUT, Launcher::OnAbout )
EVT_MENU ( MENU_ShowSettings, Launcher::OnOpenSettings )
EVT_MENU ( MENU_Oblivion, Launcher::OnGameChange )
EVT_MENU ( MENU_Nehrim, Launcher::OnGameChange )
@@ -153,7 +149,11 @@ bool BossGUI::OnInit() {
vector<unsigned int> detected, undetected;
DetectGames(detected, undetected);
if (detected.empty())
throw error(ERROR_NO_GAME_DETECTED, "None of the supported games were detected.");
wxMessageBox(
translate("Error: None of the supported games were detected."),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
NULL);
string target;
unsigned int targetGame;
@@ -205,8 +205,8 @@ Launcher::Launcher(const wxChar *title, const YAML::Node& settings, const Game&
wxMenu * HelpMenu = new wxMenu();
//Initialise controls.
wxButton * EditButton = new wxButton(this,OPTION_EditMetadata, translate("Edit Metadata"));
wxButton * SortButton = new wxButton(this,OPTION_SortPlugins, translate("Sort Plugins"));
wxButton * EditButton = new wxButton(this, OPTION_EditMetadata, translate("Edit Metadata"));
wxButton * SortButton = new wxButton(this, OPTION_SortPlugins, translate("Sort Plugins"));
ViewButton = new wxButton(this,OPTION_ViewLastReport, translate("View Last Report"));
//Construct menus.
@@ -214,7 +214,7 @@ Launcher::Launcher(const wxChar *title, const YAML::Node& settings, const Game&
FileMenu->Append(OPTION_ViewLastReport, translate("&View Last Report"), translate("Opens your last report."));
FileMenu->Append(OPTION_SortPlugins, translate("&Sort Plugins"), translate("Sorts your installed plugins."));
FileMenu->AppendSeparator();
FileMenu->Append(MENU_Quit, translate("&Quit"), translate("Quit BOSS."));
FileMenu->Append(wxID_EXIT);
MenuBar->Append(FileMenu, translate("&File"));
//Edit Menu
EditMenu->Append(OPTION_EditMetadata, translate("&Metadata..."), translate("Opens a window where you can edit plugin metadata."));
@@ -228,13 +228,9 @@ Launcher::Launcher(const wxChar *title, const YAML::Node& settings, const Game&
GameMenu->AppendRadioItem(MENU_FalloutNewVegas, wxT("&Fallout: New Vegas"), translate("Switch to running BOSS for Fallout: New Vegas."));
MenuBar->Append(GameMenu, translate("&Active Game"));
//About menu
HelpMenu->Append(MENU_OpenMainReadMe, translate("Open &Main Readme"), translate("Opens the main BOSS readme in your default web browser."));
HelpMenu->Append(MENU_OpenSyntaxReadMe, translate("Open &Metadata File Syntax Doc"), translate("Opens the BOSS metadata file syntax documentation in your default web browser."));
HelpMenu->Append(MENU_OpenAPIReadMe, translate("&Open API Readme"), translate("Opens the BOSS API readme in your default web browser."));
HelpMenu->Append(MENU_OpenVersionHistory, translate("Open &Version History"), translate("Opens the BOSS version history in your default web browser."));
HelpMenu->Append(MENU_OpenLicenses, translate("View &Copyright Licenses"), translate("View the GNU General Public License v3.0 and GNU Free Documentation License v1.3."));
HelpMenu->Append(wxID_HELP);
HelpMenu->AppendSeparator();
HelpMenu->Append(MENU_ShowAbout, translate("&About BOSS..."), translate("Shows information about BOSS."));
HelpMenu->Append(wxID_ABOUT);
MenuBar->Append(HelpMenu, translate("&Help"));
//Set up layout.
@@ -323,7 +319,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
FromUTF8(format(loc::translate("Error: Masterlist parsing failed. %1%")) % e.what()),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
NULL);
this);
}
if (mlist["globals"])
mlist_messages = mlist["globals"].as< list<boss::Message> >();
@@ -346,7 +342,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
FromUTF8(format(loc::translate("Error: Userlist parsing failed. %1%")) % e.what()),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
NULL);
this);
}
if (ulist["globals"])
ulist_messages = ulist["globals"].as< list<boss::Message> >();
@@ -399,7 +395,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
FromUTF8(format(loc::translate("Error: Condition evaluation failed. %1%")) % e.what()),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
NULL);
this);
}
}
@@ -537,7 +533,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) {
FromUTF8(format(loc::translate("Error: Masterlist parsing failed. %1%")) % e.what()),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
NULL);
this);
}
if (mlist["plugins"])
mlist_plugins = mlist["plugins"].as< vector<boss::Plugin> >();
@@ -552,7 +548,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) {
FromUTF8(format(loc::translate("Error: Userlist parsing failed. %1%")) % e.what()),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
NULL);
this);
}
if (ulist["plugins"])
ulist_plugins = ulist["plugins"].as< vector<boss::Plugin> >();
@@ -623,29 +619,22 @@ void Launcher::OnGameChange(wxCommandEvent& event) {
break;
}
} catch (error& e) {
wxMessageBox(e.what(), translate("BOSS: Error"), wxOK | wxICON_ERROR, this);
wxMessageBox(
FromUTF8(format(loc::translate("Error: Game change failed. %1%")) % e.what()),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
}
SetTitle(wxT("BOSS - " + _game.Name())); //Don't need to convert name, known to be only ASCII chars.
SetTitle(FromUTF8("BOSS - " + _game.Name()));
}
void Launcher::OnOpenFile(wxCommandEvent& event) {
string file;
if (event.GetId() == MENU_OpenMainReadMe)
file = readme_path.string();
else if (event.GetId() == MENU_OpenSyntaxReadMe)
file = syntax_doc_path.string();
else if (event.GetId() == MENU_OpenAPIReadMe)
file = api_doc_path.string();
else if (event.GetId() == MENU_OpenVersionHistory)
file = version_history_path.string();
else if (event.GetId() == MENU_OpenLicenses)
file = licenses_path.string();
void Launcher::OnHelp(wxCommandEvent& event) {
//Look for file.
if (fs::exists(file)) {
wxLaunchDefaultApplication(file);
if (fs::exists(readme_path.string())) {
wxLaunchDefaultApplication(readme_path.string());
} else //No ReadMe exists, show a pop-up message saying so.
wxMessageBox(
FromUTF8(boost::format(loc::translate("Error: \"%1%\" cannot be found.")) % file),
FromUTF8(format(loc::translate("Error: \"%1%\" cannot be found.")) % readme_path.string()),
translate("BOSS: Error"),
wxOK | wxICON_ERROR,
this);
@@ -694,7 +683,7 @@ void Launcher::DisableUndetectedGames() {
GameMenu->FindItem(MENU_FalloutNewVegas)->Enable();
}
SetTitle(wxT("BOSS - " + _game.Name())); //Don't need to convert name, known to be only ASCII chars.
SetTitle(FromUTF8("BOSS - " + _game.Name()));
}
bool Launcher::AlphaSortPlugins(const boss::Plugin& lhs, const boss::Plugin& rhs) {
+1 -1
View File
@@ -48,7 +48,7 @@ public:
void OnOpenSettings(wxCommandEvent& event);
void OnGameChange(wxCommandEvent& event);
void OnOpenFile(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
+8 -8
View File
@@ -53,10 +53,10 @@ SettingsFrame::SettingsFrame(const wxString title, wxFrame *parent, YAML::Node&
wxString Language[] = {
wxT("English"),
/* wxString("Español", wxConvUTF8),
/* wxString::FromUTF8("Español"),
wxT("Deutsch"),
wxString("Русский", wxConvUTF8),
wxString("简体中文", wxConvUTF8)*/
wxString::FromUTF8("Русский"),
wxString::FromUTF8("简体中文")*/
};
//Initialise controls.
@@ -183,19 +183,19 @@ void SettingsFrame::SetDefaultValues() {
YAML::Node urls = _settings["Masterlist URLs"];
if (urls["Oblivion"])
OblivionURL->SetValue(urls["Oblivion"].as<string>());
OblivionURL->SetValue(FromUTF8(urls["Oblivion"].as<string>()));
if (urls["Nehrim"])
NehrimURL->SetValue(urls["Nehrim"].as<string>());
NehrimURL->SetValue(FromUTF8(urls["Nehrim"].as<string>()));
if (urls["Skyrim"])
SkyrimURL->SetValue(urls["Skyrim"].as<string>());
SkyrimURL->SetValue(FromUTF8(urls["Skyrim"].as<string>()));
if (urls["Fallout 3"])
FO3URL->SetValue(urls["Fallout 3"].as<string>());
FO3URL->SetValue(FromUTF8(urls["Fallout 3"].as<string>()));
if (urls["Fallout New Vegas"])
FONVURL->SetValue(urls["Fallout New Vegas"].as<string>());
FONVURL->SetValue(FromUTF8(urls["Fallout New Vegas"].as<string>()));
}
}