refactor: introduce RuntimeContext
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
@ -191,6 +191,13 @@ void MinecraftInstance::loadSpecificSettings()
|
||||
qDebug() << "Instance-type specific settings were loaded!";
|
||||
|
||||
setSpecificSettingsLoaded(true);
|
||||
|
||||
updateRuntimeContext();
|
||||
}
|
||||
|
||||
void MinecraftInstance::updateRuntimeContext()
|
||||
{
|
||||
m_runtimeContext.updateFromInstanceSettings(m_settings);
|
||||
}
|
||||
|
||||
QString MinecraftInstance::typeName() const
|
||||
@ -328,9 +335,8 @@ QDir MinecraftInstance::versionsPath() const
|
||||
QStringList MinecraftInstance::getClassPath()
|
||||
{
|
||||
QStringList jars, nativeJars;
|
||||
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
|
||||
auto profile = m_components->getProfile();
|
||||
profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
return jars;
|
||||
}
|
||||
|
||||
@ -343,9 +349,8 @@ QString MinecraftInstance::getMainClass() const
|
||||
QStringList MinecraftInstance::getNativeJars()
|
||||
{
|
||||
QStringList jars, nativeJars;
|
||||
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
|
||||
auto profile = m_components->getProfile();
|
||||
profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
return nativeJars;
|
||||
}
|
||||
|
||||
@ -369,7 +374,7 @@ QStringList MinecraftInstance::extraArguments()
|
||||
for (auto agent : agents)
|
||||
{
|
||||
QStringList jar, temp1, temp2, temp3;
|
||||
agent->library()->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, getLocalLibraryPath());
|
||||
agent->library()->getApplicableFiles(runtimeContext(), jar, temp1, temp2, temp3, getLocalLibraryPath());
|
||||
list.append("-javaagent:"+jar[0]+(agent->argument().isEmpty() ? "" : "="+agent->argument()));
|
||||
}
|
||||
return list;
|
||||
@ -626,8 +631,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS
|
||||
// libraries and class path.
|
||||
{
|
||||
QStringList jars, nativeJars;
|
||||
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
|
||||
profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
for(auto file: jars)
|
||||
{
|
||||
launchScript += "cp " + file + "\n";
|
||||
@ -683,8 +687,7 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
|
||||
{
|
||||
out << "Libraries:";
|
||||
QStringList jars, nativeJars;
|
||||
auto javaArchitecture = settings->get("JavaArchitecture").toString();
|
||||
profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
|
||||
auto printLibFile = [&](const QString & path)
|
||||
{
|
||||
QFileInfo info(path);
|
||||
@ -749,8 +752,8 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
|
||||
out << "Jar Mods:";
|
||||
for(auto & jarmod: jarMods)
|
||||
{
|
||||
auto displayname = jarmod->displayName(currentSystem);
|
||||
auto realname = jarmod->filename(currentSystem);
|
||||
auto displayname = jarmod->displayName(runtimeContext());
|
||||
auto realname = jarmod->filename(runtimeContext());
|
||||
if(displayname != realname)
|
||||
{
|
||||
out << " " + displayname + " (" + realname + ")";
|
||||
@ -912,6 +915,7 @@ QString MinecraftInstance::getStatusbarDescription()
|
||||
|
||||
Task::Ptr MinecraftInstance::createUpdateTask(Net::Mode mode)
|
||||
{
|
||||
updateRuntimeContext();
|
||||
switch (mode)
|
||||
{
|
||||
case Net::Mode::Offline:
|
||||
@ -928,6 +932,7 @@ Task::Ptr MinecraftInstance::createUpdateTask(Net::Mode mode)
|
||||
|
||||
shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin)
|
||||
{
|
||||
updateRuntimeContext();
|
||||
// FIXME: get rid of shared_from_this ...
|
||||
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
|
||||
auto pptr = process.get();
|
||||
@ -1158,7 +1163,7 @@ QList<Mod*> MinecraftInstance::getJarMods() const
|
||||
for (auto jarmod : profile->getJarMods())
|
||||
{
|
||||
QStringList jar, temp1, temp2, temp3;
|
||||
jarmod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
|
||||
jarmod->getApplicableFiles(runtimeContext(), jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
|
||||
// QString filePath = jarmodsPath().absoluteFilePath(jarmod->filename(currentSystem));
|
||||
mods.push_back(new Mod(QFileInfo(jar[0])));
|
||||
}
|
||||
|
Reference in New Issue
Block a user