Regrab a few changes on SysInfo
Signed-off-by: timoreo <contact@timoreo.fr>
This commit is contained in:
parent
53ddba8077
commit
f946964490
@ -271,6 +271,8 @@ set(MINECRAFT_SOURCES
|
||||
minecraft/GradleSpecifier.h
|
||||
minecraft/MinecraftInstance.cpp
|
||||
minecraft/MinecraftInstance.h
|
||||
minecraft/LaunchContext.cpp
|
||||
minecraft/LaunchContext.h
|
||||
minecraft/LaunchProfile.cpp
|
||||
minecraft/LaunchProfile.h
|
||||
minecraft/Component.cpp
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include "settings/SettingsObject.h"
|
||||
#include "minecraft/LaunchContext.h"
|
||||
#ifdef Q_OS_MACOS
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
@ -68,18 +68,24 @@ QString useQTForArch(){
|
||||
return qtArch;
|
||||
}
|
||||
|
||||
QString runCheckerForArch(const SettingsObjectPtr& settingsObj){
|
||||
QString checkerJar = FS::PathCombine(APPLICATION->getJarsPath(), "JavaCheck.jar");
|
||||
QString runCheckerForArch(LaunchContext launchContext){
|
||||
QString checkerJar = JavaUtils::getJavaCheckPath();
|
||||
|
||||
if (checkerJar.isEmpty())
|
||||
{
|
||||
qDebug() << "Java checker library could not be found. Please check your installation.";
|
||||
return useQTForArch();
|
||||
}
|
||||
|
||||
QStringList args;
|
||||
|
||||
QProcessPtr process = new QProcess();
|
||||
args.append({"-jar", checkerJar});
|
||||
process->setArguments(args);
|
||||
process->setProgram(settingsObj->get("JavaPath").toString());
|
||||
process->setProgram(launchContext.getJavaPath().toString());
|
||||
process->setProcessChannelMode(QProcess::SeparateChannels);
|
||||
process->setProcessEnvironment(CleanEnviroment());
|
||||
qDebug() << "Running java checker: " + settingsObj->get("JavaPath").toString() + args.join(" ");;
|
||||
qDebug() << "Running java checker: " + launchContext.getJavaPath().toString() + args.join(" ");;
|
||||
|
||||
process->start();
|
||||
if(!process->waitForFinished(15000)){
|
||||
@ -105,7 +111,11 @@ QString runCheckerForArch(const SettingsObjectPtr& settingsObj){
|
||||
stderr_javaChecker += added;
|
||||
|
||||
QMap<QString, QString> results;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList lines = stdout_javaChecker.split("\n", Qt::SkipEmptyParts);
|
||||
#else
|
||||
QStringList lines = stdout_javaChecker.split("\n", QString::SkipEmptyParts);
|
||||
#endif
|
||||
for(QString line : lines)
|
||||
{
|
||||
line = line.trimmed();
|
||||
@ -114,7 +124,11 @@ QString runCheckerForArch(const SettingsObjectPtr& settingsObj){
|
||||
continue;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
auto parts = line.split('=', Qt::SkipEmptyParts);
|
||||
#else
|
||||
auto parts = line.split('=', QString::SkipEmptyParts);
|
||||
#endif
|
||||
if(parts.size() != 2 || parts[0].isEmpty() || parts[1].isEmpty())
|
||||
{
|
||||
continue;
|
||||
@ -136,13 +150,13 @@ QString runCheckerForArch(const SettingsObjectPtr& settingsObj){
|
||||
}
|
||||
}
|
||||
|
||||
QString currentArch(const SettingsObjectPtr& settingsObj) {
|
||||
auto realJavaArchitecture = settingsObj->get("JavaRealArchitecture").toString();
|
||||
QString currentArch(LaunchContext launchContext) {
|
||||
auto realJavaArchitecture = launchContext.getRealJavaArch().toString();
|
||||
if(realJavaArchitecture == ""){
|
||||
//BRO WHY NOW I HAVE TO USE A JAVA CHECKER >:(
|
||||
qDebug() << "SysInfo: BRO I HAVE TO USE A JAVA CHECKER WHY IS JAVA ARCH BORKED";
|
||||
settingsObj->set("JavaRealArchitecture", runCheckerForArch(settingsObj));
|
||||
realJavaArchitecture = settingsObj->get("JavaRealArchitecture").toString();
|
||||
launchContext.setRealJavaArch(runCheckerForArch(launchContext));
|
||||
realJavaArchitecture = launchContext.getRealJavaArch().toString();
|
||||
}
|
||||
//qDebug() << "SysInfo: realJavaArch = " << realJavaArchitecture;
|
||||
if(realJavaArchitecture == "aarch64"){
|
||||
|
@ -1,13 +1,12 @@
|
||||
#include <QString>
|
||||
#include "settings/SettingsObject.h"
|
||||
#include "minecraft/LaunchContext.h"
|
||||
#ifdef Q_OS_MACOS
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
namespace SysInfo {
|
||||
QString currentSystem();
|
||||
QString currentArch(const SettingsObjectPtr& settingsObj);
|
||||
QString runCheckerForArch(const SettingsObjectPtr& settingsObj);
|
||||
QString currentArch(LaunchContext launchContext);
|
||||
QString runCheckerForArch(LaunchContext launchContext);
|
||||
QString useQTForArch();
|
||||
}
|
||||
|
||||
|
39
launcher/minecraft/LaunchContext.cpp
Normal file
39
launcher/minecraft/LaunchContext.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Toshit Chawda <r58playz@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "LaunchContext.h"
|
||||
|
||||
LaunchContext::LaunchContext(SettingsObjectPtr instanceSettings){
|
||||
m_instanceSettings = instanceSettings;
|
||||
}
|
||||
|
||||
void LaunchContext::setRealJavaArch(QVariant realJavaArch)
|
||||
{
|
||||
m_instanceSettings->set("JavaRealArchitecture", realJavaArch);
|
||||
}
|
||||
|
||||
QVariant LaunchContext::getRealJavaArch()
|
||||
{
|
||||
return m_instanceSettings->get("JavaRealArchitecture");
|
||||
}
|
||||
|
||||
QVariant LaunchContext::getJavaPath()
|
||||
{
|
||||
return m_instanceSettings->get("JavaPath");
|
||||
}
|
34
launcher/minecraft/LaunchContext.h
Normal file
34
launcher/minecraft/LaunchContext.h
Normal file
@ -0,0 +1,34 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Toshit Chawda <r58playz@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QVariant>
|
||||
#include "settings/SettingsObject.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
class LaunchContext
|
||||
{
|
||||
public:
|
||||
LaunchContext(SettingsObjectPtr instanceSettings);
|
||||
void setRealJavaArch(QVariant realJavaArch);
|
||||
QVariant getRealJavaArch();
|
||||
QVariant getJavaPath();
|
||||
private:
|
||||
SettingsObjectPtr m_instanceSettings;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user