refactor: change the way instance names are handled
While working on pack updating, instance naming always gets in the way, since we need both way of respecting the user's name choice, and a standarized way of getting the original pack name / version. This tries to circunvent such problems by abstracting away the naming schema into it's own struct, holding both the original name / version, and the user-defined name, so that everyone can be happy and world peace can be achieved! (at least that's what i'd hope :c). Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
@ -1005,7 +1005,7 @@ void PackInstallTask::install()
|
||||
|
||||
components->saveNow();
|
||||
|
||||
instance.setName(m_instName);
|
||||
instance.setName(name());
|
||||
instance.setIconKey(m_instIcon);
|
||||
instance.setManagedPack("atlauncher", m_pack_safe_name, m_pack_name, m_version_name, m_version_name);
|
||||
instanceSettings->resumeSave();
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "FileSystem.h"
|
||||
#include "InstanceList.h"
|
||||
#include "Json.h"
|
||||
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
@ -288,7 +289,8 @@ bool FlameCreationTask::createInstance()
|
||||
FS::deletePath(jarmodsPath);
|
||||
}
|
||||
|
||||
instance.setName(m_instName);
|
||||
instance.setManagedPack("flame", {}, m_pack.name, {}, m_pack.version);
|
||||
instance.setName(name());
|
||||
|
||||
m_mod_id_resolver = new Flame::FileResolvingTask(APPLICATION->network(), m_pack);
|
||||
connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::succeeded, this, [this, &loop] { idResolverSucceeded(loop); });
|
||||
|
@ -228,7 +228,7 @@ void PackInstallTask::install()
|
||||
|
||||
progress(4, 4);
|
||||
|
||||
instance.setName(m_instName);
|
||||
instance.setName(name());
|
||||
if(m_instIcon == "default")
|
||||
{
|
||||
m_instIcon = "ftb_logo";
|
||||
|
@ -335,7 +335,7 @@ void PackInstallTask::install()
|
||||
|
||||
components->saveNow();
|
||||
|
||||
instance.setName(m_instName);
|
||||
instance.setName(name());
|
||||
instance.setIconKey(m_instIcon);
|
||||
instance.setManagedPack("modpacksch", QString::number(m_pack.id), m_pack.name, QString::number(m_version.id), m_version.name);
|
||||
instanceSettings->resumeSave();
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
|
||||
#include "modplatform/ModIndex.h"
|
||||
|
||||
#include "net/ChecksumValidator.h"
|
||||
|
||||
#include "settings/INISettingsObject.h"
|
||||
@ -30,11 +28,10 @@ bool ModrinthCreationTask::updateInstance()
|
||||
auto instance_list = APPLICATION->instances();
|
||||
|
||||
// FIXME: How to handle situations when there's more than one install already for a given modpack?
|
||||
// Based on the way we create the instance name (name + " " + version). Is there a better way?
|
||||
auto inst = instance_list->getInstanceByManagedName(m_instName.section(' ', 0, -2));
|
||||
auto inst = instance_list->getInstanceByManagedName(originalName());
|
||||
|
||||
if (!inst) {
|
||||
inst = instance_list->getInstanceById(m_instName);
|
||||
inst = instance_list->getInstanceById(originalName());
|
||||
|
||||
if (!inst)
|
||||
return false;
|
||||
@ -163,8 +160,9 @@ bool ModrinthCreationTask::createInstance()
|
||||
} else {
|
||||
instance.setIconKey("modrinth");
|
||||
}
|
||||
instance.setName(m_instName);
|
||||
|
||||
instance.setManagedPack("modrinth", getManagedPackID(), m_managed_name, m_managed_id, {});
|
||||
instance.setName(name());
|
||||
instance.saveNow();
|
||||
|
||||
m_files_job = new NetJob(tr("Mod download"), APPLICATION->network());
|
||||
|
@ -133,7 +133,7 @@ void Technic::SingleZipPackInstallTask::extractFinished()
|
||||
shared_qobject_ptr<Technic::TechnicPackProcessor> packProcessor = new Technic::TechnicPackProcessor();
|
||||
connect(packProcessor.get(), &Technic::TechnicPackProcessor::succeeded, this, &Technic::SingleZipPackInstallTask::emitSucceeded);
|
||||
connect(packProcessor.get(), &Technic::TechnicPackProcessor::failed, this, &Technic::SingleZipPackInstallTask::emitFailed);
|
||||
packProcessor->run(m_globalSettings, m_instName, m_instIcon, m_stagingPath, m_minecraftVersion);
|
||||
packProcessor->run(m_globalSettings, name(), m_instIcon, m_stagingPath, m_minecraftVersion);
|
||||
}
|
||||
|
||||
void Technic::SingleZipPackInstallTask::extractAborted()
|
||||
|
@ -214,7 +214,7 @@ void Technic::SolderPackInstallTask::extractFinished()
|
||||
shared_qobject_ptr<Technic::TechnicPackProcessor> packProcessor = new Technic::TechnicPackProcessor();
|
||||
connect(packProcessor.get(), &Technic::TechnicPackProcessor::succeeded, this, &Technic::SolderPackInstallTask::emitSucceeded);
|
||||
connect(packProcessor.get(), &Technic::TechnicPackProcessor::failed, this, &Technic::SolderPackInstallTask::emitFailed);
|
||||
packProcessor->run(m_globalSettings, m_instName, m_instIcon, m_stagingPath, m_minecraftVersion, true);
|
||||
packProcessor->run(m_globalSettings, name(), m_instIcon, m_stagingPath, m_minecraftVersion, true);
|
||||
}
|
||||
|
||||
void Technic::SolderPackInstallTask::extractAborted()
|
||||
|
Reference in New Issue
Block a user