mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Modified update checker to get it to compile
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@605 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <gui/control/card_editor.hpp>
|
||||
#include <gui/control/text_ctrl.hpp>
|
||||
#include <gui/about_window.hpp>
|
||||
#include <gui/update_checker.hpp>
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/set.hpp>
|
||||
@@ -64,7 +65,8 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
menuCard->Append(ID_CARD_ADD_MULT, _("card_add_multiple"), _MENU_("add cards"), _HELP_("add cards"));
|
||||
// NOTE: space after "Del" prevents wx from making del an accellerator
|
||||
// otherwise we delete a card when delete is pressed inside the editor
|
||||
menuCard->Append(ID_CARD_REMOVE, _("card_del"), _MENU_("remove card"),_HELP_("remove card"));
|
||||
// Adding a space never hurts, please keep it just to be safe.
|
||||
menuCard->Append(ID_CARD_REMOVE, _("card_del"), _MENU_("remove card")+_(" "),_HELP_("remove card"));
|
||||
menuCard->AppendSeparator();
|
||||
IconMenu* menuRotate = new IconMenu();
|
||||
menuRotate->Append(ID_CARD_ROTATE_0, _("card_rotate_0"), _MENU_("rotate 0"), _HELP_("rotate 0"), wxITEM_CHECK);
|
||||
|
||||
@@ -529,7 +529,7 @@ void SetWindow::onFileExportMWS(wxCommandEvent&) {
|
||||
}
|
||||
|
||||
void SetWindow::onFileCheckUpdates(wxCommandEvent&) {
|
||||
(new UpdateWindow)->Show();
|
||||
(new UpdatesWindow)->Show();
|
||||
}
|
||||
|
||||
void SetWindow::onFilePrint(wxCommandEvent&) {
|
||||
|
||||
+47
-34
@@ -179,11 +179,11 @@ void show_update_dialog(Window* parent) {
|
||||
shown_dialog = true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : UpdateWindow
|
||||
// ----------------------------------------------------------------------------- : PackageUpdateList
|
||||
|
||||
class PackageUpdateList: public wxVListBox {
|
||||
class PackageUpdateList : public wxVListBox {
|
||||
public:
|
||||
PackageUpdateList(UpdateWindow * parent)
|
||||
PackageUpdateList(UpdatesWindow* parent)
|
||||
: wxVListBox (parent, wxID_ANY, wxDefaultPosition, wxSize(480,210), wxNO_BORDER | wxVSCROLL)
|
||||
, parent(parent)
|
||||
{
|
||||
@@ -197,29 +197,31 @@ class PackageUpdateList: public wxVListBox {
|
||||
static wxBrush greyBrush(Color(224,224,224));
|
||||
if (checking_updates) {
|
||||
String text = _ERROR_("checking updates");
|
||||
wxSize text_size = dc.GetTextExtent(text);
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(greyBrush);
|
||||
dc.DrawRectangle(rect);
|
||||
|
||||
dc.DrawText(text, rect.GetLeft() + (rect.GetWidth() - text_size.GetWidth()) / 2, rect.GetTop() + (rect.GetHeight() - text_size.GetHeight()) / 2);
|
||||
int w, h;
|
||||
dc.GetTextExtent(text, &w, &h);
|
||||
dc.DrawText(text, rect.GetLeft() + (rect.GetWidth() - w) / 2, rect.GetTop() + (rect.GetHeight() - h) / 2);
|
||||
} else if (!update_version_data || update_version_data->packages.empty()) {
|
||||
String text = _ERROR_("no packages");
|
||||
wxSize text_size = dc.GetTextExtent(text);
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(greyBrush);
|
||||
dc.DrawRectangle(rect);
|
||||
|
||||
dc.DrawText(text, rect.GetLeft() + (rect.GetWidth() - text_size.GetWidth()) / 2, rect.GetTop() + (rect.GetHeight() - text_size.GetHeight()) / 2);
|
||||
int w, h;
|
||||
dc.GetTextExtent(text, &w, &h);
|
||||
dc.DrawText(text, rect.GetLeft() + (rect.GetWidth() - w) / 2, rect.GetTop() + (rect.GetHeight() - h) / 2);
|
||||
} else {
|
||||
static wxBrush darkBrush(Color(192,224,255));
|
||||
static wxBrush selectBrush(Color(96,96,192));
|
||||
|
||||
PackageVersionDataP pack = update_version_data->packages[n];
|
||||
UpdateWindow::PackageStatus status = parent->package_data[pack].first;
|
||||
UpdateWindow::PackageAction action = parent->package_data[pack].second;
|
||||
UpdatesWindow::PackageStatus status = parent->package_data[pack].first;
|
||||
UpdatesWindow::PackageAction action = parent->package_data[pack].second;
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(IsSelected(n) ? selectBrush : (n % 2 ? *wxWHITE_BRUSH : darkBrush));
|
||||
@@ -256,13 +258,14 @@ class PackageUpdateList: public wxVListBox {
|
||||
,_TYPE_("new mse")
|
||||
};
|
||||
|
||||
static Color textBack(0,0,0,wxALPHA_TRANSPARENT);
|
||||
// this doesn't work for me, is it really necessary?
|
||||
//static Color textBack(0,0,0,wxALPHA_TRANSPARENT);
|
||||
static Color packageFront(64,64,64);
|
||||
|
||||
#define SELECT_WHITE(color) (IsSelected(n) ? *wxWHITE : color)
|
||||
|
||||
dc.SetTextForeground(SELECT_WHITE(packageFront));
|
||||
dc.SetTextBackground(textBack);
|
||||
//dc.SetTextBackground(textBack);
|
||||
dc.DrawText(pack->name, rect.GetLeft() + 1, rect.GetTop());
|
||||
|
||||
dc.SetTextForeground(SELECT_WHITE(status_colors[status]));
|
||||
@@ -284,20 +287,23 @@ class PackageUpdateList: public wxVListBox {
|
||||
}
|
||||
|
||||
virtual wxCoord EstimateTotalHeight() const {
|
||||
return (update_version_data && !update_version_data->packages.empty()) ? 15 * update_version_data->packages.size() : 210;
|
||||
return (update_version_data && !update_version_data->packages.empty())
|
||||
? 15 * (int)update_version_data->packages.size()
|
||||
: 210;
|
||||
}
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
UpdateWindow * parent;
|
||||
UpdatesWindow* parent;
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(PackageUpdateList, wxVListBox)
|
||||
EVT_CUSTOM(UPDATE_CHECK_FINISHED_EVT, -1, PackageUpdateList::onUpdateCheckingFinished)
|
||||
EVT_CUSTOM(UPDATE_CHECK_FINISHED_EVT, wxID_ANY, PackageUpdateList::onUpdateCheckingFinished)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
UpdateWindow::UpdateWindow()
|
||||
// ----------------------------------------------------------------------------- : UpdateWindow
|
||||
|
||||
UpdatesWindow::UpdatesWindow()
|
||||
: Frame(nullptr, wxID_ANY, _TITLE_("package list"), wxDefaultPosition, wxSize(480,375), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN)
|
||||
{
|
||||
SetIcon(wxIcon());
|
||||
@@ -306,12 +312,12 @@ UpdateWindow::UpdateWindow()
|
||||
package_list = new PackageUpdateList(this);
|
||||
description_window = new HtmlWindowToBrowser(this, wxID_ANY, wxDefaultPosition, wxSize(480,100), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
|
||||
|
||||
wxCommandEvent ev;
|
||||
SetDefaultPackageStatus(ev);
|
||||
setDefaultPackageStatus();
|
||||
|
||||
package_title = new wxStaticText(this, wxID_ANY, _TITLE_("package name"), wxDefaultPosition, wxSize(120,15), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
|
||||
status_title = new wxStaticText(this, wxID_ANY, _TITLE_("package status"), wxDefaultPosition, wxSize(120,15), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
|
||||
new_title = new wxStaticText(this, wxID_ANY, _TITLE_("new status"), wxDefaultPosition, wxSize(120,15), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
|
||||
// TODO: No absolute positioning please!
|
||||
package_title = new wxStaticText(this, wxID_ANY, _TITLE_("package name"), wxDefaultPosition, wxSize(120,15), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
|
||||
status_title = new wxStaticText(this, wxID_ANY, _TITLE_("package status"), wxDefaultPosition, wxSize(120,15), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
|
||||
new_title = new wxStaticText(this, wxID_ANY, _TITLE_("new status"), wxDefaultPosition, wxSize(120,15), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
|
||||
package_title->Move(1,0);
|
||||
status_title->Move(240,0);
|
||||
new_title->Move(360,0);
|
||||
@@ -323,30 +329,37 @@ UpdateWindow::UpdateWindow()
|
||||
SetSizer(v);
|
||||
}
|
||||
|
||||
void UpdateWindow::SetDefaultPackageStatus(wxCommandEvent&)
|
||||
{
|
||||
if (!update_version_data)
|
||||
return;
|
||||
void UpdatesWindow::onUpdateCheckFinished(wxCommandEvent&) {
|
||||
setDefaultPackageStatus();
|
||||
}
|
||||
|
||||
void UpdatesWindow::setDefaultPackageStatus() {
|
||||
if (!update_version_data) return;
|
||||
FOR_EACH(p, update_version_data->packages) {
|
||||
PackagedP pack;
|
||||
try { pack = packages.openAny(p->name); }
|
||||
catch (Error& e) { } // We couldn't open a package... wonder why?
|
||||
try { pack = packages.openAny(p->name, true); }
|
||||
catch (const Error&) { } // We couldn't open a package... wonder why?
|
||||
|
||||
if (!pack) {
|
||||
if (p->app_version > file_version)
|
||||
// not installed
|
||||
if (p->app_version > file_version) {
|
||||
package_data[p] = PackageData(STATUS_NOT_INSTALLED, ACTION_NEW_MSE);
|
||||
else
|
||||
} else {
|
||||
package_data[p] = PackageData(STATUS_NOT_INSTALLED, ACTION_NOTHING);
|
||||
}
|
||||
} else if (pack->version < p->version) {
|
||||
if (p->app_version > file_version)
|
||||
// newer version
|
||||
if (p->app_version > file_version) {
|
||||
package_data[p] = PackageData(STATUS_UPGRADEABLE, ACTION_NEW_MSE);
|
||||
else
|
||||
} else {
|
||||
package_data[p] = PackageData(STATUS_UPGRADEABLE, ACTION_UPGRADE);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
package_data[p] = PackageData(STATUS_INSTALLED, ACTION_NOTHING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(UpdateWindow, Frame)
|
||||
EVT_COMMAND(-1, UPDATE_CHECK_FINISHED_EVT, UpdateWindow::SetDefaultPackageStatus)
|
||||
BEGIN_EVENT_TABLE(UpdatesWindow, Frame)
|
||||
EVT_COMMAND(wxID_ANY, UPDATE_CHECK_FINISHED_EVT, UpdatesWindow::onUpdateCheckFinished)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <wx/html/htmlwin.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Update checking
|
||||
|
||||
@@ -27,14 +26,20 @@ void check_updates_now(bool async = true);
|
||||
* Call this function from an onIdle loop */
|
||||
void show_update_dialog(Window* parent);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Update window
|
||||
|
||||
class PackageUpdateList;
|
||||
class wxHtmlWindow;
|
||||
|
||||
DECLARE_POINTER_TYPE(PackageVersionData);
|
||||
|
||||
/// A window that displays the updates and allows the user to select some.
|
||||
class UpdateWindow : public Frame {
|
||||
/** NOTE: cannot be called 'UpdateWindow' because there is a Win32 function with that name
|
||||
*/
|
||||
class UpdatesWindow : public Frame {
|
||||
public:
|
||||
UpdateWindow();
|
||||
UpdatesWindow();
|
||||
|
||||
void DrawTitles(wxPaintEvent&);
|
||||
|
||||
enum PackageStatus {
|
||||
@@ -54,13 +59,16 @@ class UpdateWindow : public Frame {
|
||||
|
||||
map<PackageVersionDataP, PackageData> package_data;
|
||||
|
||||
void SetDefaultPackageStatus(wxCommandEvent&);
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
PackageUpdateList* package_list;
|
||||
PackageUpdateList* package_list; ///< List of available packages
|
||||
wxHtmlWindow* description_window;
|
||||
|
||||
wxStaticText *package_title, *status_title, *new_title;
|
||||
|
||||
void onUpdateCheckFinished(wxCommandEvent&);
|
||||
|
||||
void setDefaultPackageStatus();
|
||||
};
|
||||
|
||||
/// Was update data found?
|
||||
|
||||
Reference in New Issue
Block a user