NOISSUE disable component install buttons in impossible cases

This commit is contained in:
Petr Mrázek 2019-07-10 22:30:42 +02:00
parent 725ec35635
commit 791a8227b6

View File

@ -41,6 +41,7 @@
#include "minecraft/Mod.h" #include "minecraft/Mod.h"
#include "icons/IconList.h" #include "icons/IconList.h"
#include "Exception.h" #include "Exception.h"
#include "Version.h"
#include "MultiMC.h" #include "MultiMC.h"
@ -126,8 +127,7 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
{ {
disableVersionControls(); disableVersionControls();
} }
connect(m_inst, &MinecraftInstance::versionReloaded, this, connect(m_inst, &MinecraftInstance::versionReloaded, this, &VersionPage::updateVersionControls);
&VersionPage::updateVersionControls);
} }
VersionPage::~VersionPage() VersionPage::~VersionPage()
@ -180,9 +180,13 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
void VersionPage::updateVersionControls() void VersionPage::updateVersionControls()
{ {
ui->fabricBtn->setEnabled(true); // FIXME: this is a dirty hack
ui->forgeBtn->setEnabled(true); auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
ui->liteloaderBtn->setEnabled(true); bool newCraft = minecraftVersion >= Version("1.14");
bool oldCraft = minecraftVersion <= Version("1.12.2");
ui->fabricBtn->setEnabled(newCraft);
ui->forgeBtn->setEnabled(oldCraft);
ui->liteloaderBtn->setEnabled(oldCraft);
updateButtons(); updateButtons();
} }