mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-10-06 06:50:16 +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).
|
* This source is subject to the Microsoft Public License (MS-PL).
|
||||||
* Please see the COPYING.md file for more information.
|
* Please see the COPYING.md file for more information.
|
||||||
@ -13,6 +13,8 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "minecraft/auth/AccountList.h"
|
#include "minecraft/auth/AccountList.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
|
#include "minecraft/WorldList.h"
|
||||||
|
#include "minecraft/VersionFilterData.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "icons/IconList.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
|
// 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
|
// 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)
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
|
||||||
ui->createScriptCheckBox->setEnabled(false);
|
ui->createScriptCheckBox->setEnabled(false);
|
||||||
@ -90,16 +109,16 @@ void CreateShortcutDialog::accept()
|
|||||||
|
|
||||||
void CreateShortcutDialog::updateDialogState()
|
void CreateShortcutDialog::updateDialogState()
|
||||||
{
|
{
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(
|
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(
|
||||||
!ui->shortcutPath->text().isEmpty()
|
!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->offlineUsernameCheckBox->isChecked() || !ui->offlineUsername->text().isEmpty())
|
||||||
&& (!ui->useProfileCheckBox->isChecked() || !ui->profileComboBox->currentText().isEmpty())
|
&& (!ui->useProfileCheckBox->isChecked() || !ui->profileComboBox->currentText().isEmpty())
|
||||||
);
|
);
|
||||||
ui->joinServer->setEnabled(ui->joinServerCheckBox->isChecked());
|
ui->joinServer->setEnabled(ui->joinWorldCheckBox->isChecked() && ui->joinServerRadioButton->isChecked());
|
||||||
ui->profileComboBox->setEnabled(ui->useProfileCheckBox->isChecked());
|
ui->joinSingleplayer->setEnabled(ui->joinWorldCheckBox->isChecked() && ui->joinSingleplayerRadioButton->isChecked());
|
||||||
ui->offlineUsernameCheckBox->setEnabled(ui->launchOfflineCheckBox->isChecked());
|
|
||||||
ui->offlineUsername->setEnabled(ui->launchOfflineCheckBox->isChecked() && ui->offlineUsernameCheckBox->isChecked());
|
ui->offlineUsername->setEnabled(ui->launchOfflineCheckBox->isChecked() && ui->offlineUsernameCheckBox->isChecked());
|
||||||
if (!ui->launchOfflineCheckBox->isChecked())
|
if (!ui->launchOfflineCheckBox->isChecked())
|
||||||
{
|
{
|
||||||
@ -117,7 +136,8 @@ QString CreateShortcutDialog::getLaunchArgs(bool escapeQuotesTwice)
|
|||||||
{
|
{
|
||||||
return " -d \"" + QDir::toNativeSeparators(QDir::currentPath()).replace('"', escapeQuotesTwice ? "\\\\\"" : "\\\"") + "\""
|
return " -d \"" + QDir::toNativeSeparators(QDir::currentPath()).replace('"', escapeQuotesTwice ? "\\\\\"" : "\\\"") + "\""
|
||||||
+ " -l \"" + m_instance->id() + "\""
|
+ " -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->useProfileCheckBox->isChecked() ? " -a \"" + ui->profileComboBox->currentText() + "\"" : "")
|
||||||
+ (ui->launchOfflineCheckBox->isChecked() ? " -o" : "")
|
+ (ui->launchOfflineCheckBox->isChecked() ? " -o" : "")
|
||||||
+ (ui->offlineUsernameCheckBox->isChecked() ? " -n \"" + ui->offlineUsername->text() + "\"" : "");
|
+ (ui->offlineUsernameCheckBox->isChecked() ? " -n \"" + ui->offlineUsername->text() + "\"" : "");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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).
|
This source is subject to the Microsoft Public License (MS-PL).
|
||||||
Please see the COPYING.md file for more information.
|
Please see the COPYING.md file for more information.
|
||||||
-->
|
-->
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>796</width>
|
<width>796</width>
|
||||||
<height>232</height>
|
<height>330</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -30,17 +30,82 @@
|
|||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
</property>
|
</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">
|
<widget class="QCheckBox" name="launchOfflineCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Launch in offline mode</string>
|
<string>Launch in offline mode</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="6" column="1">
|
||||||
<widget class="QLabel" name="shortcutPathLabel">
|
<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">
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -51,39 +116,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<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">
|
<property name="text">
|
||||||
<string>Use specific profile:</string>
|
<string>Server address:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="joinServer"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -173,18 +215,18 @@
|
|||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>joinServerCheckBox</sender>
|
<sender>joinWorldCheckBox</sender>
|
||||||
<signal>stateChanged(int)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>CreateShortcutDialog</receiver>
|
<receiver>joinServerRadioButton</receiver>
|
||||||
<slot>updateDialogState()</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>122</x>
|
<x>122</x>
|
||||||
<y>61</y>
|
<y>61</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>397</x>
|
<x>140</x>
|
||||||
<y>114</y>
|
<y>93</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@ -284,5 +326,136 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</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>
|
</connections>
|
||||||
|
<slots>
|
||||||
|
<slot>updateDialogState()</slot>
|
||||||
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user