summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/ComponentList.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-11-11 01:38:31 +0100
committerPetr Mrázek <peterix@gmail.com>2017-12-03 01:22:34 +0100
commit85ae710d407eb31527183d5f8bec0399eb209f33 (patch)
tree23647a83506ad3bd052720fb40068240e9768481 /api/logic/minecraft/ComponentList.h
parent17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96 (diff)
downloadMultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar.gz
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar.lz
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar.xz
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.zip
GH-2026 implement changes necessary to support 1.13 snapshots
Diffstat (limited to 'api/logic/minecraft/ComponentList.h')
-rw-r--r--api/logic/minecraft/ComponentList.h93
1 files changed, 53 insertions, 40 deletions
diff --git a/api/logic/minecraft/ComponentList.h b/api/logic/minecraft/ComponentList.h
index 0811a829..7971650d 100644
--- a/api/logic/minecraft/ComponentList.h
+++ b/api/logic/minecraft/ComponentList.h
@@ -23,19 +23,21 @@
#include "Library.h"
#include "LaunchProfile.h"
-#include "ProfilePatch.h"
+#include "Component.h"
#include "ProfileUtils.h"
#include "BaseVersion.h"
#include "MojangDownloadInfo.h"
#include "multimc_logic_export.h"
+#include "net/Mode.h"
class MinecraftInstance;
-
+struct ComponentListData;
+class ComponentUpdateTask;
class MULTIMC_LOGIC_EXPORT ComponentList : public QAbstractListModel
{
Q_OBJECT
-
+ friend ComponentUpdateTask;
public:
explicit ComponentList(MinecraftInstance * instance);
virtual ~ComponentList();
@@ -46,6 +48,9 @@ public:
virtual int columnCount(const QModelIndex &parent) const override;
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
+ /// call this to explicitly mark the component list as loaded - this is used to build a new component list from scratch.
+ void buildingFromScratch();
+
/// is this version unchanged by the user?
bool isVanilla();
@@ -58,68 +63,76 @@ public:
/// install a jar/zip as a replacement for the main jar
void installCustomJar(QString selectedFile);
- /// DEPRECATED, remove ASAP
- int getFreeOrderNumber();
-
enum MoveDirection { MoveUp, MoveDown };
- /// move patch file # up or down the list
+ /// move component file # up or down the list
void move(const int index, const MoveDirection direction);
- /// remove patch file # - including files/records
+ /// remove component file # - including files/records
bool remove(const int index);
- /// remove patch file by id - including files/records
+ /// remove component file by id - including files/records
bool remove(const QString id);
bool customize(int index);
bool revertToBase(int index);
- void resetOrder();
+ /// reload the list, reload all components, resolve dependencies
+ void reload(Net::Mode netmode);
- /// reload all profile patches from storage, clear the profile and apply the patches
- void reload();
+ // reload all components, resolve dependencies
+ void resolve(Net::Mode netmode);
- /// apply the patches. Catches all the errors and returns true/false for success/failure
- bool reapplyPatches();
+ /// get current running task...
+ shared_qobject_ptr<Task> getCurrentTask();
std::shared_ptr<LaunchProfile> getProfile() const;
- void clearProfile();
+
+ // NOTE: used ONLY by MinecraftInstance to provide legacy version mappings from instance config
+ void setOldConfigVersion(const QString &uid, const QString &version);
+
+ QString getComponentVersion(const QString &uid) const;
+
+ bool setComponentVersion(const QString &uid, const QString &version, bool important = false);
+
+ QString patchFilePathForUid(const QString &uid) const;
public:
- /// get the profile patch by id
- ProfilePatchPtr versionPatch(const QString &id);
+ /// get the profile component by id
+ ComponentPtr getComponent(const QString &id);
+
+ /// get the profile component by index
+ ComponentPtr getComponent(int index);
+
+private:
+ void scheduleSave();
+ bool saveIsScheduled() const;
- /// get the profile patch by index
- ProfilePatchPtr versionPatch(int index);
+ /// apply the component patches. Catches all the errors and returns true/false for success/failure
+ void invalidateLaunchProfile();
- /// save the current patch order
- void saveCurrentOrder() const;
+ /// Add the component to the internal list of patches
+ void appendComponent(ComponentPtr component);
+ /// insert component so that its index is ideally the specified one (returns real index)
+ void insertComponent(size_t index, ComponentPtr component);
- /// Remove all the patches
- void clearPatches();
+ QString componentsFilePath() const;
+ QString patchesPattern() const;
- /// Add the patch object to the internal list of patches
- void appendPatch(ProfilePatchPtr patch);
+private slots:
+ void save();
+ void updateSucceeded();
+ void updateFailed(const QString & error);
+ void componentDataChanged();
private:
- void load_internal();
- bool resetOrder_internal();
- bool saveOrder_internal(ProfileUtils::PatchOrder order) const;
+ bool load();
bool installJarMods_internal(QStringList filepaths);
bool installCustomJar_internal(QString filepath);
- bool removePatch_internal(ProfilePatchPtr patch);
- bool customizePatch_internal(ProfilePatchPtr patch);
- bool revertPatch_internal(ProfilePatchPtr patch);
- void loadDefaultBuiltinPatches_internal();
- void loadUserPatches_internal();
- void upgradeDeprecatedFiles_internal();
+ bool removeComponent_internal(ComponentPtr patch);
-private: /* data */
- /// list of attached profile patches
- QList<ProfilePatchPtr> m_patches;
+ bool migratePreComponentConfig();
- // the instance this belongs to
- MinecraftInstance *m_instance;
+private: /* data */
- std::shared_ptr<LaunchProfile> m_profile;
+ std::unique_ptr<ComponentListData> d;
};