aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--launcher/BaseInstance.cpp2
-rw-r--r--launcher/InstanceList.cpp16
-rw-r--r--launcher/icons/IconList.cpp11
-rw-r--r--launcher/icons/IconList.h1
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp2
-rw-r--r--launcher/ui/MainWindow.cpp11
-rw-r--r--launcher/ui/MainWindow.h2
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.ui6
-rw-r--r--libraries/launcher/net/minecraft/Launcher.java65
10 files changed, 95 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11d58213..a0ae0a4f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,8 +45,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEPRECATED_WARNINGS=Y")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_DISABLE_DEPRECATED_BEFORE=0x050C00")
# set CXXFLAGS for build targets
-set(CMAKE_CXX_FLAGS_DEBUG "-O2 -D_FORTIFY_SOURCE=2 ${CMAKE_CXX_FLAGS}")
-set(CMAKE_CXX_FLAGS_RELEASE "-O2 -D_FORTIFY_SOURCE=2 ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS_RELEASE "-O2 -D_FORTIFY_SOURCE=2 ${CMAKE_CXX_FLAGS_RELEASE}")
option(ENABLE_LTO "Enable Link Time Optimization" off)
diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp
index 2fb31d94..0240afa8 100644
--- a/launcher/BaseInstance.cpp
+++ b/launcher/BaseInstance.cpp
@@ -59,7 +59,7 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
m_settings->registerSetting("lastLaunchTime", 0);
m_settings->registerSetting("totalTimePlayed", 0);
m_settings->registerSetting("lastTimePlayed", 0);
- m_settings->registerSetting("InstanceType", "OneSix");
+ m_settings->registerSetting("InstanceType", "");
// Custom Commands
auto commandSetting = m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp
index 847d897e..3e3c81f7 100644
--- a/launcher/InstanceList.cpp
+++ b/launcher/InstanceList.cpp
@@ -547,8 +547,20 @@ InstancePtr InstanceList::loadInstance(const InstanceId& id)
auto instanceRoot = FS::PathCombine(m_instDir, id);
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(instanceRoot, "instance.cfg"));
InstancePtr inst;
- // TODO: Handle incompatible instances
- inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
+
+ instanceSettings->registerSetting("InstanceType", "");
+
+ QString inst_type = instanceSettings->get("InstanceType").toString();
+
+ // NOTE: Some PolyMC versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a OneSix instance
+ if (inst_type == "OneSix" || inst_type.isEmpty())
+ {
+ inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
+ }
+ else
+ {
+ inst.reset(new NullInstance(m_globalSettings, instanceSettings, instanceRoot));
+ }
qDebug() << "Loaded instance " << inst->name() << " from " << inst->instanceRoot();
return inst;
}
diff --git a/launcher/icons/IconList.cpp b/launcher/icons/IconList.cpp
index 0ddfae55..d426aa80 100644
--- a/launcher/icons/IconList.cpp
+++ b/launcher/icons/IconList.cpp
@@ -56,6 +56,15 @@ IconList::IconList(const QStringList &builtinPaths, QString path, QObject *paren
emit iconUpdated({});
}
+void IconList::sortIconList()
+{
+ qDebug() << "Sorting icon list...";
+ std::sort(icons.begin(), icons.end(), [](const MMCIcon& a, const MMCIcon& b) {
+ return a.m_key.localeAwareCompare(b.m_key) < 0;
+ });
+ reindex();
+}
+
void IconList::directoryChanged(const QString &path)
{
QDir new_dir (path);
@@ -141,6 +150,8 @@ void IconList::directoryChanged(const QString &path)
emit iconUpdated(key);
}
}
+
+ sortIconList();
}
void IconList::fileChanged(const QString &path)
diff --git a/launcher/icons/IconList.h b/launcher/icons/IconList.h
index ebbb52e2..f9f49e7f 100644
--- a/launcher/icons/IconList.h
+++ b/launcher/icons/IconList.h
@@ -71,6 +71,7 @@ private:
// hide assign op
IconList &operator=(const IconList &) = delete;
void reindex();
+ void sortIconList();
public slots:
void directoryChanged(const QString &path);
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index 2f339014..e99d30fe 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -168,6 +168,8 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
m_settings->registerOverride(globalSettings->getSetting("CloseAfterLaunch"), miscellaneousOverride);
m_settings->registerOverride(globalSettings->getSetting("QuitAfterGameStop"), miscellaneousOverride);
+ m_settings->set("InstanceType", "OneSix");
+
m_components.reset(new PackProfile(this));
}
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 7e152b96..0a5f2000 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -2101,6 +2101,9 @@ void MainWindow::instanceChanged(const QModelIndex &current, const QModelIndex &
selectionBad();
return;
}
+ if (m_selectedInstance) {
+ disconnect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
+ }
QString id = current.data(InstanceList::InstanceIDRole).toString();
m_selectedInstance = APPLICATION->instances()->getInstanceById(id);
if (m_selectedInstance)
@@ -2127,6 +2130,8 @@ void MainWindow::instanceChanged(const QModelIndex &current, const QModelIndex &
updateToolsMenu();
APPLICATION->settings()->set("SelectedInstance", m_selectedInstance->id());
+
+ connect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
}
else
{
@@ -2216,3 +2221,9 @@ void MainWindow::updateStatusCenter()
m_statusCenter->setText(tr("Total playtime: %1").arg(Time::prettifyDuration(timePlayed)));
}
}
+
+void MainWindow::refreshCurrentInstance(bool running)
+{
+ auto current = view->selectionModel()->currentIndex();
+ instanceChanged(current, current);
+}
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index 2032acba..61a75c45 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -192,6 +192,8 @@ private slots:
void keyReleaseEvent(QKeyEvent *event) override;
#endif
+ void refreshCurrentInstance(bool running);
+
private:
void retranslateUi();
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.ui b/launcher/ui/pages/modplatform/technic/TechnicPage.ui
index ca6a9b7e..15bf645f 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.ui
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.ui
@@ -60,7 +60,11 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QTextBrowser" name="packDescription"/>
+ <widget class="QTextBrowser" name="packDescription">
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
</layout>
</item>
diff --git a/libraries/launcher/net/minecraft/Launcher.java b/libraries/launcher/net/minecraft/Launcher.java
index 265fa66a..6bf671be 100644
--- a/libraries/launcher/net/minecraft/Launcher.java
+++ b/libraries/launcher/net/minecraft/Launcher.java
@@ -24,24 +24,65 @@ import java.net.URL;
import java.util.Map;
import java.util.TreeMap;
+/*
+ * WARNING: This class is reflectively accessed by legacy Forge versions.
+ * Changing field and method declarations without further testing is not recommended.
+ */
public final class Launcher extends Applet implements AppletStub {
private final Map<String, String> params = new TreeMap<>();
- private final Applet wrappedApplet;
+ private Applet wrappedApplet;
+
+ private URL documentBase;
private boolean active = false;
public Launcher(Applet applet) {
+ this(applet, null);
+ }
+
+ public Launcher(Applet applet, URL documentBase) {
this.setLayout(new BorderLayout());
this.add(applet, "Center");
this.wrappedApplet = applet;
+
+ try {
+ if (documentBase != null) {
+ this.documentBase = documentBase;
+ } else if (applet.getClass().getPackage().getName().startsWith("com.mojang")) {
+ // Special case only for Classic versions
+
+ this.documentBase = new URL("http", "www.minecraft.net", 80, "/game/");
+ } else {
+ this.documentBase = new URL("http://www.minecraft.net/game/");
+ }
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void replace(Applet applet) {
+ this.wrappedApplet = applet;
+
+ applet.setStub(this);
+ applet.setSize(getWidth(), getHeight());
+
+ this.setLayout(new BorderLayout());
+ this.add(applet, "Center");
+
+ applet.init();
+
+ active = true;
+
+ applet.start();
+
+ validate();
}
- public void setParameter(String name, String value)
- {
+ public void setParameter(String name, String value) {
params.put(name, value);
}
@@ -54,7 +95,7 @@ public final class Launcher extends Applet implements AppletStub {
try {
return super.getParameter(name);
- } catch (Exception ignore) {}
+ } catch (Exception ignored) {}
return null;
}
@@ -108,25 +149,13 @@ public final class Launcher extends Applet implements AppletStub {
try {
return new URL("http://www.minecraft.net/game/");
} catch (MalformedURLException e) {
- e.printStackTrace();
+ throw new RuntimeException(e);
}
-
- return null;
}
@Override
public URL getDocumentBase() {
- try {
- // Special case only for Classic versions
- if (wrappedApplet.getClass().getCanonicalName().startsWith("com.mojang"))
- return new URL("http", "www.minecraft.net", 80, "/game/");
-
- return new URL("http://www.minecraft.net/game/");
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
-
- return null;
+ return documentBase;
}
@Override