diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp
deleted file mode 100644
index 1d9d78c1..00000000
--- a/src/gui/editor.cpp
+++ /dev/null
@@ -1,1267 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-
-#include "editor.h"
-#include "../backend/generators.h"
-#include "../backend/helpers.h"
-#include "../backend/streams.h"
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-using namespace std;
-
-//////////////////////////////
-// TextDropTarget class
-//////////////////////////////
-
-TextDropTarget::TextDropTarget(wxListView * owner, wxControl * name) : targetOwner(owner), targetName(name) {}
-
-bool TextDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString &data) {
- if (data == targetName->GetLabelText() || targetOwner->FindItem(-1, data) != wxNOT_FOUND)
- return false;
- targetOwner->InsertItem(targetOwner->GetItemCount(), data);
- targetOwner->SetColumnWidth(0, wxLIST_AUTOSIZE);
- return true;
-}
-
-///////////////////////////////////
-// EditorPanel Class
-///////////////////////////////////
-
-EditorPanel::EditorPanel(wxWindow *parent, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game) : wxPanel(parent, wxID_ANY), _basePlugins(basePlugins), _game(game), _editedPlugins(editedPlugins) {
-
- //Initialise child windows.
- listBook = new wxNotebook(this, BOOK_Lists);
-
- reqsTab = new wxPanel(listBook);
- incsTab = new wxPanel(listBook);
- loadAfterTab = new wxPanel(listBook);
- messagesTab = new wxPanel(listBook);
- tagsTab = new wxPanel(listBook);
- dirtyTab = new wxPanel(listBook);
-
- //Initialise controls.
- prioritySpin = new wxSpinCtrl(this, wxID_ANY, "0");
- prioritySpin->SetRange(-999999, 999999);
- priorityCheckbox = new wxCheckBox(this, wxID_ANY, translate("Compare priority against all other plugins"));
- pluginCheckbox = new wxCheckBox(this, wxID_ANY, "");
- filterCheckbox = new wxCheckBox(this, CHECKBOX_Filter, translate("Show only conflicting plugins"));
-
- addBtn = new wxButton(this, BUTTON_AddRow, translate("Add File"));
- editBtn = new wxButton(this, BUTTON_EditRow, translate("Edit File"));
- removeBtn = new wxButton(this, BUTTON_RemoveRow, translate("Remove File"));
-
- pluginList = new wxListView(this, LIST_Plugins, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
- reqsList = new wxListView(reqsTab, LIST_Reqs, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
- incsList = new wxListView(incsTab, LIST_Incs, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
- loadAfterList = new wxListView(loadAfterTab, LIST_LoadAfter, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
- tagsList = new wxListView(tagsTab, LIST_BashTags, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
- dirtyList = new wxListView(dirtyTab, LIST_DirtyInfo, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
- messageList = new MessageList(messagesTab, LIST_Messages, language);
-
- pluginMenu = new wxMenu();
-
- //Tie together notebooks and panels.
- listBook->AddPage(reqsTab, translate("Requirements"), true);
- listBook->AddPage(incsTab, translate("Incompatibilities"));
- listBook->AddPage(loadAfterTab, translate("Load After"));
- listBook->AddPage(messagesTab, translate("Messages"));
- listBook->AddPage(tagsTab, translate("Bash Tags"));
- listBook->AddPage(dirtyTab, translate("Dirty Info"));
-
- //Set up list columns.
- pluginList->AppendColumn(translate("User Metadata Enabled"));
- pluginList->AppendColumn(translate("Plugin Name"));
- pluginList->AppendColumn(translate("Priority"));
- pluginList->AppendColumn(translate("Global Priority"));
-
- reqsList->AppendColumn(translate("Filename"));
- reqsList->AppendColumn(translate("Display Name"));
- reqsList->AppendColumn(translate("Condition"));
-
- incsList->AppendColumn(translate("Filename"));
- incsList->AppendColumn(translate("Display Name"));
- incsList->AppendColumn(translate("Condition"));
-
- loadAfterList->AppendColumn(translate("Filename"));
- loadAfterList->AppendColumn(translate("Display Name"));
- loadAfterList->AppendColumn(translate("Condition"));
-
- tagsList->AppendColumn(translate("Add/Remove"));
- tagsList->AppendColumn(translate("Bash Tag"));
- tagsList->AppendColumn(translate("Condition"));
-
- dirtyList->AppendColumn(translate("CRC"));
- dirtyList->AppendColumn(translate("ITM Count"));
- dirtyList->AppendColumn(translate("UDR Count"));
- dirtyList->AppendColumn(translate("Deleted Navmesh Count"));
- dirtyList->AppendColumn(translate("Cleaning Utility"));
-
- //Set up plugin right-click menu.
- pluginMenu->Append(MENU_CopyName, translate("Copy Plugin Name"));
- pluginMenu->Append(MENU_CopyMetadata, translate("Copy Plugin Metadata As Text"));
- pluginMenu->Append(MENU_ClearPluginMetadata, translate("Remove Plugin User-Added Metadata"));
- pluginMenu->AppendSeparator();
- pluginMenu->Append(MENU_ClearAllMetadata, translate("Remove All User-Added Metadata"));
-
- //Initialise control states.
- addBtn->Enable(false);
- editBtn->Enable(false);
- removeBtn->Enable(false);
- prioritySpin->Enable(false);
- priorityCheckbox->Enable(false);
- pluginCheckbox->Enable(false);
- filterCheckbox->Enable(false);
-
- //Make plugin name bold text.
- wxFont font = pluginCheckbox->GetFont();
- font.SetWeight(wxFONTWEIGHT_BOLD);
- pluginCheckbox->SetFont(font);
-
- //Set up event handling.
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnPluginSelect, this, LIST_Plugins);
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnRowSelect, this, LIST_Reqs);
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnRowSelect, this, LIST_Incs);
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnRowSelect, this, LIST_LoadAfter);
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnRowSelect, this, LIST_Messages);
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnRowSelect, this, LIST_BashTags);
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnRowSelect, this, LIST_DirtyInfo);
- Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &EditorPanel::OnListBookChange, this, BOOK_Lists);
- Bind(wxEVT_BUTTON, &EditorPanel::OnAddRow, this, BUTTON_AddRow);
- Bind(wxEVT_BUTTON, &EditorPanel::OnEditRow, this, BUTTON_EditRow);
- Bind(wxEVT_BUTTON, &EditorPanel::OnRemoveRow, this, BUTTON_RemoveRow);
- Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &EditorPanel::OnPluginListRightClick, this);
- Bind(wxEVT_MENU, &EditorPanel::OnPluginCopyName, this, MENU_CopyName);
- Bind(wxEVT_MENU, &EditorPanel::OnPluginCopyMetadata, this, MENU_CopyMetadata);
- Bind(wxEVT_MENU, &EditorPanel::OnPluginClearMetadata, this, MENU_ClearPluginMetadata);
- Bind(wxEVT_MENU, &EditorPanel::OnClearAllMetadata, this, MENU_ClearAllMetadata);
- Bind(wxEVT_LIST_BEGIN_DRAG, &EditorPanel::OnDragStart, this, LIST_Plugins);
- Bind(wxEVT_CHECKBOX, &EditorPanel::OnFilterToggle, this, CHECKBOX_Filter);
-
- //Set up drag 'n' drop.
- reqsList->SetDropTarget(new TextDropTarget(reqsList, pluginCheckbox));
- incsList->SetDropTarget(new TextDropTarget(incsList, pluginCheckbox));
- loadAfterList->SetDropTarget(new TextDropTarget(loadAfterList, pluginCheckbox));
-
- //Set up tooltips.
- pluginList->SetToolTip(translate("Select a plugin to edit its load order metadata."));
- reqsList->SetToolTip(translate("Drag and drop a plugin here to add it to the list. The \"Show only conflicting plugins\" checkbox must be checked."));
- incsList->SetToolTip(translate("Drag and drop a plugin here to add it to the list. The \"Show only conflicting plugins\" checkbox must be checked."));
- loadAfterList->SetToolTip(translate("Drag and drop a plugin here to make the selected plugin load after it. The \"Show only conflicting plugins\" checkbox must be checked."));
- prioritySpin->SetToolTip(translate("Plugins with higher priorities will load after plugins with smaller priorities that they conflict with, unless one must explicitly load after the other."));
- pluginCheckbox->SetToolTip(translate("If unchecked, any user-added metadata will be ignored during sorting."));
- editBtn->SetToolTip(translate("Only user-added data may be removed."));
- removeBtn->SetToolTip(translate("Only user-added data may be removed."));
- priorityCheckbox->SetToolTip(translate("Otherwise, priorities are only compared between conflicting plugins."));
- filterCheckbox->SetToolTip(translate("Filters the plugin list to only display plugins which can be loaded after the currently selected plugin, and which either conflict with it, or, if it loads a BSA, also load BSAs. Also enables drag and drop of plugins into the Load After box."));
-
- //Set up layout.
- wxBoxSizer * bigBox = new wxBoxSizer(wxHORIZONTAL);
-
- bigBox->Add(pluginList, 0, wxEXPAND | wxALL, 10);
-
- wxBoxSizer * mainBox = new wxBoxSizer(wxVERTICAL);
-
- mainBox->Add(pluginCheckbox, 0, wxTOP | wxBOTTOM | wxEXPAND, 10);
-
-
- wxBoxSizer * hbox1 = new wxBoxSizer(wxHORIZONTAL);
- hbox1->Add(filterCheckbox, 0, wxALIGN_LEFT | wxRIGHT, 10);
- hbox1->AddStretchSpacer(1);
- hbox1->Add(new wxStaticText(this, wxID_ANY, translate("Priority: ")), 0, wxALIGN_RIGHT | wxLEFT | wxRIGHT, 5);
- hbox1->Add(prioritySpin, 0, wxALIGN_RIGHT);
-
- mainBox->Add(hbox1, 0, wxEXPAND | wxALIGN_RIGHT | wxTOP | wxBOTTOM, 5);
- mainBox->Add(priorityCheckbox, 0, wxALIGN_RIGHT | wxBOTTOM, 10);
-
- wxBoxSizer * tabBox1 = new wxBoxSizer(wxVERTICAL);
- tabBox1->Add(reqsList, 1, wxEXPAND);
- reqsTab->SetSizer(tabBox1);
-
- wxBoxSizer * tabBox2 = new wxBoxSizer(wxVERTICAL);
- tabBox2->Add(incsList, 1, wxEXPAND);
- incsTab->SetSizer(tabBox2);
-
- wxBoxSizer * tabBox3 = new wxBoxSizer(wxVERTICAL);
- tabBox3->Add(loadAfterList, 1, wxEXPAND);
- loadAfterTab->SetSizer(tabBox3);
-
- wxBoxSizer * tabBox4 = new wxBoxSizer(wxVERTICAL);
- tabBox4->Add(messageList, 1, wxEXPAND);
- messagesTab->SetSizer(tabBox4);
-
- wxBoxSizer * tabBox5 = new wxBoxSizer(wxVERTICAL);
- tabBox5->Add(tagsList, 1, wxEXPAND);
- tagsTab->SetSizer(tabBox5);
-
- wxBoxSizer * tabBox6 = new wxBoxSizer(wxVERTICAL);
- tabBox6->Add(dirtyList, 1, wxEXPAND);
- dirtyTab->SetSizer(tabBox6);
-
- mainBox->Add(listBook, 1, wxEXPAND | wxTOP | wxBOTTOM, 10);
-
- wxBoxSizer * hbox2 = new wxBoxSizer(wxHORIZONTAL);
- hbox2->Add(addBtn, 0, wxRIGHT, 5);
- hbox2->Add(editBtn, 0, wxLEFT | wxRIGHT, 5);
- hbox2->Add(removeBtn, 0, wxLEFT, 5);
- mainBox->Add(hbox2, 0, wxALIGN_RIGHT);
-
- bigBox->Add(mainBox, 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 10);
-
- //Fill pluginList with the contents of basePlugins.
- int i = 0;
- for (const auto &plugin : _basePlugins) {
- AddPluginToList(plugin, i);
- ++i;
- }
- pluginList->SetColumnWidth(0, wxLIST_AUTOSIZE);
- pluginList->SetColumnWidth(1, wxLIST_AUTOSIZE);
- pluginList->SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER);
- pluginList->SetColumnWidth(3, wxLIST_AUTOSIZE_USEHEADER);
-
- SetBackgroundColour(wxColour(255, 255, 255));
-
- SetSizerAndFit(bigBox);
- Layout();
-}
-
-void EditorPanel::OnPluginSelect(wxListEvent& event) {
- //Create Plugin object for selected plugin.
- wxString selectedPlugin = pluginList->GetItemText(event.GetIndex(), 1);
- wxString currentPlugin = pluginCheckbox->GetLabelText();
-
- //Check if the selected plugin is the same as the current plugin.
- if (selectedPlugin != currentPlugin) {
- BOOST_LOG_TRIVIAL(debug) << "User selected plugin: " << selectedPlugin.ToUTF8();
-
- //Apply any current edits.
- if (!currentPlugin.empty()) {
- ApplyEdits(currentPlugin);
- //Also update plugin list UI.
- long position = FindPlugin(currentPlugin);
- loot::Plugin userEdits = GetUserData(currentPlugin);
- if (!userEdits.HasNameOnly()) {
- if (userEdits.Enabled())
- pluginList->SetItem(position, 0, FromUTF8("\xE2\x9C\x93"));
- else
- pluginList->SetItem(position, 0, FromUTF8("\xE2\x9C\x97"));
- }
- //Also update the item's priority value in the plugins list in case it has changed.
- pluginList->SetItem(position, 2, FromUTF8(to_string(prioritySpin->GetValue())));
- if (priorityCheckbox->IsChecked())
- pluginList->SetItem(position, 3, FromUTF8("\xE2\x9C\x93"));
- else
- pluginList->SetItem(position, 3, FromUTF8("\xE2\x9C\x97"));
- }
-
- //Merge metadata.
- loot::Plugin plugin = GetMasterData(selectedPlugin);
- plugin.MergeMetadata(GetUserData(selectedPlugin));
-
- //Now fill editor fields with new plugin's info and update control states.
- BOOST_LOG_TRIVIAL(debug) << "Filling editor fields with plugin info.";
- pluginCheckbox->SetLabelText(FromUTF8(plugin.Name()));
-
- prioritySpin->SetValue(loot::modulo(plugin.Priority(), loot::max_priority));
-
- if (abs(plugin.Priority()) >= loot::max_priority)
- priorityCheckbox->SetValue(true);
- else
- priorityCheckbox->SetValue(false);
-
- pluginCheckbox->SetValue(plugin.Enabled());
-
- loadAfterList->DeleteAllItems();
- reqsList->DeleteAllItems();
- incsList->DeleteAllItems();
- messageList->DeleteAllItems();
- tagsList->DeleteAllItems();
- dirtyList->DeleteAllItems();
-
- set files = plugin.LoadAfter();
- int i = 0;
- for (const auto &file : files) {
- loadAfterList->InsertItem(i, FromUTF8(file.Name()));
- loadAfterList->SetItem(i, 1, FromUTF8(file.DisplayName()));
- loadAfterList->SetItem(i, 2, FromUTF8(file.Condition()));
- ++i;
- }
- if (loadAfterList->GetItemCount() == 0)
- loadAfterList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
- else
- loadAfterList->SetColumnWidth(0, wxLIST_AUTOSIZE);
-
- files = plugin.Reqs();
- i = 0;
- for (const auto &file : files) {
- reqsList->InsertItem(i, FromUTF8(file.Name()));
- reqsList->SetItem(i, 1, FromUTF8(file.DisplayName()));
- reqsList->SetItem(i, 2, FromUTF8(file.Condition()));
- ++i;
- }
- if (reqsList->GetItemCount() == 0)
- reqsList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
- else
- reqsList->SetColumnWidth(0, wxLIST_AUTOSIZE);
-
- files = plugin.Incs();
- i = 0;
- for (const auto &file : files) {
- incsList->InsertItem(i, FromUTF8(file.Name()));
- incsList->SetItem(i, 1, FromUTF8(file.DisplayName()));
- incsList->SetItem(i, 2, FromUTF8(file.Condition()));
- ++i;
- }
- if (incsList->GetItemCount() == 0)
- incsList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
- else
- incsList->SetColumnWidth(0, wxLIST_AUTOSIZE);
-
- list messages = plugin.Messages();
- vector vec(messages.begin(), messages.end());
- messageList->SetItems(vec);
-
- set tags = plugin.Tags();
- i = 0;
- for (const auto &tag : tags) {
- if (tag.IsAddition())
- tagsList->InsertItem(i, State[0]);
- else
- tagsList->InsertItem(i, State[1]);
- tagsList->SetItem(i, 1, FromUTF8(tag.Name()));
- tagsList->SetItem(i, 2, FromUTF8(tag.Condition()));
- ++i;
- }
- if (tagsList->GetItemCount() == 0)
- tagsList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
- else
- tagsList->SetColumnWidth(0, wxLIST_AUTOSIZE);
-
- set dirtyInfo = plugin.DirtyInfo();
- i = 0;
- for (const auto &element : dirtyInfo) {
- dirtyList->InsertItem(i, FromUTF8(loot::IntToHexString(element.CRC())));
- dirtyList->SetItem(i, 1, FromUTF8(to_string(element.ITMs())));
- dirtyList->SetItem(i, 2, FromUTF8(to_string(element.UDRs())));
- dirtyList->SetItem(i, 3, FromUTF8(to_string(element.DeletedNavmeshes())));
- dirtyList->SetItem(i, 4, FromUTF8(element.CleaningUtility()));
- ++i;
- }
- if (dirtyList->GetItemCount() == 0)
- dirtyList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
- else
- dirtyList->SetColumnWidth(0, wxLIST_AUTOSIZE);
-
- //Set control states.
- prioritySpin->Enable(true);
- priorityCheckbox->Enable(true);
- pluginCheckbox->Enable(true);
- filterCheckbox->Enable(true);
- addBtn->Enable(true);
- editBtn->Enable(false);
- removeBtn->Enable(false);
- }
- InvalidateBestSize(); //Makes the priority column visible without scrolling.
- if (GetBestSize().GetHeight() > GetSize().GetHeight() || GetBestSize().GetWidth() > GetSize().GetWidth()) {
- Fit();
- }
-}
-
-void EditorPanel::OnPluginListRightClick(wxListEvent& event) {
- PopupMenu(pluginMenu);
-}
-
-void EditorPanel::OnPluginCopyName(wxCommandEvent& event) {
- if (wxTheClipboard->Open()) {
- wxTheClipboard->SetData(new wxTextDataObject(pluginList->GetItemText(pluginList->GetFirstSelected(), 1)));
- wxTheClipboard->Close();
- }
-}
-
-void EditorPanel::OnPluginCopyMetadata(wxCommandEvent& event) {
- wxString selectedPlugin = pluginList->GetItemText(pluginList->GetFirstSelected(), 1);
- loot::Plugin plugin = GetUserData(selectedPlugin);
-
- string text;
- if (plugin.HasNameOnly())
- text = "name: " + plugin.Name();
- else {
- YAML::Emitter yout;
- yout.SetIndent(2);
- yout << plugin;
- text = yout.c_str();
- }
-
- BOOST_LOG_TRIVIAL(info) << "Exported userlist metadata text for \"" << selectedPlugin.ToUTF8() << "\": " << text;
-
- if (!text.empty() && wxTheClipboard->Open()) {
- wxTheClipboard->SetData(new wxTextDataObject(FromUTF8(text)));
- wxTheClipboard->Close();
- }
-}
-
-void EditorPanel::OnPluginClearMetadata(wxCommandEvent& event) {
- wxMessageDialog dialog(this,
- translate("Are you sure you want to clear all existing user-added metadata from this plugin?"),
- translate("LOOT: Warning"),
- wxYES_NO | wxCANCEL | wxICON_EXCLAMATION);
-
- if (dialog.ShowModal() == wxID_YES) {
- long i = pluginList->GetFirstSelected();
- wxString selectedPlugin = pluginList->GetItemText(i, 1);
- loot::Plugin p(string(selectedPlugin.ToUTF8()));
-
- //Need to clear what's currently in the editor and what's from the userlist.
-
- list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p);
-
- //Delete existing userlist entry.
- if (it != _editedPlugins.end())
- _editedPlugins.erase(it);
-
- //Also clear any unapplied data. Easiest way to do this is to simulate loading the plugin's data again.
- pluginCheckbox->SetLabelText("");
- pluginList->Select(i, false);
- pluginList->Select(i, true);
- pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- }
-}
-
-void EditorPanel::OnClearAllMetadata(wxCommandEvent& event) {
- wxMessageDialog dialog(this,
- translate("Are you sure you want to clear all existing user-added metadata from all plugins?"),
- translate("LOOT: Warning"),
- wxYES_NO | wxCANCEL | wxICON_EXCLAMATION);
-
- if (dialog.ShowModal() == wxID_YES) {
- //Delete all existing userlist entries.
- _editedPlugins.clear();
-
- //Also clear any unapplied data. Easiest way to do this is to simulate loading the plugin's data again.
- pluginCheckbox->SetLabelText("");
- long i = pluginList->GetFirstSelected();
- pluginList->Select(i, false);
- pluginList->Select(i, true);
- for (int i = 0, max = pluginList->GetItemCount(); i < max; ++i) {
- pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- }
- }
-}
-
-void EditorPanel::OnListBookChange(wxBookCtrlEvent& event) {
- BOOST_LOG_TRIVIAL(trace) << "Changed list tab.";
- if (listBook->GetPageCount() == 1 || event.GetSelection() == 2) { //First check is for simple view mode.
- addBtn->SetLabel(translate("Add Plugin"));
- editBtn->SetLabel(translate("Edit Plugin"));
- removeBtn->SetLabel(translate("Remove Plugin"));
- }
- else if (event.GetSelection() == 0 || event.GetSelection() == 1) {
- addBtn->SetLabel(translate("Add File"));
- editBtn->SetLabel(translate("Edit File"));
- removeBtn->SetLabel(translate("Remove File"));
- }
- else if (event.GetSelection() == 3) {
- addBtn->SetLabel(translate("Add Message"));
- editBtn->SetLabel(translate("Edit Message"));
- removeBtn->SetLabel(translate("Remove Message"));
- }
- else if (event.GetSelection() == 4) {
- addBtn->SetLabel(translate("Add Bash Tag"));
- editBtn->SetLabel(translate("Edit Bash Tag"));
- removeBtn->SetLabel(translate("Remove Bash Tag"));
- }
- else if (event.GetSelection() == 5) {
- addBtn->SetLabel(translate("Add Dirty Info"));
- editBtn->SetLabel(translate("Edit Dirty Info"));
- removeBtn->SetLabel(translate("Remove Dirty Info"));
- }
- editBtn->Enable(false);
- removeBtn->Enable(false);
-
- reqsList->Select(reqsList->GetFirstSelected(), false);
- incsList->Select(incsList->GetFirstSelected(), false);
- loadAfterList->Select(loadAfterList->GetFirstSelected(), false);
- messageList->Select(messageList->GetFirstSelected(), false);
- tagsList->Select(tagsList->GetFirstSelected(), false);
-
- Layout();
-}
-
-void EditorPanel::OnAddRow(wxCommandEvent& event) {
- if (listBook->GetSelection() < 3) {
- BOOST_LOG_TRIVIAL(debug) << "Adding new file row.";
-
- FileEditDialog * rowDialog = new FileEditDialog(this, translate("LOOT: Add File/Plugin"));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new file row.";
- return;
- }
-
- wxListView * list;
- if (listBook->GetPageCount() == 1 || listBook->GetSelection() == 2)
- list = loadAfterList;
- else if (listBook->GetSelection() == 0)
- list = reqsList;
- else if (listBook->GetSelection() == 1)
- list = incsList;
-
- long i = list->GetItemCount();
- list->InsertItem(i, rowDialog->GetName());
- list->SetItem(i, 1, rowDialog->GetDisplayName());
- list->SetItem(i, 2, rowDialog->GetCondition());
- }
- else if (listBook->GetSelection() == 3) {
- BOOST_LOG_TRIVIAL(debug) << "Adding new message row.";
-
- MessageEditDialog * rowDialog = new MessageEditDialog(this, translate("LOOT: Add Message"));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new message row.";
- return;
- }
-
- if (rowDialog->GetMessage().Content().empty()) {
- BOOST_LOG_TRIVIAL(error) << "No content specified. Row will not be added.";
- wxMessageBox(
- translate("Error: No content specified. Row will not be added."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- }
-
- messageList->AppendItem(rowDialog->GetMessage());
- }
- else if (listBook->GetSelection() == 4) {
- BOOST_LOG_TRIVIAL(debug) << "Adding new tag row.";
-
- TagEditDialog * rowDialog = new TagEditDialog(this, translate("LOOT: Add Tag"));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled adding new tag row.";
- return;
- }
-
- long i = tagsList->GetItemCount();
- tagsList->InsertItem(i, rowDialog->GetState());
- tagsList->SetItem(i, 1, rowDialog->GetName());
- tagsList->SetItem(i, 2, rowDialog->GetCondition());
- }
- else if (listBook->GetSelection() == 5) {
- BOOST_LOG_TRIVIAL(debug) << "Adding new dirty info row.";
-
- DirtInfoEditDialog * rowDialog = new DirtInfoEditDialog(this, translate("LOOT: Add Dirty Info"));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled adding dirty info row.";
- return;
- }
-
- long i = tagsList->GetItemCount();
- dirtyList->InsertItem(i, rowDialog->GetCRC());
- dirtyList->SetItem(i, 1, FromUTF8(to_string(rowDialog->GetITMs())));
- dirtyList->SetItem(i, 2, FromUTF8(to_string(rowDialog->GetUDRs())));
- dirtyList->SetItem(i, 3, FromUTF8(to_string(rowDialog->GetDeletedNavmeshes())));
- dirtyList->SetItem(i, 4, rowDialog->GetUtility());
- }
-}
-
-void EditorPanel::OnEditRow(wxCommandEvent& event) {
- if (listBook->GetSelection() < 3) {
- BOOST_LOG_TRIVIAL(debug) << "Editing file row.";
- FileEditDialog * rowDialog = new FileEditDialog(this, translate("LOOT: Edit File/Plugin"));
-
- wxListView * list;
- if (listBook->GetPageCount() == 1 || listBook->GetSelection() == 2)
- list = loadAfterList;
- else if (listBook->GetSelection() == 0)
- list = reqsList;
- else if (listBook->GetSelection() == 1)
- list = incsList;
-
- long i = list->GetFirstSelected();
-
- rowDialog->SetValues(list->GetItemText(i, 0), list->GetItemText(i, 1), list->GetItemText(i, 2));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled editing file row.";
- return;
- }
-
- list->SetItem(i, 0, rowDialog->GetName());
- list->SetItem(i, 1, rowDialog->GetDisplayName());
- list->SetItem(i, 2, rowDialog->GetCondition());
- }
- else if (listBook->GetSelection() == 3) {
- BOOST_LOG_TRIVIAL(debug) << "Editing message row.";
- MessageEditDialog * rowDialog = new MessageEditDialog(this, translate("LOOT: Edit Message"));
-
- long i = messageList->GetFirstSelected();
-
- rowDialog->SetMessage(messageList->GetItem(i));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled editing message row.";
- return;
- }
-
- if (rowDialog->GetMessage().Content().empty()) {
- BOOST_LOG_TRIVIAL(error) << "No content specified. Row will not be edited.";
- wxMessageBox(
- translate("Error: No content specified. Row will not be edited."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- }
-
- messageList->SetItem(i, rowDialog->GetMessage());
- }
- else if (listBook->GetSelection() == 4) {
- BOOST_LOG_TRIVIAL(debug) << "Editing tag row.";
- TagEditDialog * rowDialog = new TagEditDialog(this, translate("LOOT: Edit Tag"));
-
- long i = tagsList->GetFirstSelected();
-
- int stateNo;
- if (tagsList->GetItemText(i, 0) == State[0])
- stateNo = 0;
- else
- stateNo = 1;
-
- rowDialog->SetValues(stateNo, tagsList->GetItemText(i, 1), tagsList->GetItemText(i, 2));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled editing tag row.";
- return;
- }
-
- tagsList->SetItem(i, 0, rowDialog->GetState());
- tagsList->SetItem(i, 1, rowDialog->GetName());
- tagsList->SetItem(i, 2, rowDialog->GetCondition());
- }
- else if (listBook->GetSelection() == 5) {
- BOOST_LOG_TRIVIAL(debug) << "Editing dirty info row.";
- DirtInfoEditDialog * rowDialog = new DirtInfoEditDialog(this, translate("LOOT: Edit Dirty Info"));
-
- long i = tagsList->GetFirstSelected();
-
- rowDialog->SetValues(tagsList->GetItemText(i, 0),
- atoi(string(tagsList->GetItemText(i, 1)).c_str()),
- atoi(string(tagsList->GetItemText(i, 2)).c_str()),
- atoi(string(tagsList->GetItemText(i, 3)).c_str()),
- tagsList->GetItemText(i, 4));
-
- if (rowDialog->ShowModal() != wxID_OK) {
- BOOST_LOG_TRIVIAL(debug) << "Cancelled editing tag row.";
- return;
- }
-
- dirtyList->SetItem(i, 0, rowDialog->GetCRC());
- dirtyList->SetItem(i, 1, FromUTF8(to_string(rowDialog->GetITMs())));
- dirtyList->SetItem(i, 2, FromUTF8(to_string(rowDialog->GetUDRs())));
- dirtyList->SetItem(i, 3, FromUTF8(to_string(rowDialog->GetDeletedNavmeshes())));
- dirtyList->SetItem(i, 4, rowDialog->GetUtility());
- }
-}
-
-void EditorPanel::OnRemoveRow(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Removing row.";
- wxListView * list;
- if (listBook->GetPageCount() == 1 || listBook->GetSelection() == 2)
- list = loadAfterList;
- else if (listBook->GetSelection() == 0)
- list = reqsList;
- else if (listBook->GetSelection() == 1)
- list = incsList;
- else if (listBook->GetSelection() == 3)
- list = messageList;
- else if (listBook->GetSelection() == 4)
- list = tagsList;
- else if (listBook->GetSelection() == 5)
- list = dirtyList;
-
- list->DeleteItem(list->GetFirstSelected());
-
- editBtn->Enable(false);
- removeBtn->Enable(false);
-}
-
-void EditorPanel::OnRowSelect(wxListEvent& event) {
- if (event.GetId() == LIST_Reqs) {
-
- //Create File object, search the masterlist vector for the plugin and search its reqs for this object.
- loot::File file = RowToFile(reqsList, event.GetIndex());
- loot::Plugin plugin(string(pluginCheckbox->GetLabelText().ToUTF8()));
-
- list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin);
-
- if (it != _basePlugins.end())
- plugin = *it;
- else
- BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
-
- set reqs = plugin.Reqs();
-
- if (reqs.find(file) == reqs.end()) {
- BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled.";
- editBtn->Enable(true);
- removeBtn->Enable(true);
- }
- else {
- BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled.";
- editBtn->Enable(false);
- removeBtn->Enable(false);
- }
-
- }
- else if (event.GetId() == LIST_Incs) {
-
- loot::File file = RowToFile(incsList, event.GetIndex());
- loot::Plugin plugin(string(pluginCheckbox->GetLabelText().ToUTF8()));
-
- list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin);
-
- if (it != _basePlugins.end())
- plugin = *it;
- else
- BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
-
- set incs = plugin.Incs();
-
- if (incs.find(file) == incs.end()) {
- BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled.";
- editBtn->Enable(true);
- removeBtn->Enable(true);
- }
- else {
- BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled.";
- editBtn->Enable(false);
- removeBtn->Enable(false);
- }
-
- }
- else if (event.GetId() == LIST_LoadAfter) {
-
- loot::File file = RowToFile(loadAfterList, event.GetIndex());
- loot::Plugin plugin(string(pluginCheckbox->GetLabelText().ToUTF8()));
-
- list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin);
-
- if (it != _basePlugins.end())
- plugin = *it;
- else
- BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
-
- set loadAfter = plugin.LoadAfter();
-
- if (loadAfter.find(file) == loadAfter.end()) {
- BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled.";
- editBtn->Enable(true);
- removeBtn->Enable(true);
- }
- else {
- BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was found in base plugin metadata. Editing disabled.";
- editBtn->Enable(false);
- removeBtn->Enable(false);
- }
-
- }
- else if (event.GetId() == LIST_Messages) {
-
- loot::Message message = messageList->GetItem(event.GetIndex());
- loot::Plugin plugin(string(pluginCheckbox->GetLabelText().ToUTF8()));
-
- list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin);
-
- if (it != _basePlugins.end())
- plugin = *it;
- else
- BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
-
- list messages = plugin.Messages();
-
- if (find(messages.begin(), messages.end(), message) == messages.end()) {
- BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(loot::Language::any).Str() << "\" was not found in base plugin metadata. Editing enabled.";
- editBtn->Enable(true);
- removeBtn->Enable(true);
- }
- else {
- BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(loot::Language::any).Str() << "\" was found in base plugin metadata. Editing disabled.";
- editBtn->Enable(false);
- removeBtn->Enable(false);
- }
-
- }
- else if (event.GetId() == LIST_BashTags) {
-
- loot::Tag tag = RowToTag(tagsList, event.GetIndex());
- loot::Plugin plugin(string(pluginCheckbox->GetLabelText().ToUTF8()));
-
- list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin);
-
- if (it != _basePlugins.end())
- plugin = *it;
- else
- BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
-
- set tags = plugin.Tags();
-
- if (tags.find(tag) == tags.end()) {
- BOOST_LOG_TRIVIAL(trace) << "Bash Tag \"" << tag.Name() << "\" was not found in base plugin metadata. Editing enabled.";
- editBtn->Enable(true);
- removeBtn->Enable(true);
- }
- else {
- BOOST_LOG_TRIVIAL(trace) << "Bash Tag \"" << tag.Name() << "\" was found in base plugin metadata. Editing disabled.";
- editBtn->Enable(false);
- removeBtn->Enable(false);
- }
-
- }
- else {
- loot::PluginDirtyInfo dirtyData = RowToPluginDirtyInfo(dirtyList, event.GetIndex());
- loot::Plugin plugin(string(pluginCheckbox->GetLabelText().ToUTF8()));
-
- list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin);
-
- if (it != _basePlugins.end())
- plugin = *it;
- else
- BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name();
-
- set dirtyInfo = plugin.DirtyInfo();
-
- if (dirtyInfo.find(dirtyData) == dirtyInfo.end()) {
- BOOST_LOG_TRIVIAL(trace) << "Dirty info for CRC \"" << dirtyData.CRC() << "\" was not found in base plugin metadata. Editing enabled.";
- editBtn->Enable(true);
- removeBtn->Enable(true);
- }
- else {
- BOOST_LOG_TRIVIAL(trace) << "Dirty info for CRC \"" << dirtyData.CRC() << "\" was found in base plugin metadata. Editing disabled.";
- editBtn->Enable(false);
- removeBtn->Enable(false);
- }
- }
-}
-
-loot::Plugin EditorPanel::GetNewData(const wxString& plugin) const {
- BOOST_LOG_TRIVIAL(debug) << "Getting metadata from editor fields for plugin: " << plugin.ToUTF8();
- loot::Plugin p(string(plugin.ToUTF8()));
-
- p.Enabled(pluginCheckbox->IsChecked());
-
- int priority = prioritySpin->GetValue();
- if (priorityCheckbox->IsChecked()) {
- if (priority < 0)
- priority -= loot::max_priority;
- else
- priority += loot::max_priority;
- }
- p.Priority(priority);
-
- set files;
- for (int i = 0, max = reqsList->GetItemCount(); i < max; ++i) {
- files.insert(RowToFile(reqsList, i));
- }
- p.Reqs(files);
- files.clear();
-
- for (int i = 0, max = incsList->GetItemCount(); i < max; ++i) {
- files.insert(RowToFile(incsList, i));
- }
- p.Incs(files);
- files.clear();
-
- for (int i = 0, max = loadAfterList->GetItemCount(); i < max; ++i) {
- files.insert(RowToFile(loadAfterList, i));
- }
- p.LoadAfter(files);
-
- set tags;
- for (int i = 0, max = tagsList->GetItemCount(); i < max; ++i) {
- tags.insert(RowToTag(tagsList, i));
- }
- p.Tags(tags);
-
- set dirtyInfo;
- for (int i = 0, max = dirtyList->GetItemCount(); i < max; ++i) {
- dirtyInfo.insert(RowToPluginDirtyInfo(dirtyList, i));
- }
- p.DirtyInfo(dirtyInfo);
-
- vector vec = messageList->GetItems();
- list messages(vec.begin(), vec.end());
- p.Messages(messages);
-
- return p;
-}
-
-void EditorPanel::OnFilterToggle(wxCommandEvent& event) {
- //First need to merge the base and edited plugin lists so that the right priority values get displayed.
-
- list plugins(_basePlugins);
- for (const auto &plugin : _editedPlugins) {
- list::iterator pos = std::find(plugins.begin(), plugins.end(), plugin);
- if (pos != plugins.end())
- pos->MergeMetadata(plugin);
- }
-
- //Disable list selection.
- if (event.IsChecked())
- Unbind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnPluginSelect, this, LIST_Plugins);
- else
- Bind(wxEVT_LIST_ITEM_SELECTED, &EditorPanel::OnPluginSelect, this, LIST_Plugins);
-
- pluginList->Freeze();
- if (event.IsChecked()) {
- loot::Plugin plugin(string(pluginCheckbox->GetLabelText().ToUTF8()));
- list::const_iterator pos = std::find(plugins.begin(), plugins.end(), plugin);
-
- if (pos != plugins.end()) {
- pluginList->DeleteAllItems();
-
- bool loadsBSA = pos->LoadsBSA(_game);
-
- int i = 0;
- for (const auto &plugin : plugins) {
- //Want to filter to show only those the selected plugin can load after validly, and which also either conflict with it,
- //or which load a BSA (if the selected plugin loads a BSA).
- if (plugin == *pos || !plugin.MustLoadAfter(*pos) && (pos->DoFormIDsOverlap(plugin) || (loadsBSA && plugin.LoadsBSA(_game)))) {
- AddPluginToList(plugin, i);
- ++i;
- }
- }
- }
- }
- else {
- pluginList->DeleteAllItems();
- int i = 0;
- for (const auto &plugin : plugins) {
- AddPluginToList(plugin, i);
- ++i;
- }
- }
-
- //Now re-select the current plugin in the list.
- pluginList->Select(FindPlugin(pluginCheckbox->GetLabelText()));
- pluginList->Thaw();
- Refresh();
-}
-
-void EditorPanel::OnDragStart(wxListEvent& event) {
- wxTextDataObject data(pluginList->GetItemText(event.GetItem(), 1));
- wxDropSource dropSource(pluginList);
- dropSource.SetData(data);
- wxDragResult result = dropSource.DoDragDrop();
-}
-
-void EditorPanel::AddPluginToList(const loot::Plugin& plugin, int position) {
- loot::Plugin userEdits = GetUserData(FromUTF8(plugin.Name()));
- loot::Plugin mergedPlugin(plugin);
- mergedPlugin.MergeMetadata(userEdits);
-
- if (!userEdits.HasNameOnly()) {
- if (userEdits.Enabled())
- pluginList->InsertItem(position, FromUTF8("\xE2\x9C\x93"));
- else
- pluginList->InsertItem(position, FromUTF8("\xE2\x9C\x97"));
- }
- else
- pluginList->InsertItem(position, "");
-
- pluginList->SetItem(position, 1, FromUTF8(mergedPlugin.Name()));
- pluginList->SetItem(position, 2, FromUTF8(to_string(loot::modulo(mergedPlugin.Priority(), loot::max_priority))));
- if (abs(mergedPlugin.Priority()) >= loot::max_priority)
- pluginList->SetItem(position, 3, FromUTF8("\xE2\x9C\x93"));
- else
- pluginList->SetItem(position, 3, FromUTF8("\xE2\x9C\x97"));
- if (mergedPlugin.LoadsBSA(_game)) {
- pluginList->SetItemTextColour(position, wxColour(0, 142, 219));
- }
-}
-
-void EditorPanel::SetSimpleView(bool on) {
- if (on) {
- listBook->RemovePage(5);
- listBook->RemovePage(4);
- listBook->RemovePage(3);
- listBook->RemovePage(1);
- listBook->RemovePage(0);
- addBtn->Show(false);
- editBtn->Show(false);
- loadAfterList->SetColumnWidth(1, 0);
- loadAfterList->SetColumnWidth(2, 0);
- }
- else {
- listBook->InsertPage(0, reqsTab, translate("Requirements"));
- listBook->InsertPage(1, incsTab, translate("Incompatibilities"));
- listBook->AddPage(messagesTab, translate("Messages"));
- listBook->AddPage(tagsTab, translate("Bash Tags"));
- listBook->AddPage(dirtyTab, translate("Dirty Info"));
- addBtn->Show(true);
- editBtn->Show(true);
- loadAfterList->SetColumnWidth(1, wxLIST_AUTOSIZE);
- loadAfterList->SetColumnWidth(2, wxLIST_AUTOSIZE);
- }
-}
-
-void EditorPanel::ApplyCurrentEdits() {
- //Apply any current edits.
- wxString currentPlugin = pluginCheckbox->GetLabelText();
- if (!currentPlugin.empty())
- ApplyEdits(currentPlugin);
-}
-
-loot::MetadataList EditorPanel::GetNewUserlist() const {
- loot::MetadataList newUserlist;
- newUserlist.plugins = _editedPlugins;
- return newUserlist;
-}
-
-loot::Plugin EditorPanel::GetMasterData(const wxString& plugin) const {
- BOOST_LOG_TRIVIAL(debug) << "Getting hardcoded and masterlist metadata for plugin: " << plugin.ToUTF8();
- loot::Plugin p;
- loot::Plugin p_in(string(plugin.ToUTF8()));
-
- list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), p_in);
-
- if (it != _basePlugins.end())
- p = *it;
-
- return p;
-}
-
-loot::Plugin EditorPanel::GetUserData(const wxString& plugin) const {
- BOOST_LOG_TRIVIAL(debug) << "Getting userlist metadata for plugin: " << plugin.ToUTF8();
- loot::Plugin p(string(plugin.ToUTF8()));
-
- list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p);
-
- if (it != _editedPlugins.end())
- p = *it;
-
- return p;
-}
-
-void EditorPanel::ApplyEdits(const wxString& plugin) {
- BOOST_LOG_TRIVIAL(debug) << "Applying edits to plugin: " << plugin.ToUTF8();
-
- //Get recorded data.
- loot::Plugin master(GetMasterData(plugin));
- loot::Plugin edited(GetNewData(plugin));
-
- loot::Plugin diff = master.DiffMetadata(edited);
-
- list::iterator pos = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff);
- long i = FindPlugin(plugin);
-
- if (!diff.HasNameOnly()) {
- if (pos != _editedPlugins.end()) {
- if (!pos->DiffMetadata(diff).HasNameOnly())
- pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold());
- *pos = diff;
- }
- else {
- _editedPlugins.push_back(diff);
- pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold());
- }
- }
- else {
- pluginList->SetItemFont(i, wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- if (pos != _editedPlugins.end())
- _editedPlugins.erase(pos); //Prevents unnecessary writes.
- }
-}
-
-long EditorPanel::FindPlugin(const wxString& plugin) {
- for (int i = 0, max = pluginList->GetItemCount(); i < max; ++i) {
- if (pluginList->GetItemText(i, 1) == plugin)
- return i;
- }
- return -1;
-}
-
-loot::File EditorPanel::RowToFile(wxListView * list, long row) const {
- return loot::File(
- string(list->GetItemText(row, 0).ToUTF8()),
- string(list->GetItemText(row, 1).ToUTF8()),
- string(list->GetItemText(row, 2).ToUTF8())
- );
-}
-
-loot::Tag EditorPanel::RowToTag(wxListView * list, long row) const {
- string name = string(list->GetItemText(row, 1).ToUTF8());
-
- if (list->GetItemText(row, 0) == State[1])
- return loot::Tag(
- name,
- false,
- string(list->GetItemText(row, 2).ToUTF8())
- );
- else
- return loot::Tag(
- name,
- true,
- string(list->GetItemText(row, 2).ToUTF8())
- );
-}
-
-loot::PluginDirtyInfo EditorPanel::RowToPluginDirtyInfo(wxListView * list, long row) const {
- string text(list->GetItemText(row, 0).ToUTF8());
- uint32_t crc = strtoul(text.c_str(), nullptr, 16);
- return loot::PluginDirtyInfo(
- crc,
- atoi(string(list->GetItemText(row, 1).ToUTF8()).c_str()),
- atoi(string(list->GetItemText(row, 2).ToUTF8()).c_str()),
- atoi(string(list->GetItemText(row, 3).ToUTF8()).c_str()),
- string(list->GetItemText(row, 4).ToUTF8()));
-}
-
-
-///////////////////////////////////
-// Mini Editor Class
-///////////////////////////////////
-
-MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const std::list& basePlugins, std::list& editedPlugins, const loot::Game& game) : wxDialog(parent, wxID_ANY, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
-
- //Initialise content.
- editorPanel = new EditorPanel(this, basePlugins, editedPlugins, loot::Language::any, game);
- editorPanel->SetSimpleView(true);
-
- feedbackText = translate("If LOOT has gotten something wrong, please let the team know. See the Contributing To LOOT section of the readme for details.");
- descText = new wxStaticText(this, wxID_ANY, feedbackText);
-
- //Set up event handling.
- Bind(wxEVT_BUTTON, &MiniEditor::OnApply, this, wxID_APPLY);
- Bind(wxEVT_SIZE, &MiniEditor::OnResize, this);
-
- //Set up layout.
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- bigBox->Add(editorPanel, 1, wxEXPAND | wxALL, 10);
- bigBox->Add(descText, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 15);
-
- //Need to add 'Yes' and 'No' buttons.
- wxSizer * sizer = CreateSeparatedButtonSizer(wxAPPLY | wxCANCEL);
-
- //Now add buttons to window sizer.
- if (sizer != nullptr)
- bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15);
-
- descText->Wrap(editorPanel->GetClientSize().GetWidth());
-
- SetBackgroundColour(wxColour(255, 255, 255));
- SetIcon(wxIconLocation("LOOT.exe"));
-
- SetSizerAndFit(bigBox);
-
- if (size != wxDefaultSize)
- SetSize(size);
-}
-
-void MiniEditor::OnApply(wxCommandEvent& event) {
- editorPanel->ApplyCurrentEdits();
- EndModal(event.GetId());
-}
-
-void MiniEditor::OnResize(wxSizeEvent& event) {
- descText->SetLabel(feedbackText);
- descText->Wrap(GetClientSize().GetWidth()-30);
- event.Skip();
-}
-
-loot::MetadataList MiniEditor::GetNewUserlist() const {
- return editorPanel->GetNewUserlist();
-}
-
-
-///////////////////////////////////
-// Full Editor Class
-///////////////////////////////////
-
-FullEditor::FullEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const boost::filesystem::path& userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game, YAML::Node &settings) : wxFrame(parent, wxID_ANY, title, pos, size), _userlistPath(userlistPath), _settings(settings) {
- //Set up content.
- editorPanel = new EditorPanel(this, basePlugins, editedPlugins, language, game);
- applyBtn = new wxButton(this, BUTTON_Apply, translate("Save Changes"));
- cancelBtn = new wxButton(this, BUTTON_Cancel, translate("Cancel"));
-
- //Set up event handling.
- Bind(wxEVT_BUTTON, &FullEditor::OnQuit, this, BUTTON_Apply);
- Bind(wxEVT_BUTTON, &FullEditor::OnQuit, this, BUTTON_Cancel);
- Bind(wxEVT_CLOSE_WINDOW, &FullEditor::OnClose, this);
-
- //Set up layout.
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- bigBox->Add(editorPanel, 1, wxEXPAND | wxALL, 10);
-
- wxBoxSizer * hbox6 = new wxBoxSizer(wxHORIZONTAL);
- hbox6->Add(applyBtn, 0, wxRIGHT, 10);
- hbox6->Add(cancelBtn);
- bigBox->Add(hbox6, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 10);
-
- SetBackgroundColour(wxColour(255, 255, 255));
- SetIcon(wxIconLocation("LOOT.exe"));
-
- SetSizerAndFit(bigBox);
-
- if (size != wxDefaultSize)
- SetSize(size);
-}
-
-void FullEditor::OnQuit(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Exiting metadata editor.";
- if (event.GetId() == BUTTON_Apply) {
-
- //Apply any current edits.
- editorPanel->ApplyCurrentEdits();
-
- BOOST_LOG_TRIVIAL(debug) << "Saving metadata edits to userlist.";
-
- loot::MetadataList userlist = editorPanel->GetNewUserlist();
- userlist.Save(_userlistPath);
- }
- Close();
-}
-
-void FullEditor::OnClose(wxCloseEvent &event) {
- //Record window settings.
- YAML::Node node;
- node["height"] = GetSize().GetHeight();
- node["width"] = GetSize().GetWidth();
- node["xPos"] = GetPosition().x;
- node["yPos"] = GetPosition().y;
-
- _settings["windows"]["editor"] = node;
-
- Destroy();
-}
\ No newline at end of file
diff --git a/src/gui/editor.h b/src/gui/editor.h
deleted file mode 100644
index ef18a0cc..00000000
--- a/src/gui/editor.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-#ifndef __LOOT_GUI_EDITOR__
-#define __LOOT_GUI_EDITOR__
-
-#include "ids.h"
-#include "misc.h"
-
-#include "../backend/metadata.h"
-#include "../backend/game.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/* Have two versions of the editor: one mini editor that only contains
- controls for editing the load order related metadata, and a full editor
- that contains controls for editing all the metadata.
-
- Both editors need to convert between metadata and control data, and to
- keep track of what edits have been made.
-
- Have a immutable plugin list to keep track of non-user-edit metadata,
- and a mutable plugin list to keep track of user-edit metadata. When
- recording edits, diff the metadata obtained from the control values with
- the metadata in the immutable plugin entry to get the new user-edit metadata.
-
- If a metadata type's corresponding control is not present (ie. in the mini
- editor), then use the immutable plugin entry's metadata for that type.
-*/
-
-class TextDropTarget : public wxTextDropTarget { //Class to override virtual functions.
-public:
- TextDropTarget(wxListView * owner, wxControl * name);
- virtual bool OnDropText(wxCoord x, wxCoord y, const wxString &data);
-private:
- wxListView * targetOwner;
- wxControl * targetName;
-};
-
-class EditorPanel : public wxPanel {
-public:
- EditorPanel(wxWindow *parent, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game);
-
- void SetSimpleView(bool on = true);
- void ApplyCurrentEdits();
-
- loot::MetadataList GetNewUserlist() const;
-
- void OnPluginSelect(wxListEvent& event);
- void OnPluginListRightClick(wxListEvent& event);
- void OnPluginCopyName(wxCommandEvent& event);
- void OnPluginCopyMetadata(wxCommandEvent& event);
- void OnPluginClearMetadata(wxCommandEvent& event);
- void OnClearAllMetadata(wxCommandEvent& event);
- void OnListBookChange(wxBookCtrlEvent& event);
- void OnAddRow(wxCommandEvent& event);
- void OnEditRow(wxCommandEvent& event);
- void OnRemoveRow(wxCommandEvent& event);
- void OnRowSelect(wxListEvent& event);
- void OnFilterToggle(wxCommandEvent& event);
- void OnDragStart(wxListEvent& event);
-private:
- wxMenu * pluginMenu;
- wxButton * addBtn;
- wxButton * editBtn;
- wxButton * removeBtn;
- wxListView * pluginList;
- wxListView * reqsList;
- wxListView * incsList;
- wxListView * loadAfterList;
- MessageList * messageList;
- wxListView * tagsList;
- wxListView * dirtyList;
- wxNotebook * listBook;
- wxCheckBox * priorityCheckbox;
- wxSpinCtrl * prioritySpin;
- wxCheckBox * pluginCheckbox;
- wxCheckBox * filterCheckbox;
-
- wxPanel * reqsTab;
- wxPanel * incsTab;
- wxPanel * loadAfterTab;
- wxPanel * messagesTab;
- wxPanel * tagsTab;
- wxPanel * dirtyTab;
-
- void AddPluginToList(const loot::Plugin& plugin, int position);
-protected:
- const loot::Game& _game;
- const std::list _basePlugins;
- std::list _editedPlugins;
-
- loot::Plugin GetMasterData(const wxString& plugin) const;
- loot::Plugin GetUserData(const wxString& plugin) const;
- loot::Plugin GetNewData(const wxString& plugin) const;
-
- void ApplyEdits(const wxString& plugin);
- long FindPlugin(const wxString& plugin);
-
- loot::File RowToFile(wxListView * list, long row) const;
- loot::Tag RowToTag(wxListView * list, long row) const;
- loot::PluginDirtyInfo RowToPluginDirtyInfo(wxListView * list, long row) const;
-};
-
-class MiniEditor : public wxDialog {
-public:
- MiniEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const std::list& basePlugins, std::list& editedPlugins, const loot::Game& game);
-
- void OnApply(wxCommandEvent& event);
- void OnResize(wxSizeEvent& event);
-
- loot::MetadataList GetNewUserlist() const;
-private:
- EditorPanel * editorPanel;
- wxStaticText * descText;
-
- wxString feedbackText;
-};
-
-class FullEditor : public wxFrame {
-public:
- FullEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const boost::filesystem::path& userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game, YAML::Node &settings);
-
- void OnQuit(wxCommandEvent& event);
- void OnClose(wxCloseEvent &event);
-private:
- EditorPanel * editorPanel;
- wxButton * applyBtn;
- wxButton * cancelBtn;
-
- const boost::filesystem::path _userlistPath;
- YAML::Node& _settings;
-};
-#endif
diff --git a/src/gui/ids.cpp b/src/gui/ids.cpp
deleted file mode 100644
index 58b6e72b..00000000
--- a/src/gui/ids.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-
-#include "ids.h"
-
-#include
-
-wxString translate(const std::string& str) {
- return wxString::FromUTF8(boost::locale::translate(str).str().c_str());
-}
-
-wxString FromUTF8(const std::string& str) {
- return wxString::FromUTF8(str.c_str());
-}
-
-wxString FromUTF8(const boost::format& f) {
- return FromUTF8(f.str());
-}
\ No newline at end of file
diff --git a/src/gui/ids.h b/src/gui/ids.h
deleted file mode 100644
index 8230c7e2..00000000
--- a/src/gui/ids.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-
-#ifndef __LOOT_GUI_IDS__
-#define __LOOT_GUI_IDS__
-
-#include
-#include
-#include "wx/wxprec.h"
-
-#ifndef WX_PRECOMP
-# include "wx/wx.h"
-#endif
-
-
-enum {
- //Main window.
- OPTION_EditMetadata = wxID_HIGHEST + 1, // declares an id which will be used to call our button
- OPTION_ViewLastReport,
- OPTION_SortPlugins,
- MENU_ViewDebugLog,
- MENU_ShowSettings,
- MENU_RedatePlugins,
- //Settings window.
- LIST_Games,
- BUTTON_AddGame,
- BUTTON_EditGame,
- BUTTON_RemoveGame,
- //Editor window.
- LIST_Plugins,
- LIST_Reqs,
- LIST_Incs,
- LIST_LoadAfter,
- LIST_Messages,
- LIST_BashTags,
- LIST_DirtyInfo,
- LIST_MessageContent,
- BUTTON_AddRow,
- BUTTON_EditRow,
- BUTTON_RemoveRow,
- BUTTON_AddContent,
- BUTTON_EditContent,
- BUTTON_RemoveContent,
- BUTTON_Apply,
- BUTTON_Cancel,
- BOOK_Lists,
- MENU_CopyName,
- MENU_CopyMetadata,
- MENU_ClearPluginMetadata,
- MENU_ClearAllMetadata,
- CHECKBOX_Filter,
- //Main window - dynamically created IDs.
- MENU_LowestDynamicGameID,
-};
-
-wxString translate(const std::string& str);
-
-wxString FromUTF8(const std::string& str);
-
-wxString FromUTF8(const boost::format& f);
-
-#endif
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
deleted file mode 100644
index dfde8c53..00000000
--- a/src/gui/main.cpp
+++ /dev/null
@@ -1,890 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-#include "main.h"
-#include "settings.h"
-#include "editor.h"
-#include "viewer.h"
-#include "misc.h"
-
-#include "../backend/globals.h"
-#include "../backend/metadata.h"
-#include "../backend/parsers.h"
-#include "../backend/error.h"
-#include "../backend/helpers.h"
-#include "../backend/generators.h"
-#include "../backend/streams.h"
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-wxIMPLEMENT_APP(LOOT);
-
-using namespace loot;
-using namespace std;
-using boost::format;
-
-namespace fs = boost::filesystem;
-namespace loc = boost::locale;
-
-bool LOOT::OnInit() {
-
- //Check if GUI is already running.
- wxSingleInstanceChecker *checker = new wxSingleInstanceChecker;
-
- if (checker->IsAnotherRunning()) {
- wxMessageBox(
- translate("Error: LOOT is already running. This instance will now quit."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- delete checker; // OnExit() won't be called if we return false
- checker = nullptr;
-
- return false;
- }
-
- //Load settings.
- if (!fs::exists(g_path_settings)) {
- try {
- if (!fs::exists(g_path_settings.parent_path()))
- fs::create_directory(g_path_settings.parent_path());
- } catch (fs::filesystem_error& /*e*/) {
- wxMessageBox(
- translate("Error: Could not create local app data LOOT folder."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return false;
- }
- GenerateDefaultSettingsFile(g_path_settings.string());
- }
- try {
- loot::ifstream in(g_path_settings);
- _settings = YAML::Load(in);
- in.close();
- } catch (YAML::ParserException& e) {
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: Settings parsing failed. %1%")) % e.what()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return false;
- }
-
- //Set up logging.
- boost::log::add_file_log(
- boost::log::keywords::file_name = g_path_log.string().c_str(),
- boost::log::keywords::auto_flush = true,
- boost::log::keywords::format = (
- boost::log::expressions::stream
- << "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]"
- << " [" << boost::log::trivial::severity << "]: "
- << boost::log::expressions::smessage
- )
- );
- boost::log::add_common_attributes();
- if (_settings["Debug Verbosity"]) {
- unsigned int verbosity = _settings["Debug Verbosity"].as();
- if (verbosity == 0)
- boost::log::core::get()->set_logging_enabled(false);
- else {
- boost::log::core::get()->set_logging_enabled(true);
-
- if (verbosity == 1)
- boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning); //Log all warnings, errors and fatals.
- else if (verbosity == 2)
- boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug); //Log debugs, infos, warnings, errors and fatals.
- else
- boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace); //Log everything.
- }
- }
- BOOST_LOG_TRIVIAL(info) << "LOOT Version: " << g_version_major << "." << g_version_minor << "." << g_version_patch;
-
-
- //Set the locale to get encoding and language conversions working correctly.
- BOOST_LOG_TRIVIAL(debug) << "Initialising language settings.";
- //Defaults in case language string is empty or setting is missing.
- string localeId = loot::Language(loot::Language::english).Locale() + ".UTF-8";
- wxLanguage wxLang = wxLANGUAGE_ENGLISH;
- if (_settings["Language"]) {
- loot::Language lang(_settings["Language"].as());
- BOOST_LOG_TRIVIAL(debug) << "Selected language: " << lang.Name();
- localeId = lang.Locale() + ".UTF-8";
- if (lang.Code() == loot::Language::english)
- wxLang = wxLANGUAGE_ENGLISH;
- else if (lang.Code() == loot::Language::spanish)
- wxLang = wxLANGUAGE_SPANISH;
- else if (lang.Code() == loot::Language::russian)
- wxLang = wxLANGUAGE_RUSSIAN;
- else if (lang.Code() == loot::Language::french)
- wxLang = wxLANGUAGE_FRENCH;
- else if (lang.Code() == loot::Language::chinese)
- wxLang = wxLANGUAGE_CHINESE;
- else if (lang.Code() == loot::Language::polish)
- wxLang = wxLANGUAGE_POLISH;
- else if (lang.Code() == loot::Language::brazilian_portuguese)
- wxLang = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
- else if (lang.Code() == loot::Language::finnish)
- wxLang = wxLANGUAGE_FINNISH;
- else if (lang.Code() == loot::Language::german)
- wxLang = wxLANGUAGE_GERMAN;
- }
-
- //Boost.Locale initialisation: Specify location of language dictionaries.
- boost::locale::generator gen;
- gen.add_messages_path(g_path_l10n.string());
- gen.add_messages_domain("loot");
-
- //Boost.Locale initialisation: Generate and imbue locales.
- locale::global(gen(localeId));
- cout.imbue(locale());
- boost::filesystem::path::imbue(locale());
-
- //wxWidgets initalisation.
- if (wxLocale::IsAvailable(wxLang)) {
- BOOST_LOG_TRIVIAL(trace) << "Selected language is available, setting language file paths.";
- wxLoc = new wxLocale(wxLang);
-
- wxLocale::AddCatalogLookupPathPrefix(g_path_l10n.string().c_str());
-
- wxLoc->AddCatalog("wxstd");
-
- if (!wxLoc->IsOk()) {
- BOOST_LOG_TRIVIAL(error) << "Could not load translations.";
- wxMessageBox(
- translate("Error: Could not apply translation."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- }
- } else {
- wxLoc = new wxLocale(wxLANGUAGE_ENGLISH);
-
- BOOST_LOG_TRIVIAL(error) << "The selected language is not available on this system.";
- wxMessageBox(
- translate("Error: The selected language is not available on this system."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- }
-
- //Detect installed games.
- BOOST_LOG_TRIVIAL(debug) << "Detecting installed games.";
- try {
- _games = GetGames(_settings);
- } catch (YAML::Exception& e) {
- BOOST_LOG_TRIVIAL(error) << "Games' settings parsing failed. " << e.what();
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: Games' settings parsing failed. %1%")) % e.what()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return false;
- }
- catch (std::exception& e) {
- BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what();
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return false;
- }
-
- BOOST_LOG_TRIVIAL(debug) << "Selecting game.";
- string target;
-
- wxCmdLineEntryDesc cmdLineDesc[2];
- cmdLineDesc[0].kind = wxCMD_LINE_OPTION;
- cmdLineDesc[0].shortName = "g";
- cmdLineDesc[0].longName = "game";
- cmdLineDesc[0].description = "The folder name of the game to run for.";
- cmdLineDesc[0].type = wxCMD_LINE_VAL_STRING;
- cmdLineDesc[0].flags = wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_NEEDS_SEPARATOR;
- cmdLineDesc[1].kind = wxCMD_LINE_NONE;
-
- wxCmdLineParser parser(cmdLineDesc, argc, argv);
- wxString value;
- switch (parser.Parse()) {
- case -1:
- BOOST_LOG_TRIVIAL(info) << "Help was given.";
- break;
- case 0:
- if (parser.Found("game", &value))
- target = value.ToUTF8();
- break;
- default:
- BOOST_LOG_TRIVIAL(error) << "A command line syntax error was detected.";
- break;
- }
-
- size_t gameIndex(0);
- try {
- gameIndex = SelectGame(_settings, _games, target);
- }
- catch (exception &) {
- BOOST_LOG_TRIVIAL(error) << "None of the supported games were detected.";
- wxMessageBox(
- translate("Error: None of the supported games were detected."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return false;
- }
- BOOST_LOG_TRIVIAL(debug) << "Game selected is " << _games[gameIndex].Name();
-
- //Now that game is selected, initialise it.
- BOOST_LOG_TRIVIAL(debug) << "Initialising game-specific settings.";
- try {
- _games[gameIndex].Init();
- } catch (std::exception& e) {
- BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what();
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return false;
- }
-
- //Load window size/pos settings.
- wxSize size = wxDefaultSize;
- wxPoint pos = wxDefaultPosition;
- if (_settings["windows"] && _settings["windows"]["main"]) {
- YAML::Node node = _settings["windows"]["main"];
- if (node["width"] && node["height"] && node["xPos"] && node["yPos"]) {
- size = wxSize(node["width"].as(), node["height"].as());
- pos = wxPoint(node["xPos"].as(), node["yPos"].as());
-
- // Now check that those values are sensible given current screen dimensions.
- int screenX = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
- int screenY = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
- BOOST_LOG_TRIVIAL(trace) << "Current screen dimensions: " << screenX << "x" << screenY;
-
- if (size.GetHeight() > screenY || size.GetWidth() > screenX) {
- BOOST_LOG_TRIVIAL(trace) << "Previous window size is larger than primary screeen, using default size.";
- size = wxDefaultSize;
- }
- if (pos.x < 0 || pos.x > screenX || pos.y < 0 || pos.y > screenY) {
- BOOST_LOG_TRIVIAL(trace) << "Previous window position lies outside primary screeen, using default position.";
- pos = wxDefaultPosition;
- }
- }
- }
-
- //Create launcher window.
- BOOST_LOG_TRIVIAL(debug) << "Opening the main LOOT window.";
- Launcher * launcher = new Launcher(wxT("LOOT"), _settings, _games, gameIndex, pos, size);
-
- launcher->SetIcon(wxIconLocation("LOOT.exe"));
- launcher->Show();
- SetTopWindow(launcher);
-
- return true;
-}
-
-Launcher::Launcher(const wxChar *title, YAML::Node& settings, vector& games, size_t currentGame, wxPoint pos, wxSize size) : wxFrame(nullptr, wxID_ANY, title, pos, size), _settings(settings), _games(games), _currentGame(currentGame) {
-
- //Initialise menu items.
- wxMenuBar * MenuBar = new wxMenuBar();
- wxMenu * FileMenu = new wxMenu();
- wxMenu * EditMenu = new wxMenu();
- GameMenu = new wxMenu();
- 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"));
- ViewButton = new wxButton(this,OPTION_ViewLastReport, translate("View Last Report"));
-
- //Construct menus.
- //File Menu
- FileMenu->Append(OPTION_ViewLastReport, translate("&View Last Report"));
- FileMenu->Append(MENU_ViewDebugLog, translate("View &Debug Log"));
- FileMenu->Append(OPTION_SortPlugins, translate("&Sort Plugins"));
- RedatePluginsItem = FileMenu->Append(MENU_RedatePlugins, translate("&Redate Plugins"));
- FileMenu->AppendSeparator();
- FileMenu->Append(wxID_EXIT);
- MenuBar->Append(FileMenu, translate("&File"));
- //Edit Menu
- EditMenu->Append(OPTION_EditMetadata, translate("&Metadata..."));
- EditMenu->Append(MENU_ShowSettings, translate("&Settings..."));
- MenuBar->Append(EditMenu, translate("&Edit"));
- //Game menu - set up initial item states here too.
- for (size_t i=0,max=_games.size(); i < max; ++i) {
- wxMenuItem * item = GameMenu->AppendRadioItem(MENU_LowestDynamicGameID + i, FromUTF8(_games[i].Name()));
- if (_games[_currentGame] == _games[i])
- item->Check();
-
- if (_games[i].IsInstalled())
- Bind(wxEVT_MENU, &Launcher::OnGameChange, this, MENU_LowestDynamicGameID + i);
- else
- item->Enable(false);
- }
- MenuBar->Append(GameMenu, translate("&Game"));
- //About menu
- HelpMenu->Append(wxID_HELP);
- HelpMenu->AppendSeparator();
- HelpMenu->Append(wxID_ABOUT);
- MenuBar->Append(HelpMenu, translate("&Help"));
-
- //Set up layout.
- wxBoxSizer *buttonBox = new wxBoxSizer(wxVERTICAL);
- buttonBox->Add(EditButton, 1, wxEXPAND|wxALIGN_CENTRE|wxALL, 10);
- buttonBox->Add(SortButton, 1, wxEXPAND|wxALIGN_CENTRE|wxLEFT|wxRIGHT, 10);
- buttonBox->Add(ViewButton, 1, wxEXPAND|wxALIGN_CENTRE|wxALL, 10);
-
- //Bind event handlers.
- Bind(wxEVT_MENU, &Launcher::OnQuit, this, wxID_EXIT);
- Bind(wxEVT_MENU, &Launcher::OnViewLastReport, this, OPTION_ViewLastReport);
- Bind(wxEVT_MENU, &Launcher::OnOpenDebugLog, this, MENU_ViewDebugLog);
- Bind(wxEVT_MENU, &Launcher::OnSortPlugins, this, OPTION_SortPlugins);
- Bind(wxEVT_MENU, &Launcher::OnEditMetadata, this, OPTION_EditMetadata);
- Bind(wxEVT_MENU, &Launcher::OnRedatePlugins, this, MENU_RedatePlugins);
- Bind(wxEVT_MENU, &Launcher::OnOpenSettings, this, MENU_ShowSettings);
- Bind(wxEVT_MENU, &Launcher::OnHelp, this, wxID_HELP);
- Bind(wxEVT_MENU, &Launcher::OnAbout, this, wxID_ABOUT);
- Bind(wxEVT_BUTTON, &Launcher::OnSortPlugins, this, OPTION_SortPlugins);
- Bind(wxEVT_BUTTON, &Launcher::OnEditMetadata, this, OPTION_EditMetadata);
- Bind(wxEVT_BUTTON, &Launcher::OnViewLastReport, this, OPTION_ViewLastReport);
- Bind(wxEVT_CLOSE_WINDOW, &Launcher::OnClose, this);
-
- //Set up tooltips.
- EditButton->SetToolTip(translate("Opens the Metadata Editor, where plugins' sorting metadata, messages, dirty info and Bash Tag suggestions can be edited."));
- SortButton->SetToolTip(translate("Sorts your plugins, then displays a report of the results."));
- ViewButton->SetToolTip(translate("Opens the last report generated for the current game."));
-
- //Set up initial state.
- SortButton->SetDefault();
-
- if (!fs::exists(g_path_report))
- ViewButton->Enable(false);
-
- if (_games[_currentGame].Id() == loot::Game::tes5)
- RedatePluginsItem->Enable(true);
- else
- RedatePluginsItem->Enable(false);
-
- //Set title bar text.
- SetTitle(FromUTF8("LOOT - " + _games[_currentGame].Name()));
-
- //Now set the layout and sizes.
- SetMenuBar(MenuBar);
- SetBackgroundColour(wxColour(255,255,255));
- SetSizerAndFit(buttonBox);
-
- if (size != wxDefaultSize)
- SetSize(size);
- else
- SetSize(wxSize(250, 200));
-
- SortButton->SetFocus();
-}
-
-//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) {
- BOOST_LOG_TRIVIAL(debug) << "Quiting LOOT.";
-
- //Record window settings.
- YAML::Node main;
- main["height"] = GetSize().GetHeight();
- main["width"] = GetSize().GetWidth();
- main["xPos"] = GetPosition().x;
- main["yPos"] = GetPosition().y;
-
- _settings["windows"]["main"] = main;
-
- //Record game settings.
- _settings["Last Game"] = _games[_currentGame].FolderName();
- _settings["Games"] = _games;
-
- //Save settings.
- try {
- BOOST_LOG_TRIVIAL(debug) << "Saving LOOT settings.";
- YAML::Emitter yout;
- yout.SetIndent(2);
- yout << _settings;
-
- loot::ofstream out(loot::g_path_settings);
- out << yout.c_str();
- out.close();
- }
- catch (std::exception &e) {
- BOOST_LOG_TRIVIAL(error) << "Failed to save LOOT's settings. Error: " << e.what();
- }
-
- Destroy();
-}
-
-void Launcher::OnViewLastReport(wxCommandEvent& event) {
- //Load window size/pos settings.
- wxSize size = wxDefaultSize;
- wxPoint pos = wxDefaultPosition;
- if (_settings["windows"] && _settings["windows"]["viewer"]) {
- GetWindowSizePos(_settings["windows"]["viewer"], pos, size);
- }
- //Create viewer window.
- BOOST_LOG_TRIVIAL(debug) << "Opening viewer window...";
- Viewer *viewer = new Viewer(this, translate("LOOT: Report Viewer"), FromUTF8(ToFileURL(g_path_report.string() + "?data=" + _games[_currentGame].ReportDataPath().string())), pos, size, _settings);
- viewer->Show();
- BOOST_LOG_TRIVIAL(debug) << "Report displayed.";
-}
-
-void Launcher::OnOpenSettings(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Opening settings window...";
-
- //Load window size/pos settings.
- wxSize size = wxDefaultSize;
- wxPoint pos = wxDefaultPosition;
- if (_settings["windows"] && _settings["windows"]["settings"]) {
- GetWindowSizePos(_settings["windows"]["settings"], pos, size);
- }
-
- SettingsFrame settings = SettingsFrame(this, translate("LOOT: Settings"), _settings, _games, _currentGame, pos, size);
- BOOST_LOG_TRIVIAL(debug) << "Settings window opened.";
- settings.ShowModal();
-
- //Record window settings.
- YAML::Node node;
- node["height"] = settings.GetSize().GetHeight();
- node["width"] = settings.GetSize().GetWidth();
- node["xPos"] = settings.GetPosition().x;
- node["yPos"] = settings.GetPosition().y;
-
- _settings["windows"]["settings"] = node;
-
- // Clear existing games menu items.
- for (size_t i = 0, max = GameMenu->GetMenuItemCount(); i < max; ++i) {
- GameMenu->Delete(MENU_LowestDynamicGameID + i);
- }
- // Fill games list again.
- for (size_t i = 0, max = _games.size(); i < max; ++i) {
- wxMenuItem * item = GameMenu->AppendRadioItem(MENU_LowestDynamicGameID + i, FromUTF8(_games[i].Name()));
- if (_games[_currentGame] == _games[i])
- item->Check();
-
- if (_games[i].IsInstalled())
- Bind(wxEVT_MENU, &Launcher::OnGameChange, this, MENU_LowestDynamicGameID + i);
- else
- item->Enable(false);
- }
-
-}
-
-void Launcher::OnGameChange(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Changing current game...";
- _currentGame = event.GetId() - MENU_LowestDynamicGameID;
- try {
- _games[_currentGame].Init(); //In case it hasn't already been done.
- BOOST_LOG_TRIVIAL(debug) << "New game is " << _games[_currentGame].Name();
- }
- catch (std::exception& e) {
- BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised." << e.what();
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- }
- SetTitle(FromUTF8("LOOT - " + _games[_currentGame].Name()));
- if (_games[_currentGame].Id() == loot::Game::tes5)
- RedatePluginsItem->Enable(true);
- else
- RedatePluginsItem->Enable(false);
-}
-
-void Launcher::OnHelp(wxCommandEvent& event) {
- //Look for file.
- BOOST_LOG_TRIVIAL(debug) << "Opening readme at: " << g_path_readme;
- if (fs::exists(g_path_readme)) {
- wxLaunchDefaultBrowser(FromUTF8(ToFileURL(g_path_readme.string())));
- }
- else { //No readme exists, show a pop-up message saying so.
- BOOST_LOG_TRIVIAL(error) << "File \"" << g_path_readme.string() << "\" could not be found.";
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: \"%1%\" cannot be found.")) % g_path_readme.string()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- }
-}
-
-void Launcher::OnOpenDebugLog(wxCommandEvent& event) {
- //Look for file.
- BOOST_LOG_TRIVIAL(debug) << "Opening debug log at: " << g_path_log;
- if (fs::exists(g_path_log)) {
- wxLaunchDefaultApplication(FromUTF8(g_path_log.string()));
- }
- else { //No log exists, show a pop-up message saying so.
- BOOST_LOG_TRIVIAL(error) << "File \"" << g_path_log.string() << "\" could not be found.";
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: \"%1%\" cannot be found.")) % g_path_log.string()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- }
-}
-
-void Launcher::OnAbout(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Opening About dialog.";
- wxAboutDialogInfo aboutInfo;
- aboutInfo.SetName("LOOT");
- aboutInfo.SetVersion(to_string(g_version_major) + "." + to_string(g_version_minor) + "." + to_string(g_version_patch));
- aboutInfo.SetDescription(translate("Load order optimisation for Oblivion, Skyrim, Fallout 3 and Fallout: New Vegas."));
- aboutInfo.SetCopyright("Copyright (C) 2012-2014 LOOT Team.");
- aboutInfo.SetWebSite("http://loot.github.io");
- aboutInfo.SetLicence("This program is free software: you can redistribute it and/or modify\n"
- "it under the terms of the GNU General Public License as published by\n"
- "the Free Software Foundation, either version 3 of the License, or\n"
- "(at your option) any later version.\n"
- "\n"
- "This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
- "GNU General Public License for more details.\n"
- "\n"
- "You should have received a copy of the GNU General Public License\n"
- "along with this program. If not, see .");
- aboutInfo.SetIcon(wxIconLocation("LOOT.exe"));
- wxAboutBox(aboutInfo);
-}
-
-void Launcher::OnSortPlugins(wxCommandEvent& event) {
-
- BOOST_LOG_TRIVIAL(debug) << "Beginning sorting process.";
-
- list messages;
- unsigned int lang;
-
- wxProgressDialog *progDia = new wxProgressDialog(translate("LOOT: Working..."), translate("LOOT working..."), 1000, this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_ELAPSED_TIME);
-
- function progressCallback([progDia](const std::string& message) {
- progDia->Pulse(FromUTF8(message));
- });
-
- //Set language.
- if (_settings["Language"])
- lang = Language(_settings["Language"].as()).Code();
- else
- lang = loot::Language::any;
-
- BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(lang).Name();
-
- ///////////////////////////////////////////////////////
- // Load Plugins & Lists
- ///////////////////////////////////////////////////////
-
- _games[_currentGame].SortPrep(lang, messages, progressCallback);
-
- ///////////////////////////////////////////////////////
- // Build Graph Edges & Sort
- ///////////////////////////////////////////////////////
-
- /* Need to loop this section. There are 3 ways to exit the loop:
-
- 1. Accept the load order at the preview with no changes.
- 2. Cancel at the preview.
- 3. Cancel making changes.
-
- Otherwise, the sorting must loop.
-
- */
-
- list plugins;
- try {
- bool applyLoadOrder = false;
-
- do {
-
- // Perform sort.
- plugins = _games[_currentGame].Sort(lang, messages, progressCallback);
-
- progDia->Destroy();
- progDia = nullptr;
-
- BOOST_LOG_TRIVIAL(info) << "Displaying load order preview.";
-
- //Load window size/pos settings.
- wxSize size = wxDefaultSize;
- wxPoint pos = wxDefaultPosition;
- if (_settings["windows"] && _settings["windows"]["editor"]) {
- GetWindowSizePos(_settings["windows"]["editor"], pos, size);
- }
-
- // Display mini editor.
- MiniEditor editor(this, translate("LOOT: Calculated Load Order"), pos, size, plugins, _games[_currentGame].userlist.plugins, _games[_currentGame]);
-
- long ret = editor.ShowModal();
- MetadataList newUserlist = editor.GetNewUserlist();
-
- //Record window settings.
- YAML::Node node;
- node["height"] = editor.GetSize().GetHeight();
- node["width"] = editor.GetSize().GetWidth();
- node["xPos"] = editor.GetPosition().x;
- node["yPos"] = editor.GetPosition().y;
-
- _settings["windows"]["editor"] = node;
-
- if (ret != wxID_APPLY) {
- applyLoadOrder = false;
- break;
- }
- else if (_games[_currentGame].userlist == newUserlist) {
- applyLoadOrder = true;
- break;
- }
- else {
- //Recreate progress dialog.
- progDia = new wxProgressDialog(translate("LOOT: Working..."), translate("Recalculating load order..."), 1000, this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_ELAPSED_TIME);
-
- //User accepted edits, now apply them, then loop.
- _games[_currentGame].userlist = newUserlist;
-
- //Save edits to userlist.
- _games[_currentGame].userlist.Save(_games[_currentGame].UserlistPath());
-
- //Now loop.
- }
- } while (true);
-
- if (applyLoadOrder) {
- //Applying the load order.
- BOOST_LOG_TRIVIAL(debug) << "Setting load order.";
- try {
- _games[_currentGame].SetLoadOrder(plugins);
- }
- catch (std::exception& e) {
- BOOST_LOG_TRIVIAL(error) << "Failed to set the load order. Details: " << e.what();
- messages.push_back(loot::Message(loot::Message::error, (format(loc::translate("Failed to set the load order. Details: %1%")) % e.what()).str()));
- }
- BOOST_LOG_TRIVIAL(info) << "Load order set:";
- for (const auto &plugin: plugins) {
- BOOST_LOG_TRIVIAL(info) << '\t' << plugin.Name();
- }
- }
- else {
- //User decided to cancel sorting. Just go straight to displaying the report.
- BOOST_LOG_TRIVIAL(info) << "The load order calculated was not applied as sorting was canceled.";
- messages.push_back(loot::Message(loot::Message::warn, loc::translate("The load order displayed in the Details tab was not applied as sorting was canceled.")));
- }
-
- } catch (std::exception& e) {
- BOOST_LOG_TRIVIAL(error) << "Failed to calculate the load order. Details: " << e.what();
- messages.push_back(loot::Message(loot::Message::error, (format(loc::translate("Failed to calculate the load order. Details: %1%")) % e.what()).str()));
-
- progDia->Destroy();
- progDia = nullptr;
- }
-
- ///////////////////////////////////////////////////////
- // Build & Display Report
- ///////////////////////////////////////////////////////
-
- BOOST_LOG_TRIVIAL(debug) << "Generating report...";
- try {
- GenerateReportData(_games[_currentGame],
- messages,
- plugins,
- _games[_currentGame].masterlist.GetRevision(_games[_currentGame].MasterlistPath()),
- _games[_currentGame].masterlist.GetDate(_games[_currentGame].MasterlistPath()),
- true);
- } catch (std::exception& e) {
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: %1%")) % e.what()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- if (progDia != nullptr)
- progDia->Destroy();
- return;
- }
-
- //Now a results report definitely exists.
- ViewButton->Enable(true);
-
- BOOST_LOG_TRIVIAL(debug) << "Displaying report...";
- //Load window size/pos settings.
- wxSize size = wxDefaultSize;
- wxPoint pos = wxDefaultPosition;
- if (_settings["windows"] && _settings["windows"]["viewer"]) {
- GetWindowSizePos(_settings["windows"]["viewer"], pos, size);
- }
-
- //Create viewer window.
- Viewer *viewer = new Viewer(this, translate("LOOT: Report Viewer"), FromUTF8(ToFileURL(g_path_report.string() + "?data=" + _games[_currentGame].ReportDataPath().string())), pos, size, _settings);
- viewer->Show();
-
- BOOST_LOG_TRIVIAL(debug) << "Report display successful. Sorting process complete.";
-}
-
-void Launcher::OnEditMetadata(wxCommandEvent& event) {
-
- //Should probably check for masterlist updates before opening metadata editor.
- list installed;
- unsigned int lang;
-
- wxProgressDialog *progDia = new wxProgressDialog(translate("LOOT: Working..."), translate("LOOT working..."), 1000, this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_ELAPSED_TIME);
-
- //Set language.
- if (_settings["Language"])
- lang = Language(_settings["Language"].as()).Code();
- else
- lang = loot::Language::any;
-
- //Scan for installed plugins.
- BOOST_LOG_TRIVIAL(debug) << "Reading installed plugins' headers.";
- _games[_currentGame].LoadPlugins(true);
- //Sort plugins into their load order.
- list loadOrder;
- _games[_currentGame].GetLoadOrder(loadOrder);
- for (const auto &pluginName: loadOrder) {
- const auto pos = _games[_currentGame].plugins.find(pluginName);
-
- if (pos != _games[_currentGame].plugins.end())
- installed.push_back(pos->second);
- }
-
- //Parse masterlist.
- if (fs::exists(_games[_currentGame].MasterlistPath())) {
- BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist.";
- _games[_currentGame].masterlist.Load(_games[_currentGame], lang);
- }
-
- progDia->Pulse();
-
- //Parse userlist.
- if (fs::exists(_games[_currentGame].UserlistPath())) {
- BOOST_LOG_TRIVIAL(debug) << "Parsing userlist.";
- _games[_currentGame].userlist.Load(_games[_currentGame].UserlistPath());
- }
-
- progDia->Pulse();
-
- //Merge the masterlist down into the installed mods list.
- BOOST_LOG_TRIVIAL(debug) << "Merging the masterlist down into the installed mods list.";
- for (const auto &plugin: _games[_currentGame].masterlist.plugins) {
- auto pos = find(installed.begin(), installed.end(), plugin);
-
- if (pos != installed.end())
- pos->MergeMetadata(plugin);
- }
-
- progDia->Pulse();
-
- //Add empty entries for any userlist entries that aren't installed.
- BOOST_LOG_TRIVIAL(debug) << "Padding the installed mods list to match the plugins in the userlist.";
- for (const auto &plugin : _games[_currentGame].userlist.plugins) {
- if (find(installed.begin(), installed.end(), plugin) == installed.end())
- installed.push_back(loot::Plugin(plugin.Name()));
- }
-
- progDia->Pulse();
-
- //Load window size/pos settings.
- wxSize size = wxDefaultSize;
- wxPoint pos = wxDefaultPosition;
- if (_settings["windows"] && _settings["windows"]["editor"]) {
- GetWindowSizePos(_settings["windows"]["editor"], pos, size);
- }
-
- //Create editor window.
- BOOST_LOG_TRIVIAL(debug) << "Opening editor window.";
- FullEditor *editor = new FullEditor(this, translate("LOOT: Metadata Editor"), pos, size, _games[_currentGame].UserlistPath().string(), installed, _games[_currentGame].userlist.plugins, lang, _games[_currentGame], _settings);
-
- progDia->Destroy();
-
- editor->Show();
- BOOST_LOG_TRIVIAL(debug) << "Editor window opened.";
-}
-
-void Launcher::OnRedatePlugins(wxCommandEvent& event) {
- wxMessageDialog * dia = new wxMessageDialog(this, translate("This feature is provided so that modders using the Creation Kit may set the load order it uses. A side-effect is that any subscribed Steam Workshop mods will be re-downloaded by Steam. Do you wish to continue?"), translate("LOOT: Warning"), wxYES_NO|wxCANCEL|wxICON_EXCLAMATION);
-
- if (dia->ShowModal() == wxID_YES) {
- BOOST_LOG_TRIVIAL(debug) << "Redating plugins.";
- try {
- _games[_currentGame].RedatePlugins();
- } catch (std::exception& e) {
- BOOST_LOG_TRIVIAL(error) << "Failed to redate plugins. " << e.what();
- wxMessageBox(
- FromUTF8(format(loc::translate("Error: Failed to redate plugins. %1%")) % e.what()),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- }
-
- wxMessageBox(
- translate("Plugins were successfully redated."),
- translate("LOOT: Plugin Redate"),
- wxOK|wxCENTRE,
- this);
- }
-}
-
-void Launcher::GetWindowSizePos(const YAML::Node& node, wxPoint& pos, wxSize& size) {
- if (node["width"] && node["height"] && node["xPos"] && node["yPos"]) {
- size = wxSize(node["width"].as(), node["height"].as());
- pos = wxPoint(node["xPos"].as(), node["yPos"].as());
-
- // Now check that those values are sensible given current screen dimensions.
- int screenX = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
- int screenY = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
- BOOST_LOG_TRIVIAL(trace) << "Current screen dimensions: " << screenX << "x" << screenY;
-
- if (size.GetHeight() > screenY || size.GetWidth() > screenX) {
- BOOST_LOG_TRIVIAL(trace) << "Previous window size is larger than primary screeen, using default size.";
- size = wxDefaultSize;
- }
- if (pos.x < 0 || pos.x > screenX || pos.y < 0 || pos.y > screenY) {
- BOOST_LOG_TRIVIAL(trace) << "Previous window position lies outside primary screeen, using default position.";
- pos = wxDefaultPosition;
- }
- }
- else {
- size = wxDefaultSize;
- pos = wxDefaultPosition;
- }
-}
\ No newline at end of file
diff --git a/src/gui/main.h b/src/gui/main.h
deleted file mode 100644
index ea646ca3..00000000
--- a/src/gui/main.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-
-#ifndef __LOOT_GUI_MAIN__
-#define __LOOT_GUI_MAIN__
-
-#include "ids.h"
-#include "../backend/game.h"
-
-#include
-#include
-#include
-
-//Program class.
-class LOOT : public wxApp {
-public:
- bool OnInit(); //Load settings, apply logging and language settings, check if LOOT is already running, detect games, set game to last game or to first detected game if auto, create launcher window.
-private:
- wxLocale * wxLoc;
-
- YAML::Node _settings;
- std::vector _games;
-};
-
-class Launcher : public wxFrame {
-public:
- Launcher(const wxChar *title, YAML::Node& settings, std::vector& games, size_t currentGame, wxPoint pos, wxSize size);
-
- void OnSortPlugins(wxCommandEvent& event);
- void OnEditMetadata(wxCommandEvent& event);
- void OnViewLastReport(wxCommandEvent& event);
- void OnRedatePlugins(wxCommandEvent& event);
-
- void OnOpenSettings(wxCommandEvent& event);
- void OnOpenDebugLog(wxCommandEvent& event);
- void OnGameChange(wxCommandEvent& event);
- void OnHelp(wxCommandEvent& event);
- void OnAbout(wxCommandEvent& event);
- void OnQuit(wxCommandEvent& event);
-
- void OnClose(wxCloseEvent& event);
-private:
- wxMenu * GameMenu;
- wxMenuItem * RedatePluginsItem;
- wxButton * ViewButton;
-
- YAML::Node& _settings; //LOOT Settings.
- std::vector& _games;
- size_t _currentGame;
-
- void GetWindowSizePos(const YAML::Node& node, wxPoint& pos, wxSize& size);
-};
-
-#endif
diff --git a/src/gui/misc.cpp b/src/gui/misc.cpp
deleted file mode 100644
index b0d97998..00000000
--- a/src/gui/misc.cpp
+++ /dev/null
@@ -1,481 +0,0 @@
-/* LOOT
-
-A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
-Copyright (C) 2013-2014 WrinklyNinja
-
-This file is part of LOOT.
-
-LOOT is free software: you can redistribute
-it and/or modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation, either version 3 of
-the License, or (at your option) any later version.
-
-LOOT is distributed in the hope that it will
-be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with LOOT. If not, see
-.
-*/
-
-#include "misc.h"
-#include "../backend/helpers.h"
-
-#include
-
-
-
-using namespace std;
-
-MessageList::MessageList(wxWindow * parent, wxWindowID id, const unsigned int language) : wxListView(parent, id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL | wxLC_SINGLE_SEL), _language(language) {
- InsertColumn(0, translate("Type"));
- InsertColumn(1, translate("Content"));
- InsertColumn(2, translate("Condition"));
- InsertColumn(3, translate("Language"));
-
- Bind(wxEVT_LIST_DELETE_ITEM, &MessageList::OnDeleteItem, this);
-
- SetItemCount(0);
-}
-
-std::vector MessageList::GetItems() const {
- return _messages;
-}
-
-void MessageList::SetItems(const std::vector& messages) {
- _messages = messages;
- SetItemCount(_messages.size());
- RefreshItems(0, _messages.size() - 1);
-}
-
-loot::Message MessageList::GetItem(long item) const {
- return _messages[item];
-}
-
-void MessageList::SetItem(long item, const loot::Message& message) {
- _messages[item] = message;
- RefreshItem(item);
-}
-
-void MessageList::AppendItem(const loot::Message& message) {
- _messages.push_back(message);
- SetItemCount(_messages.size());
- RefreshItem(_messages.size() - 1);
-}
-
-void MessageList::OnDeleteItem(wxListEvent& event) {
- _messages.erase(_messages.begin() + event.GetIndex());
- SetItemCount(_messages.size());
- RefreshItems(event.GetIndex(), _messages.size() - 1);
-}
-
-wxString MessageList::OnGetItemText(long item, long column) const {
- if (column < 0 || column > 3 || item < 0 || item > _messages.size() - 1)
- return wxString();
-
- if (column == 0) {
- if (_messages[item].Type() == loot::Message::say)
- return Type[0];
- else if (_messages[item].Type() == loot::Message::warn)
- return Type[1];
- else
- return Type[2];
- }
- else if (column == 1) {
- return FromUTF8(_messages[item].ChooseContent(_language).Str());
- }
- else if (column == 2) {
- return FromUTF8(_messages[item].Condition());
- }
- else {
- return FromUTF8(loot::Language(_messages[item].ChooseContent(_language).Language()).Name());
- }
-}
-
-
-FileEditDialog::FileEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
-
- _name = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY));
- _display = new wxTextCtrl(this, wxID_ANY);
- _condition = new wxTextCtrl(this, wxID_ANY);
-
- wxSizerFlags leftItem(0);
- leftItem.Left();
-
- wxSizerFlags rightItem(1);
- rightItem.Right().Expand();
-
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5);
- GridSizer->AddGrowableCol(1, 1);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Filename (required):")), leftItem);
- GridSizer->Add(_name, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Displayed Name:")), leftItem);
- GridSizer->Add(_display, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Condition:")), leftItem);
- GridSizer->Add(_condition, rightItem);
-
- bigBox->Add(GridSizer, 0, wxEXPAND | wxALL, 15);
-
- bigBox->AddSpacer(10);
- bigBox->AddStretchSpacer(1);
-
- //Need to add 'OK' and 'Cancel' buttons.
- wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
- if (sizer != nullptr)
- bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15);
-
- SetBackgroundColour(wxColour(255, 255, 255));
- SetIcon(wxIconLocation("LOOT.exe"));
- SetSizerAndFit(bigBox);
-}
-
-void FileEditDialog::SetValues(const wxString& name, const wxString& display, const wxString& condition) {
-
- _name->SetValue(name);
- _display->SetValue(display);
- _condition->SetValue(condition);
-}
-
-wxString FileEditDialog::GetName() const {
- return _name->GetValue();
-}
-
-wxString FileEditDialog::GetDisplayName() const {
- return _display->GetValue();
-}
-
-wxString FileEditDialog::GetCondition() const {
- return _condition->GetValue();
-}
-
-MessageEditDialog::MessageEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
-
- wxArrayString languages;
- vector langs = loot::Language::Names();
- for (size_t i = 0; i < langs.size(); i++) {
- languages.Add(FromUTF8(langs[i]));
- }
-
- //Initialise controls.
- _type = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 3, Type);
- _language = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, languages);
-
- _condition = new wxTextCtrl(this, wxID_ANY);
- _str = new wxTextCtrl(this, wxID_ANY);
-
- _content = new wxListView(this, LIST_MessageContent, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
-
- addBtn = new wxButton(this, BUTTON_AddContent, translate("Add Content"));
- editBtn = new wxButton(this, BUTTON_EditContent, translate("Edit Content"));
- removeBtn = new wxButton(this, BUTTON_RemoveContent, translate("Remove Content"));
-
- _content->InsertColumn(0, translate("Language"));
- _content->InsertColumn(1, translate("String"));
-
- //Set up event handling.
- Bind(wxEVT_BUTTON, &MessageEditDialog::OnAdd, this, BUTTON_AddContent);
- Bind(wxEVT_BUTTON, &MessageEditDialog::OnEdit, this, BUTTON_EditContent);
- Bind(wxEVT_BUTTON, &MessageEditDialog::OnRemove, this, BUTTON_RemoveContent);
- Bind(wxEVT_LIST_ITEM_SELECTED, &MessageEditDialog::OnSelect, this, LIST_MessageContent);
-
- wxSizerFlags leftItem(0);
- leftItem.Left();
-
- wxSizerFlags rightItem(1);
- rightItem.Right();
-
- wxSizerFlags wholeItem(0);
- wholeItem.Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 15);
-
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5);
- GridSizer->AddGrowableCol(1, 1);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Type:")), leftItem);
- GridSizer->Add(_type, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Condition:")), leftItem);
- GridSizer->Add(_condition, rightItem);
-
- bigBox->AddSpacer(15);
-
- bigBox->Add(GridSizer, wholeItem);
-
- bigBox->Add(_content, wholeItem);
-
- wxFlexGridSizer * GridSizer2 = new wxFlexGridSizer(2, 5, 5);
- GridSizer2->AddGrowableCol(1, 1);
-
- GridSizer2->Add(new wxStaticText(this, wxID_ANY, translate("Language:")), leftItem);
- GridSizer2->Add(_language, rightItem);
-
- GridSizer2->Add(new wxStaticText(this, wxID_ANY, translate("Content:")), leftItem);
- GridSizer2->Add(_str, rightItem);
-
- bigBox->Add(GridSizer2, wholeItem);
-
- wxBoxSizer * hbox = new wxBoxSizer(wxHORIZONTAL);
- hbox->Add(addBtn, 0, wxRIGHT, 5);
- hbox->Add(editBtn, 0, wxLEFT | wxRIGHT, 5);
- hbox->Add(removeBtn, 0, wxLEFT, 5);
- bigBox->Add(hbox, 0, wxALIGN_RIGHT | wxLEFT | wxRIGHT, 15);
-
- bigBox->AddSpacer(10);
- bigBox->AddStretchSpacer(1);
-
- //Need to add 'OK' and 'Cancel' buttons.
- wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
- if (sizer != nullptr)
- bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15);
-
- //Set defaults.
- _type->SetSelection(0);
- _language->SetSelection(0);
- editBtn->Enable(false);
- removeBtn->Enable(false);
-
- SetBackgroundColour(wxColour(255, 255, 255));
- SetIcon(wxIconLocation("LOOT.exe"));
- SetSizerAndFit(bigBox);
-}
-
-void MessageEditDialog::SetMessage(const loot::Message& message) {
-
- if (message.Type() == loot::Message::say)
- _type->SetSelection(0);
- else if (message.Type() == loot::Message::warn)
- _type->SetSelection(1);
- else
- _type->SetSelection(2);
-
- _condition->SetValue(FromUTF8(message.Condition()));
-
- vector contents = message.Content();
- for (size_t i = 0, max = contents.size(); i < max; ++i) {
- _content->InsertItem(i, FromUTF8(loot::Language(contents[i].Language()).Name()));
- _content->SetItem(i, 1, FromUTF8(contents[i].Str()));
- }
-}
-
-loot::Message MessageEditDialog::GetMessage() const {
-
- unsigned int type;
- string condition;
- if (_type->GetSelection() == 0)
- type = loot::Message::say;
- else if (_type->GetSelection() == 1)
- type = loot::Message::warn;
- else
- type = loot::Message::error;
-
- condition = string(_condition->GetValue().ToUTF8());
-
- vector contents;
- for (size_t i = 0, max = _content->GetItemCount(); i < max; ++i) {
-
- string str = string(_content->GetItemText(i, 1).ToUTF8());
- unsigned int lang = loot::Language(string(_content->GetItemText(i, 0).ToUTF8())).Code();
-
- contents.push_back(loot::MessageContent(str, lang));
- }
-
- return loot::Message(type, contents, condition);
-}
-
-void MessageEditDialog::OnSelect(wxListEvent& event) {
- _language->SetSelection(loot::Language(string(_content->GetItemText(event.GetIndex(), 0).ToUTF8())).Code());
- _str->SetValue(_content->GetItemText(event.GetIndex(), 1));
- editBtn->Enable(true);
- removeBtn->Enable(true);
-}
-
-void MessageEditDialog::OnAdd(wxCommandEvent& event) {
- long i = _content->GetItemCount();
- _content->InsertItem(i, FromUTF8(loot::Language(_language->GetSelection()).Name()));
- _content->SetItem(i, 1, _str->GetValue());
-}
-
-void MessageEditDialog::OnEdit(wxCommandEvent& event) {
- if (_content->GetFirstSelected() == -1) {
- BOOST_LOG_TRIVIAL(error) << "Attempting to edit message content, but no content row selected.";
- wxMessageBox(
- translate("Error: No content row selected."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return;
- }
- long i = _content->GetFirstSelected();
- _content->SetItem(i, 0, FromUTF8(loot::Language(_language->GetSelection()).Name()));
- _content->SetItem(i, 1, _str->GetValue());
-}
-
-void MessageEditDialog::OnRemove(wxCommandEvent& event) {
- if (_content->GetFirstSelected() == -1) {
- BOOST_LOG_TRIVIAL(error) << "Attempting to remove message content, but no content row selected.";
- wxMessageBox(
- translate("Error: No content row selected."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- nullptr);
- return;
- }
- _content->DeleteItem(_content->GetFirstSelected());
- editBtn->Enable(false);
- removeBtn->Enable(false);
-}
-
-TagEditDialog::TagEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
-
- //Initialise controls.
- _state = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 2, State);
-
- _name = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY));
- _condition = new wxTextCtrl(this, wxID_ANY);
-
- wxSizerFlags leftItem(0);
- leftItem.Left();
-
- wxSizerFlags rightItem(1);
- rightItem.Right().Expand();
-
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5);
- GridSizer->AddGrowableCol(1, 1);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Add/Remove:")), leftItem);
- GridSizer->Add(_state, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Name (required):")), leftItem);
- GridSizer->Add(_name, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Condition:")), leftItem);
- GridSizer->Add(_condition, rightItem);
-
- bigBox->Add(GridSizer, 0, wxEXPAND | wxALL, 15);
-
- bigBox->AddSpacer(10);
- bigBox->AddStretchSpacer(1);
-
- //Need to add 'OK' and 'Cancel' buttons.
- wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
- if (sizer != nullptr)
- bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15);
-
- //Set defaults.
- _state->SetSelection(0);
-
- SetBackgroundColour(wxColour(255, 255, 255));
- SetIcon(wxIconLocation("LOOT.exe"));
- SetSizerAndFit(bigBox);
-}
-
-void TagEditDialog::SetValues(int state, const wxString& name, const wxString& condition) {
-
- _state->SetSelection(state);
- _name->SetValue(name);
- _condition->SetValue(condition);
-}
-
-wxString TagEditDialog::GetState() const {
- return State[_state->GetSelection()];
-}
-
-wxString TagEditDialog::GetName() const {
- return _name->GetValue();
-}
-
-wxString TagEditDialog::GetCondition() const {
- return _condition->GetValue();
-}
-
-DirtInfoEditDialog::DirtInfoEditDialog(wxWindow * parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
- //Initialise controls.
- wxTextValidator val(wxFILTER_EMPTY | wxFILTER_INCLUDE_CHAR_LIST);
- val.SetCharIncludes("0123456789ABCDEFabcdef");
-
- _itm = new wxSpinCtrl(this, wxID_ANY, "0");
- _udr = new wxSpinCtrl(this, wxID_ANY, "0");
- _nav = new wxSpinCtrl(this, wxID_ANY, "0");
- _crc = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, val);
- _utility = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY));
-
- wxSizerFlags leftItem(0);
- leftItem.Left();
-
- wxSizerFlags rightItem(1);
- rightItem.Right().Expand();
-
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5);
- GridSizer->AddGrowableCol(1, 1);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("CRC (required):")), leftItem);
- GridSizer->Add(_crc, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("ITM Count:")), leftItem);
- GridSizer->Add(_itm, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("UDR Count:")), leftItem);
- GridSizer->Add(_udr, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Deleted Navmesh Count:")), leftItem);
- GridSizer->Add(_nav, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Cleaning Utility (required):")), leftItem);
- GridSizer->Add(_utility, rightItem);
-
- bigBox->Add(GridSizer, 0, wxEXPAND | wxALL, 15);
-
- bigBox->AddSpacer(10);
- bigBox->AddStretchSpacer(1);
-
- //Need to add 'OK' and 'Cancel' buttons.
- wxSizer * sizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
- if (sizer != nullptr)
- bigBox->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 15);
-
- SetBackgroundColour(wxColour(255, 255, 255));
- SetIcon(wxIconLocation("LOOT.exe"));
- SetSizerAndFit(bigBox);
-}
-
-void DirtInfoEditDialog::SetValues(const wxString& crc, unsigned int itm, unsigned int udr, unsigned int nav, const wxString& utility) {
- _crc->SetValue(crc);
- _itm->SetValue(itm);
- _udr->SetValue(udr);
- _nav->SetValue(nav);
- _utility->SetValue(utility);
-}
-
-wxString DirtInfoEditDialog::GetCRC() const {
- return _crc->GetValue();
-}
-
-unsigned int DirtInfoEditDialog::GetITMs() const {
- return _itm->GetValue();
-}
-
-unsigned int DirtInfoEditDialog::GetUDRs() const {
- return _udr->GetValue();
-}
-
-unsigned int DirtInfoEditDialog::GetDeletedNavmeshes() const {
- return _nav->GetValue();
-}
-
-wxString DirtInfoEditDialog::GetUtility() const {
- return _utility->GetValue();
-}
\ No newline at end of file
diff --git a/src/gui/misc.h b/src/gui/misc.h
deleted file mode 100644
index dc7134d8..00000000
--- a/src/gui/misc.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* LOOT
-
-A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
-Copyright (C) 2013-2014 WrinklyNinja
-
-This file is part of LOOT.
-
-LOOT is free software: you can redistribute
-it and/or modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation, either version 3 of
-the License, or (at your option) any later version.
-
-LOOT is distributed in the hope that it will
-be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with LOOT. If not, see
-.
-*/
-#ifndef __LOOT_GUI_MISC__
-#define __LOOT_GUI_MISC__
-
-#include "ids.h"
-#include "../backend/metadata.h"
-
-#include
-#include
-#include
-#include
-
-const wxString Type[3] = {
- translate("Note"),
- translate("Warning"),
- translate("Error")
-};
-
-const wxString State[2] = {
- translate("Add"),
- translate("Remove")
-};
-
-class MessageList : public wxListView {
-public:
- MessageList(wxWindow * parent, wxWindowID id, const unsigned int language);
-
- void SetItems(const std::vector& messages);
- std::vector GetItems() const;
-
- loot::Message GetItem(long item) const;
- void SetItem(long item, const loot::Message& message);
- void AppendItem(const loot::Message& message);
-
- void OnDeleteItem(wxListEvent& event);
-protected:
- wxString OnGetItemText(long item, long column) const;
-
-private:
- std::vector _messages;
- const unsigned int _language;
-};
-
-class FileEditDialog : public wxDialog {
-public:
- FileEditDialog(wxWindow *parent, const wxString& title);
-
- void SetValues(const wxString& name, const wxString& display, const wxString& condition);
- wxString GetName() const;
- wxString GetDisplayName() const;
- wxString GetCondition() const;
-private:
- wxTextCtrl * _name;
- wxTextCtrl * _display;
- wxTextCtrl * _condition;
-};
-
-class MessageEditDialog : public wxDialog {
-public:
- MessageEditDialog(wxWindow *parent, const wxString& title);
-
- void SetMessage(const loot::Message& message);
- loot::Message GetMessage() const;
-
- void OnSelect(wxListEvent& event);
- void OnAdd(wxCommandEvent& event);
- void OnEdit(wxCommandEvent& event);
- void OnRemove(wxCommandEvent& event);
-private:
- wxButton * addBtn;
- wxButton * editBtn;
- wxButton * removeBtn;
- wxChoice * _type;
- wxChoice * _language;
- wxListView * _content;
- wxTextCtrl * _condition;
- wxTextCtrl * _str;
-};
-
-class TagEditDialog : public wxDialog {
-public:
- TagEditDialog(wxWindow *parent, const wxString& title);
-
- void SetValues(int state, const wxString& name, const wxString& condition);
- wxString GetState() const;
- wxString GetName() const;
- wxString GetCondition() const;
-private:
- wxChoice * _state;
- wxTextCtrl * _name;
- wxTextCtrl * _condition;
-};
-
-class DirtInfoEditDialog : public wxDialog {
-public:
- DirtInfoEditDialog(wxWindow * parent, const wxString& title);
-
- void SetValues(const wxString& crc, unsigned int itm, unsigned int udr, unsigned int nav, const wxString& utility);
- wxString GetCRC() const;
- wxString GetUtility() const;
- unsigned int GetITMs() const;
- unsigned int GetUDRs() const;
- unsigned int GetDeletedNavmeshes() const;
-private:
- wxTextCtrl * _crc;
- wxSpinCtrl * _itm;
- wxSpinCtrl * _udr;
- wxSpinCtrl * _nav;
- wxTextCtrl * _utility;
-};
-#endif
\ No newline at end of file
diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp
deleted file mode 100644
index b23b6861..00000000
--- a/src/gui/settings.cpp
+++ /dev/null
@@ -1,538 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-
-#include "settings.h"
-#include "../backend/helpers.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using namespace std;
-
-SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games, size_t currentGameIndex, wxPoint pos, wxSize size) : wxDialog(parent, wxID_ANY, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), _settings(settings), _games(games), _currentGameIndex(currentGameIndex) {
-
- //Initialise drop-down list contents.
- wxString DebugVerbosity[] = {
- translate("None"),
- translate("Low"),
- translate("Medium"),
- translate("High")
- };
-
- wxArrayString Games;
- Games.Add(translate("Autodetect"));
- for (size_t i=0,max=_games.size(); i < max; ++i) {
- Games.Add(FromUTF8(_games[i].Name()));
- }
-
- wxArrayString languages;
- vector langs = loot::Language::Names();
- for (size_t i = 0; i < langs.size(); i++) {
- languages.Add(FromUTF8(langs[i]));
- }
-
- //Initialise controls.
- GameChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Games);
- LanguageChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, languages);
- DebugVerbosityChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, DebugVerbosity);
-
- gamesList = new wxListView(this, LIST_Games, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL);
-
- addBtn = new wxButton(this, BUTTON_AddGame, translate("Add Game"));
- editBtn = new wxButton(this, BUTTON_EditGame, translate("Edit Game"));
- removeBtn = new wxButton(this, BUTTON_RemoveGame, translate("Remove Game"));
-
- UpdateMasterlistBox = new wxCheckBox(this, wxID_ANY, translate("Update masterlist before sorting."));
-
- //Set up list columns.
- gamesList->AppendColumn(translate("Name"));
- gamesList->AppendColumn(translate("Base Game Type"));
- gamesList->AppendColumn(translate("LOOT Folder Name"));
- gamesList->AppendColumn(translate("Master File"));
- gamesList->AppendColumn(translate("Masterlist Repository URL"));
- gamesList->AppendColumn(translate("Masterlist Repository Branch"));
- gamesList->AppendColumn(translate("Install Path"));
- gamesList->AppendColumn(translate("Install Path Registry Key"));
-
- //Set up event handling.
- Bind(wxEVT_LIST_ITEM_SELECTED, &SettingsFrame::OnGameSelect, this, LIST_Games);
- Bind(wxEVT_BUTTON, &SettingsFrame::OnQuit, this, wxID_OK);
- Bind(wxEVT_BUTTON, &SettingsFrame::OnAddGame, this, BUTTON_AddGame);
- Bind(wxEVT_BUTTON, &SettingsFrame::OnEditGame, this, BUTTON_EditGame);
- Bind(wxEVT_BUTTON, &SettingsFrame::OnRemoveGame, this, BUTTON_RemoveGame);
-
- //Set up layout.
- wxSizerFlags leftItem(0);
- leftItem.Left();
-
- wxSizerFlags rightItem(1);
- rightItem.Right();
-
- wxSizerFlags wholeItem(0);
- wholeItem.Border(wxLEFT|wxRIGHT|wxBOTTOM, 15);
-
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5);
- GridSizer->AddGrowableCol(1,1);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Default Game:")), leftItem);
- GridSizer->Add(GameChoice, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Language:")), leftItem);
- GridSizer->Add(LanguageChoice, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Debug Verbosity:")), leftItem);
- GridSizer->Add(DebugVerbosityChoice, rightItem);
-
- bigBox->Add(GridSizer, 0, wxEXPAND|wxALL, 15);
-
- bigBox->Add(gamesList, 1, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 15);
-
- wxBoxSizer * hbox2 = new wxBoxSizer(wxHORIZONTAL);
- hbox2->Add(addBtn, 0, wxRIGHT, 5);
- hbox2->Add(editBtn, 0, wxLEFT|wxRIGHT, 5);
- hbox2->Add(removeBtn, 0, wxLEFT, 5);
- bigBox->Add(hbox2, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT, 15);
-
- bigBox->Add(UpdateMasterlistBox, wholeItem);
-
- bigBox->AddSpacer(10);
-
- bigBox->Add(new wxStaticText(this, wxID_ANY, translate("Language and game changes will be applied after LOOT is restarted.")), wholeItem);
-
- //Need to add 'OK' and 'Cancel' buttons.
- wxSizer * sizer = CreateSeparatedButtonSizer(wxOK|wxCANCEL);
-
- //Now add TabHolder and OK button to window sizer.
- if (sizer != nullptr)
- bigBox->Add(sizer, 0, wxEXPAND|wxLEFT|wxBOTTOM|wxRIGHT, 15);
-
- //Initialise options with values. For checkboxes, they are off by default.
- SetDefaultValues();
-
- //Tooltips.
- DebugVerbosityChoice->SetToolTip(translate("The output is logged to the LOOTDebugLog.txt file."));
-
- //Now set the layout and sizes.
- SetBackgroundColour(wxColour(255,255,255));
- SetIcon(wxIconLocation("LOOT.exe"));
- SetSizerAndFit(bigBox);
-
- if (size != wxDefaultSize)
- SetSize(size);
-}
-
-void SettingsFrame::SetDefaultValues() {
-
- BOOST_LOG_TRIVIAL(debug) << "Setting default values for LOOT's settings.";
-
- if (_settings["Language"]) {
- LanguageChoice->SetSelection(loot::Language(_settings["Language"].as()).Code() - 1);
- }
-
- if (_settings["Game"]) {
- string game = _settings["Game"].as();
- if (boost::iequals(game, "auto"))
- GameChoice->SetSelection(0);
- 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"]) {
- unsigned int verbosity = _settings["Debug Verbosity"].as();
- DebugVerbosityChoice->SetSelection(verbosity);
- }
-
- if (_settings["Update Masterlist"]) {
- bool update = _settings["Update Masterlist"].as();
- UpdateMasterlistBox->SetValue(update);
- }
-
- for (size_t i=0, max=_games.size(); i < max; ++i) {
- gamesList->InsertItem(i, FromUTF8(_games[i].Name()));
- gamesList->SetItem(i, 1, FromUTF8(loot::Game(_games[i].Id()).FolderName()));
- gamesList->SetItem(i, 2, FromUTF8(_games[i].FolderName()));
- gamesList->SetItem(i, 3, FromUTF8(_games[i].Master()));
- gamesList->SetItem(i, 4, FromUTF8(_games[i].RepoURL()));
- gamesList->SetItem(i, 5, FromUTF8(_games[i].RepoBranch()));
- gamesList->SetItem(i, 6, FromUTF8(_games[i].GamePath().string()));
- gamesList->SetItem(i, 7, FromUTF8(_games[i].RegistryKey()));
- }
-
- addBtn->Enable(true);
- editBtn->Enable(false);
- removeBtn->Enable(false);
-}
-
-void SettingsFrame::OnQuit(wxCommandEvent& event) {
- if (event.GetId() == wxID_OK) {
-
- BOOST_LOG_TRIVIAL(debug) << "Applying settings.";
-
- if (GameChoice->GetSelection() == 0)
- _settings["Game"] = "auto";
- else
- _settings["Game"] = _games[GameChoice->GetSelection() - 1].FolderName();
-
- _settings["Language"] = loot::Language(LanguageChoice->GetSelection() + 1).Locale();
-
- _settings["Debug Verbosity"] = DebugVerbosityChoice->GetSelection();
-
- unsigned int verbosity = _settings["Debug Verbosity"].as();
- if (verbosity == 0)
- boost::log::core::get()->set_logging_enabled(false);
- else {
- boost::log::core::get()->set_logging_enabled(true);
-
- if (verbosity == 1)
- boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning); //Log all warnings, errors and fatals.
- else if (verbosity == 2)
- boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug); //Log debugs, infos, warnings, errors and fatals.
- else
- boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace); //Log everything.
- }
-
- _settings["Update Masterlist"] = UpdateMasterlistBox->IsChecked();
-
- unordered_set newGameFolders;
- for (size_t i=0,max=gamesList->GetItemCount(); i < max; ++i) {
- /* We want to avoid overwriting existing game objects as doing so
- clears the game caches. Instead, recognise that game folder names
- must be unique. Therefore, use Game::SetDetails() to set
- the settings for each existing game, and add new games on.
- For any games that have been deleted, check against the newGameNames
- hashset and remove any not in it.
- */
-
- string name = gamesList->GetItemText(i, 0).ToUTF8();
- string folder = gamesList->GetItemText(i, 2).ToUTF8();
- string master = gamesList->GetItemText(i, 3).ToUTF8();
- string repo = gamesList->GetItemText(i, 4).ToUTF8();
- string branch = gamesList->GetItemText(i, 5).ToUTF8();
- string path = gamesList->GetItemText(i, 6).ToUTF8();
- string registry = gamesList->GetItemText(i, 7).ToUTF8();
-
- unsigned int id;
- if (gamesList->GetItemText(i, 1).ToUTF8() == loot::Game(loot::Game::tes4).FolderName())
- id = loot::Game::tes4;
- else if (gamesList->GetItemText(i, 1).ToUTF8() == loot::Game(loot::Game::tes5).FolderName())
- id = loot::Game::tes5;
- else if (gamesList->GetItemText(i, 1).ToUTF8() == loot::Game(loot::Game::fo3).FolderName())
- id = loot::Game::fo3;
- else
- id = loot::Game::fonv;
-
- auto pos = find(_games.begin(), _games.end(), folder);
-
- if (pos != _games.end()) {
- pos->SetDetails(name, master, repo, branch, path, registry);
- }
- else {
- _games.push_back(loot::Game(id, folder).SetDetails(name, master, repo, branch, path, registry));
- }
-
- newGameFolders.insert(folder);
- }
-
- for (auto it = _games.begin(); it != _games.end();) {
- if (newGameFolders.find(it->FolderName()) == newGameFolders.end())
- it = _games.erase(it);
- else
- ++it;
- }
- }
-
- EndModal(0);
-}
-
-void SettingsFrame::OnGameSelect(wxListEvent& event) {
- wxString name = gamesList->GetItemText(event.GetIndex());
- if (name == loot::Game(loot::Game::tes4).Name()
- || name == loot::Game(loot::Game::tes5).Name()
- || name == loot::Game(loot::Game::fo3).Name()
- || name == loot::Game(loot::Game::fonv).Name()
- || event.GetIndex() == _currentGameIndex) {
- removeBtn->Enable(false);
- } else {
- removeBtn->Enable(true);
- }
- editBtn->Enable(true);
-}
-
-void SettingsFrame::OnAddGame(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Adding new game to settings.";
-
- GameEditDialog * rowDialog = new GameEditDialog(this, translate("LOOT: Add Game"));
-
- if (rowDialog->ShowModal() == wxID_OK) {
-
- if (rowDialog->GetPath().empty() && rowDialog->GetRegistryKey().empty()) {
- BOOST_LOG_TRIVIAL(error) << "Tried to add a new game with no path or registry key given.";
- wxMessageBox(
- translate("Error: A path and/or registry key is required. Row will not be added."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- }
-
- //Also check that name and folder name don't already exist in the list.
- for (size_t i=0,max=gamesList->GetItemCount(); i < max; ++i) {
- if (rowDialog->GetName() == gamesList->GetItemText(i, 0)) {
- BOOST_LOG_TRIVIAL(error) << "Tried to add a new game with the same name as one that is already defined.";
- wxMessageBox(
- translate("Error: A game with this name is already defined. Row will not be added."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- } else if (rowDialog->GetFolderName() == gamesList->GetItemText(i, 2)) {
- BOOST_LOG_TRIVIAL(error) << "Tried to add a new game with the same folder as one that is already defined.";
- wxMessageBox(
- translate("Error: A game with this folder name is already defined. Row will not be added."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- }
- }
-
- long i = gamesList->GetItemCount();
- gamesList->InsertItem(i, rowDialog->GetName());
- gamesList->SetItem(i, 1, rowDialog->GetType().ToUTF8());
- gamesList->SetItem(i, 2, rowDialog->GetFolderName());
- gamesList->SetItem(i, 3, rowDialog->GetMaster());
- gamesList->SetItem(i, 4, rowDialog->GetRepoURL());
- gamesList->SetItem(i, 5, rowDialog->GetRepoBranch());
- gamesList->SetItem(i, 6, rowDialog->GetPath());
- gamesList->SetItem(i, 7, rowDialog->GetRegistryKey());
- }
-}
-
-void SettingsFrame::OnEditGame(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Editing game settings.";
-
- GameEditDialog * rowDialog = new GameEditDialog(this, translate("LOOT: Edit Game"));
-
- long i = gamesList->GetFirstSelected();
-
- int stateNo;
- if (gamesList->GetItemText(i, 1) == loot::Game(loot::Game::tes4).FolderName())
- stateNo = loot::Game::tes4;
- else if (gamesList->GetItemText(i, 1) == loot::Game(loot::Game::tes5).FolderName())
- stateNo = loot::Game::tes5;
- else if (gamesList->GetItemText(i, 1) == loot::Game(loot::Game::fo3).FolderName())
- stateNo = loot::Game::fo3;
- else
- stateNo = loot::Game::fonv;
-
- rowDialog->SetValues(stateNo, gamesList->GetItemText(i, 0), gamesList->GetItemText(i, 2), gamesList->GetItemText(i, 3), gamesList->GetItemText(i, 4), gamesList->GetItemText(i, 5), gamesList->GetItemText(i, 6), gamesList->GetItemText(i, 7));
-
- if (rowDialog->ShowModal() == wxID_OK) {
-
- if (rowDialog->GetName().empty()) {
- BOOST_LOG_TRIVIAL(error) << "Tried to blank a game's name field.";
- wxMessageBox(
- translate("Error: Name is required. Row will not be added."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- } else if (rowDialog->GetFolderName().empty()) {
- BOOST_LOG_TRIVIAL(error) << "Tried to blank a game's folder field.";
- wxMessageBox(
- translate("Error: Folder is required. Row will not be added."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- } else if (rowDialog->GetPath().empty() && rowDialog->GetRegistryKey().empty()) {
- BOOST_LOG_TRIVIAL(error) << "Tried to edit a game with no path or registry key given.";
- wxMessageBox(
- translate("Error: A path and/or registry key is required. Row will not be added."),
- translate("LOOT: Error"),
- wxOK | wxICON_ERROR,
- this);
- return;
- }
-
- gamesList->SetItem(i, 0, rowDialog->GetName());
- gamesList->SetItem(i, 1, rowDialog->GetType());
- gamesList->SetItem(i, 2, rowDialog->GetFolderName());
- gamesList->SetItem(i, 3, rowDialog->GetMaster());
- gamesList->SetItem(i, 4, rowDialog->GetRepoURL());
- gamesList->SetItem(i, 5, rowDialog->GetRepoBranch());
- gamesList->SetItem(i, 6, rowDialog->GetPath());
- gamesList->SetItem(i, 7, rowDialog->GetRegistryKey());
- }
-}
-
-void SettingsFrame::OnRemoveGame(wxCommandEvent& event) {
- BOOST_LOG_TRIVIAL(debug) << "Removing game from settings.";
-
- gamesList->DeleteItem(gamesList->GetFirstSelected());
-
- editBtn->Enable(false);
- removeBtn->Enable(false);
-}
-
-GameEditDialog::GameEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) {
-
- wxString Types[] = {
- FromUTF8(loot::Game(loot::Game::tes4).FolderName()),
- FromUTF8(loot::Game(loot::Game::tes5).FolderName()),
- FromUTF8(loot::Game(loot::Game::fo3).FolderName()),
- FromUTF8(loot::Game(loot::Game::fonv).FolderName())
- };
-
- //Initialise controls.
- _type = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, Types);
-
- _name = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY));
- _folderName = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_EMPTY));
- _master = new wxTextCtrl(this, wxID_ANY);
- _repo = new wxTextCtrl(this, wxID_ANY);
- _branch = new wxTextCtrl(this, wxID_ANY);
- _path = new wxTextCtrl(this, wxID_ANY);
- _registry = new wxTextCtrl(this, wxID_ANY);
-
- //Sizers stuff.
- wxSizerFlags leftItem(0);
- leftItem.Left();
-
- wxSizerFlags rightItem(1);
- rightItem.Right().Expand();
-
- wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL);
-
- wxFlexGridSizer * GridSizer = new wxFlexGridSizer(2, 5, 5);
- GridSizer->AddGrowableCol(1,1);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Name (required):")), leftItem);
- GridSizer->Add(_name, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Type:")), leftItem);
- GridSizer->Add(_type, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("LOOT Folder Name (required):")), leftItem);
- GridSizer->Add(_folderName, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Master File:")), leftItem);
- GridSizer->Add(_master, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Masterlist Repository URL:")), leftItem);
- GridSizer->Add(_repo, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Masterlist Repository Branch:")), leftItem);
- GridSizer->Add(_branch, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Install Path:")), leftItem);
- GridSizer->Add(_path, rightItem);
-
- GridSizer->Add(new wxStaticText(this, wxID_ANY, translate("Install Path Registry Key:")), leftItem);
- GridSizer->Add(_registry, rightItem);
-
- bigBox->Add(GridSizer, 0, wxEXPAND|wxALL, 15);
-
- bigBox->AddSpacer(10);
- bigBox->AddStretchSpacer(1);
-
- //Need to add 'OK' and 'Cancel' buttons.
- wxSizer * sizer = CreateSeparatedButtonSizer(wxOK|wxCANCEL);
- if (sizer != nullptr)
- bigBox->Add(sizer, 0, wxEXPAND|wxLEFT|wxBOTTOM|wxRIGHT, 15);
-
- //Set defaults.
- _type->SetSelection(0);
-
- SetBackgroundColour(wxColour(255,255,255));
- SetIcon(wxIconLocation("LOOT.exe"));
- SetSizerAndFit(bigBox);
-}
-
-void GameEditDialog::SetValues(unsigned int type, const wxString& name, const wxString& folderName, const wxString& master,
- const wxString& repo, const wxString& branch, const wxString& path, const wxString& registry) {
- if (type == loot::Game::tes4)
- _type->SetSelection(0);
- else if (type == loot::Game::tes5)
- _type->SetSelection(1);
- else if (type == loot::Game::fo3)
- _type->SetSelection(2);
- else
- _type->SetSelection(3);
-
- _name->SetValue(name);
- _folderName->SetValue(folderName);
- _master->SetValue(master);
- _repo->SetValue(repo);
- _branch->SetValue(branch);
- _path->SetValue(path);
- _registry->SetValue(registry);
-
- //Also disable the name and folder name text controls to prevent them being changed for games that already exist.
- _name->Enable(false);
- _folderName->Enable(false);
-}
-
-wxString GameEditDialog::GetName() const {
- return _name->GetValue();
-}
-
-wxString GameEditDialog::GetType() const {
- return _type->GetString(_type->GetSelection());
-}
-
-wxString GameEditDialog::GetFolderName() const {
- return _folderName->GetValue();
-}
-
-wxString GameEditDialog::GetMaster() const {
- return _master->GetValue();
-}
-
-wxString GameEditDialog::GetRepoURL() const {
- return _repo->GetValue();
-}
-
-wxString GameEditDialog::GetRepoBranch() const {
- return _branch->GetValue();
-}
-
-wxString GameEditDialog::GetPath() const {
- return _path->GetValue();
-}
-
-wxString GameEditDialog::GetRegistryKey() const {
- return _registry->GetValue();
-}
-
diff --git a/src/gui/settings.h b/src/gui/settings.h
deleted file mode 100644
index 43e8a2f7..00000000
--- a/src/gui/settings.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* LOOT
-
- A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
- Fallout: New Vegas.
-
- Copyright (C) 2013-2014 WrinklyNinja
-
- This file is part of LOOT.
-
- LOOT is free software: you can redistribute
- it and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- LOOT is distributed in the hope that it will
- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with LOOT. If not, see
- .
-*/
-
-#ifndef __LOOT_GUI_SETTINGS__
-#define __LOOT_GUI_SETTINGS__
-
-#include "ids.h"
-#include "../backend/game.h"
-
-#include
-#include
-
-class SettingsFrame : public wxDialog {
-public:
- SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games, size_t currentGameIndex, wxPoint pos, wxSize size);
-
- void OnQuit(wxCommandEvent& event);
- void OnGameSelect(wxListEvent& event);
- void OnAddGame(wxCommandEvent& event);
- void OnEditGame(wxCommandEvent& event);
- void OnRemoveGame(wxCommandEvent& event);
-
- void SetDefaultValues();
-private:
- wxChoice *DebugVerbosityChoice;
- wxChoice *GameChoice;
- wxChoice *LanguageChoice;
- wxCheckBox *UpdateMasterlistBox;
-
- wxListView *gamesList;
- wxButton * addBtn;
- wxButton * editBtn;
- wxButton * removeBtn;
-
- YAML::Node& _settings;
- std::vector& _games;
- size_t _currentGameIndex;
-};
-
-class GameEditDialog : public wxDialog {
-public:
- GameEditDialog(wxWindow *parent, const wxString& title);
-
- void SetValues(unsigned int type, const wxString& name, const wxString& folderName, const wxString& master,
- const wxString& repo, const wxString& branch, const wxString& path, const wxString& registry);
- wxString GetName() const;
- wxString GetType() const;
- wxString GetFolderName() const;
- wxString GetMaster() const;
- wxString GetRepoURL() const;
- wxString GetRepoBranch() const;
- wxString GetPath() const;
- wxString GetRegistryKey() const;
-private:
- wxChoice * _type;
- wxTextCtrl * _name;
- wxTextCtrl * _folderName;
- wxTextCtrl * _master;
- wxTextCtrl * _repo;
- wxTextCtrl * _branch;
- wxTextCtrl * _path;
- wxTextCtrl * _registry;
-};
-
-#endif