From 7896dd19c12c0276551ba188adc6184dcf0a3184 Mon Sep 17 00:00:00 2001
From: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
Date: Sat, 11 Feb 2023 17:36:06 -0500
Subject: nilmods instance page mostly copied from the coremod page impl

Signed-off-by: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
---
 launcher/ui/pages/instance/ModFolderPage.cpp |  9 +++++++++
 launcher/ui/pages/instance/ModFolderPage.h   | 13 +++++++++++++
 2 files changed, 22 insertions(+)

(limited to 'launcher/ui')

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;
+};
-- 
cgit 


From 9c2a3231c5ee1b15b09bae9b064827ad3dcb86e0 Mon Sep 17 00:00:00 2001
From: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
Date: Mon, 13 Feb 2023 01:45:23 -0500
Subject: do not create nilmods folder "it cant be that easy" - me, clueless

Signed-off-by: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
---
 launcher/minecraft/MinecraftInstance.cpp       | 2 +-
 launcher/minecraft/mod/ModFolderModel.cpp      | 2 +-
 launcher/minecraft/mod/ModFolderModel.h        | 2 +-
 launcher/minecraft/mod/ResourceFolderModel.cpp | 6 ++++--
 launcher/minecraft/mod/ResourceFolderModel.h   | 3 ++-
 launcher/ui/pages/instance/ModFolderPage.cpp   | 2 +-
 launcher/ui/pages/instance/ModFolderPage.h     | 2 +-
 7 files changed, 11 insertions(+), 8 deletions(-)

(limited to 'launcher/ui')

diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index 0737a648..af4da5d0 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -1135,7 +1135,7 @@ 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.reset(new ModFolderModel(nilModsDir(), is_indexed, false));
         m_nil_mod_list->disableInteraction(isRunning());
         connect(this, &BaseInstance::runningStatusChanged, m_nil_mod_list.get(), &ModFolderModel::disableInteraction);
     }
diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp
index f258ad69..2d777656 100644
--- a/launcher/minecraft/mod/ModFolderModel.cpp
+++ b/launcher/minecraft/mod/ModFolderModel.cpp
@@ -50,7 +50,7 @@
 #include "minecraft/mod/tasks/ModFolderLoadTask.h"
 #include "modplatform/ModIndex.h"
 
-ModFolderModel::ModFolderModel(const QString &dir, bool is_indexed) : ResourceFolderModel(QDir(dir)), m_is_indexed(is_indexed)
+ModFolderModel::ModFolderModel(const QString &dir, bool is_indexed, bool create_dir) : ResourceFolderModel(QDir(dir), create_dir), m_is_indexed(is_indexed)
 {
     m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::VERSION, SortType::DATE, SortType::PROVIDER };
 }
diff --git a/launcher/minecraft/mod/ModFolderModel.h b/launcher/minecraft/mod/ModFolderModel.h
index 6898f6eb..84e70db9 100644
--- a/launcher/minecraft/mod/ModFolderModel.h
+++ b/launcher/minecraft/mod/ModFolderModel.h
@@ -75,7 +75,7 @@ public:
         Enable,
         Toggle
     };
-    ModFolderModel(const QString &dir, bool is_indexed = false);
+    ModFolderModel(const QString &dir, bool is_indexed = false, bool create_dir = true);
 
     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
 
diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp
index fdfb434b..b8353133 100644
--- a/launcher/minecraft/mod/ResourceFolderModel.cpp
+++ b/launcher/minecraft/mod/ResourceFolderModel.cpp
@@ -12,9 +12,11 @@
 
 #include "tasks/Task.h"
 
-ResourceFolderModel::ResourceFolderModel(QDir dir, QObject* parent) : QAbstractListModel(parent), m_dir(dir), m_watcher(this)
+ResourceFolderModel::ResourceFolderModel(QDir dir, bool create_dir, QObject* parent) : QAbstractListModel(parent), m_dir(dir), m_watcher(this)
 {
-    FS::ensureFolderPathExists(m_dir.absolutePath());
+    if (create_dir) {
+        FS::ensureFolderPathExists(m_dir.absolutePath());
+    }
 
     m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
     m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h
index f1bc2dd7..e4227a33 100644
--- a/launcher/minecraft/mod/ResourceFolderModel.h
+++ b/launcher/minecraft/mod/ResourceFolderModel.h
@@ -24,7 +24,8 @@ class QSortFilterProxyModel;
 class ResourceFolderModel : public QAbstractListModel {
     Q_OBJECT
    public:
-    ResourceFolderModel(QDir, QObject* parent = nullptr);
+    ResourceFolderModel(QDir, bool, QObject* parent = nullptr);
+    ResourceFolderModel(QDir dir, QObject* parent = nullptr) : ResourceFolderModel(dir, true, parent) {};
     ~ResourceFolderModel() override;
 
     /** Starts watching the paths for changes.
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index 8c87a8a0..4548af59 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -280,5 +280,5 @@ NilModFolderPage::NilModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolder
 
 bool NilModFolderPage::shouldDisplay() const
 {
-    return !m_model->dir().isEmpty();
+    return m_model->dir().exists();
 }
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index cad240bd..2fc7b574 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -90,7 +90,7 @@ class NilModFolderPage : public ModFolderPage {
     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 QString helpPage() const override { return "Nilmods"; }
 
     virtual bool shouldDisplay() const override;
 };
-- 
cgit