Skip to content

Commit

Permalink
Merge branch 'MultiMC:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Neptune650 authored Mar 2, 2024
2 parents bb30191 + 2c9e7b7 commit 9648a93
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
3 changes: 3 additions & 0 deletions launcher/minecraft/VersionFilterData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ VersionFilterData::VersionFilterData()
java16BeginsDate = timeFromS3Time("2021-05-12T11:19:15+00:00");
java17BeginsDate = timeFromS3Time("2021-11-16T17:04:48+00:00");
quickPlayBeginsDate = timeFromS3Time("2023-04-05T12:05:17+00:00");
liteLoaderEndsDate = timeFromS3Time("2017-09-18T08:39:46+00:00");
fabricBeginsDate = timeFromS3Time("2019-04-23T14:52:44+00:00");
neoForgeBeginsDate = timeFromS3Time("2023-06-12T13:25:51+00:00");
}
6 changes: 6 additions & 0 deletions launcher/minecraft/VersionFilterData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ struct VersionFilterData
QDateTime java17BeginsDate;
// release date of first version to use --quickPlayMultiplayer instead of --server/--port for directly joining servers
QDateTime quickPlayBeginsDate;
// release date of last version to support LiteLoader (1.12.2)
QDateTime liteLoaderEndsDate;
// release date of first version supported by Fabric/Quilt (1.14)
QDateTime fabricBeginsDate;
// release date of first version supported by NeoForge (1.20.1)
QDateTime neoForgeBeginsDate;
};
extern VersionFilterData g_VersionFilterData;
41 changes: 37 additions & 4 deletions launcher/ui/pages/instance/VersionPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "minecraft/PackProfile.h"
#include "minecraft/auth/AccountList.h"
#include "minecraft/mod/Mod.h"
#include "minecraft/VersionFilterData.h"
#include "icons/IconList.h"
#include "Exception.h"
#include "Version.h"
Expand Down Expand Up @@ -209,16 +210,19 @@ void VersionPage::updateRunningStatus(bool running)

void VersionPage::updateVersionControls()
{
// FIXME: this is a dirty hack
auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
// FIXME: This is better than the broken stuff we had before, but it would probably be better to handle this in meta somehow
auto minecraftReleaseDate = m_profile->getComponent("net.minecraft")->getReleaseDateTime();

bool supportsFabric = minecraftVersion >= Version("1.14");
bool supportsFabric = minecraftReleaseDate >= g_VersionFilterData.fabricBeginsDate;
ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric);
ui->actionInstall_Quilt->setEnabled((controlsEnabled) && supportsFabric);

bool supportsLiteLoader = minecraftVersion <= Version("1.12.2");
bool supportsLiteLoader = minecraftReleaseDate <= g_VersionFilterData.liteLoaderEndsDate;
ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader);

bool supportsNeoForge = minecraftReleaseDate >= g_VersionFilterData.neoForgeBeginsDate;
ui->actionInstall_NeoForge->setEnabled(controlsEnabled && supportsNeoForge);

updateButtons();
}

Expand Down Expand Up @@ -444,6 +448,35 @@ void VersionPage::on_actionInstall_Forge_triggered()
}
}

void VersionPage::on_actionInstall_NeoForge_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("net.neoforged");
if(!vlist)
{
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select NeoForge version"), this);
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyString(tr("No NeoForge versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyErrorString(tr("Couldn't load or download the NeoForge version lists!"));

auto currentVersion = m_profile->getComponentVersion("net.neoforged");
if(!currentVersion.isEmpty())
{
vselect.setCurrentVersion(currentVersion);
}

if (vselect.exec() && vselect.selectedVersion())
{
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("net.neoforged", 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");
Expand Down
1 change: 1 addition & 0 deletions launcher/ui/pages/instance/VersionPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class VersionPage : public QMainWindow, public BasePage
private slots:
void on_actionChange_version_triggered();
void on_actionInstall_Forge_triggered();
void on_actionInstall_NeoForge_triggered();
void on_actionInstall_Fabric_triggered();
void on_actionInstall_Quilt_triggered();
void on_actionAdd_Empty_triggered();
Expand Down
9 changes: 9 additions & 0 deletions launcher/ui/pages/instance/VersionPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<addaction name="actionRevert"/>
<addaction name="separator"/>
<addaction name="actionInstall_Forge"/>
<addaction name="actionInstall_NeoForge"/>
<addaction name="actionInstall_Fabric"/>
<addaction name="actionInstall_Quilt"/>
<addaction name="actionInstall_LiteLoader"/>
Expand Down Expand Up @@ -270,6 +271,14 @@
<string>Open the instance's local libraries folder.</string>
</property>
</action>
<action name="actionInstall_NeoForge">
<property name="text">
<string>Install NeoForge</string>
</property>
<property name="toolTip">
<string>Install the NeoForge package.</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down

0 comments on commit 9648a93

Please sign in to comment.