mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-23 12:10:00 +00:00
NOISSUE Add support for launching worlds directly via Quick Play
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTreeView>
|
||||
#include <QInputDialog>
|
||||
#include <QProcess>
|
||||
|
||||
#include "tools/MCEditTool.h"
|
||||
#include "FileSystem.h"
|
||||
@@ -32,6 +31,9 @@
|
||||
#include "ui/GuiUtil.h"
|
||||
#include "DesktopServices.h"
|
||||
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
|
||||
@@ -62,7 +64,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QWidget *parent)
|
||||
WorldListPage::WorldListPage(InstancePtr inst, std::shared_ptr<WorldList> worlds, QWidget *parent)
|
||||
: QMainWindow(parent), m_inst(inst), ui(new Ui::WorldListPage), m_worlds(worlds)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -311,8 +313,15 @@ void WorldListPage::mceditState(LoggedProcess::State state)
|
||||
|
||||
void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
auto mcInst = std::dynamic_pointer_cast<MinecraftInstance>(m_inst);
|
||||
bool enableJoinActions = mcInst && mcInst->getPackProfile()->getComponent("net.minecraft")->getReleaseDateTime() >= g_VersionFilterData.quickPlayBeginsDate;
|
||||
|
||||
QModelIndex index = getSelectedWorld();
|
||||
bool enable = index.isValid();
|
||||
// FIXME: Hide the join buttons if the Minecraft version is too old instead of just disabling them.
|
||||
// ui->actionJoin->setVisible(false) had no effect for some reason, at least on my machine -arthomnix
|
||||
ui->actionJoin->setEnabled(enable && enableJoinActions);
|
||||
ui->actionJoinOffline->setEnabled(enable && enableJoinActions);
|
||||
ui->actionCopy_Seed->setEnabled(enable);
|
||||
ui->actionMCEdit->setEnabled(enable);
|
||||
ui->actionRemove->setEnabled(enable);
|
||||
@@ -409,4 +418,29 @@ void WorldListPage::on_actionRefresh_triggered()
|
||||
m_worlds->update();
|
||||
}
|
||||
|
||||
void WorldListPage::joinSelectedWorld(bool online)
|
||||
{
|
||||
auto index = getSelectedWorld();
|
||||
if (!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
|
||||
auto world = (World *) worldVariant.value<void *>();
|
||||
auto name = world->folderName();
|
||||
|
||||
APPLICATION->launch(m_inst, online, nullptr, std::make_shared<QuickPlayTarget>(QuickPlayTarget::parseSingleplayer(name)));
|
||||
}
|
||||
|
||||
void WorldListPage::on_actionJoin_triggered()
|
||||
{
|
||||
joinSelectedWorld(true);
|
||||
}
|
||||
|
||||
void WorldListPage::on_actionJoinOffline_triggered()
|
||||
{
|
||||
joinSelectedWorld(false);
|
||||
}
|
||||
|
||||
#include "WorldListPage.moc"
|
||||
|
||||
Reference in New Issue
Block a user