Finally got precompiled headers to work.

Now all C++ files need to #include <util/prec.hpp>
 That is why all .cpp files are touched by this commit

Many changes to installers and update checking:
     - the window is now called PackagesWindow, in a new source file
     - update checking is now independent from the PackagesWindow. For update checking only a list of package versions are needed (vector<PackageDependency>). This is much less information to download at each startup.
     - the list of available packages is now a list of available Installers, since an installer can contain multiple packages.
     - moved the logic of dependency checking etc. to data/installer
     - moved the actual installation to util/io/package_manager
     - moved directory iteration/creation logic to util/file_utils
     - added PackageDirectory: the local and global package directory now have their own object (was part of PackageManager)
     - added PackageVersion: for detecting if a package has been modified after it was installed.
     - added PackageDescription: description/header of a package. Basicly the same as what Packaged provides.
     - added DownloadableInstaller: where to find an insaller, what does it contain?
     - added InstallablePackage: brining it all together: installer, package, status, action.

Current status: the insaller is currently broken in a few places, more on that soon.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@792 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-12-29 18:30:41 +00:00
parent 361488b4fe
commit d2196eea09
182 changed files with 2508 additions and 809 deletions
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/action/keyword.hpp>
#include <data/keyword.hpp>
#include <data/set.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/action/set.hpp>
#include <data/set.hpp>
#include <data/card.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/action/symbol.hpp>
#include <data/action/symbol_part.hpp>
#include <util/error.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/action/symbol_part.hpp>
#include <gfx/bezier.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/action/value.hpp>
#include <data/field.hpp>
#include <data/field/text.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/card.hpp>
#include <data/game.hpp>
#include <data/stylesheet.hpp>
+1 -1
View File
@@ -49,7 +49,7 @@ class Card : public IntrusivePtrVirtualBase {
/// Extra values for specitic stylesheets, indexed by stylesheet name
DelayedIndexMaps<FieldP,ValueP> extra_data;
/// Styling information for a particular stylesheet
IndexMap<FieldP, ValueP>& extraDataFor(const StyleSheet& stylesheet) ;
IndexMap<FieldP, ValueP>& extraDataFor(const StyleSheet& stylesheet);
/// Keyword usage statistics
vector<pair<Value*,const Keyword*> > keyword_usage;
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/export_template.hpp>
#include <data/game.hpp>
#include <data/field.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field.hpp>
#include <data/field/text.hpp>
#include <data/field/choice.hpp>
+3 -2
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/boolean.hpp>
// ----------------------------------------------------------------------------- : BooleanField
@@ -31,8 +32,8 @@ BooleanStyle::BooleanStyle(const ChoiceFieldP& field)
: ChoiceStyle(field)
{
render_style = RENDER_BOTH;
//%%choice_images[_("yes")] = ScriptableImage(_("buildin_image(\"bool_yes\")"));
//%%choice_images[_("no")] = ScriptableImage(_("buildin_image(\"bool_no\")"));
//choice_images[_("yes")] = ScriptableImage(_("buildin_image(\"bool_yes\")"));
//choice_images[_("no")] = ScriptableImage(_("buildin_image(\"bool_no\")"));
choice_images[_("yes")] = ScriptableImage(new_intrusive1<BuiltInImage>(_("bool_yes")));
choice_images[_("no")] = ScriptableImage(new_intrusive1<BuiltInImage>(_("bool_no")));
}
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/choice.hpp>
#include <util/io/package.hpp>
#include <wx/imaglist.h>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/color.hpp>
#include <script/script.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/image.hpp>
// ----------------------------------------------------------------------------- : ImageField
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/information.hpp>
#include <script/script.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/multiple_choice.hpp>
// ----------------------------------------------------------------------------- : MultipleChoiceField
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/package_choice.hpp>
#include <util/io/package_manager.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/symbol.hpp>
#include <render/symbol/filter.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field/text.hpp>
#include <util/tagged_string.hpp>
#include <script/script.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/font.hpp>
// ----------------------------------------------------------------------------- : Font
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
#include <data/settings.hpp>
#include <data/set.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/clipboard.hpp>
#include <data/format/formats.hpp>
#include <data/card.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
#include <data/set.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
// ----------------------------------------------------------------------------- :
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
#include <data/set.hpp>
#include <data/stylesheet.hpp>
+1
View File
@@ -13,6 +13,7 @@
#pragma warning(disable:4996)
#endif
#include <util/prec.hpp>
#include <data/format/image_to_symbol.hpp>
#include <gfx/bezier.hpp>
#include <util/error.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
#include <data/set.hpp>
#include <data/game.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
#include <data/set.hpp>
#include <data/settings.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
#include <data/set.hpp>
#include <data/game.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/format/formats.hpp>
#include <data/game.hpp>
#include <data/set.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/game.hpp>
#include <data/field.hpp>
#include <data/field/choice.hpp>
+290 -5
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/installer.hpp>
#include <data/locale.hpp>
#include <data/game.hpp>
@@ -23,6 +24,8 @@
DECLARE_TYPEOF_COLLECTION(String);
DECLARE_TYPEOF_COLLECTION(PackagedP);
DECLARE_TYPEOF_COLLECTION(PackageDependencyP);
DECLARE_TYPEOF_COLLECTION(PackageDescriptionP);
DECLARE_TYPEOF_COLLECTION(InstallablePackageP);
DECLARE_POINTER_TYPE(wxFileInputStream);
DECLARE_POINTER_TYPE(wxZipInputStream);
@@ -64,11 +67,12 @@ struct dependency_check : public unary_function<bool, PackagedP> {
void Installer::install(bool local, bool check_dependencies) {
// Destination directory
String install_dir = local ? ::packages.getLocalDataDir() : ::packages.getGlobalDataDir();
// String install_dir = local ? ::packages.getLocalDataDir() : ::packages.getGlobalDataDir();
String install_dir = _("TODO");
if (!wxDirExists(install_dir)) {
wxMkdir(install_dir, 0755);
}
/*
// All the packages we're installing.
vector<PackagedP> new_packages;
@@ -130,6 +134,7 @@ void Installer::install(bool local, bool check_dependencies) {
}
os.Write(*is);
}
*/
}
void Installer::install(const String& package) {
@@ -151,13 +156,16 @@ void Installer::addPackage(const String& package) {
void Installer::addPackage(Packaged& package) {
// Add to list of packages
String name = package.relativeFilename();
if (find(packages.begin(), packages.end(), package.name()) != packages.end()) {
return; // already added
FOR_EACH(p, packages) {
if (p->name == name) {
return; // already added
}
}
packages.push_back(new_intrusive1<PackageDescription>(package));
// use this as a filename?
if (prefered_filename.empty()) {
prefered_filename = package.name() + _(".mse-installer");
}
packages.push_back(name);
// Copy all files from that package to this one
const FileInfos& file_infos = package.getFileInfos();
for (FileInfos::const_iterator it = file_infos.begin() ; it != file_infos.end() ; ++it) {
@@ -167,3 +175,280 @@ void Installer::addPackage(Packaged& package) {
os->Write(*is);
}
}
// ----------------------------------------------------------------------------- : Installer descriptions
PackageDescription::PackageDescription() : position_hint(0) {}
PackageDescription::PackageDescription(const Packaged& package)
: name(package.relativeFilename())
, version(package.version)
, short_name(package.short_name)
, full_name(package.full_name)
, icon_url(_(""))
, installer_group(package.installer_group)
, position_hint(package.position_hint)
//, description(package.description)
, dependencies(package.dependencies)
{
// name
if (short_name.empty()) {
if (!full_name.empty()) short_name = full_name;
else short_name = package.name();
}
if (full_name.empty()) full_name = short_name;
// installer group
if (installer_group.empty()) {
// "game-style.mse-something" -> "game/style" -> "game"
installer_group = replace_all(package.name(),_("-"),_("/"));
size_t pos = installer_group.find_last_of(_('/'));
if (pos != String::npos) installer_group.resize(pos);
}
// icon
InputStreamP file = const_cast<Packaged&>(package).openIconFile();
if (file) icon.LoadFile(*file);
}
IMPLEMENT_REFLECTION_NO_SCRIPT(PackageDescription) {
REFLECT(name);
REFLECT(version);
REFLECT(short_name);
REFLECT(full_name);
REFLECT(icon_url);
REFLECT(installer_group);
REFLECT(position_hint);
REFLECT(description);
REFLECT_N("depends ons", dependencies);
}
IMPLEMENT_REFLECTION_NO_SCRIPT(InstallerDescription) {
REFLECT(packages);
}
IMPLEMENT_REFLECTION_NO_SCRIPT(DownloadableInstaller) {
REFLECT_N("url", installer_url);
REFLECT(downloadable);
REFLECT(packages);
}
DownloadableInstaller::~DownloadableInstaller() {
if (!installer_file.empty()) {
wxRemoveFile(installer_file);
}
}
// ----------------------------------------------------------------------------- : Installable package
InstallablePackage::InstallablePackage() : action(PACKAGE_NOTHING) {}
InstallablePackage::InstallablePackage(const PackageVersionP& installed, const PackageDescriptionP& description)
: installed(installed)
, description(description)
, action(PACKAGE_NOTHING)
{}
void InstallablePackage::determineStatus() {
status = PACKAGE_NOT_INSTALLED;
if (installer) {
status = (PackageStatus)(status | PACKAGE_INSTALLABLE);
}
if (installed) {
status = (PackageStatus)(status | PACKAGE_INSTALLED);
if (!(installed->status & PackageVersion::STATUS_FIXED)) {
status = (PackageStatus)(status | PACKAGE_REMOVABLE);
}
}
if (installed && installed->version < description->version) {
status = (PackageStatus)(status | PACKAGE_UPDATES);
}
if (installed && (installed->status & PackageVersion::STATUS_MODIFIED)) {
status = (PackageStatus)(status | PACKAGE_MODIFIED);
}
}
bool InstallablePackage::can(PackageAction act) const {
if (act & PACKAGE_INSTALL) return (status & PACKAGE_INSTALLABLE) == PACKAGE_INSTALLABLE;
if (act & PACKAGE_UPGRADE) return (status & PACKAGE_UPDATES) == PACKAGE_UPDATES;
if (act & PACKAGE_REMOVE) {
bool ok = (status & PACKAGE_REMOVABLE) == PACKAGE_REMOVABLE;
if (!(act & PACKAGE_GLOBAL) && installed && PackageVersion::STATUS_GLOBAL) {
// package installed globally can't be removed locally
return false;
}
return ok;
}
else return false;
}
bool InstallablePackage::has(PackageAction act) const {
return (action & act) == act;
}
void InstallablePackage::merge(const InstallablePackage& p) {
if (!installed) installed = p.installed;
if (!installer) {
description = p.description; // installer has new description
installer = p.installer;
}
}
bool before(const InstallablePackageP& a, const InstallablePackageP& b) {
assert(a->description && b->description);
return a->description->name < b->description->name;
}
void sort(InstallablePackages& packages) {
sort(packages.begin(), packages.end(), before);
}
void merge(InstallablePackages& list1, const InstallablePackages& list2) {
InstallablePackages::iterator it1 = list1.begin();
InstallablePackages::const_iterator it2 = list2.begin();
InstallablePackages add;
while (it1 != list1.end() || it2 != list2.end()) {
if (it1 != list1.end() && (it2 == list2.end() || before(*it1,*it2))) {
++it1;
} else if (it1 == list1.end() || before(*it2,*it1)) {
add.push_back(*it2);
++it2;
} else {
(*it1)->merge(**it2);
++it1,++it2;
}
}
if (!add.empty()) {
list1.insert(list1.end(), add.begin(), add.end());
sort(list1);
}
}
void merge(InstallablePackages& installed, const DownloadableInstallerP& installer) {
InstallablePackages ips;
FOR_EACH(p, installer->packages) {
InstallablePackageP ip(new InstallablePackage);
ip->description = p;
ip->installer = installer;
ips.push_back(ip);
}
merge(installed, ips);
}
bool add_package_dependency(InstallablePackages& packages, const PackageDependency& dep, int where, bool set) {
FOR_EACH(p, packages) {
if (p->description->name == dep.package) {
// Some package depends on this package, so install it if needed
// Mark the installation as "automatically needed for X packages"
// if !set then instead the dependency is no longer needed because we are not installing the package
if (!p->installed || p->installed->version < dep.version) {
bool change = false;
if (p->action & (PACKAGE_INSTALL | PACKAGE_UPGRADE)) {
// this package is already scheduled for installation
if (p->automatic) {
// we are already automatically depending on this package
p->automatic += set ? +1 : -1;
if (p->automatic == 0) {
// no one needs this package anymore
p->action = PACKAGE_NOTHING;
change = true;
}
}
} else if (set) {
p->action = (PackageAction)(where |
(p->installed ? PACKAGE_UPGRADE : PACKAGE_INSTALL));
p->automatic = 1;
change = true;
}
// recursively add/remove dependencies
FOR_EACH(dep, p->description->dependencies) {
if (!add_package_dependency(packages, *dep, where, set)) {
return false; // failed
}
}
}
return true;
}
}
return false;
}
void remove_package_dependency(InstallablePackages& packages, const PackageDescription& ver, int where, bool set) {
FOR_EACH(p, packages) {
FOR_EACH(dep, p->description->dependencies) {
if (dep->package == ver.name) {
// we can no longer use package p
if (p->action & PACKAGE_REMOVE) {
if (p->automatic) {
p->automatic += set ? +1 : -1;
if (p->automatic == 0) {
// no one needs this package anymore
p->action = PACKAGE_NOTHING;
remove_package_dependency(packages, *p->description, where, set);
}
}
} else if (set) {
p->action = (PackageAction)(where | PACKAGE_REMOVE);
p->automatic = 1;
remove_package_dependency(packages, *p->description, where, set);
}
break;
}
}
}
}
bool set_package_action_unsafe(InstallablePackages& packages, const InstallablePackageP& package, PackageAction action) {
int where = action & PACKAGE_WHERE;
if ((action & PACKAGE_INSTALL) || (action & PACKAGE_UPGRADE) || ((action & PACKAGE_NOTHING) && (package->status & PACKAGE_INSTALLED))) {
// need the package
package->automatic = 0;
package->action = action;
// check dependencies
FOR_EACH(dep, package->description->dependencies) {
if (!add_package_dependency(packages, *dep, where, !(action & PACKAGE_NOTHING))) return false;
}
return true;
} else if ((action & PACKAGE_REMOVE) || ((action & PACKAGE_NOTHING) && !(package->status & PACKAGE_INSTALLED))) {
package->automatic = 0;
package->action = action;
// check dependencies
remove_package_dependency(packages, *package->description, where, !(action & PACKAGE_NOTHING));
return true;
}
return false;
}
bool set_package_action(InstallablePackages& packages, const InstallablePackageP& package, PackageAction action) {
if (package->has(action)) return false;
// backup
FOR_EACH(p,packages) {
p->old_action = p->action;
p->old_automatic = p->automatic;
}
// set
if (set_package_action_unsafe(packages, package, action)) return true;
// undo
FOR_EACH(p,packages) {
p->action = p->old_action;
p->automatic = p->old_automatic;
}
return false;
}
// ----------------------------------------------------------------------------- : MSE package
String mse_package = _("magicseteditor.exe");
InstallablePackageP mse_installable_package() {
PackageVersionP mse_version(new PackageVersion(
PackageVersion::STATUS_GLOBAL |
PackageVersion::STATUS_BLESSED |
PackageVersion::STATUS_FIXED));
mse_version->name = mse_package;
mse_version->version = app_version;
PackageDescriptionP mse_description(new PackageDescription);
mse_description->name = mse_package;
mse_description->short_name = mse_description->full_name = _TITLE_("magic set editor");
mse_description->position_hint = -100;
//mse_description->icon = load_resource_image(_("mse_icon"));
//mse_description->description = _LABEL_("magic set editor package");
return new_intrusive2<InstallablePackage>(mse_version,mse_description);
}
+135 -15
View File
@@ -9,22 +9,14 @@
// ----------------------------------------------------------------------------- : 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;
}
DECLARE_POINTER_TYPE(Installer);
DECLARE_POINTER_TYPE(PackageVersion);
DECLARE_POINTER_TYPE(PackageDescription);
DECLARE_POINTER_TYPE(DownloadableInstaller);
DECLARE_POINTER_TYPE(InstallablePackage);
// ----------------------------------------------------------------------------- : Installer
@@ -32,7 +24,7 @@ inline bool isInstallLocal(const InstallType& type)
class Installer : public Packaged {
public:
String prefered_filename; ///< What filename should be used (by default)
vector<String> packages; ///< Packages to install
vector<PackageDescriptionP> packages; ///< Packages to install
/// Load an installer from a file, and run it
static void installFrom(const String& filename, bool message_on_success, bool local);
@@ -40,7 +32,7 @@ class Installer : public Packaged {
void install(bool local, bool check_dependencies = true);
/// Install a specific package
void install(const String& package);
/// Add a package to the installer (if it is not already added).
/** If the package is named *.mse-installer uses it as the filename instead */
void addPackage(const String& package);
@@ -54,5 +46,133 @@ class Installer : public Packaged {
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Installer descriptions
/// A description of a package in an installer
class PackageDescription : public IntrusivePtrBase<PackageDescription> {
public:
PackageDescription();
PackageDescription(const Packaged& package);
String name; ///< Filename of the package
Version version; ///< Version number of this package
String short_name; ///< Short name of this package
String full_name; ///< Name of this package, for menus etc.
String icon_url; ///< Filename or URL of icon to use in package lists
Image icon; ///< Icon for the package
String installer_group; ///< Where to put this package in the installer
int position_hint; ///< A hint for the package list
String description; ///< Changelog/description
vector<PackageDependencyP> dependencies; ///< Dependencies of this package
DECLARE_REFLECTION();
};
/// A description of the contents of an installer
class InstallerDescription : public IntrusivePtrBase<InstallerDescription> {
public:
vector<PackageDescriptionP> packages;
DECLARE_REFLECTION();
};
/// Information on an installer that can be downloaded
class DownloadableInstaller : public IntrusivePtrBase<DownloadableInstaller> {
public:
DownloadableInstaller() : downloadable(true) {}
DownloadableInstaller(const InstallerP& installer);
~DownloadableInstaller();
InstallerP installer; ///< The installer, if it is loaded
String installer_url; ///< The URL where the installer can be found
String installer_file; ///< The temp file where the installer can be found (after downloading)
bool downloadable; ///< Is the installer downloadable (in)directly from that url?
vector<PackageDescriptionP> packages; ///< Packages provided by this installer
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Installable package
/// Installation status of a package
enum PackageStatus
{ PACKAGE_NOT_INSTALLED = 0x0000
, PACKAGE_INSTALLED = 0x0001
, PACKAGE_REMOVABLE = 0x0002
, PACKAGE_INSTALLABLE = 0x0010
, PACKAGE_UPDATES = 0x0111 ///< Remote updates available
, PACKAGE_MODIFIED = 0x1001 ///< Local changes made
, PACKAGE_CONFLICTS = PACKAGE_UPDATES | PACKAGE_MODIFIED
};
/// (un)install a package?
enum PackageAction
{ PACKAGE_NOTHING = 0x001 ///< Don't change anything
, PACKAGE_INSTALL = 0x002 ///< Install the package
, PACKAGE_UPGRADE = 0x004 ///< Upgrade the package
, PACKAGE_REMOVE = 0x008 ///< Remove the package
, PACKAGE_LOCAL = 0x010 ///< In the local package directory
, PACKAGE_GLOBAL = 0x020 ///< In the global package directory
, PACKAGE_WHERE = PACKAGE_LOCAL | PACKAGE_GLOBAL
};
/// A package that can be installed, or is already installed
class InstallablePackage : public IntrusivePtrVirtualBase {
public:
InstallablePackage();
InstallablePackage(const PackageVersionP&, const PackageDescriptionP&);
PackageVersionP installed; ///< The information of the installed package (if installed)
PackageDescriptionP description; ///< The details of the package. Either from the installed package or from an installer
DownloadableInstallerP installer; ///< The installer to install from (if updates are available)
PackageStatus status; ///< Status of installation
PackageAction action; ///< What to do with this package?
int automatic; ///< Install/upgrade/remove automaticly to satisfy this many packages
PackageAction old_action;
int old_automatic;
void determineStatus();
/// Is the action possible?
bool can(PackageAction act) const;
/// Is the action currently selected?
bool has(PackageAction act) const;
/// Merge two descriptions of installable packages
void merge(const InstallablePackage& p2);
};
typedef vector<InstallablePackageP> InstallablePackages;
/// Sort a list of InstallablePackages by package name
void sort(InstallablePackages& packages);
/// Merge two lists of InstallablePackages.
/** The first list contains installed packages, the second list contains packages in an installer
* @pre both lists are sorted by package name
* @post the output will be sorted
*/
void merge(InstallablePackages& installed, const InstallablePackages& from_installer);
/// Merge the packages from a DownloadableInstaller into a list of InstallablePackages.
void merge(InstallablePackages& installed, const DownloadableInstallerP& installer);
/// Set the action to perform on a given package, makes sure the dependencies are also set correctly
/** Returns true on success
* action may be PACKAGE_NOTHING to clear the action
*/
bool set_package_action(InstallablePackages& packages, const InstallablePackageP& package, PackageAction action);
// ----------------------------------------------------------------------------- : Program package
/// The "magicseteditor.exe" package is special, it refers to the program
extern String mse_package;
InstallablePackageP mse_installable_package();
// ----------------------------------------------------------------------------- : EOF
#endif
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/keyword.hpp>
#include <util/tagged_string.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/locale.hpp>
#include <data/game.hpp>
#include <data/stylesheet.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/pack.hpp>
// ----------------------------------------------------------------------------- : PackType
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/set.hpp>
#include <data/game.hpp>
#include <data/stylesheet.hpp>
+17 -2
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/settings.hpp>
#include <data/installer.hpp>
#include <data/game.hpp>
@@ -38,6 +39,15 @@ IMPLEMENT_REFLECTION_ENUM(InstallType) {
VALUE_N("global", INSTALL_GLOBAL);
}
bool is_install_local(InstallType type) {
#ifdef __WXMSW__
#define DEFAULT_INSTALL_LOCAL false
#else
#define DEFAULT_INSTALL_LOCAL true
#endif
return type == INSTALL_DEFAULT ? DEFAULT_INSTALL_LOCAL : type == INSTALL_LOCAL;
}
IMPLEMENT_REFLECTION_ENUM(FilenameConflicts) {
VALUE_N("keep old", CONFLICT_KEEP_OLD);
VALUE_N("overwrite", CONFLICT_OVERWRITE);
@@ -143,8 +153,10 @@ Settings::Settings()
, symbol_grid_size (30)
, symbol_grid (true)
, symbol_grid_snap (false)
, updates_url (_("http://magicseteditor.sourceforge.net/updates"))
, package_versions_url (_("http://magicseteditor.sourceforge.net/packages"))
, installer_list_url (_("http://magicseteditor.sourceforge.net/installers"))
, check_updates (CHECK_IF_CONNECTED)
, check_updates_all (true)
, install_type (INSTALL_DEFAULT)
, website_url (_("http://magicseteditor.sourceforge.net/"))
{}
@@ -221,8 +233,11 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(symbol_grid_snap);
REFLECT(default_game);
REFLECT(apprentice_location);
REFLECT(updates_url);
REFLECT_IGNORE(306,"updates url");
REFLECT(package_versions_url);
REFLECT(installer_list_url);
REFLECT(check_updates);
REFLECT(check_updates_all);
REFLECT(install_type);
REFLECT(website_url);
REFLECT(game_settings);
+4 -2
View File
@@ -41,6 +41,7 @@ enum InstallType
};
bool parse_enum(const String&, InstallType&);
bool is_install_local(InstallType type);
/// How to handle filename conflicts
enum FilenameConflicts
@@ -164,11 +165,12 @@ class Settings {
// --------------------------------------------------- : Special game stuff
String apprentice_location;
String mws_location;
// --------------------------------------------------- : Update checking
String updates_url;
String package_versions_url; ///< latest package versions
String installer_list_url; ///< available installers
CheckUpdates check_updates;
bool check_updates_all; ///< Check updates of all packages, not just the program
String website_url;
// --------------------------------------------------- : Installation settings
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/statistics.hpp>
#include <data/field.hpp>
#include <data/field/choice.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/stylesheet.hpp>
#include <data/game.hpp>
#include <data/field.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/symbol.hpp>
#include <script/to_value.hpp>
#include <gfx/bezier.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/symbol_font.hpp>
#include <data/stylesheet.hpp>
#include <util/dynamic_arg.hpp>
+1
View File
@@ -6,6 +6,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/word_list.hpp>
// ----------------------------------------------------------------------------- : WordList