aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2023-02-11 17:36:06 -0500
committerkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2023-02-11 17:46:17 -0500
commit7896dd19c12c0276551ba188adc6184dcf0a3184 (patch)
tree41b557da92f6cfcb5922a79055ffcd2835a1365b
parentf5f2d33f930674e03f8c81c1eaa3d35ddabc2886 (diff)
downloadPrismLauncher-7896dd19c12c0276551ba188adc6184dcf0a3184.tar.gz
PrismLauncher-7896dd19c12c0276551ba188adc6184dcf0a3184.tar.bz2
PrismLauncher-7896dd19c12c0276551ba188adc6184dcf0a3184.zip
nilmods instance page
mostly copied from the coremod page impl Signed-off-by: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
-rw-r--r--launcher/InstancePageProvider.h1
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp17
-rw-r--r--launcher/minecraft/MinecraftInstance.h3
-rw-r--r--launcher/minecraft/launch/ScanModFolders.cpp14
-rw-r--r--launcher/minecraft/launch/ScanModFolders.h2
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp9
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.h13
7 files changed, 58 insertions, 1 deletions
diff --git a/launcher/InstancePageProvider.h b/launcher/InstancePageProvider.h
index 286298cc..b4b6e739 100644
--- a/launcher/InstancePageProvider.h
+++ b/launcher/InstancePageProvider.h
@@ -39,6 +39,7 @@ public:
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
values.append(modsPage);
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList()));
+ values.append(new NilModFolderPage(onesix.get(), onesix->nilModList()));
values.append(new ResourcePackPage(onesix.get(), onesix->resourcePackList()));
values.append(new TexturePackPage(onesix.get(), onesix->texturePackList()));
values.append(new ShaderPackPage(onesix.get(), onesix->shaderPackList()));
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index 4fe234c4..0737a648 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -290,6 +290,11 @@ QString MinecraftInstance::coreModsDir() const
return FS::PathCombine(gameRoot(), "coremods");
}
+QString MinecraftInstance::nilModsDir() const
+{
+ return FS::PathCombine(gameRoot(), "nilmods");
+}
+
QString MinecraftInstance::resourcePacksDir() const
{
return FS::PathCombine(gameRoot(), "resourcepacks");
@@ -1125,6 +1130,18 @@ std::shared_ptr<ModFolderModel> MinecraftInstance::coreModList() const
return m_core_mod_list;
}
+std::shared_ptr<ModFolderModel> MinecraftInstance::nilModList() const
+{
+ if (!m_nil_mod_list)
+ {
+ bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
+ m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), is_indexed));
+ m_nil_mod_list->disableInteraction(isRunning());
+ connect(this, &BaseInstance::runningStatusChanged, m_nil_mod_list.get(), &ModFolderModel::disableInteraction);
+ }
+ return m_nil_mod_list;
+}
+
std::shared_ptr<ResourcePackFolderModel> MinecraftInstance::resourcePackList() const
{
if (!m_resource_pack_list)
diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h
index 1bbd7b83..a75fa481 100644
--- a/launcher/minecraft/MinecraftInstance.h
+++ b/launcher/minecraft/MinecraftInstance.h
@@ -84,6 +84,7 @@ public:
QString shaderPacksDir() const;
QString modsRoot() const override;
QString coreModsDir() const;
+ QString nilModsDir() const;
QString modsCacheLocation() const;
QString libDir() const;
QString worldDir() const;
@@ -116,6 +117,7 @@ public:
////// Mod Lists //////
std::shared_ptr<ModFolderModel> loaderModList() const;
std::shared_ptr<ModFolderModel> coreModList() const;
+ std::shared_ptr<ModFolderModel> nilModList() const;
std::shared_ptr<ResourcePackFolderModel> resourcePackList() const;
std::shared_ptr<TexturePackFolderModel> texturePackList() const;
std::shared_ptr<ShaderPackFolderModel> shaderPackList() const;
@@ -170,6 +172,7 @@ protected: // data
std::shared_ptr<PackProfile> m_components;
mutable std::shared_ptr<ModFolderModel> m_loader_mod_list;
mutable std::shared_ptr<ModFolderModel> m_core_mod_list;
+ mutable std::shared_ptr<ModFolderModel> m_nil_mod_list;
mutable std::shared_ptr<ResourcePackFolderModel> m_resource_pack_list;
mutable std::shared_ptr<ShaderPackFolderModel> m_shader_pack_list;
mutable std::shared_ptr<TexturePackFolderModel> m_texture_pack_list;
diff --git a/launcher/minecraft/launch/ScanModFolders.cpp b/launcher/minecraft/launch/ScanModFolders.cpp
index bdffeadd..71e7638c 100644
--- a/launcher/minecraft/launch/ScanModFolders.cpp
+++ b/launcher/minecraft/launch/ScanModFolders.cpp
@@ -55,6 +55,12 @@ void ScanModFolders::executeTask()
if(!cores->update()) {
m_coreModsDone = true;
}
+
+ auto nils = m_inst->nilModList();
+ connect(nils.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
+ if(!nils->update()) {
+ m_nilModsDone = true;
+ }
checkDone();
}
@@ -70,9 +76,15 @@ void ScanModFolders::coreModsDone()
checkDone();
}
+void ScanModFolders::nilModsDone()
+{
+ m_nilModsDone = true;
+ checkDone();
+}
+
void ScanModFolders::checkDone()
{
- if(m_modsDone && m_coreModsDone) {
+ if(m_modsDone && m_coreModsDone && m_nilModsDone) {
emitSucceeded();
}
}
diff --git a/launcher/minecraft/launch/ScanModFolders.h b/launcher/minecraft/launch/ScanModFolders.h
index d5989170..111a5850 100644
--- a/launcher/minecraft/launch/ScanModFolders.h
+++ b/launcher/minecraft/launch/ScanModFolders.h
@@ -33,10 +33,12 @@ public:
private slots:
void coreModsDone();
void modsDone();
+ void nilModsDone();
private:
void checkDone();
private: // DATA
bool m_modsDone = false;
+ bool m_nilModsDone = false;
bool m_coreModsDone = false;
};
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index d9069915..8c87a8a0 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -273,3 +273,12 @@ bool CoreModFolderPage::shouldDisplay() const
}
return false;
}
+
+NilModFolderPage::NilModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel> mods, QWidget* parent)
+ : ModFolderPage(inst, mods, parent)
+{}
+
+bool NilModFolderPage::shouldDisplay() const
+{
+ return !m_model->dir().isEmpty();
+}
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index ff58b38a..cad240bd 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -81,3 +81,16 @@ class CoreModFolderPage : public ModFolderPage {
virtual bool shouldDisplay() const override;
};
+
+class NilModFolderPage : public ModFolderPage {
+ public:
+ explicit NilModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel> mods, QWidget* parent = 0);
+ virtual ~NilModFolderPage() = default;
+
+ virtual QString displayName() const override { return tr("Nilmods"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("coremods"); }
+ virtual QString id() const override { return "nilmods"; }
+ virtual QString helpPage() const override { return "Nil-mods"; }
+
+ virtual bool shouldDisplay() const override;
+};