Commit 86ba08c8 authored by coppro's avatar coppro

Added some fixes

More work on update window.
parent 2f3fcf44
...@@ -32,6 +32,7 @@ String card_rarity_code(const String& rarity); ...@@ -32,6 +32,7 @@ String card_rarity_code(const String& rarity);
class WithProgress { class WithProgress {
public: public:
virtual void onProgress(float progress, const String& message) = 0; virtual void onProgress(float progress, const String& message) = 0;
virtual ~WithProgress () {}
}; };
/// Exception thrown to indicate exporting should be aborted /// Exception thrown to indicate exporting should be aborted
...@@ -64,7 +65,7 @@ void ExportProgressDialog::onProgress(float progress, const String& message) { ...@@ -64,7 +65,7 @@ void ExportProgressDialog::onProgress(float progress, const String& message) {
class ApprDatabase { class ApprDatabase {
public: public:
ApprDatabase(WithProgress* progress_target, const String& name); ApprDatabase(WithProgress* progress_target, const String& name);
~ApprDatabase(); virtual ~ApprDatabase();
/// Read the database /// Read the database
void read(); void read();
......
...@@ -9,9 +9,23 @@ ...@@ -9,9 +9,23 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <data/settings.hpp>
#include <util/prec.hpp> #include <util/prec.hpp>
#include <util/io/package.hpp> #include <util/io/package.hpp>
// ----------------------------------------------------------------------------- : InstallType
// Platform default install directory.
#ifdef __WXMSW__
#define DEFAULT_INSTALL_LOCAL false
#else
#define DEFAULT_INSTALL_LOCAL true
#endif
inline bool isInstallLocal(const InstallType& type)
{
return type == INSTALL_DEFAULT ? DEFAULT_INSTALL_LOCAL : type == INSTALL_LOCAL;
}
// ----------------------------------------------------------------------------- : Installer // ----------------------------------------------------------------------------- : Installer
/// A package that contains other packages that can be installed /// A package that contains other packages that can be installed
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <data/settings.hpp> #include <data/settings.hpp>
#include <data/installer.hpp>
#include <data/game.hpp> #include <data/game.hpp>
#include <data/stylesheet.hpp> #include <data/stylesheet.hpp>
#include <data/field.hpp> #include <data/field.hpp>
...@@ -31,6 +32,12 @@ IMPLEMENT_REFLECTION_ENUM(CheckUpdates) { ...@@ -31,6 +32,12 @@ IMPLEMENT_REFLECTION_ENUM(CheckUpdates) {
VALUE_N("never", CHECK_NEVER); VALUE_N("never", CHECK_NEVER);
} }
IMPLEMENT_REFLECTION_ENUM(InstallType) {
VALUE_N("default", INSTALL_DEFAULT); //default
VALUE_N("local", INSTALL_LOCAL);
VALUE_N("global", INSTALL_GLOBAL);
}
IMPLEMENT_REFLECTION_ENUM(FilenameConflicts) { IMPLEMENT_REFLECTION_ENUM(FilenameConflicts) {
VALUE_N("keep old", CONFLICT_KEEP_OLD); VALUE_N("keep old", CONFLICT_KEEP_OLD);
VALUE_N("overwrite", CONFLICT_OVERWRITE); VALUE_N("overwrite", CONFLICT_OVERWRITE);
...@@ -135,6 +142,7 @@ Settings::Settings() ...@@ -135,6 +142,7 @@ Settings::Settings()
, symbol_grid_snap (false) , symbol_grid_snap (false)
, updates_url (_("http://magicseteditor.sourceforge.net/updates")) , updates_url (_("http://magicseteditor.sourceforge.net/updates"))
, check_updates (CHECK_IF_CONNECTED) , check_updates (CHECK_IF_CONNECTED)
, install_type (INSTALL_DEFAULT)
, website_url (_("http://magicseteditor.sourceforge.net/")) , website_url (_("http://magicseteditor.sourceforge.net/"))
{} {}
...@@ -212,6 +220,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { ...@@ -212,6 +220,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(apprentice_location); REFLECT(apprentice_location);
REFLECT(updates_url); REFLECT(updates_url);
REFLECT(check_updates); REFLECT(check_updates);
REFLECT(install_type);
REFLECT(website_url); REFLECT(website_url);
REFLECT(game_settings); REFLECT(game_settings);
REFLECT(stylesheet_settings); REFLECT(stylesheet_settings);
......
...@@ -33,6 +33,15 @@ enum CheckUpdates ...@@ -33,6 +33,15 @@ enum CheckUpdates
, CHECK_NEVER , CHECK_NEVER
}; };
/// Where to install to?
enum InstallType
{ INSTALL_DEFAULT // the platform default.
, INSTALL_LOCAL // install to the user's files
, INSTALL_GLOBAL // install to the global files
};
bool parse_enum(const String&, InstallType&);
/// How to handle filename conflicts /// How to handle filename conflicts
enum FilenameConflicts enum FilenameConflicts
{ CONFLICT_KEEP_OLD // always keep old file { CONFLICT_KEEP_OLD // always keep old file
...@@ -161,6 +170,9 @@ class Settings { ...@@ -161,6 +170,9 @@ class Settings {
CheckUpdates check_updates; CheckUpdates check_updates;
String website_url; String website_url;
// --------------------------------------------------- : Installation settings
InstallType install_type;
// --------------------------------------------------- : The io // --------------------------------------------------- : The io
/// Read the settings file from the standard location /// Read the settings file from the standard location
......
...@@ -103,7 +103,7 @@ void AutoReplaceList::removeSelected() { ...@@ -103,7 +103,7 @@ void AutoReplaceList::removeSelected() {
items.erase(items.begin() + i); items.erase(items.begin() + i);
// select next // select next
refreshList(); refreshList();
selectItem(items.empty() ? VoidP() : items[min(i, items.size())], true, true); selectItem(items.empty() ? VoidP() : VoidP(items[min(i, items.size())]), true, true);
return; return;
} }
} }
......
...@@ -302,12 +302,13 @@ END_EVENT_TABLE() ...@@ -302,12 +302,13 @@ END_EVENT_TABLE()
// ----------------------------------------------------------------------------- : UpdateWindow // ----------------------------------------------------------------------------- : UpdateWindow
UpdatesWindow::UpdatesWindow() UpdatesWindow::UpdatesWindow()
: Frame(nullptr, wxID_ANY, _TITLE_("package list"), wxDefaultPosition, wxSize(480,400), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN) : Frame(nullptr, wxID_ANY, _TITLE_("package list"), wxDefaultPosition, wxSize(480,440), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN)
{ {
SetIcon(wxIcon()); SetIcon(wxIcon());
wxBoxSizer *v = new wxBoxSizer(wxVERTICAL); wxBoxSizer *v = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *h1 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *h1 = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *h2 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *h2 = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *h3 = new wxBoxSizer(wxHORIZONTAL);
package_list = new PackageUpdateList(this); package_list = new PackageUpdateList(this);
description_window = new HtmlWindowToBrowser(this, wxID_ANY, wxDefaultPosition, wxSize(480,100), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER); description_window = new HtmlWindowToBrowser(this, wxID_ANY, wxDefaultPosition, wxSize(480,100), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
...@@ -322,10 +323,10 @@ UpdatesWindow::UpdatesWindow() ...@@ -322,10 +323,10 @@ UpdatesWindow::UpdatesWindow()
h1->Add(status_title); h1->Add(status_title);
h1->Add(new_title, 2); h1->Add(new_title, 2);
(install_button = new wxButton(this, ID_INSTALL, _("Install")))->Disable(); (install_button = new wxButton(this, ID_INSTALL, _MENU_("install package")))->Disable();
(upgrade_button = new wxButton(this, ID_UPGRADE, _("Update")))->Disable(); (upgrade_button = new wxButton(this, ID_UPGRADE, _MENU_("upgrade package")))->Disable();
(remove_button = new wxButton(this, ID_REMOVE, _("Remove")))->Disable(); (remove_button = new wxButton(this, ID_REMOVE, _MENU_("remove package")))->Disable();
(cancel_button = new wxButton(this, ID_CANCEL, _("Cancel")))->Disable(); (cancel_button = new wxButton(this, ID_CANCEL, _MENU_("cancel changes")))->Disable();
h2->AddStretchSpacer(1); h2->AddStretchSpacer(1);
h2->Add(install_button); h2->Add(install_button);
...@@ -337,13 +338,21 @@ UpdatesWindow::UpdatesWindow() ...@@ -337,13 +338,21 @@ UpdatesWindow::UpdatesWindow()
h2->Add(cancel_button); h2->Add(cancel_button);
h2->AddStretchSpacer(1); h2->AddStretchSpacer(1);
apply_button = new wxButton(this, ID_APPLY, _MENU_("apply changes"));
h3->AddStretchSpacer(1);
h3->Add(apply_button);
h3->AddStretchSpacer(1);
v->Add(h1); v->Add(h1);
v->Add(package_list); v->Add(package_list);
v->AddStretchSpacer(1); v->AddStretchSpacer(2);
v->Add(description_window); v->Add(description_window);
v->AddStretchSpacer(1); v->AddStretchSpacer(2);
v->Add(h2); v->Add(h2);
v->AddStretchSpacer(1); v->AddStretchSpacer(1);
v->Add(h3);
v->AddStretchSpacer(2);
SetSizer(v); SetSizer(v);
} }
...@@ -356,7 +365,7 @@ void UpdatesWindow::onPackageSelect(wxCommandEvent& ev) { ...@@ -356,7 +365,7 @@ void UpdatesWindow::onPackageSelect(wxCommandEvent& ev) {
updateButtons(ev.GetInt()); updateButtons(ev.GetInt());
} }
void UpdatesWindow::onButton(wxCommandEvent& ev) { void UpdatesWindow::onActionChange(wxCommandEvent& ev) {
PackageVersionDataP pack = update_version_data->packages[package_list->GetSelection()]; PackageVersionDataP pack = update_version_data->packages[package_list->GetSelection()];
PackageAction& action = package_data[pack].second; PackageAction& action = package_data[pack].second;
switch (ev.GetId()) { switch (ev.GetId()) {
...@@ -369,6 +378,9 @@ void UpdatesWindow::onButton(wxCommandEvent& ev) { ...@@ -369,6 +378,9 @@ void UpdatesWindow::onButton(wxCommandEvent& ev) {
package_list->Refresh(); package_list->Refresh();
} }
void UpdatesWindow::onApplyChanges(wxCommandEvent& ev) {
}
void UpdatesWindow::updateButtons(int id) { void UpdatesWindow::updateButtons(int id) {
PackageVersionDataP pack = update_version_data->packages[id]; PackageVersionDataP pack = update_version_data->packages[id];
...@@ -405,7 +417,7 @@ void UpdatesWindow::setDefaultPackageStatus() { ...@@ -405,7 +417,7 @@ void UpdatesWindow::setDefaultPackageStatus() {
FOR_EACH(p, update_version_data->packages) { FOR_EACH(p, update_version_data->packages) {
PackagedP pack; PackagedP pack;
try { pack = packages.openAny(p->name, true); } try { pack = packages.openAny(p->name, true); }
catch (const Error&) { } // We couldn't open a package... wonder why? catch (const PackageError&) { } // We couldn't open a package... wonder why?
if (!pack) { if (!pack) {
// not installed // not installed
...@@ -430,8 +442,9 @@ void UpdatesWindow::setDefaultPackageStatus() { ...@@ -430,8 +442,9 @@ void UpdatesWindow::setDefaultPackageStatus() {
BEGIN_EVENT_TABLE(UpdatesWindow, Frame) BEGIN_EVENT_TABLE(UpdatesWindow, Frame)
EVT_COMMAND(wxID_ANY, UPDATE_CHECK_FINISHED_EVT, UpdatesWindow::onUpdateCheckFinished) EVT_COMMAND(wxID_ANY, UPDATE_CHECK_FINISHED_EVT, UpdatesWindow::onUpdateCheckFinished)
EVT_LISTBOX(ID_PACKAGE_LIST, UpdatesWindow::onPackageSelect) EVT_LISTBOX(ID_PACKAGE_LIST, UpdatesWindow::onPackageSelect)
EVT_BUTTON(ID_INSTALL, UpdatesWindow::onButton) EVT_BUTTON(ID_INSTALL, UpdatesWindow::onActionChange)
EVT_BUTTON(ID_REMOVE, UpdatesWindow::onButton) EVT_BUTTON(ID_REMOVE, UpdatesWindow::onActionChange)
EVT_BUTTON(ID_UPGRADE, UpdatesWindow::onButton) EVT_BUTTON(ID_UPGRADE, UpdatesWindow::onActionChange)
EVT_BUTTON(ID_CANCEL, UpdatesWindow::onButton) EVT_BUTTON(ID_CANCEL, UpdatesWindow::onActionChange)
EVT_BUTTON(ID_APPLY, UpdatesWindow::onApplyChanges)
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -65,11 +65,12 @@ class UpdatesWindow : public Frame { ...@@ -65,11 +65,12 @@ class UpdatesWindow : public Frame {
wxHtmlWindow* description_window; wxHtmlWindow* description_window;
wxStaticText *package_title, *status_title, *new_title; wxStaticText *package_title, *status_title, *new_title;
wxButton *install_button, *upgrade_button, *remove_button, *cancel_button; wxButton *install_button, *upgrade_button, *remove_button, *cancel_button, *apply_button;
void onUpdateCheckFinished(wxCommandEvent&); void onUpdateCheckFinished(wxCommandEvent&);
void onPackageSelect(wxCommandEvent&); void onPackageSelect(wxCommandEvent&);
void onButton(wxCommandEvent&); void onActionChange(wxCommandEvent&);
void onApplyChanges(wxCommandEvent&);
/// Update the buttons to indicate that this is selected. /// Update the buttons to indicate that this is selected.
void updateButtons(int index); void updateButtons(int index);
......
...@@ -241,7 +241,7 @@ DropDownList* DropDownWordList::submenu(size_t item) const { ...@@ -241,7 +241,7 @@ DropDownList* DropDownWordList::submenu(size_t item) const {
if (i.flags & FLAG_SUBMENU) { if (i.flags & FLAG_SUBMENU) {
// create submenu? // create submenu?
if (!i.submenu) { if (!i.submenu) {
i.submenu.reset(new DropDownWordList(const_cast<DropDownWordList*>(this), true, tve, pos, i.word)); i.submenu.reset(new DropDownWordList(const_cast<DropDownWordList*>(this), true, tve, pos, WordListWordP(i.word)));
} }
return i.submenu.get(); return i.submenu.get();
} else { } else {
......
...@@ -99,12 +99,13 @@ int MSE::OnRun() { ...@@ -99,12 +99,13 @@ int MSE::OnRun() {
return wxApp::OnRun(); return wxApp::OnRun();
} else if (f.GetExt() == _("mse-installer")) { } else if (f.GetExt() == _("mse-installer")) {
// Installer; install it // Installer; install it
bool local = false; InstallType type = settings.install_type;
if (argc > 2) { if (argc > 2) {
String arg2 = argv[2]; String arg = argv[2];
local = arg2 == _("--local"); if (arg.Mid(0,2) == _("--"))
parse_enum(arg.Mid(2), type);
} }
Installer::installFrom(argv[1], true, local); Installer::installFrom(argv[1], true, isInstallLocal(type));
return EXIT_SUCCESS; return EXIT_SUCCESS;
} else if (arg == _("--symbol-editor")) { } else if (arg == _("--symbol-editor")) {
Window* wnd = new SymbolWindow(nullptr); Window* wnd = new SymbolWindow(nullptr);
......
...@@ -270,9 +270,11 @@ menu: ...@@ -270,9 +270,11 @@ menu:
add card: 0 add card: 0
add cards: 0 add cards: 0
add keyword: 0 add keyword: 0
apply changes: 0
auto replace: 0 auto replace: 0
basic shapes: 0 basic shapes: 0
bold: 0 bold: 0
cancel changes: 0
card list columns: 0 card list columns: 0
cards: 0 cards: 0
cards tab: 0 cards tab: 0
...@@ -298,6 +300,7 @@ menu: ...@@ -298,6 +300,7 @@ menu:
help: 0 help: 0
index: 0 index: 0
insert symbol: 0 insert symbol: 0
install package: 0
italic: 0 italic: 0
keywords: 0 keywords: 0
keywords tab: 0 keywords tab: 0
...@@ -322,6 +325,7 @@ menu: ...@@ -322,6 +325,7 @@ menu:
reminder text: 0 reminder text: 0
remove card: 0 remove card: 0
remove keyword: 0 remove keyword: 0
remove package: 0
replace: 0 replace: 0
rotate: 0 rotate: 0
rotate 0: 0 rotate 0: 0
...@@ -342,6 +346,7 @@ menu: ...@@ -342,6 +346,7 @@ menu:
tool: 0 tool: 0
undo: 1 undo: 1
ungroup: 0 ungroup: 0
upgrade package: 0
website: 0 website: 0
window: 0 window: 0
title: title:
......
...@@ -166,7 +166,7 @@ void CachedScriptableImage::generateCached(const GeneratedImage::Options& option ...@@ -166,7 +166,7 @@ void CachedScriptableImage::generateCached(const GeneratedImage::Options& option
set_alpha(cached_i, *mask); set_alpha(cached_i, *mask);
} else { } else {
Image mask_scaled(cached_i.GetWidth(),cached_i.GetHeight(), false); Image mask_scaled(cached_i.GetWidth(),cached_i.GetHeight(), false);
resample(mask,mask_scaled); resample(*mask,mask_scaled);
set_alpha(cached_i, mask_scaled); set_alpha(cached_i, mask_scaled);
} }
} }
......
...@@ -62,13 +62,13 @@ void writeUTF8(wxTextOutputStream& stream, const String& str); ...@@ -62,13 +62,13 @@ void writeUTF8(wxTextOutputStream& stream, const String& str);
/// Some constants we like to use /// Some constants we like to use
#ifdef UNICODE #ifdef UNICODE
#define LEFT_ANGLE_BRACKET _("\x2039") #define LEFT_ANGLE_BRACKET _("\u2039")
#define RIGHT_ANGLE_BRACKET _("\x203A") #define RIGHT_ANGLE_BRACKET _("\u203A")
#define LEFT_SINGLE_QUOTE _('\x2018') #define LEFT_SINGLE_QUOTE _('\u2018')
#define RIGHT_SINGLE_QUOTE _('\x2019') #define RIGHT_SINGLE_QUOTE _('\u2019')
#define LEFT_DOUBLE_QUOTE _('\x201C') #define LEFT_DOUBLE_QUOTE _('\u201C')
#define RIGHT_DOUBLE_QUOTE _('\x201D') #define RIGHT_DOUBLE_QUOTE _('\u201D')
#define CONNECTION_SPACE _('\xEB00') // in private use are, untags to ' ' #define CONNECTION_SPACE _('\uEB00') // in private use are, untags to ' '
#else #else
#define LEFT_ANGLE_BRACKET _("<") #define LEFT_ANGLE_BRACKET _("<")
#define RIGHT_ANGLE_BRACKET _(">") #define RIGHT_ANGLE_BRACKET _(">")
......
...@@ -243,7 +243,9 @@ enum ControlID { ...@@ -243,7 +243,9 @@ enum ControlID {
, ID_INSTALL , ID_INSTALL
, ID_UPGRADE , ID_UPGRADE
, ID_REMOVE , ID_REMOVE
, ID_CANCEL = wxID_CANCEL // Don't use wxID_CANCEL because it makes the button look out of place
, ID_CANCEL
, ID_APPLY
// Auto replace window // Auto replace window
, ID_USE_AUTO_REPLACE , ID_USE_AUTO_REPLACE
, ID_ITEM_VALUE , ID_ITEM_VALUE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment