mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Added some fixes
More work on update window. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@700 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -32,6 +32,7 @@ String card_rarity_code(const String& rarity);
|
||||
class WithProgress {
|
||||
public:
|
||||
virtual void onProgress(float progress, const String& message) = 0;
|
||||
virtual ~WithProgress () {}
|
||||
};
|
||||
|
||||
/// Exception thrown to indicate exporting should be aborted
|
||||
@@ -64,7 +65,7 @@ void ExportProgressDialog::onProgress(float progress, const String& message) {
|
||||
class ApprDatabase {
|
||||
public:
|
||||
ApprDatabase(WithProgress* progress_target, const String& name);
|
||||
~ApprDatabase();
|
||||
virtual ~ApprDatabase();
|
||||
|
||||
/// Read the database
|
||||
void read();
|
||||
|
||||
@@ -9,9 +9,23 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/settings.hpp>
|
||||
#include <util/prec.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
|
||||
|
||||
/// A package that contains other packages that can be installed
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/settings.hpp>
|
||||
#include <data/installer.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/field.hpp>
|
||||
@@ -31,6 +32,12 @@ IMPLEMENT_REFLECTION_ENUM(CheckUpdates) {
|
||||
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) {
|
||||
VALUE_N("keep old", CONFLICT_KEEP_OLD);
|
||||
VALUE_N("overwrite", CONFLICT_OVERWRITE);
|
||||
@@ -135,6 +142,7 @@ Settings::Settings()
|
||||
, symbol_grid_snap (false)
|
||||
, updates_url (_("http://magicseteditor.sourceforge.net/updates"))
|
||||
, check_updates (CHECK_IF_CONNECTED)
|
||||
, install_type (INSTALL_DEFAULT)
|
||||
, website_url (_("http://magicseteditor.sourceforge.net/"))
|
||||
{}
|
||||
|
||||
@@ -212,6 +220,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
|
||||
REFLECT(apprentice_location);
|
||||
REFLECT(updates_url);
|
||||
REFLECT(check_updates);
|
||||
REFLECT(install_type);
|
||||
REFLECT(website_url);
|
||||
REFLECT(game_settings);
|
||||
REFLECT(stylesheet_settings);
|
||||
|
||||
@@ -33,6 +33,15 @@ enum CheckUpdates
|
||||
, 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
|
||||
enum FilenameConflicts
|
||||
{ CONFLICT_KEEP_OLD // always keep old file
|
||||
@@ -161,6 +170,9 @@ class Settings {
|
||||
CheckUpdates check_updates;
|
||||
String website_url;
|
||||
|
||||
// --------------------------------------------------- : Installation settings
|
||||
InstallType install_type;
|
||||
|
||||
// --------------------------------------------------- : The io
|
||||
|
||||
/// Read the settings file from the standard location
|
||||
|
||||
@@ -103,7 +103,7 @@ void AutoReplaceList::removeSelected() {
|
||||
items.erase(items.begin() + i);
|
||||
// select next
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-13
@@ -302,12 +302,13 @@ END_EVENT_TABLE()
|
||||
// ----------------------------------------------------------------------------- : UpdateWindow
|
||||
|
||||
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());
|
||||
wxBoxSizer *v = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer *h1 = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *h2 = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *h3 = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
package_list = new PackageUpdateList(this);
|
||||
description_window = new HtmlWindowToBrowser(this, wxID_ANY, wxDefaultPosition, wxSize(480,100), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
|
||||
@@ -322,10 +323,10 @@ UpdatesWindow::UpdatesWindow()
|
||||
h1->Add(status_title);
|
||||
h1->Add(new_title, 2);
|
||||
|
||||
(install_button = new wxButton(this, ID_INSTALL, _("Install")))->Disable();
|
||||
(upgrade_button = new wxButton(this, ID_UPGRADE, _("Update")))->Disable();
|
||||
(remove_button = new wxButton(this, ID_REMOVE, _("Remove")))->Disable();
|
||||
(cancel_button = new wxButton(this, ID_CANCEL, _("Cancel")))->Disable();
|
||||
(install_button = new wxButton(this, ID_INSTALL, _MENU_("install package")))->Disable();
|
||||
(upgrade_button = new wxButton(this, ID_UPGRADE, _MENU_("upgrade package")))->Disable();
|
||||
(remove_button = new wxButton(this, ID_REMOVE, _MENU_("remove package")))->Disable();
|
||||
(cancel_button = new wxButton(this, ID_CANCEL, _MENU_("cancel changes")))->Disable();
|
||||
|
||||
h2->AddStretchSpacer(1);
|
||||
h2->Add(install_button);
|
||||
@@ -336,14 +337,22 @@ UpdatesWindow::UpdatesWindow()
|
||||
h2->AddStretchSpacer(2);
|
||||
h2->Add(cancel_button);
|
||||
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(package_list);
|
||||
v->AddStretchSpacer(1);
|
||||
v->AddStretchSpacer(2);
|
||||
v->Add(description_window);
|
||||
v->AddStretchSpacer(1);
|
||||
v->AddStretchSpacer(2);
|
||||
v->Add(h2);
|
||||
v->AddStretchSpacer(1);
|
||||
v->Add(h3);
|
||||
v->AddStretchSpacer(2);
|
||||
|
||||
SetSizer(v);
|
||||
}
|
||||
@@ -356,7 +365,7 @@ void UpdatesWindow::onPackageSelect(wxCommandEvent& ev) {
|
||||
updateButtons(ev.GetInt());
|
||||
}
|
||||
|
||||
void UpdatesWindow::onButton(wxCommandEvent& ev) {
|
||||
void UpdatesWindow::onActionChange(wxCommandEvent& ev) {
|
||||
PackageVersionDataP pack = update_version_data->packages[package_list->GetSelection()];
|
||||
PackageAction& action = package_data[pack].second;
|
||||
switch (ev.GetId()) {
|
||||
@@ -369,6 +378,9 @@ void UpdatesWindow::onButton(wxCommandEvent& ev) {
|
||||
package_list->Refresh();
|
||||
}
|
||||
|
||||
void UpdatesWindow::onApplyChanges(wxCommandEvent& ev) {
|
||||
}
|
||||
|
||||
void UpdatesWindow::updateButtons(int id) {
|
||||
PackageVersionDataP pack = update_version_data->packages[id];
|
||||
|
||||
@@ -405,7 +417,7 @@ void UpdatesWindow::setDefaultPackageStatus() {
|
||||
FOR_EACH(p, update_version_data->packages) {
|
||||
PackagedP pack;
|
||||
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) {
|
||||
// not installed
|
||||
@@ -430,8 +442,9 @@ void UpdatesWindow::setDefaultPackageStatus() {
|
||||
BEGIN_EVENT_TABLE(UpdatesWindow, Frame)
|
||||
EVT_COMMAND(wxID_ANY, UPDATE_CHECK_FINISHED_EVT, UpdatesWindow::onUpdateCheckFinished)
|
||||
EVT_LISTBOX(ID_PACKAGE_LIST, UpdatesWindow::onPackageSelect)
|
||||
EVT_BUTTON(ID_INSTALL, UpdatesWindow::onButton)
|
||||
EVT_BUTTON(ID_REMOVE, UpdatesWindow::onButton)
|
||||
EVT_BUTTON(ID_UPGRADE, UpdatesWindow::onButton)
|
||||
EVT_BUTTON(ID_CANCEL, UpdatesWindow::onButton)
|
||||
EVT_BUTTON(ID_INSTALL, UpdatesWindow::onActionChange)
|
||||
EVT_BUTTON(ID_REMOVE, UpdatesWindow::onActionChange)
|
||||
EVT_BUTTON(ID_UPGRADE, UpdatesWindow::onActionChange)
|
||||
EVT_BUTTON(ID_CANCEL, UpdatesWindow::onActionChange)
|
||||
EVT_BUTTON(ID_APPLY, UpdatesWindow::onApplyChanges)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@@ -65,11 +65,12 @@ class UpdatesWindow : public Frame {
|
||||
wxHtmlWindow* description_window;
|
||||
|
||||
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 onPackageSelect(wxCommandEvent&);
|
||||
void onButton(wxCommandEvent&);
|
||||
void onActionChange(wxCommandEvent&);
|
||||
void onApplyChanges(wxCommandEvent&);
|
||||
|
||||
/// Update the buttons to indicate that this is selected.
|
||||
void updateButtons(int index);
|
||||
|
||||
@@ -241,7 +241,7 @@ DropDownList* DropDownWordList::submenu(size_t item) const {
|
||||
if (i.flags & FLAG_SUBMENU) {
|
||||
// create 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();
|
||||
} else {
|
||||
|
||||
+6
-5
@@ -99,12 +99,13 @@ int MSE::OnRun() {
|
||||
return wxApp::OnRun();
|
||||
} else if (f.GetExt() == _("mse-installer")) {
|
||||
// Installer; install it
|
||||
bool local = false;
|
||||
InstallType type = settings.install_type;
|
||||
if (argc > 2) {
|
||||
String arg2 = argv[2];
|
||||
local = arg2 == _("--local");
|
||||
}
|
||||
Installer::installFrom(argv[1], true, local);
|
||||
String arg = argv[2];
|
||||
if (arg.Mid(0,2) == _("--"))
|
||||
parse_enum(arg.Mid(2), type);
|
||||
}
|
||||
Installer::installFrom(argv[1], true, isInstallLocal(type));
|
||||
return EXIT_SUCCESS;
|
||||
} else if (arg == _("--symbol-editor")) {
|
||||
Window* wnd = new SymbolWindow(nullptr);
|
||||
|
||||
@@ -270,9 +270,11 @@ menu:
|
||||
add card: 0
|
||||
add cards: 0
|
||||
add keyword: 0
|
||||
apply changes: 0
|
||||
auto replace: 0
|
||||
basic shapes: 0
|
||||
bold: 0
|
||||
cancel changes: 0
|
||||
card list columns: 0
|
||||
cards: 0
|
||||
cards tab: 0
|
||||
@@ -298,6 +300,7 @@ menu:
|
||||
help: 0
|
||||
index: 0
|
||||
insert symbol: 0
|
||||
install package: 0
|
||||
italic: 0
|
||||
keywords: 0
|
||||
keywords tab: 0
|
||||
@@ -322,6 +325,7 @@ menu:
|
||||
reminder text: 0
|
||||
remove card: 0
|
||||
remove keyword: 0
|
||||
remove package: 0
|
||||
replace: 0
|
||||
rotate: 0
|
||||
rotate 0: 0
|
||||
@@ -342,6 +346,7 @@ menu:
|
||||
tool: 0
|
||||
undo: 1
|
||||
ungroup: 0
|
||||
upgrade package: 0
|
||||
website: 0
|
||||
window: 0
|
||||
title:
|
||||
|
||||
@@ -166,7 +166,7 @@ void CachedScriptableImage::generateCached(const GeneratedImage::Options& option
|
||||
set_alpha(cached_i, *mask);
|
||||
} else {
|
||||
Image mask_scaled(cached_i.GetWidth(),cached_i.GetHeight(), false);
|
||||
resample(mask,mask_scaled);
|
||||
resample(*mask,mask_scaled);
|
||||
set_alpha(cached_i, mask_scaled);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -62,13 +62,13 @@ void writeUTF8(wxTextOutputStream& stream, const String& str);
|
||||
|
||||
/// Some constants we like to use
|
||||
#ifdef UNICODE
|
||||
#define LEFT_ANGLE_BRACKET _("\x2039")
|
||||
#define RIGHT_ANGLE_BRACKET _("\x203A")
|
||||
#define LEFT_SINGLE_QUOTE _('\x2018')
|
||||
#define RIGHT_SINGLE_QUOTE _('\x2019')
|
||||
#define LEFT_DOUBLE_QUOTE _('\x201C')
|
||||
#define RIGHT_DOUBLE_QUOTE _('\x201D')
|
||||
#define CONNECTION_SPACE _('\xEB00') // in private use are, untags to ' '
|
||||
#define LEFT_ANGLE_BRACKET _("\u2039")
|
||||
#define RIGHT_ANGLE_BRACKET _("\u203A")
|
||||
#define LEFT_SINGLE_QUOTE _('\u2018')
|
||||
#define RIGHT_SINGLE_QUOTE _('\u2019')
|
||||
#define LEFT_DOUBLE_QUOTE _('\u201C')
|
||||
#define RIGHT_DOUBLE_QUOTE _('\u201D')
|
||||
#define CONNECTION_SPACE _('\uEB00') // in private use are, untags to ' '
|
||||
#else
|
||||
#define LEFT_ANGLE_BRACKET _("<")
|
||||
#define RIGHT_ANGLE_BRACKET _(">")
|
||||
|
||||
@@ -243,7 +243,9 @@ enum ControlID {
|
||||
, ID_INSTALL
|
||||
, ID_UPGRADE
|
||||
, 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
|
||||
, ID_USE_AUTO_REPLACE
|
||||
, ID_ITEM_VALUE
|
||||
|
||||
Reference in New Issue
Block a user