diff options
Diffstat (limited to 'archived/projt-launcher/launcher/tools')
12 files changed, 843 insertions, 0 deletions
diff --git a/archived/projt-launcher/launcher/tools/BaseExternalTool.cpp b/archived/projt-launcher/launcher/tools/BaseExternalTool.cpp new file mode 100644 index 0000000000..c957607fba --- /dev/null +++ b/archived/projt-launcher/launcher/tools/BaseExternalTool.cpp @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "BaseExternalTool.h" + +#include <QDir> +#include <QProcess> + +#ifdef Q_OS_WIN +#include <windows.h> +#endif + +#include "BaseInstance.h" + +BaseExternalTool::BaseExternalTool(SettingsObjectPtr settings, InstancePtr instance, QObject* parent) + : QObject(parent), + m_instance(instance), + globalSettings(settings) +{} + +BaseExternalTool::~BaseExternalTool() +{} + +BaseDetachedTool::BaseDetachedTool(SettingsObjectPtr settings, InstancePtr instance, QObject* parent) + : BaseExternalTool(settings, instance, parent) +{} + +void BaseDetachedTool::run() +{ + runImpl(); +} + +BaseExternalToolFactory::~BaseExternalToolFactory() +{} + +BaseDetachedTool* BaseDetachedToolFactory::createDetachedTool(InstancePtr instance, QObject* parent) +{ + return qobject_cast<BaseDetachedTool*>(createTool(instance, parent)); +} diff --git a/archived/projt-launcher/launcher/tools/BaseExternalTool.h b/archived/projt-launcher/launcher/tools/BaseExternalTool.h new file mode 100644 index 0000000000..2e61536ed0 --- /dev/null +++ b/archived/projt-launcher/launcher/tools/BaseExternalTool.h @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#pragma once + +#include <BaseInstance.h> +#include <QObject> + +class BaseInstance; +class SettingsObject; +class QProcess; + +class BaseExternalTool : public QObject +{ + Q_OBJECT + public: + explicit BaseExternalTool(SettingsObjectPtr settings, InstancePtr instance, QObject* parent = 0); + virtual ~BaseExternalTool(); + + protected: + InstancePtr m_instance; + SettingsObjectPtr globalSettings; +}; + +class BaseDetachedTool : public BaseExternalTool +{ + Q_OBJECT + public: + explicit BaseDetachedTool(SettingsObjectPtr settings, InstancePtr instance, QObject* parent = 0); + + public slots: + void run(); + + protected: + virtual void runImpl() = 0; +}; + +class BaseExternalToolFactory +{ + public: + virtual ~BaseExternalToolFactory(); + + virtual QString name() const = 0; + + virtual void registerSettings(SettingsObjectPtr settings) = 0; + + virtual BaseExternalTool* createTool(InstancePtr instance, QObject* parent = 0) = 0; + + virtual bool check(QString* error) = 0; + virtual bool check(const QString& path, QString* error) = 0; + + protected: + SettingsObjectPtr globalSettings; +}; + +class BaseDetachedToolFactory : public BaseExternalToolFactory +{ + public: + virtual BaseDetachedTool* createDetachedTool(InstancePtr instance, QObject* parent = 0); +}; diff --git a/archived/projt-launcher/launcher/tools/BaseProfiler.cpp b/archived/projt-launcher/launcher/tools/BaseProfiler.cpp new file mode 100644 index 0000000000..efa4da3277 --- /dev/null +++ b/archived/projt-launcher/launcher/tools/BaseProfiler.cpp @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "BaseProfiler.h" +#include "QObjectPtr.h" + +#include <QProcess> + +BaseProfiler::BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent) + : BaseExternalTool(settings, instance, parent) +{} + +void BaseProfiler::beginProfiling(shared_qobject_ptr<projt::launch::LaunchPipeline> process) +{ + beginProfilingImpl(process); +} + +void BaseProfiler::abortProfiling() +{ + abortProfilingImpl(); +} + +void BaseProfiler::abortProfilingImpl() +{ + if (!m_profilerProcess) + { + return; + } + m_profilerProcess->terminate(); + m_profilerProcess->deleteLater(); + m_profilerProcess = 0; + emit abortLaunch(tr("Profiler aborted")); +} + +BaseProfiler* BaseProfilerFactory::createProfiler(InstancePtr instance, QObject* parent) +{ + return qobject_cast<BaseProfiler*>(createTool(instance, parent)); +} diff --git a/archived/projt-launcher/launcher/tools/BaseProfiler.h b/archived/projt-launcher/launcher/tools/BaseProfiler.h new file mode 100644 index 0000000000..401e12f794 --- /dev/null +++ b/archived/projt-launcher/launcher/tools/BaseProfiler.h @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#pragma once + +#include "BaseExternalTool.h" +#include "QObjectPtr.h" + +class BaseInstance; +class SettingsObject; +namespace projt::launch +{ + class LaunchPipeline; +} +class QProcess; + +class BaseProfiler : public BaseExternalTool +{ + Q_OBJECT + public: + explicit BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent = 0); + + public slots: + void beginProfiling(shared_qobject_ptr<projt::launch::LaunchPipeline> process); + void abortProfiling(); + + protected: + QProcess* m_profilerProcess; + + virtual void beginProfilingImpl(shared_qobject_ptr<projt::launch::LaunchPipeline> process) = 0; + virtual void abortProfilingImpl(); + + signals: + void readyToLaunch(const QString& message); + void abortLaunch(const QString& message); +}; + +class BaseProfilerFactory : public BaseExternalToolFactory +{ + public: + virtual BaseProfiler* createProfiler(InstancePtr instance, QObject* parent = 0); +}; diff --git a/archived/projt-launcher/launcher/tools/GenericProfiler.cpp b/archived/projt-launcher/launcher/tools/GenericProfiler.cpp new file mode 100644 index 0000000000..9e1906438d --- /dev/null +++ b/archived/projt-launcher/launcher/tools/GenericProfiler.cpp @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * === Upstream License Block (Do Not Modify) ============================== + * + * + * + * Prism Launcher - Minecraft Launcher + * Copyright (c) 2023 Trial97 <alexandru.tripon97@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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + * + * + * ======================================================================== */ +#include "GenericProfiler.h" + +#include "BaseInstance.h" +#include "launch/LaunchPipeline.hpp" +#include "settings/SettingsObject.h" + +class GenericProfiler : public BaseProfiler +{ + Q_OBJECT + public: + GenericProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent = 0); + + protected: + void beginProfilingImpl(shared_qobject_ptr<projt::launch::LaunchPipeline> process); +}; + +GenericProfiler::GenericProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent) + : BaseProfiler(settings, instance, parent) +{} + +void GenericProfiler::beginProfilingImpl(shared_qobject_ptr<projt::launch::LaunchPipeline> process) +{ + emit readyToLaunch(tr("Started process: %1").arg(process->pid())); +} + +BaseExternalTool* GenericProfilerFactory::createTool(InstancePtr instance, QObject* parent) +{ + return new GenericProfiler(globalSettings, instance, parent); +} +#include "GenericProfiler.moc" diff --git a/archived/projt-launcher/launcher/tools/GenericProfiler.h b/archived/projt-launcher/launcher/tools/GenericProfiler.h new file mode 100644 index 0000000000..bdcbbc9c0c --- /dev/null +++ b/archived/projt-launcher/launcher/tools/GenericProfiler.h @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * === Upstream License Block (Do Not Modify) ============================== + * + * + * + * Prism Launcher - Minecraft Launcher + * Copyright (c) 2023 Trial97 <alexandru.tripon97@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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + * + * + * ======================================================================== */ +#pragma once + +#include "BaseProfiler.h" + +class GenericProfilerFactory : public BaseProfilerFactory +{ + public: + QString name() const override + { + return "Generic"; + } + void registerSettings([[maybe_unused]] SettingsObjectPtr settings) override {}; + BaseExternalTool* createTool(InstancePtr instance, QObject* parent = 0) override; + bool check([[maybe_unused]] QString* error) override + { + return true; + }; + bool check([[maybe_unused]] const QString& path, [[maybe_unused]] QString* error) override + { + return true; + }; +}; diff --git a/archived/projt-launcher/launcher/tools/JProfiler.cpp b/archived/projt-launcher/launcher/tools/JProfiler.cpp new file mode 100644 index 0000000000..0710037fdd --- /dev/null +++ b/archived/projt-launcher/launcher/tools/JProfiler.cpp @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "JProfiler.h" + +#include <QDir> + +#include "BaseInstance.h" +#include "launch/LaunchPipeline.hpp" +#include "settings/SettingsObject.h" + +class JProfiler : public BaseProfiler +{ + Q_OBJECT + public: + JProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent = 0); + + private slots: + void profilerStarted(); + void profilerFinished(int exit, QProcess::ExitStatus status); + + protected: + void beginProfilingImpl(shared_qobject_ptr<projt::launch::LaunchPipeline> process); + + private: + int listeningPort = 0; +}; + +JProfiler::JProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject* parent) + : BaseProfiler(settings, instance, parent) +{} + +void JProfiler::profilerStarted() +{ + emit readyToLaunch(tr("Listening on port: %1").arg(listeningPort)); +} + +void JProfiler::profilerFinished([[maybe_unused]] int exit, QProcess::ExitStatus status) +{ + if (status == QProcess::CrashExit) + { + emit abortLaunch(tr("Profiler aborted")); + } + if (m_profilerProcess) + { + m_profilerProcess->deleteLater(); + m_profilerProcess = 0; + } +} + +void JProfiler::beginProfilingImpl(shared_qobject_ptr<projt::launch::LaunchPipeline> process) +{ + listeningPort = globalSettings->get("JProfilerPort").toInt(); + QProcess* profiler = new QProcess(this); + QStringList profilerArgs = { "-d", QString::number(process->pid()), "--gui", "-p", QString::number(listeningPort) }; + auto basePath = globalSettings->get("JProfilerPath").toString(); + +#ifdef Q_OS_WIN + QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable.exe"); +#else + QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable"); +#endif + + profiler->setArguments(profilerArgs); + profiler->setProgram(profilerProgram); + + connect(profiler, &QProcess::started, this, &JProfiler::profilerStarted); + connect(profiler, &QProcess::finished, this, &JProfiler::profilerFinished); + + m_profilerProcess = profiler; + profiler->start(); +} + +void JProfilerFactory::registerSettings(SettingsObjectPtr settings) +{ + settings->registerSetting("JProfilerPath"); + settings->registerSetting("JProfilerPort", 42042); + globalSettings = settings; +} + +BaseExternalTool* JProfilerFactory::createTool(InstancePtr instance, QObject* parent) +{ + return new JProfiler(globalSettings, instance, parent); +} + +bool JProfilerFactory::check(QString* error) +{ + return check(globalSettings->get("JProfilerPath").toString(), error); +} + +bool JProfilerFactory::check(const QString& path, QString* error) +{ + if (path.isEmpty()) + { + *error = QObject::tr("Empty path"); + return false; + } + QDir dir(path); + if (!dir.exists()) + { + *error = QObject::tr("Path does not exist"); + return false; + } + if (!dir.exists("bin") || !(dir.exists("bin/jprofiler") || dir.exists("bin/jprofiler.exe")) + || !dir.exists("bin/agent.jar")) + { + *error = QObject::tr("Invalid JProfiler install"); + return false; + } + return true; +} + +#include "JProfiler.moc" diff --git a/archived/projt-launcher/launcher/tools/JProfiler.h b/archived/projt-launcher/launcher/tools/JProfiler.h new file mode 100644 index 0000000000..57f62e7ad5 --- /dev/null +++ b/archived/projt-launcher/launcher/tools/JProfiler.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#pragma once + +#include "BaseProfiler.h" + +class JProfilerFactory : public BaseProfilerFactory +{ + public: + QString name() const override + { + return "JProfiler"; + } + void registerSettings(SettingsObjectPtr settings) override; + BaseExternalTool* createTool(InstancePtr instance, QObject* parent = 0) override; + bool check(QString* error) override; + bool check(const QString& path, QString* error) override; +}; diff --git a/archived/projt-launcher/launcher/tools/JVisualVM.cpp b/archived/projt-launcher/launcher/tools/JVisualVM.cpp new file mode 100644 index 0000000000..33e872e60c --- /dev/null +++ b/archived/projt-launcher/launcher/tools/JVisualVM.cpp @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "JVisualVM.h" + +#include <QDir> +#include <QStandardPaths> + +#include "BaseInstance.h" +#include "launch/LaunchPipeline.hpp" +#include "settings/SettingsObject.h" + +class JVisualVM : public BaseProfiler +{ + Q_OBJECT + public: + JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject* parent = 0); + + private slots: + void profilerStarted(); + void profilerFinished(int exit, QProcess::ExitStatus status); + + protected: + void beginProfilingImpl(shared_qobject_ptr<projt::launch::LaunchPipeline> process); +}; + +JVisualVM::JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject* parent) + : BaseProfiler(settings, instance, parent) +{} + +void JVisualVM::profilerStarted() +{ + emit readyToLaunch(tr("VisualVM started")); +} + +void JVisualVM::profilerFinished([[maybe_unused]] int exit, QProcess::ExitStatus status) +{ + if (status == QProcess::CrashExit) + { + emit abortLaunch(tr("Profiler aborted")); + } + if (m_profilerProcess) + { + m_profilerProcess->deleteLater(); + m_profilerProcess = 0; + } +} + +void JVisualVM::beginProfilingImpl(shared_qobject_ptr<projt::launch::LaunchPipeline> process) +{ + QProcess* profiler = new QProcess(this); + QStringList profilerArgs = { "--openpid", QString::number(process->pid()) }; + auto programPath = globalSettings->get("JVisualVMPath").toString(); + + profiler->setArguments(profilerArgs); + profiler->setProgram(programPath); + + connect(profiler, &QProcess::started, this, &JVisualVM::profilerStarted); + connect(profiler, &QProcess::finished, this, &JVisualVM::profilerFinished); + + profiler->start(); + m_profilerProcess = profiler; +} + +void JVisualVMFactory::registerSettings(SettingsObjectPtr settings) +{ + QString defaultValue = QStandardPaths::findExecutable("jvisualvm"); + if (defaultValue.isNull()) + { + defaultValue = QStandardPaths::findExecutable("visualvm"); + } + settings->registerSetting("JVisualVMPath", defaultValue); + globalSettings = settings; +} + +BaseExternalTool* JVisualVMFactory::createTool(InstancePtr instance, QObject* parent) +{ + return new JVisualVM(globalSettings, instance, parent); +} + +bool JVisualVMFactory::check(QString* error) +{ + return check(globalSettings->get("JVisualVMPath").toString(), error); +} + +bool JVisualVMFactory::check(const QString& path, QString* error) +{ + if (path.isEmpty()) + { + *error = QObject::tr("Empty path"); + return false; + } + QFileInfo finfo(path); + if (!finfo.isExecutable() || !finfo.fileName().contains("visualvm")) + { + *error = QObject::tr("Invalid path to VisualVM"); + return false; + } + return true; +} + +#include "JVisualVM.moc" diff --git a/archived/projt-launcher/launcher/tools/JVisualVM.h b/archived/projt-launcher/launcher/tools/JVisualVM.h new file mode 100644 index 0000000000..ab65c76843 --- /dev/null +++ b/archived/projt-launcher/launcher/tools/JVisualVM.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#pragma once + +#include "BaseProfiler.h" + +class JVisualVMFactory : public BaseProfilerFactory +{ + public: + QString name() const override + { + return "VisualVM"; + } + void registerSettings(SettingsObjectPtr settings) override; + BaseExternalTool* createTool(InstancePtr instance, QObject* parent = 0) override; + bool check(QString* error) override; + bool check(const QString& path, QString* error) override; +}; diff --git a/archived/projt-launcher/launcher/tools/MCEditTool.cpp b/archived/projt-launcher/launcher/tools/MCEditTool.cpp new file mode 100644 index 0000000000..ae8062371b --- /dev/null +++ b/archived/projt-launcher/launcher/tools/MCEditTool.cpp @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "MCEditTool.h" + +#include <QDir> +#include <QProcess> +#include <QUrl> + +#include "BaseInstance.h" +#include "minecraft/MinecraftInstance.h" +#include "settings/SettingsObject.h" + +MCEditTool::MCEditTool(SettingsObjectPtr settings) +{ + settings->registerSetting("MCEditPath"); + m_settings = settings; +} + +void MCEditTool::setPath(QString& path) +{ + m_settings->set("MCEditPath", path); +} + +QString MCEditTool::path() const +{ + return m_settings->get("MCEditPath").toString(); +} + +bool MCEditTool::check(const QString& toolPath, QString& error) +{ + if (toolPath.isEmpty()) + { + error = QObject::tr("Path is empty"); + return false; + } + const QDir dir(toolPath); + if (!dir.exists()) + { + error = QObject::tr("Path does not exist"); + return false; + } + if (!dir.exists("mcedit.sh") && !dir.exists("mcedit.py") && !dir.exists("mcedit.exe") && !dir.exists("Contents") + && !dir.exists("mcedit2.exe")) + { + error = QObject::tr("Path does not seem to be a MCEdit path"); + return false; + } + return true; +} + +QString MCEditTool::getProgramPath() +{ +#ifdef Q_OS_MACOS + return path(); +#else + const QString mceditPath = path(); + QDir mceditDir(mceditPath); +#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) + if (mceditDir.exists("mcedit.sh")) + { + return mceditDir.absoluteFilePath("mcedit.sh"); + } + else if (mceditDir.exists("mcedit.py")) + { + return mceditDir.absoluteFilePath("mcedit.py"); + } + return QString(); +#elif defined(Q_OS_WIN32) + if (mceditDir.exists("mcedit.exe")) + { + return mceditDir.absoluteFilePath("mcedit.exe"); + } + else if (mceditDir.exists("mcedit2.exe")) + { + return mceditDir.absoluteFilePath("mcedit2.exe"); + } + return QString(); +#endif +#endif +} diff --git a/archived/projt-launcher/launcher/tools/MCEditTool.h b/archived/projt-launcher/launcher/tools/MCEditTool.h new file mode 100644 index 0000000000..58549bce84 --- /dev/null +++ b/archived/projt-launcher/launcher/tools/MCEditTool.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team +/* + * ProjT Launcher - Minecraft Launcher + * Copyright (C) 2026 Project Tick + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#pragma once + +#include <QString> +#include "settings/SettingsObject.h" + +class MCEditTool +{ + public: + MCEditTool(SettingsObjectPtr settings); + void setPath(QString& path); + QString path() const; + bool check(const QString& toolPath, QString& error); + QString getProgramPath(); + + private: + SettingsObjectPtr m_settings; +}; |
