Basic, unfinished & broken impl

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2023-06-19 22:42:27 +01:00
parent fd9a8d1551
commit 6ccc7e77f9
18 changed files with 287 additions and 217 deletions

View File

@ -52,6 +52,7 @@
#include <QUrl>
#include "VersionPage.h"
#include "ui/dialogs/InstallLoaderDialog.h"
#include "ui_VersionPage.h"
#include "ui/dialogs/CustomMessageBox.h"
@ -254,20 +255,6 @@ void VersionPage::updateRunningStatus(bool running)
void VersionPage::updateVersionControls()
{
// FIXME: this is a dirty hack
auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
ui->actionInstall_Forge->setEnabled(controlsEnabled);
bool supportsFabric = minecraftVersion >= Version("1.14");
ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric);
bool supportsQuilt = minecraftVersion >= Version("1.14");
ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt);
bool supportsLiteLoader = minecraftVersion <= Version("1.12.2");
ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader);
updateButtons();
}
@ -287,7 +274,6 @@ void VersionPage::updateButtons(int row)
ui->actionAdd_Empty->setEnabled(controlsEnabled);
ui->actionImport_Components->setEnabled(controlsEnabled);
ui->actionReload->setEnabled(controlsEnabled);
ui->actionInstall_mods->setEnabled(controlsEnabled);
ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled);
ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled);
ui->actionAdd_Agents->setEnabled(controlsEnabled);
@ -446,17 +432,6 @@ void VersionPage::on_actionChange_version_triggered()
return;
}
auto uid = list->uid();
// FIXME: this is a horrible HACK. Get version filtering information from the actual metadata...
if(uid == "net.minecraftforge")
{
on_actionInstall_Forge_triggered();
return;
}
else if (uid == "com.mumfrey.liteloader")
{
on_actionInstall_LiteLoader_triggered();
return;
}
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed")
{
@ -508,87 +483,11 @@ void VersionPage::on_actionDownload_All_triggered()
m_container->refreshContainer();
}
void VersionPage::on_actionInstall_Forge_triggered()
void VersionPage::on_actionInstall_Loader_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge");
if(!vlist)
{
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this);
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
auto currentVersion = m_profile->getComponentVersion("net.minecraftforge");
if(!currentVersion.isEmpty())
{
vselect.setCurrentVersion(currentVersion);
}
if (vselect.exec() && vselect.selectedVersion())
{
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("net.minecraftforge", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
// m_profile->installVersion();
preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
}
}
void VersionPage::on_actionInstall_Fabric_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader");
if(!vlist)
{
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select Fabric Loader version"), this);
vselect.setEmptyString(tr("No Fabric Loader versions are currently available."));
vselect.setEmptyErrorString(tr("Couldn't load or download the Fabric Loader version lists!"));
auto currentVersion = m_profile->getComponentVersion("net.fabricmc.fabric-loader");
if(!currentVersion.isEmpty())
{
vselect.setCurrentVersion(currentVersion);
}
if (vselect.exec() && vselect.selectedVersion())
{
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("net.fabricmc.fabric-loader", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
}
}
void VersionPage::on_actionInstall_Quilt_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader");
if(!vlist)
{
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this);
vselect.setEmptyString(tr("No Quilt Loader versions are currently available."));
vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!"));
auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader");
if(!currentVersion.isEmpty())
{
vselect.setCurrentVersion(currentVersion);
}
if (vselect.exec() && vselect.selectedVersion())
{
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
}
InstallLoaderDialog dialog(m_inst->getPackProfile(), this);
dialog.exec();
m_container->refreshContainer();
}
void VersionPage::on_actionAdd_Empty_triggered()
@ -609,35 +508,6 @@ void VersionPage::on_actionAdd_Empty_triggered()
}
}
void VersionPage::on_actionInstall_LiteLoader_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader");
if(!vlist)
{
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this);
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader");
if(!currentVersion.isEmpty())
{
vselect.setCurrentVersion(currentVersion);
}
if (vselect.exec() && vselect.selectedVersion())
{
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
// m_profile->installVersion(vselect.selectedVersion());
preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
}
}
void VersionPage::on_actionLibrariesFolder_triggered()
{
DesktopServices::openDirectory(m_inst->getLocalLibraryPath(), true);

View File

@ -79,11 +79,8 @@ public:
private slots:
void on_actionChange_version_triggered();
void on_actionInstall_Forge_triggered();
void on_actionInstall_Fabric_triggered();
void on_actionInstall_Quilt_triggered();
void on_actionInstall_Loader_triggered();
void on_actionAdd_Empty_triggered();
void on_actionInstall_LiteLoader_triggered();
void on_actionReload_triggered();
void on_actionRemove_triggered();
void on_actionMove_up_triggered();

View File

@ -98,12 +98,7 @@
<addaction name="actionEdit"/>
<addaction name="actionRevert"/>
<addaction name="separator"/>
<addaction name="actionInstall_Forge"/>
<addaction name="actionInstall_Fabric"/>
<addaction name="actionInstall_Quilt"/>
<addaction name="actionInstall_LiteLoader"/>
<addaction name="actionInstall_mods"/>
<addaction name="separator"/>
<addaction name="actionInstall_Loader"/>
<addaction name="actionAdd_to_Minecraft_jar"/>
<addaction name="actionReplace_Minecraft_jar"/>
<addaction name="actionAdd_Agents"/>
@ -118,26 +113,26 @@
</widget>
<action name="actionChange_version">
<property name="text">
<string>Change version</string>
<string>Change Version</string>
</property>
<property name="toolTip">
<string>Change version of the selected package.</string>
<string>Change version of the selected component.</string>
</property>
</action>
<action name="actionMove_up">
<property name="text">
<string>Move up</string>
<string>Move Up</string>
</property>
<property name="toolTip">
<string>Make the selected package apply sooner.</string>
<string>Make the selected component apply sooner.</string>
</property>
</action>
<action name="actionMove_down">
<property name="text">
<string>Move down</string>
<string>Move Down</string>
</property>
<property name="toolTip">
<string>Make the selected package apply later.</string>
<string>Make the selected component apply later.</string>
</property>
</action>
<action name="actionRemove">
@ -145,7 +140,7 @@
<string>Remove</string>
</property>
<property name="toolTip">
<string>Remove selected package from the instance.</string>
<string>Remove selected component from the instance.</string>
</property>
</action>
<action name="actionCustomize">
@ -153,7 +148,7 @@
<string>Customize</string>
</property>
<property name="toolTip">
<string>Customize selected package.</string>
<string>Customize selected component.</string>
</property>
</action>
<action name="actionEdit">
@ -161,7 +156,7 @@
<string>Edit</string>
</property>
<property name="toolTip">
<string>Edit selected package.</string>
<string>Edit selected component.</string>
</property>
</action>
<action name="actionRevert">
@ -169,47 +164,15 @@
<string>Revert</string>
</property>
<property name="toolTip">
<string>Revert the selected package to default.</string>
<string>Revert the selected component to default.</string>
</property>
</action>
<action name="actionInstall_Forge">
<action name="actionInstall_Loader">
<property name="text">
<string>Install Forge</string>
<string>Install Loader</string>
</property>
<property name="toolTip">
<string>Install the Minecraft Forge package.</string>
</property>
</action>
<action name="actionInstall_Fabric">
<property name="text">
<string>Install Fabric</string>
</property>
<property name="toolTip">
<string>Install the Fabric Loader package.</string>
</property>
</action>
<action name="actionInstall_Quilt">
<property name="text">
<string>Install Quilt</string>
</property>
<property name="toolTip">
<string>Install the Quilt Loader package.</string>
</property>
</action>
<action name="actionInstall_LiteLoader">
<property name="text">
<string>Install LiteLoader</string>
</property>
<property name="toolTip">
<string>Install the LiteLoader package.</string>
</property>
</action>
<action name="actionInstall_mods">
<property name="text">
<string>Install mods</string>
</property>
<property name="toolTip">
<string>Install normal mods.</string>
<string>Install a mod loader.</string>
</property>
</action>
<action name="actionAdd_to_Minecraft_jar">
@ -238,7 +201,7 @@
<string>Add Empty</string>
</property>
<property name="toolTip">
<string>Add an empty custom package.</string>
<string>Add an empty custom component.</string>
</property>
</action>
<action name="actionReload">
@ -246,12 +209,12 @@
<string>Reload</string>
</property>
<property name="toolTip">
<string>Reload all packages.</string>
<string>Reload all components.</string>
</property>
</action>
<action name="actionDownload_All">
<property name="text">
<string>Download All</string>
<string>Download all</string>
</property>
<property name="toolTip">
<string>Download the files needed to launch the instance now.</string>