mirror of
https://github.com/UltimMC/Launcher.git
synced 2026-01-02 21:59:59 +00:00
Merge branch 'MultiMC:develop' into develop
This commit is contained in:
@@ -46,7 +46,7 @@ public:
|
||||
values.append(new TexturePackPage(onesix.get()));
|
||||
values.append(new NotesPage(onesix.get()));
|
||||
values.append(new WorldListPage(onesix.get(), onesix->worldList()));
|
||||
values.append(new ServersPage(onesix.get()));
|
||||
values.append(new ServersPage(onesix));
|
||||
// values.append(new GameOptionsPage(onesix.get()));
|
||||
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
|
||||
values.append(new InstanceSettingsPage(onesix.get()));
|
||||
|
||||
@@ -218,7 +218,7 @@ void LaunchController::launchInstance()
|
||||
return;
|
||||
}
|
||||
|
||||
m_launcher = m_instance->createLaunchTask(m_session);
|
||||
m_launcher = m_instance->createLaunchTask(m_session, m_serverToJoin);
|
||||
if (!m_launcher)
|
||||
{
|
||||
emitFailed(tr("Couldn't instantiate a launcher."));
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <BaseInstance.h>
|
||||
#include <tools/BaseProfiler.h>
|
||||
|
||||
#include "minecraft/launch/MinecraftServerTarget.h"
|
||||
|
||||
class InstanceWindow;
|
||||
class LaunchController: public Task
|
||||
{
|
||||
@@ -33,6 +35,10 @@ public:
|
||||
{
|
||||
m_parentWidget = widget;
|
||||
}
|
||||
void setServerToJoin(MinecraftServerTargetPtr serverToJoin)
|
||||
{
|
||||
m_serverToJoin = std::move(serverToJoin);
|
||||
}
|
||||
QString id()
|
||||
{
|
||||
return m_instance->id();
|
||||
@@ -58,4 +64,5 @@ private:
|
||||
InstanceWindow *m_console = nullptr;
|
||||
AuthSessionPtr m_session;
|
||||
shared_qobject_ptr<LaunchTask> m_launcher;
|
||||
MinecraftServerTargetPtr m_serverToJoin;
|
||||
};
|
||||
|
||||
@@ -191,6 +191,11 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
parser.addOption("launch");
|
||||
parser.addShortOpt("launch", 'l');
|
||||
parser.addDocumentation("launch", "Launch the specified instance (by instance ID)");
|
||||
// --server
|
||||
parser.addOption("server");
|
||||
parser.addShortOpt("server", 's');
|
||||
parser.addDocumentation("server", "Join the specified server on launch "
|
||||
"(only valid in combination with --launch)");
|
||||
// --alive
|
||||
parser.addSwitch("alive");
|
||||
parser.addDocumentation("alive", "Write a small '" + liveCheckFile + "' file after MultiMC starts");
|
||||
@@ -232,6 +237,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
}
|
||||
}
|
||||
m_instanceIdToLaunch = args["launch"].toString();
|
||||
m_serverToJoin = args["server"].toString();
|
||||
m_liveCheck = args["alive"].toBool();
|
||||
m_zipToImport = args["import"].toUrl();
|
||||
|
||||
@@ -293,6 +299,13 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_instanceIdToLaunch.isEmpty() && !m_serverToJoin.isEmpty())
|
||||
{
|
||||
std::cerr << "--server can only be used in combination with --launch!" << std::endl;
|
||||
m_status = MultiMC::Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Establish the mechanism for communication with an already running MultiMC that uses the same data path.
|
||||
* If there is one, tell it what the user actually wanted to do and exit.
|
||||
@@ -318,7 +331,15 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_peerInstance->sendMessage("launch " + m_instanceIdToLaunch, timeout);
|
||||
if(!m_serverToJoin.isEmpty())
|
||||
{
|
||||
m_peerInstance->sendMessage(
|
||||
"launch-with-server " + m_instanceIdToLaunch + " " + m_serverToJoin, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_peerInstance->sendMessage("launch " + m_instanceIdToLaunch, timeout);
|
||||
}
|
||||
}
|
||||
m_status = MultiMC::Succeeded;
|
||||
return;
|
||||
@@ -399,6 +420,10 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
{
|
||||
qDebug() << "ID of instance to launch : " << m_instanceIdToLaunch;
|
||||
}
|
||||
if(!m_serverToJoin.isEmpty())
|
||||
{
|
||||
qDebug() << "Address of server to join :" << m_serverToJoin;
|
||||
}
|
||||
qDebug() << "<> Paths set.";
|
||||
}
|
||||
|
||||
@@ -844,8 +869,19 @@ void MultiMC::performMainStartupAction()
|
||||
auto inst = instances()->getInstanceById(m_instanceIdToLaunch);
|
||||
if(inst)
|
||||
{
|
||||
qDebug() << "<> Instance launching:" << m_instanceIdToLaunch;
|
||||
launch(inst, true, nullptr);
|
||||
MinecraftServerTargetPtr serverToJoin = nullptr;
|
||||
|
||||
if(!m_serverToJoin.isEmpty())
|
||||
{
|
||||
serverToJoin.reset(new MinecraftServerTarget(MinecraftServerTarget::parse(m_serverToJoin)));
|
||||
qDebug() << "<> Instance" << m_instanceIdToLaunch << "launching with server" << m_serverToJoin;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "<> Instance" << m_instanceIdToLaunch << "launching";
|
||||
}
|
||||
|
||||
launch(inst, true, nullptr, serverToJoin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -927,6 +963,31 @@ void MultiMC::messageReceived(const QString& message)
|
||||
launch(inst, true, nullptr);
|
||||
}
|
||||
}
|
||||
else if(command == "launch-with-server")
|
||||
{
|
||||
QString instanceID = message.section(' ', 1, 1);
|
||||
QString serverToJoin = message.section(' ', 2, 2);
|
||||
if(instanceID.isEmpty())
|
||||
{
|
||||
qWarning() << "Received" << command << "message without an instance ID.";
|
||||
return;
|
||||
}
|
||||
if(serverToJoin.isEmpty())
|
||||
{
|
||||
qWarning() << "Received" << command << "message without a server to join.";
|
||||
return;
|
||||
}
|
||||
auto inst = instances()->getInstanceById(instanceID);
|
||||
if(inst)
|
||||
{
|
||||
launch(
|
||||
inst,
|
||||
true,
|
||||
nullptr,
|
||||
std::make_shared<MinecraftServerTarget>(MinecraftServerTarget::parse(serverToJoin))
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Received invalid message" << message;
|
||||
@@ -1014,8 +1075,12 @@ bool MultiMC::openJsonEditor(const QString &filename)
|
||||
}
|
||||
}
|
||||
|
||||
bool MultiMC::launch(InstancePtr instance, bool online, BaseProfilerFactory *profiler)
|
||||
{
|
||||
bool MultiMC::launch(
|
||||
InstancePtr instance,
|
||||
bool online,
|
||||
BaseProfilerFactory *profiler,
|
||||
MinecraftServerTargetPtr serverToJoin
|
||||
) {
|
||||
if(m_updateRunning)
|
||||
{
|
||||
qDebug() << "Cannot launch instances while an update is running. Please try again when updates are completed.";
|
||||
@@ -1036,6 +1101,7 @@ bool MultiMC::launch(InstancePtr instance, bool online, BaseProfilerFactory *pro
|
||||
controller->setInstance(instance);
|
||||
controller->setOnline(online);
|
||||
controller->setProfiler(profiler);
|
||||
controller->setServerToJoin(serverToJoin);
|
||||
if(window)
|
||||
{
|
||||
controller->setParentWidget(window);
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <BaseInstance.h>
|
||||
|
||||
#include "minecraft/launch/MinecraftServerTarget.h"
|
||||
|
||||
class LaunchController;
|
||||
class LocalPeer;
|
||||
class InstanceWindow;
|
||||
@@ -150,7 +152,12 @@ signals:
|
||||
void globalSettingsClosed();
|
||||
|
||||
public slots:
|
||||
bool launch(InstancePtr instance, bool online = true, BaseProfilerFactory *profiler = nullptr);
|
||||
bool launch(
|
||||
InstancePtr instance,
|
||||
bool online = true,
|
||||
BaseProfilerFactory *profiler = nullptr,
|
||||
MinecraftServerTargetPtr serverToJoin = nullptr
|
||||
);
|
||||
bool kill(InstancePtr instance);
|
||||
|
||||
private slots:
|
||||
@@ -221,6 +228,7 @@ private:
|
||||
SetupWizard * m_setupWizard = nullptr;
|
||||
public:
|
||||
QString m_instanceIdToLaunch;
|
||||
QString m_serverToJoin;
|
||||
bool m_liveCheck = false;
|
||||
QUrl m_zipToImport;
|
||||
std::unique_ptr<QFile> logFile;
|
||||
|
||||
@@ -191,6 +191,18 @@ void InstanceSettingsPage::applySettings()
|
||||
m_settings->reset("ShowGameTime");
|
||||
m_settings->reset("RecordGameTime");
|
||||
}
|
||||
|
||||
// Join server on launch
|
||||
bool joinServerOnLaunch = ui->serverJoinGroupBox->isChecked();
|
||||
m_settings->set("JoinServerOnLaunch", joinServerOnLaunch);
|
||||
if (joinServerOnLaunch)
|
||||
{
|
||||
m_settings->set("JoinServerOnLaunchAddress", ui->serverJoinAddress->text());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings->reset("JoinServerOnLaunchAddress");
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSettingsPage::loadSettings()
|
||||
@@ -257,6 +269,9 @@ void InstanceSettingsPage::loadSettings()
|
||||
ui->gameTimeGroupBox->setChecked(m_settings->get("OverrideGameTime").toBool());
|
||||
ui->showGameTime->setChecked(m_settings->get("ShowGameTime").toBool());
|
||||
ui->recordGameTime->setChecked(m_settings->get("RecordGameTime").toBool());
|
||||
|
||||
ui->serverJoinGroupBox->setChecked(m_settings->get("JoinServerOnLaunch").toBool());
|
||||
ui->serverJoinAddress->setText(m_settings->get("JoinServerOnLaunchAddress").toString());
|
||||
}
|
||||
|
||||
void InstanceSettingsPage::on_javaDetectBtn_clicked()
|
||||
|
||||
@@ -453,6 +453,41 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="serverJoinGroupBox">
|
||||
<property name="title">
|
||||
<string>Set a server to join on launch</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="serverJoinLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="serverJoinAddressLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Server address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="serverJoinAddress"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacerMiscellanous">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -556,7 +556,7 @@ private:
|
||||
QTimer m_saveTimer;
|
||||
};
|
||||
|
||||
ServersPage::ServersPage(MinecraftInstance * inst, QWidget* parent)
|
||||
ServersPage::ServersPage(InstancePtr inst, QWidget* parent)
|
||||
: QMainWindow(parent), ui(new Ui::ServersPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -579,7 +579,7 @@ ServersPage::ServersPage(MinecraftInstance * inst, QWidget* parent)
|
||||
|
||||
auto selectionModel = ui->serversView->selectionModel();
|
||||
connect(selectionModel, &QItemSelectionModel::currentChanged, this, &ServersPage::currentChanged);
|
||||
connect(m_inst, &MinecraftInstance::runningStatusChanged, this, &ServersPage::on_RunningState_changed);
|
||||
connect(m_inst.get(), &MinecraftInstance::runningStatusChanged, this, &ServersPage::on_RunningState_changed);
|
||||
connect(ui->nameLine, &QLineEdit::textEdited, this, &ServersPage::nameEdited);
|
||||
connect(ui->addressLine, &QLineEdit::textEdited, this, &ServersPage::addressEdited);
|
||||
connect(ui->resourceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(resourceIndexChanged(int)));
|
||||
@@ -695,6 +695,7 @@ void ServersPage::updateState()
|
||||
ui->actionMove_Down->setEnabled(serverEditEnabled);
|
||||
ui->actionMove_Up->setEnabled(serverEditEnabled);
|
||||
ui->actionRemove->setEnabled(serverEditEnabled);
|
||||
ui->actionJoin->setEnabled(serverEditEnabled);
|
||||
|
||||
if(server)
|
||||
{
|
||||
@@ -758,4 +759,10 @@ void ServersPage::on_actionMove_Down_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
void ServersPage::on_actionJoin_triggered()
|
||||
{
|
||||
const auto &address = m_model->at(currentServer)->m_address;
|
||||
MMC->launch(m_inst, true, nullptr, std::make_shared<MinecraftServerTarget>(MinecraftServerTarget::parse(address)));
|
||||
}
|
||||
|
||||
#include "ServersPage.moc"
|
||||
|
||||
@@ -35,7 +35,7 @@ class ServersPage : public QMainWindow, public BasePage
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ServersPage(MinecraftInstance *inst, QWidget *parent = 0);
|
||||
explicit ServersPage(InstancePtr inst, QWidget *parent = 0);
|
||||
virtual ~ServersPage();
|
||||
|
||||
void openedImpl() override;
|
||||
@@ -74,6 +74,7 @@ private slots:
|
||||
void on_actionRemove_triggered();
|
||||
void on_actionMove_Up_triggered();
|
||||
void on_actionMove_Down_triggered();
|
||||
void on_actionJoin_triggered();
|
||||
|
||||
void on_RunningState_changed(bool running);
|
||||
|
||||
@@ -88,6 +89,6 @@ private: // data
|
||||
bool m_locked = true;
|
||||
Ui::ServersPage *ui = nullptr;
|
||||
ServersModel * m_model = nullptr;
|
||||
MinecraftInstance * m_inst = nullptr;
|
||||
InstancePtr m_inst = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
<addaction name="actionRemove"/>
|
||||
<addaction name="actionMove_Up"/>
|
||||
<addaction name="actionMove_Down"/>
|
||||
<addaction name="actionJoin"/>
|
||||
</widget>
|
||||
<action name="actionAdd">
|
||||
<property name="text">
|
||||
@@ -169,6 +170,11 @@
|
||||
<string>Move Down</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionJoin">
|
||||
<property name="text">
|
||||
<string>Join</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user