Made changes to address feedback from code review (#4374)
Signed-off-by: Pagwin <dev@pagwin.xyz>
This commit is contained in:
@@ -66,7 +66,6 @@
|
||||
#include "tasks/Task.h"
|
||||
#include "ui/dialogs/ProgressDialog.h"
|
||||
|
||||
inline void HandleNoModLoader(ModFolderPage* self);
|
||||
ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel> model, QWidget* parent)
|
||||
: ExternalResourcesPage(inst, model, parent), m_model(model)
|
||||
{
|
||||
@@ -147,8 +146,9 @@ void ModFolderPage::downloadMods()
|
||||
|
||||
auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile();
|
||||
if (!profile->getModLoaders().has_value()) {
|
||||
HandleNoModLoader(this);
|
||||
return;
|
||||
if (HandleNoModLoader()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_downloadDialog = new ResourceDownload::ModDownloadDialog(this, m_model, m_instance);
|
||||
@@ -203,8 +203,9 @@ void ModFolderPage::updateMods(bool includeDeps)
|
||||
|
||||
auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile();
|
||||
if (!profile->getModLoaders().has_value()) {
|
||||
HandleNoModLoader(this);
|
||||
return;
|
||||
if (HandleNoModLoader()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!"));
|
||||
@@ -307,8 +308,9 @@ void ModFolderPage::changeModVersion()
|
||||
|
||||
auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile();
|
||||
if (!profile->getModLoaders().has_value()) {
|
||||
HandleNoModLoader(this);
|
||||
return;
|
||||
if (HandleNoModLoader()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!"));
|
||||
@@ -389,28 +391,25 @@ bool NilModFolderPage::shouldDisplay() const
|
||||
}
|
||||
|
||||
// Helper function so this doesn't need to be duplicated 3 times
|
||||
inline void HandleNoModLoader(ModFolderPage* self)
|
||||
inline bool ModFolderPage::HandleNoModLoader()
|
||||
{
|
||||
// QMessageBox::critical(self, tr("Error"), tr("Please install a mod loader first!"));
|
||||
int resp = QMessageBox::question(self, self->tr("Missing ModLoader"),
|
||||
self->tr("You need to install a mod loader before installing mods, would you like to do so?"),
|
||||
int resp = QMessageBox::question(this, this->tr("Missing ModLoader"),
|
||||
this->tr("You need to install a mod loader before installing mods, would you like to do so?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
switch (resp) {
|
||||
case QMessageBox::Yes: {
|
||||
// now how do I get the values this all needs
|
||||
if (self->m_instance->typeName() != "Minecraft") {
|
||||
// not what we need
|
||||
return;
|
||||
}
|
||||
auto profile = static_cast<MinecraftInstance*>(self->m_instance)->getPackProfile();
|
||||
InstallLoaderDialog dialog(profile, QString(), self);
|
||||
// Should be safe
|
||||
auto profile = static_cast<MinecraftInstance*>(this->m_instance)->getPackProfile();
|
||||
InstallLoaderDialog dialog(profile, QString(), this);
|
||||
dialog.exec();
|
||||
self->m_container->refreshContainer();
|
||||
break;
|
||||
this->m_container->refreshContainer();
|
||||
// returning false so the caller can go and open up the dialog it was originally going to
|
||||
return false;
|
||||
}
|
||||
case QMessageBox::No: {
|
||||
// Nothing happens the dialog is already closing
|
||||
break;
|
||||
// returning true so the caller doesn't go and continue with opening it's dialog without a mod loader
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
// Unreachable
|
||||
|
||||
Reference in New Issue
Block a user