nilmods instance page

mostly copied from the coremod page impl

Signed-off-by: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
This commit is contained in:
kumquat-ir 2023-02-11 17:36:06 -05:00
parent f5f2d33f93
commit 7896dd19c1
7 changed files with 58 additions and 1 deletions

View File

@ -39,6 +39,7 @@ public:
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)"); modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
values.append(modsPage); values.append(modsPage);
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList())); 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 ResourcePackPage(onesix.get(), onesix->resourcePackList()));
values.append(new TexturePackPage(onesix.get(), onesix->texturePackList())); values.append(new TexturePackPage(onesix.get(), onesix->texturePackList()));
values.append(new ShaderPackPage(onesix.get(), onesix->shaderPackList())); values.append(new ShaderPackPage(onesix.get(), onesix->shaderPackList()));

View File

@ -290,6 +290,11 @@ QString MinecraftInstance::coreModsDir() const
return FS::PathCombine(gameRoot(), "coremods"); return FS::PathCombine(gameRoot(), "coremods");
} }
QString MinecraftInstance::nilModsDir() const
{
return FS::PathCombine(gameRoot(), "nilmods");
}
QString MinecraftInstance::resourcePacksDir() const QString MinecraftInstance::resourcePacksDir() const
{ {
return FS::PathCombine(gameRoot(), "resourcepacks"); return FS::PathCombine(gameRoot(), "resourcepacks");
@ -1125,6 +1130,18 @@ std::shared_ptr<ModFolderModel> MinecraftInstance::coreModList() const
return m_core_mod_list; 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 std::shared_ptr<ResourcePackFolderModel> MinecraftInstance::resourcePackList() const
{ {
if (!m_resource_pack_list) if (!m_resource_pack_list)

View File

@ -84,6 +84,7 @@ public:
QString shaderPacksDir() const; QString shaderPacksDir() const;
QString modsRoot() const override; QString modsRoot() const override;
QString coreModsDir() const; QString coreModsDir() const;
QString nilModsDir() const;
QString modsCacheLocation() const; QString modsCacheLocation() const;
QString libDir() const; QString libDir() const;
QString worldDir() const; QString worldDir() const;
@ -116,6 +117,7 @@ public:
////// Mod Lists ////// ////// Mod Lists //////
std::shared_ptr<ModFolderModel> loaderModList() const; std::shared_ptr<ModFolderModel> loaderModList() const;
std::shared_ptr<ModFolderModel> coreModList() const; std::shared_ptr<ModFolderModel> coreModList() const;
std::shared_ptr<ModFolderModel> nilModList() const;
std::shared_ptr<ResourcePackFolderModel> resourcePackList() const; std::shared_ptr<ResourcePackFolderModel> resourcePackList() const;
std::shared_ptr<TexturePackFolderModel> texturePackList() const; std::shared_ptr<TexturePackFolderModel> texturePackList() const;
std::shared_ptr<ShaderPackFolderModel> shaderPackList() const; std::shared_ptr<ShaderPackFolderModel> shaderPackList() const;
@ -170,6 +172,7 @@ protected: // data
std::shared_ptr<PackProfile> m_components; std::shared_ptr<PackProfile> m_components;
mutable std::shared_ptr<ModFolderModel> m_loader_mod_list; mutable std::shared_ptr<ModFolderModel> m_loader_mod_list;
mutable std::shared_ptr<ModFolderModel> m_core_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<ResourcePackFolderModel> m_resource_pack_list;
mutable std::shared_ptr<ShaderPackFolderModel> m_shader_pack_list; mutable std::shared_ptr<ShaderPackFolderModel> m_shader_pack_list;
mutable std::shared_ptr<TexturePackFolderModel> m_texture_pack_list; mutable std::shared_ptr<TexturePackFolderModel> m_texture_pack_list;

View File

@ -55,6 +55,12 @@ void ScanModFolders::executeTask()
if(!cores->update()) { if(!cores->update()) {
m_coreModsDone = true; m_coreModsDone = true;
} }
auto nils = m_inst->nilModList();
connect(nils.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
if(!nils->update()) {
m_nilModsDone = true;
}
checkDone(); checkDone();
} }
@ -70,9 +76,15 @@ void ScanModFolders::coreModsDone()
checkDone(); checkDone();
} }
void ScanModFolders::nilModsDone()
{
m_nilModsDone = true;
checkDone();
}
void ScanModFolders::checkDone() void ScanModFolders::checkDone()
{ {
if(m_modsDone && m_coreModsDone) { if(m_modsDone && m_coreModsDone && m_nilModsDone) {
emitSucceeded(); emitSucceeded();
} }
} }

View File

@ -33,10 +33,12 @@ public:
private slots: private slots:
void coreModsDone(); void coreModsDone();
void modsDone(); void modsDone();
void nilModsDone();
private: private:
void checkDone(); void checkDone();
private: // DATA private: // DATA
bool m_modsDone = false; bool m_modsDone = false;
bool m_nilModsDone = false;
bool m_coreModsDone = false; bool m_coreModsDone = false;
}; };

View File

@ -273,3 +273,12 @@ bool CoreModFolderPage::shouldDisplay() const
} }
return false; 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();
}

View File

@ -81,3 +81,16 @@ class CoreModFolderPage : public ModFolderPage {
virtual bool shouldDisplay() const override; 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;
};