diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-08-28 04:38:29 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-08-28 04:38:29 +0200 |
commit | 5ff6fbf4648d286ff0f07a4dbf37c0b72651f66b (patch) | |
tree | 09f3f739d22370b8ce96144057d2cec2d74febb5 /logic | |
parent | aa8766581ebad668194fcab87f53af4270e9679a (diff) | |
download | MultiMC-5ff6fbf4648d286ff0f07a4dbf37c0b72651f66b.tar MultiMC-5ff6fbf4648d286ff0f07a4dbf37c0b72651f66b.tar.gz MultiMC-5ff6fbf4648d286ff0f07a4dbf37c0b72651f66b.tar.lz MultiMC-5ff6fbf4648d286ff0f07a4dbf37c0b72651f66b.tar.xz MultiMC-5ff6fbf4648d286ff0f07a4dbf37c0b72651f66b.zip |
Basic 1.6 mod management (no jar mods)
Diffstat (limited to 'logic')
-rw-r--r-- | logic/LegacyInstance.cpp | 15 | ||||
-rw-r--r-- | logic/LegacyInstance.h | 2 | ||||
-rw-r--r-- | logic/OneSixInstance.cpp | 42 | ||||
-rw-r--r-- | logic/OneSixInstance.h | 18 | ||||
-rw-r--r-- | logic/OneSixInstance_p.h | 5 | ||||
-rw-r--r-- | logic/OneSixUpdate.cpp | 2 | ||||
-rw-r--r-- | logic/OneSixVersion.cpp | 4 | ||||
-rw-r--r-- | logic/OneSixVersion.h | 4 | ||||
-rw-r--r-- | logic/VersionFactory.cpp | 12 | ||||
-rw-r--r-- | logic/VersionFactory.h | 6 |
10 files changed, 77 insertions, 33 deletions
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp index 73a02cbd..6b2341d7 100644 --- a/logic/LegacyInstance.cpp +++ b/logic/LegacyInstance.cpp @@ -87,6 +87,11 @@ MinecraftProcess* LegacyInstance::prepareForLaunch(QString user, QString session return proc; } +void LegacyInstance::cleanupAfterRun() +{ + //FIXME: delete the launcher and icons and whatnot. +} + QSharedPointer< ModList > LegacyInstance::coreModList() { I_D(LegacyInstance); @@ -136,7 +141,7 @@ QSharedPointer< ModList > LegacyInstance::texturePackList() I_D(LegacyInstance); if(!d->texture_pack_list) { - d->texture_pack_list.reset(new ModList(texturePackDir())); + d->texture_pack_list.reset(new ModList(texturePacksDir())); } else d->texture_pack_list->update(); @@ -150,12 +155,6 @@ QDialog * LegacyInstance::createModEditDialog ( QWidget* parent ) } -void LegacyInstance::cleanupAfterRun() -{ - //FIXME: delete the launcher and icons and whatnot. -} - - QString LegacyInstance::jarModsDir() const { return PathCombine(instanceRoot(), "instMods"); @@ -185,7 +184,7 @@ QString LegacyInstance::resourceDir() const { return PathCombine(minecraftRoot(), "resources"); } -QString LegacyInstance::texturePackDir() const +QString LegacyInstance::texturePacksDir() const { return PathCombine(minecraftRoot(), "texturepacks"); } diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h index 4df884d2..b36026fc 100644 --- a/logic/LegacyInstance.h +++ b/logic/LegacyInstance.h @@ -26,7 +26,7 @@ public: ////// Directories ////// QString savesDir() const; - QString texturePackDir() const; + QString texturePacksDir() const; QString jarModsDir() const; QString binDir() const; QString loaderModsDir() const; diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 44af6707..8609e4a1 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -8,6 +8,7 @@ #include <pathutils.h> #include <cmdutils.h> #include <JlCompress.h> +#include <gui/OneSixModEditDialog.h> OneSixInstance::OneSixInstance ( const QString& rootDir, SettingsObject* setting_obj, QObject* parent ) : BaseInstance ( new OneSixInstancePrivate(), rootDir, setting_obj, parent ) @@ -155,12 +156,35 @@ void OneSixInstance::cleanupAfterRun() dir.removeRecursively(); } -QDialog * OneSixInstance::createModEditDialog ( QWidget* parent ) +QSharedPointer< ModList > OneSixInstance::loaderModList() +{ + I_D(OneSixInstance); + if(!d->loader_mod_list) + { + d->loader_mod_list.reset(new ModList(loaderModsDir())); + } + else + d->loader_mod_list->update(); + return d->loader_mod_list; +} + +QSharedPointer< ModList > OneSixInstance::resourcePackList() { - return nullptr; + I_D(OneSixInstance); + if(!d->resource_pack_list) + { + d->resource_pack_list.reset(new ModList(resourcePacksDir())); + } + else + d->resource_pack_list->update(); + return d->resource_pack_list; } +QDialog * OneSixInstance::createModEditDialog ( QWidget* parent ) +{ + return new OneSixModEditDialog(this, parent); +} bool OneSixInstance::setIntendedVersionId ( QString version ) { @@ -215,7 +239,7 @@ bool OneSixInstance::reloadFullVersion() return false; } -QSharedPointer< FullVersion > OneSixInstance::getFullVersion() +QSharedPointer< OneSixVersion > OneSixInstance::getFullVersion() { I_D(OneSixInstance); return d->version; @@ -235,8 +259,6 @@ bool OneSixInstance::menuActionEnabled ( QString action_name ) const { if(action_name == "actionChangeInstLWJGLVersion") return false; - if(action_name == "actionEditInstMods") - return false; return true; } @@ -245,6 +267,16 @@ QString OneSixInstance::getStatusbarDescription() return "One Six : " + intendedVersionId(); } +QString OneSixInstance::loaderModsDir() const +{ + return PathCombine(minecraftRoot(), "mods"); +} + +QString OneSixInstance::resourcePacksDir() const +{ + return PathCombine(minecraftRoot(), "resourcepacks"); +} + QString OneSixInstance::instanceConfigFolder() const { return PathCombine(minecraftRoot(), "config"); diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index 7c28b4cc..a4c67ed1 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -2,14 +2,26 @@ #include "BaseInstance.h" #include <QStringList> -class FullVersion; +class OneSixVersion; class BaseUpdate; +class ModList; class OneSixInstance : public BaseInstance { Q_OBJECT public: explicit OneSixInstance(const QString &rootDir, SettingsObject * settings, QObject *parent = 0); + + + ////// Mod Lists ////// + QSharedPointer<ModList> loaderModList(); + QSharedPointer<ModList> resourcePackList(); + + ////// Directories ////// + QString resourcePacksDir() const; + QString loaderModsDir() const; + virtual QString instanceConfigFolder() const; + virtual BaseUpdate* doUpdate(); virtual MinecraftProcess* prepareForLaunch ( QString user, QString session ); virtual void cleanupAfterRun(); @@ -28,15 +40,13 @@ public: /// reload the full version json file. return true on success! bool reloadFullVersion(); /// get the current full version info - QSharedPointer<FullVersion> getFullVersion(); + QSharedPointer<OneSixVersion> getFullVersion(); virtual QString defaultBaseJar() const; virtual QString defaultCustomBaseJar() const; virtual bool menuActionEnabled ( QString action_name ) const; virtual QString getStatusbarDescription(); - virtual QString instanceConfigFolder() const; - private: QStringList processMinecraftArgs( QString user, QString session ); };
\ No newline at end of file diff --git a/logic/OneSixInstance_p.h b/logic/OneSixInstance_p.h index 1037e03c..c098c9e2 100644 --- a/logic/OneSixInstance_p.h +++ b/logic/OneSixInstance_p.h @@ -2,8 +2,11 @@ #include "BaseInstance_p.h" #include "OneSixVersion.h" +#include "ModList.h" struct OneSixInstancePrivate: public BaseInstancePrivate { - QSharedPointer<FullVersion> version; + QSharedPointer<OneSixVersion> version; + QSharedPointer<ModList> loader_mod_list; + QSharedPointer<ModList> resource_pack_list; };
\ No newline at end of file diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 09d3cb14..a47beda0 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -129,7 +129,7 @@ void OneSixUpdate::jarlibStart() return; } - QSharedPointer<FullVersion> version = inst->getFullVersion(); + QSharedPointer<OneSixVersion> version = inst->getFullVersion(); // download the right jar, save it in versions/$version/$version.jar QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/"); diff --git a/logic/OneSixVersion.cpp b/logic/OneSixVersion.cpp index 2b2f79f5..56e272e2 100644 --- a/logic/OneSixVersion.cpp +++ b/logic/OneSixVersion.cpp @@ -103,7 +103,7 @@ QString Library::storagePath() } -QList<QSharedPointer<Library> > FullVersion::getActiveNormalLibs() +QList<QSharedPointer<Library> > OneSixVersion::getActiveNormalLibs() { QList<QSharedPointer<Library> > output; for ( auto lib: libraries ) @@ -116,7 +116,7 @@ QList<QSharedPointer<Library> > FullVersion::getActiveNormalLibs() return output; } -QList<QSharedPointer<Library> > FullVersion::getActiveNativeLibs() +QList<QSharedPointer<Library> > OneSixVersion::getActiveNativeLibs() { QList<QSharedPointer<Library> > output; for ( auto lib: libraries ) diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h index 46055304..89b7c911 100644 --- a/logic/OneSixVersion.h +++ b/logic/OneSixVersion.h @@ -147,7 +147,7 @@ public: }; -class FullVersion +class OneSixVersion { public: /// the ID - determines which jar to use! ACTUALLY IMPORTANT! @@ -203,7 +203,7 @@ public: // QList<Rule> rules; public: - FullVersion() + OneSixVersion() { minimumLauncherVersion = 0xDEADBEEF; } diff --git a/logic/VersionFactory.cpp b/logic/VersionFactory.cpp index 9eccce26..71c4d747 100644 --- a/logic/VersionFactory.cpp +++ b/logic/VersionFactory.cpp @@ -45,7 +45,7 @@ QList<QSharedPointer<Rule> > FullVersionFactory::parse4rules(QJsonObject & baseO } -QSharedPointer<FullVersion> FullVersionFactory::parse4(QJsonObject root, QSharedPointer<FullVersion> fullVersion) +QSharedPointer<OneSixVersion> FullVersionFactory::parse4(QJsonObject root, QSharedPointer<OneSixVersion> fullVersion) { fullVersion->id = root.value("id").toString(); @@ -154,9 +154,9 @@ QSharedPointer<FullVersion> FullVersionFactory::parse4(QJsonObject root, QShared return fullVersion; } -QSharedPointer<FullVersion> FullVersionFactory::parse(QByteArray data) +QSharedPointer<OneSixVersion> FullVersionFactory::parse(QByteArray data) { - QSharedPointer<FullVersion> readVersion(new FullVersion()); + QSharedPointer<OneSixVersion> readVersion(new OneSixVersion()); QJsonParseError jsonError; QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); @@ -165,14 +165,14 @@ QSharedPointer<FullVersion> FullVersionFactory::parse(QByteArray data) { error_string = QString( "Error reading version file :") + " " + jsonError.errorString(); m_error = FullVersionFactory::ParseError; - return QSharedPointer<FullVersion>(); + return QSharedPointer<OneSixVersion>(); } if(!jsonDoc.isObject()) { error_string = "Error reading version file."; m_error = FullVersionFactory::ParseError; - return QSharedPointer<FullVersion>(); + return QSharedPointer<OneSixVersion>(); } QJsonObject root = jsonDoc.object(); @@ -184,7 +184,7 @@ QSharedPointer<FullVersion> FullVersionFactory::parse(QByteArray data) { error_string = "Version file was for an unrecognized launcher version. RIP"; m_error = FullVersionFactory::UnsupportedVersion; - return QSharedPointer<FullVersion>(); + return QSharedPointer<OneSixVersion>(); } } diff --git a/logic/VersionFactory.h b/logic/VersionFactory.h index 82c5278a..0c0ee2d4 100644 --- a/logic/VersionFactory.h +++ b/logic/VersionFactory.h @@ -1,7 +1,7 @@ #pragma once #include <QtCore> -struct FullVersion; +struct OneSixVersion; class Rule; class FullVersionFactory @@ -17,8 +17,8 @@ public: public: FullVersionFactory(); - QSharedPointer<FullVersion> parse(QByteArray data); + QSharedPointer<OneSixVersion> parse(QByteArray data); private: - QSharedPointer<FullVersion> parse4(QJsonObject root, QSharedPointer<FullVersion> product); + QSharedPointer<OneSixVersion> parse4(QJsonObject root, QSharedPointer<OneSixVersion> product); QList<QSharedPointer<Rule> > parse4rules(QJsonObject & baseObj); };
\ No newline at end of file |