mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 05:36:59 -04:00
PackagesWindow can show just the packages from an installer.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@905 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -246,6 +246,12 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(DownloadableInstaller) {
|
|||||||
REFLECT(packages);
|
REFLECT(packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DownloadableInstaller::DownloadableInstaller(const InstallerP& installer)
|
||||||
|
: installer(installer)
|
||||||
|
, downloadable(false)
|
||||||
|
, packages(installer->packages)
|
||||||
|
{}
|
||||||
|
|
||||||
DownloadableInstaller::~DownloadableInstaller() {
|
DownloadableInstaller::~DownloadableInstaller() {
|
||||||
if (!installer_file.empty()) {
|
if (!installer_file.empty()) {
|
||||||
wxRemoveFile(installer_file);
|
wxRemoveFile(installer_file);
|
||||||
|
|||||||
@@ -34,6 +34,15 @@ void TreeList::expand(size_t item, bool expand) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TreeList::expandAll(bool expand) {
|
||||||
|
for (size_t item = 0 ; item < items.size() ; ++item) {
|
||||||
|
if (hasChildren(item)) {
|
||||||
|
items[item]->expanded = expand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rebuild(false);
|
||||||
|
}
|
||||||
|
|
||||||
void TreeList::select(size_t item, bool event) {
|
void TreeList::select(size_t item, bool event) {
|
||||||
if (item >= items.size() || selection == item) return;
|
if (item >= items.size() || selection == item) return;
|
||||||
// select
|
// select
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class TreeList : public wxPanel {
|
|||||||
|
|
||||||
/// Expand/collapse an item
|
/// Expand/collapse an item
|
||||||
void expand(size_t item, bool expand = true);
|
void expand(size_t item, bool expand = true);
|
||||||
|
/// Expand/collapse all items
|
||||||
|
void expandAll(bool expand = true);
|
||||||
/// Select an item
|
/// Select an item
|
||||||
void select(size_t item, bool event = true);
|
void select(size_t item, bool event = true);
|
||||||
|
|
||||||
|
|||||||
@@ -189,8 +189,9 @@ class PackageIconRequest : public ThumbnailRequest {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : PackageUpdateList : implementation
|
// ----------------------------------------------------------------------------- : PackageUpdateList : implementation
|
||||||
|
|
||||||
PackageUpdateList::PackageUpdateList(Window* parent, const InstallablePackages& packages, int id)
|
PackageUpdateList::PackageUpdateList(Window* parent, const InstallablePackages& packages, bool show_only_installable, int id)
|
||||||
: TreeList(parent, id)
|
: TreeList(parent, id)
|
||||||
|
, show_only_installable(show_only_installable)
|
||||||
, packages(packages)
|
, packages(packages)
|
||||||
{
|
{
|
||||||
item_height = max(item_height,17);
|
item_height = max(item_height,17);
|
||||||
@@ -206,7 +207,9 @@ void PackageUpdateList::initItems() {
|
|||||||
FOR_EACH_CONST(ip, packages) {
|
FOR_EACH_CONST(ip, packages) {
|
||||||
String group = ip->description->installer_group;
|
String group = ip->description->installer_group;
|
||||||
if (group.empty()) group = _("custom");
|
if (group.empty()) group = _("custom");
|
||||||
root.add(ip, group);
|
if (!show_only_installable || ip->installer) {
|
||||||
|
root.add(ip, group);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// tree to treelist items
|
// tree to treelist items
|
||||||
items.clear();
|
items.clear();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
/// A list of installed and downloadable packages
|
/// A list of installed and downloadable packages
|
||||||
class PackageUpdateList : public TreeList {
|
class PackageUpdateList : public TreeList {
|
||||||
public:
|
public:
|
||||||
PackageUpdateList(Window* parent, const InstallablePackages& packages, int id = wxID_ANY);
|
PackageUpdateList(Window* parent, const InstallablePackages& packages, bool show_only_installable, int id = wxID_ANY);
|
||||||
~PackageUpdateList();
|
~PackageUpdateList();
|
||||||
|
|
||||||
inline InstallablePackageP getSelection() const {
|
inline InstallablePackageP getSelection() const {
|
||||||
@@ -39,7 +39,10 @@ class PackageUpdateList : public TreeList {
|
|||||||
virtual int columnWidth(size_t column) const;
|
virtual int columnWidth(size_t column) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// The list of packages we are displaying
|
||||||
const InstallablePackages& packages;
|
const InstallablePackages& packages;
|
||||||
|
/// Show only packages with an installer?
|
||||||
|
bool show_only_installable;
|
||||||
|
|
||||||
class TreeItem;
|
class TreeItem;
|
||||||
public:
|
public:
|
||||||
|
|||||||
+34
-17
@@ -48,8 +48,8 @@ class DownloadableInstallerList {
|
|||||||
public:
|
public:
|
||||||
DownloadableInstallerList() : status(NONE) {}
|
DownloadableInstallerList() : status(NONE) {}
|
||||||
|
|
||||||
/// are we done? if not, start downloading
|
/// start downloading, return true if we are done
|
||||||
bool done();
|
bool download();
|
||||||
|
|
||||||
vector<DownloadableInstallerP> installers;
|
vector<DownloadableInstallerP> installers;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ class DownloadableInstallerList {
|
|||||||
/// The global installer downloader
|
/// The global installer downloader
|
||||||
DownloadableInstallerList downloadable_installers;
|
DownloadableInstallerList downloadable_installers;
|
||||||
|
|
||||||
bool DownloadableInstallerList::done() {
|
bool DownloadableInstallerList::download() {
|
||||||
if (status == DONE) return true;
|
if (status == DONE) return true;
|
||||||
if (status == NONE) {
|
if (status == NONE) {
|
||||||
status = DOWNLOADING;
|
status = DOWNLOADING;
|
||||||
@@ -157,12 +157,29 @@ END_EVENT_TABLE()
|
|||||||
// ----------------------------------------------------------------------------- : PackagesWindow
|
// ----------------------------------------------------------------------------- : PackagesWindow
|
||||||
|
|
||||||
PackagesWindow::PackagesWindow(Window* parent, bool download_package_list)
|
PackagesWindow::PackagesWindow(Window* parent, bool download_package_list)
|
||||||
: wxDialog(parent, wxID_ANY, _TITLE_("packages window"), wxDefaultPosition, wxSize(640,480), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN | wxRESIZE_BORDER)
|
: waiting_for_list(download_package_list)
|
||||||
, where(is_install_local(settings.install_type) ? PACKAGE_LOCAL : PACKAGE_GLOBAL)
|
|
||||||
, waiting_for_list(download_package_list)
|
|
||||||
{
|
{
|
||||||
// request download before searching disk so we do two things at once
|
// request download before searching disk so we do two things at once
|
||||||
if (download_package_list) downloadable_installers.done();
|
if (download_package_list) downloadable_installers.download();
|
||||||
|
init(parent, false);
|
||||||
|
}
|
||||||
|
PackagesWindow::PackagesWindow(Window* parent, const InstallerP& installer)
|
||||||
|
: waiting_for_list(false)
|
||||||
|
{
|
||||||
|
init(parent, true);
|
||||||
|
// add installer
|
||||||
|
merge(installable_packages, new_intrusive1<DownloadableInstaller>(installer));
|
||||||
|
// TODO: mark all packages in the installer for installation
|
||||||
|
// update window
|
||||||
|
package_list->rebuild();
|
||||||
|
package_list->expandAll();
|
||||||
|
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PackagesWindow::init(Window* parent, bool show_only_installable) {
|
||||||
|
where = is_install_local(settings.install_type) ? PACKAGE_LOCAL : PACKAGE_GLOBAL;
|
||||||
|
Create(parent, wxID_ANY, _TITLE_("packages window"), wxDefaultPosition, wxSize(640,480), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN | wxRESIZE_BORDER);
|
||||||
|
|
||||||
// get packages
|
// get packages
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
packages.installedPackages(installable_packages);
|
packages.installedPackages(installable_packages);
|
||||||
@@ -171,7 +188,7 @@ PackagesWindow::PackagesWindow(Window* parent, bool download_package_list)
|
|||||||
|
|
||||||
// ui elements
|
// ui elements
|
||||||
SetIcon(wxIcon());
|
SetIcon(wxIcon());
|
||||||
package_list = new PackageUpdateList(this, installable_packages, ID_PACKAGE_LIST);
|
package_list = new PackageUpdateList(this, installable_packages, show_only_installable, ID_PACKAGE_LIST);
|
||||||
package_info = new PackageInfoPanel(this);
|
package_info = new PackageInfoPanel(this);
|
||||||
|
|
||||||
//wxToolbar* buttons = new wxToolbar
|
//wxToolbar* buttons = new wxToolbar
|
||||||
@@ -231,18 +248,18 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
|
|||||||
int total = (int)installable_packages.size();
|
int total = (int)installable_packages.size();
|
||||||
wxProgressDialog progress(
|
wxProgressDialog progress(
|
||||||
_TITLE_("installing updates"),
|
_TITLE_("installing updates"),
|
||||||
String::Format(_ERROR_("downloading updates"), 0, 2*total),
|
String::Format(_ERROR_("downloading updates"), 0, total),
|
||||||
total,
|
2*total,
|
||||||
this,
|
this,
|
||||||
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_SMOOTH
|
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_SMOOTH
|
||||||
);
|
);
|
||||||
// Clear package list
|
// Clear package list
|
||||||
packages.reset();
|
packages.reset();
|
||||||
// Download installers
|
// Download installers
|
||||||
int n = 0;
|
int package_pos = 0, progress = 0;
|
||||||
FOR_EACH(ip, installable_packages) {
|
FOR_EACH(ip, installable_packages) {
|
||||||
++n;
|
++package_pos; ++progress;
|
||||||
if (!progress.Update(n, String::Format(_ERROR_("downloading updates"), n, total))) {
|
if (!progress.Update(progress, String::Format(_ERROR_("downloading updates"), package_pos, total))) {
|
||||||
return; // aborted
|
return; // aborted
|
||||||
}
|
}
|
||||||
if ((ip->action & PACKAGE_INSTALL) && ip->installer && !ip->installer->installer) {
|
if ((ip->action & PACKAGE_INSTALL) && ip->installer && !ip->installer->installer) {
|
||||||
@@ -262,10 +279,10 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Install stuff
|
// Install stuff
|
||||||
int n2 = 0 ;
|
package_pos = 0 ;
|
||||||
FOR_EACH(ip, installable_packages) {
|
FOR_EACH(ip, installable_packages) {
|
||||||
++n; ++n2;
|
++package_pos; ++progress;
|
||||||
if (!progress.Update(n, String::Format(_ERROR_("installing updates"), n2, total))) {
|
if (!progress.Update(progress, String::Format(_ERROR_("installing updates"), package_pos, total))) {
|
||||||
// don't allow abort.
|
// don't allow abort.
|
||||||
}
|
}
|
||||||
packages.install(*ip);
|
packages.install(*ip);
|
||||||
@@ -303,7 +320,7 @@ void PackagesWindow::onIdle(wxIdleEvent& ev) {
|
|||||||
|
|
||||||
bool PackagesWindow::checkInstallerList(bool refresh) {
|
bool PackagesWindow::checkInstallerList(bool refresh) {
|
||||||
if (!waiting_for_list) return true;
|
if (!waiting_for_list) return true;
|
||||||
if (!downloadable_installers.done()) return false;
|
if (!downloadable_installers.download()) return false;
|
||||||
waiting_for_list = false;
|
waiting_for_list = false;
|
||||||
// merge installer lists
|
// merge installer lists
|
||||||
FOR_EACH(inst, downloadable_installers.installers) {
|
FOR_EACH(inst, downloadable_installers.installers) {
|
||||||
|
|||||||
@@ -26,13 +26,12 @@ class PackagesWindow : public wxDialog {
|
|||||||
PackagesWindow(Window* parent, const InstallerP& installer);
|
PackagesWindow(Window* parent, const InstallerP& installer);
|
||||||
~PackagesWindow();
|
~PackagesWindow();
|
||||||
|
|
||||||
/// List of the packages shown in this window
|
|
||||||
InstallablePackages installable_packages;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PackageUpdateList* package_list; ///< List of available packages
|
PackageUpdateList* package_list; ///< List of available packages
|
||||||
PackageInfoPanel* package_info; ///< Description of the selected package
|
PackageInfoPanel* package_info; ///< Description of the selected package
|
||||||
|
|
||||||
|
/// List of the packages shown in this window
|
||||||
|
InstallablePackages installable_packages;
|
||||||
InstallablePackageP package; ///< Selected package
|
InstallablePackageP package; ///< Selected package
|
||||||
PackageAction where; ///< Where to install? (PACKAGE_LOCAL or PACKAGE_GLOBAL)
|
PackageAction where; ///< Where to install? (PACKAGE_LOCAL or PACKAGE_GLOBAL)
|
||||||
|
|
||||||
@@ -46,6 +45,9 @@ class PackagesWindow : public wxDialog {
|
|||||||
void onUpdateUI(wxUpdateUIEvent&);
|
void onUpdateUI(wxUpdateUIEvent&);
|
||||||
void onIdle(wxIdleEvent&);
|
void onIdle(wxIdleEvent&);
|
||||||
|
|
||||||
|
/// Window initialization
|
||||||
|
void init(Window* parent, bool show_only_installable);
|
||||||
|
|
||||||
/// Check whether we have downloaded the list of installers
|
/// Check whether we have downloaded the list of installers
|
||||||
/** If the download is (partially) complete, update the installable_packages list */
|
/** If the download is (partially) complete, update the installable_packages list */
|
||||||
bool checkInstallerList(bool refresh = true);
|
bool checkInstallerList(bool refresh = true);
|
||||||
|
|||||||
@@ -99,14 +99,6 @@ void WelcomeWindow::onNewSet(wxCommandEvent&) {
|
|||||||
close(new_set_window(this));
|
close(new_set_window(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: MOVEME
|
|
||||||
template <typename T>
|
|
||||||
intrusive_ptr<T> open_package(const String& filename) {
|
|
||||||
intrusive_ptr<T> package(new T);
|
|
||||||
package->open(filename);
|
|
||||||
return package;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WelcomeWindow::onOpenLast(wxCommandEvent&) {
|
void WelcomeWindow::onOpenLast(wxCommandEvent&) {
|
||||||
wxBusyCursor wait;
|
wxBusyCursor wait;
|
||||||
assert(!settings.recent_sets.empty());
|
assert(!settings.recent_sets.empty());
|
||||||
|
|||||||
+7
-1
@@ -17,6 +17,7 @@
|
|||||||
#include <gui/welcome_window.hpp>
|
#include <gui/welcome_window.hpp>
|
||||||
#include <gui/update_checker.hpp>
|
#include <gui/update_checker.hpp>
|
||||||
#include <gui/images_export_window.hpp>
|
#include <gui/images_export_window.hpp>
|
||||||
|
#include <gui/packages_window.hpp>
|
||||||
#include <gui/set/window.hpp>
|
#include <gui/set/window.hpp>
|
||||||
#include <gui/symbol/window.hpp>
|
#include <gui/symbol/window.hpp>
|
||||||
#include <gui/thumbnail_thread.hpp>
|
#include <gui/thumbnail_thread.hpp>
|
||||||
@@ -108,8 +109,13 @@ int MSE::OnRun() {
|
|||||||
parse_enum(String(argv[2]).substr(2), type);
|
parse_enum(String(argv[2]).substr(2), type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//%%% Installer::installFrom(argv[1], true, isInstallLocal(type));
|
InstallerP installer = open_package<Installer>(argv[1]);
|
||||||
|
PackagesWindow wnd(nullptr, installer);
|
||||||
|
wnd.ShowModal();
|
||||||
|
//return wxApp::OnRun();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
//%%% Installer::installFrom(argv[1], true, isInstallLocal(type));
|
||||||
|
//%%% return EXIT_SUCCESS;
|
||||||
} else if (arg == _("--symbol-editor")) {
|
} else if (arg == _("--symbol-editor")) {
|
||||||
Window* wnd = new SymbolWindow(nullptr);
|
Window* wnd = new SymbolWindow(nullptr);
|
||||||
wnd->Show();
|
wnd->Show();
|
||||||
|
|||||||
@@ -247,5 +247,15 @@ class IncludePackage : public Packaged {
|
|||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : Utility
|
||||||
|
|
||||||
|
/// Open a package with the given filename
|
||||||
|
template <typename T>
|
||||||
|
intrusive_ptr<T> open_package(const String& filename) {
|
||||||
|
intrusive_ptr<T> package(new T);
|
||||||
|
package->open(filename);
|
||||||
|
return package;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user