mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-03-29 19:20:13 +00:00
NOISSUE Add singleplayer quickplay option to shortcut creation dialog
This commit is contained in:
parent
b8811039f2
commit
1ad3e4417f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022 arthomnix
|
||||
* Copyright 2022-2023 arthomnix
|
||||
*
|
||||
* This source is subject to the Microsoft Public License (MS-PL).
|
||||
* Please see the COPYING.md file for more information.
|
||||
@ -13,6 +13,8 @@
|
||||
#include "Application.h"
|
||||
#include "minecraft/auth/AccountList.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/WorldList.h"
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "icons/IconList.h"
|
||||
|
||||
@ -43,6 +45,23 @@ CreateShortcutDialog::CreateShortcutDialog(QWidget *parent, InstancePtr instance
|
||||
|
||||
// TODO: check if version is affected by crashing when joining servers on launch, ideally in meta
|
||||
|
||||
auto mcInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
|
||||
mcInstance->getPackProfile()->reload(Net::Mode::Offline);
|
||||
if (mcInstance && mcInstance->getPackProfile()->getComponent("net.minecraft")->getReleaseDateTime() >= g_VersionFilterData.quickPlayBeginsDate)
|
||||
{
|
||||
mcInstance->worldList()->update();
|
||||
for (const auto &world : mcInstance->worldList()->allWorlds())
|
||||
{
|
||||
ui->joinSingleplayer->addItem(world.folderName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->joinServerRadioButton->setChecked(true);
|
||||
ui->joinSingleplayerRadioButton->setVisible(false);
|
||||
ui->joinSingleplayer->setVisible(false);
|
||||
}
|
||||
|
||||
// Macs don't have any concept of a desktop shortcut, so force-enable the option to generate a shell script instead
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
|
||||
ui->createScriptCheckBox->setEnabled(false);
|
||||
@ -90,16 +109,16 @@ void CreateShortcutDialog::accept()
|
||||
|
||||
void CreateShortcutDialog::updateDialogState()
|
||||
{
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(
|
||||
!ui->shortcutPath->text().isEmpty()
|
||||
&& (!ui->joinServerCheckBox->isChecked() || !ui->joinServer->text().isEmpty())
|
||||
&& (!ui->joinWorldCheckBox->isChecked() || ui->joinServerRadioButton->isChecked() || ui->joinSingleplayerRadioButton->isChecked())
|
||||
&& (!ui->joinServerRadioButton->isChecked() || !ui->joinServer->text().isEmpty())
|
||||
&& (!ui->joinSingleplayerRadioButton->isChecked() || !ui->joinSingleplayer->currentText().isEmpty())
|
||||
&& (!ui->offlineUsernameCheckBox->isChecked() || !ui->offlineUsername->text().isEmpty())
|
||||
&& (!ui->useProfileCheckBox->isChecked() || !ui->profileComboBox->currentText().isEmpty())
|
||||
);
|
||||
ui->joinServer->setEnabled(ui->joinServerCheckBox->isChecked());
|
||||
ui->profileComboBox->setEnabled(ui->useProfileCheckBox->isChecked());
|
||||
ui->offlineUsernameCheckBox->setEnabled(ui->launchOfflineCheckBox->isChecked());
|
||||
ui->joinServer->setEnabled(ui->joinWorldCheckBox->isChecked() && ui->joinServerRadioButton->isChecked());
|
||||
ui->joinSingleplayer->setEnabled(ui->joinWorldCheckBox->isChecked() && ui->joinSingleplayerRadioButton->isChecked());
|
||||
ui->offlineUsername->setEnabled(ui->launchOfflineCheckBox->isChecked() && ui->offlineUsernameCheckBox->isChecked());
|
||||
if (!ui->launchOfflineCheckBox->isChecked())
|
||||
{
|
||||
@ -117,7 +136,8 @@ QString CreateShortcutDialog::getLaunchArgs(bool escapeQuotesTwice)
|
||||
{
|
||||
return " -d \"" + QDir::toNativeSeparators(QDir::currentPath()).replace('"', escapeQuotesTwice ? "\\\\\"" : "\\\"") + "\""
|
||||
+ " -l \"" + m_instance->id() + "\""
|
||||
+ (ui->joinServerCheckBox->isChecked() ? " -s \"" + ui->joinServer->text() + "\"" : "")
|
||||
+ (ui->joinServerRadioButton->isChecked() ? " -s \"" + ui->joinServer->text() + "\"" : "")
|
||||
+ (ui->joinSingleplayerRadioButton->isChecked() ? " -w \"" + ui->joinSingleplayer->currentText() + "\"" : "")
|
||||
+ (ui->useProfileCheckBox->isChecked() ? " -a \"" + ui->profileComboBox->currentText() + "\"" : "")
|
||||
+ (ui->launchOfflineCheckBox->isChecked() ? " -o" : "")
|
||||
+ (ui->offlineUsernameCheckBox->isChecked() ? " -n \"" + ui->offlineUsername->text() + "\"" : "");
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2022 arthomnix
|
||||
Copyright 2022-2023 arthomnix
|
||||
This source is subject to the Microsoft Public License (MS-PL).
|
||||
Please see the COPYING.md file for more information.
|
||||
-->
|
||||
@ -12,7 +12,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>796</width>
|
||||
<height>232</height>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@ -30,17 +30,82 @@
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="shortcutPathLabel">
|
||||
<property name="text">
|
||||
<string>Shortcut path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="useProfileCheckBox">
|
||||
<property name="text">
|
||||
<string>Use specific profile:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="joinSingleplayer">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="launchOfflineCheckBox">
|
||||
<property name="text">
|
||||
<string>Launch in offline mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="shortcutPathLabel">
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="offlineUsername">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="joinWorldCheckBox">
|
||||
<property name="text">
|
||||
<string>Shortcut path:</string>
|
||||
<string>Join world on launch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="joinServer">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="profileComboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="shortcutPath"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="offlineUsernameCheckBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set offline mode username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="joinSingleplayerRadioButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Singleplayer world:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -51,39 +116,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="shortcutPath"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="profileComboBox"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="offlineUsername"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="offlineUsernameCheckBox">
|
||||
<property name="text">
|
||||
<string>Set offline mode username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="joinServerCheckBox">
|
||||
<property name="text">
|
||||
<string>Join server on launch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="useProfileCheckBox">
|
||||
<widget class="QRadioButton" name="joinServerRadioButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use specific profile:</string>
|
||||
<string>Server address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="joinServer"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -173,18 +215,18 @@
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>joinServerCheckBox</sender>
|
||||
<signal>stateChanged(int)</signal>
|
||||
<receiver>CreateShortcutDialog</receiver>
|
||||
<slot>updateDialogState()</slot>
|
||||
<sender>joinWorldCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>joinServerRadioButton</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>122</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>397</x>
|
||||
<y>114</y>
|
||||
<x>140</x>
|
||||
<y>93</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -284,5 +326,136 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>joinWorldCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>joinSingleplayerRadioButton</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>140</x>
|
||||
<y>59</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>140</x>
|
||||
<y>132</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>joinServerRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>joinServer</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>140</x>
|
||||
<y>93</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>489</x>
|
||||
<y>93</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>joinSingleplayerRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>joinSingleplayer</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>140</x>
|
||||
<y>132</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>489</x>
|
||||
<y>132</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>useProfileCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>profileComboBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>140</x>
|
||||
<y>171</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>489</x>
|
||||
<y>171</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>launchOfflineCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>offlineUsernameCheckBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>140</x>
|
||||
<y>205</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>140</x>
|
||||
<y>239</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>joinSingleplayer</sender>
|
||||
<signal>currentTextChanged(QString)</signal>
|
||||
<receiver>CreateShortcutDialog</receiver>
|
||||
<slot>updateDialogState()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>489</x>
|
||||
<y>132</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>397</x>
|
||||
<y>164</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>joinServerRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>CreateShortcutDialog</receiver>
|
||||
<slot>updateDialogState()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>140</x>
|
||||
<y>93</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>397</x>
|
||||
<y>164</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>joinSingleplayerRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>CreateShortcutDialog</receiver>
|
||||
<slot>updateDialogState()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>140</x>
|
||||
<y>132</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>397</x>
|
||||
<y>164</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>updateDialogState()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user