NOISSE add a shortcut to the loaders mods to main window

This commit is contained in:
Petr Mrázek 2021-12-12 22:39:25 +01:00
parent 431d773eec
commit 7d047f9223
8 changed files with 58 additions and 10 deletions

View File

@ -100,6 +100,9 @@ public:
return instanceRoot();
}
/// Path to the instance's mods directory.
virtual QString modsRoot() const = 0;
QString name() const;
void setName(QString val);

View File

@ -73,4 +73,7 @@ public:
out << "Null instance - placeholder.";
return out;
}
QString modsRoot() const override {
return QString();
}
};

View File

@ -202,7 +202,7 @@ QString MinecraftInstance::jarModsDir() const
return jarmods_dir.absolutePath();
}
QString MinecraftInstance::loaderModsDir() const
QString MinecraftInstance::modsRoot() const
{
return FS::PathCombine(gameRoot(), "mods");
}
@ -961,7 +961,7 @@ std::shared_ptr<ModFolderModel> MinecraftInstance::loaderModList() const
{
if (!m_loader_mod_list)
{
m_loader_mod_list.reset(new ModFolderModel(loaderModsDir()));
m_loader_mod_list.reset(new ModFolderModel(modsRoot()));
m_loader_mod_list->disableInteraction(isRunning());
connect(this, &BaseInstance::runningStatusChanged, m_loader_mod_list.get(), &ModFolderModel::disableInteraction);
}

View File

@ -40,7 +40,7 @@ public:
QString resourcePacksDir() const;
QString texturePacksDir() const;
QString shaderPacksDir() const;
QString loaderModsDir() const;
QString modsRoot() const override;
QString coreModsDir() const;
QString modsCacheLocation() const;
QString libDir() const;

View File

@ -122,6 +122,11 @@ QString LegacyInstance::binRoot() const
return FS::PathCombine(gameRoot(), "bin");
}
QString LegacyInstance::modsRoot() const {
return FS::PathCombine(gameRoot(), "mods");
}
QString LegacyInstance::jarModsDir() const
{
return FS::PathCombine(instanceRoot(), "instMods");
@ -137,11 +142,6 @@ QString LegacyInstance::savesDir() const
return FS::PathCombine(gameRoot(), "saves");
}
QString LegacyInstance::loaderModsDir() const
{
return FS::PathCombine(gameRoot(), "mods");
}
QString LegacyInstance::coreModsDir() const
{
return FS::PathCombine(gameRoot(), "coremods");

View File

@ -45,11 +45,13 @@ public:
QString savesDir() const;
QString texturePacksDir() const;
QString jarModsDir() const;
QString loaderModsDir() const;
QString coreModsDir() const;
QString resourceDir() const;
virtual QString instanceConfigFolder() const override;
QString instanceConfigFolder() const override;
QString gameRoot() const override; // Path to the instance's minecraft directory.
QString modsRoot() const override; // Path to the instance's minecraft directory.
QString binRoot() const; // Path to the instance's minecraft bin directory.
/// Get the curent base jar of this instance. By default, it's the

View File

@ -211,8 +211,10 @@ public:
TranslatedAction actionEditInstNotes;
TranslatedAction actionEditInstance;
TranslatedAction actionWorlds;
TranslatedAction actionMods;
TranslatedAction actionViewSelectedInstFolder;
TranslatedAction actionViewSelectedMCFolder;
TranslatedAction actionViewSelectedModsFolder;
TranslatedAction actionDeleteInstance;
TranslatedAction actionConfig_Folder;
TranslatedAction actionCAT;
@ -530,6 +532,13 @@ public:
all_actions.append(&actionEditInstNotes);
instanceToolBar->addAction(actionEditInstNotes);
actionMods = TranslatedAction(MainWindow);
actionMods->setObjectName(QStringLiteral("actionMods"));
actionMods.setTextId(QT_TRANSLATE_NOOP("MainWindow", "View Mods"));
actionMods.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "View the mods of this instance."));
all_actions.append(&actionMods);
instanceToolBar->addAction(actionMods);
actionWorlds = TranslatedAction(MainWindow);
actionWorlds->setObjectName(QStringLiteral("actionWorlds"));
actionWorlds.setTextId(QT_TRANSLATE_NOOP("MainWindow", "View Worlds"));
@ -560,6 +569,15 @@ public:
all_actions.append(&actionViewSelectedMCFolder);
instanceToolBar->addAction(actionViewSelectedMCFolder);
/*
actionViewSelectedModsFolder = TranslatedAction(MainWindow);
actionViewSelectedModsFolder->setObjectName(QStringLiteral("actionViewSelectedModsFolder"));
actionViewSelectedModsFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Mods Folder"));
actionViewSelectedModsFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the selected instance's mods folder in a file browser."));
all_actions.append(&actionViewSelectedModsFolder);
instanceToolBar->addAction(actionViewSelectedModsFolder);
*/
actionConfig_Folder = TranslatedAction(MainWindow);
actionConfig_Folder->setObjectName(QStringLiteral("actionConfig_Folder"));
actionConfig_Folder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Config Folder"));
@ -1651,6 +1669,11 @@ void MainWindow::on_actionWorlds_triggered()
APPLICATION->showInstanceWindow(m_selectedInstance, "worlds");
}
void MainWindow::on_actionMods_triggered()
{
APPLICATION->showInstanceWindow(m_selectedInstance, "mods");
}
void MainWindow::on_actionEditInstance_triggered()
{
APPLICATION->showInstanceWindow(m_selectedInstance);
@ -1761,6 +1784,19 @@ void MainWindow::on_actionViewSelectedMCFolder_triggered()
}
}
void MainWindow::on_actionViewSelectedModsFolder_triggered()
{
if (m_selectedInstance)
{
QString str = m_selectedInstance->modsRoot();
if (!FS::ensureFilePathExists(str))
{
// TODO: report error
return;
}
DesktopServices::openDirectory(QDir(str).absolutePath());
}
}
void MainWindow::closeEvent(QCloseEvent *event)
{

View File

@ -93,6 +93,8 @@ private slots:
void on_actionViewSelectedMCFolder_triggered();
void on_actionViewSelectedModsFolder_triggered();
void refreshInstances();
void on_actionViewCentralModsFolder_triggered();
@ -133,6 +135,8 @@ private slots:
void on_actionEditInstNotes_triggered();
void on_actionMods_triggered();
void on_actionWorlds_triggered();
void on_actionScreenshots_triggered();