mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-03 08:41:42 +00:00
Solve conflicts
This commit is contained in:
@@ -249,6 +249,14 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
parser.addOption("profile");
|
||||
parser.addShortOpt("profile", 'a');
|
||||
parser.addDocumentation("profile", "Use the account specified by its profile name (only valid in combination with --launch)");
|
||||
// --offline
|
||||
parser.addSwitch("offline");
|
||||
parser.addShortOpt("offline", 'o');
|
||||
parser.addDocumentation("offline", "Launch offline (only valid in combination with --launch)");
|
||||
// --name
|
||||
parser.addOption("name");
|
||||
parser.addShortOpt("name", 'n');
|
||||
parser.addDocumentation("name", "When launching offline, use specified name (only makes sense in combination with --launch and --offline)");
|
||||
// --alive
|
||||
parser.addSwitch("alive");
|
||||
parser.addDocumentation("alive", "Write a small '" + liveCheckFile + "' file after the launcher starts");
|
||||
@@ -292,6 +300,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
m_instanceIdToLaunch = args["launch"].toString();
|
||||
m_serverToJoin = args["server"].toString();
|
||||
m_profileToUse = args["profile"].toString();
|
||||
if(args["offline"].toBool()) {
|
||||
m_offline = true;
|
||||
m_offlineName = args["name"].toString();
|
||||
}
|
||||
m_liveCheck = args["alive"].toBool();
|
||||
m_zipToImport = args["import"].toUrl();
|
||||
|
||||
@@ -357,18 +369,44 @@ Application::Application(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 = Application::Failed;
|
||||
return;
|
||||
}
|
||||
// all the things invalid when NOT trying to --launch
|
||||
if(m_instanceIdToLaunch.isEmpty()) {
|
||||
if(!m_serverToJoin.isEmpty())
|
||||
{
|
||||
std::cerr << "--server can only be used in combination with --launch!" << std::endl;
|
||||
m_status = Application::Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_instanceIdToLaunch.isEmpty() && !m_profileToUse.isEmpty())
|
||||
{
|
||||
std::cerr << "--account can only be used in combination with --launch!" << std::endl;
|
||||
m_status = Application::Failed;
|
||||
return;
|
||||
if(!m_profileToUse.isEmpty())
|
||||
{
|
||||
std::cerr << "--account can only be used in combination with --launch!" << std::endl;
|
||||
m_status = Application::Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_offline)
|
||||
{
|
||||
std::cerr << "--offline can only be used in combination with --launch!" << std::endl;
|
||||
m_status = Application::Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!m_offlineName.isEmpty())
|
||||
{
|
||||
std::cerr << "--offlineName can only be used in combination with --launch and --offline!" << std::endl;
|
||||
m_status = Application::Failed;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// all the things invalid when trying to --launch
|
||||
// online, and offline name is set
|
||||
if(!m_offline && !m_offlineName.isEmpty()) {
|
||||
std::cerr << "--offlineName can only be used in combination with --launch and --offline!" << std::endl;
|
||||
m_status = Application::Failed;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
@@ -475,6 +513,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
{
|
||||
launch.args["profile"] = m_profileToUse;
|
||||
}
|
||||
if(m_offline) {
|
||||
launch.args["offline_enabled"] = "true";
|
||||
launch.args["offline_name"] = m_offlineName;
|
||||
}
|
||||
m_peerInstance->sendMessage(launch.serialize(), timeout);
|
||||
}
|
||||
m_status = Application::Succeeded;
|
||||
@@ -1043,6 +1085,7 @@ void Application::performMainStartupAction()
|
||||
{
|
||||
MinecraftServerTargetPtr serverToJoin = nullptr;
|
||||
MinecraftAccountPtr accountToUse = nullptr;
|
||||
bool offline = m_offline;
|
||||
|
||||
qDebug() << "<> Instance" << m_instanceIdToLaunch << "launching";
|
||||
if(!m_serverToJoin.isEmpty())
|
||||
@@ -1061,7 +1104,7 @@ void Application::performMainStartupAction()
|
||||
qDebug() << " Launching with account" << m_profileToUse;
|
||||
}
|
||||
|
||||
launch(inst, true, nullptr, serverToJoin, accountToUse);
|
||||
launch(inst, !offline, nullptr, serverToJoin, accountToUse, m_offlineName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1134,6 +1177,8 @@ void Application::messageReceived(const QByteArray& message)
|
||||
QString id = received.args["id"];
|
||||
QString server = received.args["server"];
|
||||
QString profile = received.args["profile"];
|
||||
bool offline = received.args["offline_enabled"] == "true";
|
||||
QString offlineName = received.args["offline_name"];
|
||||
|
||||
InstancePtr instance;
|
||||
if(!id.isEmpty()) {
|
||||
@@ -1164,10 +1209,11 @@ void Application::messageReceived(const QByteArray& message)
|
||||
|
||||
launch(
|
||||
instance,
|
||||
true,
|
||||
!offline,
|
||||
nullptr,
|
||||
serverObject,
|
||||
accountObject
|
||||
accountObject,
|
||||
offlineName
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -1265,7 +1311,8 @@ bool Application::launch(
|
||||
bool online,
|
||||
BaseProfilerFactory *profiler,
|
||||
MinecraftServerTargetPtr serverToJoin,
|
||||
MinecraftAccountPtr accountToUse
|
||||
MinecraftAccountPtr accountToUse,
|
||||
const QString& offlineName
|
||||
) {
|
||||
if(m_updateRunning)
|
||||
{
|
||||
@@ -1290,6 +1337,7 @@ bool Application::launch(
|
||||
controller->setServerToJoin(serverToJoin);
|
||||
controller->setAuthserver(m_authserver);
|
||||
controller->setAccountToUse(accountToUse);
|
||||
controller->setOfflineName(offlineName);
|
||||
if(window)
|
||||
{
|
||||
controller->setParentWidget(window);
|
||||
|
@@ -155,7 +155,8 @@ public slots:
|
||||
bool online = true,
|
||||
BaseProfilerFactory *profiler = nullptr,
|
||||
MinecraftServerTargetPtr serverToJoin = nullptr,
|
||||
MinecraftAccountPtr accountToUse = nullptr
|
||||
MinecraftAccountPtr accountToUse = nullptr,
|
||||
const QString &offlineName = QString()
|
||||
);
|
||||
bool kill(InstancePtr instance);
|
||||
|
||||
@@ -236,6 +237,8 @@ public:
|
||||
QString m_instanceIdToLaunch;
|
||||
QString m_serverToJoin;
|
||||
QString m_profileToUse;
|
||||
bool m_offline = false;
|
||||
QString m_offlineName;
|
||||
bool m_liveCheck = false;
|
||||
QUrl m_zipToImport;
|
||||
std::unique_ptr<QFile> logFile;
|
||||
|
@@ -29,6 +29,10 @@ public:
|
||||
m_online = online;
|
||||
}
|
||||
|
||||
void setOfflineName(const QString &offlineName) {
|
||||
m_offlineName = offlineName;
|
||||
}
|
||||
|
||||
void setProfiler(BaseProfilerFactory *profiler) {
|
||||
m_profiler = profiler;
|
||||
}
|
||||
@@ -71,6 +75,7 @@ private slots:
|
||||
private:
|
||||
BaseProfilerFactory *m_profiler = nullptr;
|
||||
bool m_online = true;
|
||||
QString m_offlineName;
|
||||
InstancePtr m_instance;
|
||||
QWidget * m_parentWidget = nullptr;
|
||||
InstanceWindow *m_console = nullptr;
|
||||
|
Reference in New Issue
Block a user