summaryrefslogtreecommitdiffstats
path: root/logic/OneSixInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logic/OneSixInstance.cpp')
-rw-r--r--logic/OneSixInstance.cpp101
1 files changed, 34 insertions, 67 deletions
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index ab87a1db..c43a5187 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -13,32 +13,36 @@
* limitations under the License.
*/
-#include "MultiMC.h"
#include "OneSixInstance.h"
+
+#include <QIcon>
+
#include "OneSixInstance_p.h"
#include "OneSixUpdate.h"
-#include "MinecraftProcess.h"
#include "OneSixVersion.h"
-#include "JavaChecker.h"
-#include "logic/icons/IconList.h"
-
-#include <setting.h>
-#include <pathutils.h>
-#include <cmdutils.h>
-#include <JlCompress.h>
-#include "gui/dialogs/OneSixModEditDialog.h"
+#include "pathutils.h"
#include "logger/QsLog.h"
-#include "logic/assets/AssetsUtils.h"
-#include <QIcon>
+#include "assets/AssetsUtils.h"
+#include "MultiMC.h"
+#include "icons/IconList.h"
+#include "MinecraftProcess.h"
+#include "gui/dialogs/OneSixModEditDialog.h"
-OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_obj,
- QObject *parent)
- : BaseInstance(new OneSixInstancePrivate(), rootDir, setting_obj, parent)
+OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, QObject *parent)
+ : BaseInstance(new OneSixInstancePrivate(), rootDir, settings, parent)
{
I_D(OneSixInstance);
d->m_settings->registerSetting("IntendedVersion", "");
d->m_settings->registerSetting("ShouldUpdate", false);
- reloadFullVersion();
+ d->version.reset(new OneSixVersion(this, this));
+ if (QDir(instanceRoot()).exists("version.json"))
+ {
+ reloadFullVersion();
+ }
+ else
+ {
+ clearFullVersion();
+ }
}
std::shared_ptr<Task> OneSixInstance::doUpdate(bool only_prepare)
@@ -282,11 +286,8 @@ bool OneSixInstance::setIntendedVersionId(QString version)
{
settings().set("IntendedVersion", version);
setShouldUpdate(true);
- auto pathCustom = PathCombine(instanceRoot(), "custom.json");
- auto pathOrig = PathCombine(instanceRoot(), "version.json");
- QFile::remove(pathCustom);
- QFile::remove(pathOrig);
- reloadFullVersion();
+ QFile::remove(PathCombine(instanceRoot(), "version.json"));
+ clearFullVersion();
return true;
}
@@ -312,9 +313,9 @@ bool OneSixInstance::shouldUpdate() const
bool OneSixInstance::versionIsCustom()
{
- QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
- QFile versionfile(verpath_custom);
- return versionfile.exists();
+ QDir patches(PathCombine(instanceRoot(), "patches/"));
+ return QFile::exists(PathCombine(instanceRoot(), "custom.json"))
+ || (patches.exists() && patches.count() >= 0);
}
QString OneSixInstance::currentVersionId() const
@@ -322,54 +323,20 @@ QString OneSixInstance::currentVersionId() const
return intendedVersionId();
}
-bool OneSixInstance::customizeVersion()
+bool OneSixInstance::reloadFullVersion(QWidget *widgetParent)
{
- if (!versionIsCustom())
- {
- auto pathCustom = PathCombine(instanceRoot(), "custom.json");
- auto pathOrig = PathCombine(instanceRoot(), "version.json");
- QFile::copy(pathOrig, pathCustom);
- return reloadFullVersion();
- }
- else
- return true;
-}
+ I_D(OneSixInstance);
-bool OneSixInstance::revertCustomVersion()
-{
- if (versionIsCustom())
- {
- auto path = PathCombine(instanceRoot(), "custom.json");
- QFile::remove(path);
- return reloadFullVersion();
- }
- else
- return true;
+ bool ret = d->version->reload(widgetParent);
+ emit versionReloaded();
+ return ret;
}
-bool OneSixInstance::reloadFullVersion()
+void OneSixInstance::clearFullVersion()
{
I_D(OneSixInstance);
-
- QString verpath = PathCombine(instanceRoot(), "version.json");
- {
- QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
- QFile versionfile(verpath_custom);
- if (versionfile.exists())
- verpath = verpath_custom;
- }
-
- auto version = OneSixVersion::fromFile(verpath);
- if (version)
- {
- d->version = version;
- return true;
- }
- else
- {
- d->version.reset();
- return false;
- }
+ d->version->clear();
+ emit versionReloaded();
}
std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion()
@@ -397,7 +364,7 @@ bool OneSixInstance::menuActionEnabled(QString action_name) const
QString OneSixInstance::getStatusbarDescription()
{
- QString descr = "One Six : " + intendedVersionId();
+ QString descr = "OneSix : " + intendedVersionId();
if (versionIsCustom())
{
descr + " (custom)";