mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
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:
+135
-15
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user