2015-01-28 03:01:07 +05:30
|
|
|
#include "MinecraftInstance.h"
|
2015-05-05 04:39:28 +05:30
|
|
|
#include <settings/Setting.h>
|
2015-02-09 06:21:14 +05:30
|
|
|
#include "settings/SettingsObject.h"
|
2015-01-28 03:01:07 +05:30
|
|
|
#include <pathutils.h>
|
2015-02-09 06:21:14 +05:30
|
|
|
#include "Env.h"
|
|
|
|
#include "minecraft/MinecraftVersionList.h"
|
2015-01-28 03:01:07 +05:30
|
|
|
|
2015-05-05 04:39:28 +05:30
|
|
|
// all of this because keeping things compatible with deprecated old settings
|
|
|
|
// if either of the settings {a, b} is true, this also resolves to true
|
|
|
|
class OrSetting : public Setting
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
OrSetting(QString id, std::shared_ptr<Setting> a, std::shared_ptr<Setting> b)
|
|
|
|
:Setting({id}, false), m_a(a), m_b(b)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual QVariant get() const
|
|
|
|
{
|
|
|
|
bool a = m_a->get().toBool();
|
|
|
|
bool b = m_b->get().toBool();
|
|
|
|
return a || b;
|
|
|
|
}
|
|
|
|
virtual void reset() {}
|
|
|
|
virtual void set(QVariant value) {}
|
|
|
|
private:
|
|
|
|
std::shared_ptr<Setting> m_a;
|
|
|
|
std::shared_ptr<Setting> m_b;
|
|
|
|
};
|
|
|
|
|
2015-02-01 07:38:25 +05:30
|
|
|
MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
|
|
|
|
: BaseInstance(globalSettings, settings, rootDir)
|
2015-01-28 03:01:07 +05:30
|
|
|
{
|
|
|
|
// Java Settings
|
2015-05-05 04:39:28 +05:30
|
|
|
auto javaOverride = m_settings->registerSetting("OverrideJava", false);
|
2015-05-04 04:50:48 +05:30
|
|
|
auto locationOverride = m_settings->registerSetting("OverrideJavaLocation", false);
|
2015-05-05 04:39:28 +05:30
|
|
|
auto javaOrLocation = std::make_shared<OrSetting>("JavaOrLocationOverride", javaOverride, locationOverride);
|
2015-01-28 03:01:07 +05:30
|
|
|
m_settings->registerSetting("OverrideJavaArgs", false);
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("JavaPath"));
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("JvmArgs"));
|
|
|
|
|
2015-05-04 04:50:48 +05:30
|
|
|
// special!
|
2015-05-05 04:39:28 +05:30
|
|
|
m_settings->registerPassthrough(globalSettings->getSetting("JavaTimestamp"), javaOrLocation);
|
|
|
|
m_settings->registerPassthrough(globalSettings->getSetting("JavaVersion"), javaOrLocation);
|
2015-05-04 04:50:48 +05:30
|
|
|
|
2015-01-28 03:01:07 +05:30
|
|
|
// Window Size
|
|
|
|
m_settings->registerSetting("OverrideWindow", false);
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("LaunchMaximized"));
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("MinecraftWinWidth"));
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("MinecraftWinHeight"));
|
|
|
|
|
|
|
|
// Memory
|
|
|
|
m_settings->registerSetting("OverrideMemory", false);
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("MinMemAlloc"));
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("MaxMemAlloc"));
|
|
|
|
m_settings->registerOverride(globalSettings->getSetting("PermGen"));
|
|
|
|
}
|
|
|
|
|
|
|
|
QString MinecraftInstance::minecraftRoot() const
|
|
|
|
{
|
|
|
|
QFileInfo mcDir(PathCombine(instanceRoot(), "minecraft"));
|
|
|
|
QFileInfo dotMCDir(PathCombine(instanceRoot(), ".minecraft"));
|
|
|
|
|
|
|
|
if (dotMCDir.exists() && !mcDir.exists())
|
|
|
|
return dotMCDir.filePath();
|
|
|
|
else
|
|
|
|
return mcDir.filePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr< BaseVersionList > MinecraftInstance::versionList() const
|
|
|
|
{
|
2015-02-02 05:39:28 +05:30
|
|
|
return ENV.getVersionList("net.minecraft");
|
2015-01-28 03:01:07 +05:30
|
|
|
}
|
2015-05-05 04:39:28 +05:30
|
|
|
|
|
|
|
#include "MinecraftInstance.moc"
|