From 7789ba86088f3fb5c6f9f4680e829ac9834e4400 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 19 Sep 2025 09:03:34 +0100 Subject: [PATCH 1/2] Remove unused code GameOptions.{h,cpp}, GameOptionsPage.{h,cpp}, ThemeWizardPage.cpp Signed-off-by: TheKodeToad --- launcher/CMakeLists.txt | 6 - .../minecraft/gameoptions/GameOptions.cpp | 124 ------------------ launcher/minecraft/gameoptions/GameOptions.h | 32 ----- .../ui/pages/instance/GameOptionsPage.cpp | 74 ----------- launcher/ui/pages/instance/GameOptionsPage.h | 70 ---------- launcher/ui/pages/instance/GameOptionsPage.ui | 88 ------------- launcher/ui/setupwizard/ThemeWizardPage.cpp | 39 ------ 7 files changed, 433 deletions(-) delete mode 100644 launcher/minecraft/gameoptions/GameOptions.cpp delete mode 100644 launcher/minecraft/gameoptions/GameOptions.h delete mode 100644 launcher/ui/pages/instance/GameOptionsPage.cpp delete mode 100644 launcher/ui/pages/instance/GameOptionsPage.h delete mode 100644 launcher/ui/pages/instance/GameOptionsPage.ui delete mode 100644 launcher/ui/setupwizard/ThemeWizardPage.cpp diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 23b2fbfad..9bbf2f7ca 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -252,9 +252,6 @@ set(MINECRAFT_SOURCES minecraft/auth/steps/XboxUserStep.cpp minecraft/auth/steps/XboxUserStep.h - minecraft/gameoptions/GameOptions.h - minecraft/gameoptions/GameOptions.cpp - minecraft/update/AssetUpdateTask.h minecraft/update/AssetUpdateTask.cpp minecraft/update/FMLLibrariesTask.cpp @@ -915,8 +912,6 @@ SET(LAUNCHER_SOURCES # GUI - instance pages ui/pages/instance/ExternalResourcesPage.cpp ui/pages/instance/ExternalResourcesPage.h - ui/pages/instance/GameOptionsPage.cpp - ui/pages/instance/GameOptionsPage.h ui/pages/instance/VersionPage.cpp ui/pages/instance/VersionPage.h ui/pages/instance/ManagedPackPage.cpp @@ -1210,7 +1205,6 @@ qt_wrap_ui(LAUNCHER_UI ui/pages/instance/NotesPage.ui ui/pages/instance/LogPage.ui ui/pages/instance/ServersPage.ui - ui/pages/instance/GameOptionsPage.ui ui/pages/instance/OtherLogsPage.ui ui/pages/instance/VersionPage.ui ui/pages/instance/ManagedPackPage.ui diff --git a/launcher/minecraft/gameoptions/GameOptions.cpp b/launcher/minecraft/gameoptions/GameOptions.cpp deleted file mode 100644 index 25f7074ec..000000000 --- a/launcher/minecraft/gameoptions/GameOptions.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "GameOptions.h" -#include -#include -#include "FileSystem.h" - -namespace { -bool load(const QString& path, std::vector& contents, int& version) -{ - contents.clear(); - QFile file(path); - if (!file.open(QFile::ReadOnly)) { - qWarning() << "Failed to read options file."; - return false; - } - version = 0; - while (!file.atEnd()) { - auto line = file.readLine(); - if (line.endsWith('\n')) { - line.chop(1); - } - auto separatorIndex = line.indexOf(':'); - if (separatorIndex == -1) { - continue; - } - auto key = QString::fromUtf8(line.data(), separatorIndex); - auto value = QString::fromUtf8(line.data() + separatorIndex + 1, line.size() - 1 - separatorIndex); - qDebug() << "!!" << key << "!!"; - if (key == "version") { - version = value.toInt(); - continue; - } - contents.emplace_back(GameOptionItem{ key, value }); - } - qDebug() << "Loaded" << path << "with version:" << version; - return true; -} -bool save(const QString& path, std::vector& mapping, int version) -{ - QSaveFile out(path); - if (!out.open(QIODevice::WriteOnly)) { - return false; - } - if (version != 0) { - QString versionLine = QString("version:%1\n").arg(version); - out.write(versionLine.toUtf8()); - } - auto iter = mapping.begin(); - while (iter != mapping.end()) { - out.write(iter->key.toUtf8()); - out.write(":"); - out.write(iter->value.toUtf8()); - out.write("\n"); - iter++; - } - return out.commit(); -} -} // namespace - -GameOptions::GameOptions(const QString& path) : path(path) -{ - reload(); -} - -QVariant GameOptions::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) { - return QAbstractListModel::headerData(section, orientation, role); - } - switch (section) { - case 0: - return tr("Key"); - case 1: - return tr("Value"); - default: - return QVariant(); - } -} - -QVariant GameOptions::data(const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - int row = index.row(); - int column = index.column(); - - if (row < 0 || row >= int(contents.size())) - return QVariant(); - - if (role == Qt::DisplayRole) { - if (column == 0) - return contents[row].key; - return contents[row].value; - } - return QVariant(); -} - -int GameOptions::rowCount(const QModelIndex&) const -{ - return static_cast(contents.size()); -} - -int GameOptions::columnCount(const QModelIndex&) const -{ - return 2; -} - -bool GameOptions::isLoaded() const -{ - return loaded; -} - -bool GameOptions::reload() -{ - beginResetModel(); - loaded = load(path, contents, version); - endResetModel(); - return loaded; -} - -bool GameOptions::save() -{ - return ::save(path, contents, version); -} diff --git a/launcher/minecraft/gameoptions/GameOptions.h b/launcher/minecraft/gameoptions/GameOptions.h deleted file mode 100644 index ae031efb2..000000000 --- a/launcher/minecraft/gameoptions/GameOptions.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include -#include -#include - -struct GameOptionItem { - QString key; - QString value; -}; - -class GameOptions : public QAbstractListModel { - Q_OBJECT - public: - explicit GameOptions(const QString& path); - virtual ~GameOptions() = default; - - int rowCount(const QModelIndex& parent = QModelIndex()) const override; - int columnCount(const QModelIndex& parent) const override; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - - bool isLoaded() const; - bool reload(); - bool save(); - - private: - std::vector contents; - bool loaded = false; - QString path; - int version = 0; -}; diff --git a/launcher/ui/pages/instance/GameOptionsPage.cpp b/launcher/ui/pages/instance/GameOptionsPage.cpp deleted file mode 100644 index 8db392b1d..000000000 --- a/launcher/ui/pages/instance/GameOptionsPage.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -/* - * Prism Launcher - Minecraft Launcher - * Copyright (c) 2022 Jamie Mansfield - * - * 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 . - * - * This file incorporates work covered by the following copyright and - * permission notice: - * - * Copyright 2013-2021 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "GameOptionsPage.h" -#include "minecraft/MinecraftInstance.h" -#include "minecraft/gameoptions/GameOptions.h" -#include "ui_GameOptionsPage.h" - -GameOptionsPage::GameOptionsPage(MinecraftInstance* inst, QWidget* parent) : QWidget(parent), ui(new Ui::GameOptionsPage) -{ - ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); - m_model = inst->gameOptionsModel(); - ui->optionsView->setModel(m_model.get()); - auto head = ui->optionsView->header(); - if (head->count()) { - head->setSectionResizeMode(0, QHeaderView::ResizeToContents); - for (int i = 1; i < head->count(); i++) { - head->setSectionResizeMode(i, QHeaderView::Stretch); - } - } -} - -GameOptionsPage::~GameOptionsPage() -{ - // m_model->save(); -} - -void GameOptionsPage::openedImpl() -{ - // m_model->observe(); -} - -void GameOptionsPage::closedImpl() -{ - // m_model->unobserve(); -} - -void GameOptionsPage::retranslate() -{ - ui->retranslateUi(this); -} diff --git a/launcher/ui/pages/instance/GameOptionsPage.h b/launcher/ui/pages/instance/GameOptionsPage.h deleted file mode 100644 index a132843e7..000000000 --- a/launcher/ui/pages/instance/GameOptionsPage.h +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -/* - * Prism Launcher - Minecraft Launcher - * Copyright (c) 2022 Jamie Mansfield - * - * 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 . - * - * This file incorporates work covered by the following copyright and - * permission notice: - * - * Copyright 2013-2021 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -#include -#include "ui/pages/BasePage.h" - -namespace Ui { -class GameOptionsPage; -} - -class GameOptions; -class MinecraftInstance; - -class GameOptionsPage : public QWidget, public BasePage { - Q_OBJECT - - public: - explicit GameOptionsPage(MinecraftInstance* inst, QWidget* parent = 0); - virtual ~GameOptionsPage(); - - void openedImpl() override; - void closedImpl() override; - - virtual QString displayName() const override { return tr("Game Options"); } - virtual QIcon icon() const override { return APPLICATION->getThemedIcon("settings"); } - virtual QString id() const override { return "gameoptions"; } - virtual QString helpPage() const override { return "Game-Options-management"; } - void retranslate() override; - - private: // data - Ui::GameOptionsPage* ui = nullptr; - std::shared_ptr m_model; -}; diff --git a/launcher/ui/pages/instance/GameOptionsPage.ui b/launcher/ui/pages/instance/GameOptionsPage.ui deleted file mode 100644 index f0a5ce0ee..000000000 --- a/launcher/ui/pages/instance/GameOptionsPage.ui +++ /dev/null @@ -1,88 +0,0 @@ - - - GameOptionsPage - - - - 0 - 0 - 706 - 575 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - - 0 - 0 - - - - Tab 1 - - - - - - - 0 - 0 - - - - true - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - - 64 - 64 - - - - false - - - false - - - - - - - - - - - tabWidget - optionsView - - - - diff --git a/launcher/ui/setupwizard/ThemeWizardPage.cpp b/launcher/ui/setupwizard/ThemeWizardPage.cpp deleted file mode 100644 index c97037f9f..000000000 --- a/launcher/ui/setupwizard/ThemeWizardPage.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -/* - * Prism Launcher - Minecraft Launcher - * Copyright (C) 2022 Tayou - * - * 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 . - */ -#include "ThemeWizardPage.h" -#include "ui_ThemeWizardPage.h" - -#include "Application.h" -#include "ui/themes/ITheme.h" -#include "ui/themes/ThemeManager.h" -#include "ui/widgets/ThemeCustomizationWidget.h" -#include "ui_ThemeCustomizationWidget.h" - -ThemeWizardPage::ThemeWizardPage(QWidget* parent) : BaseWizardPage(parent), ui(new Ui::ThemeWizardPage) -{ - ui->setupUi(this); - - connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentIconThemeChanged, this, &ThemeWizardPage::updateIcons); - connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentCatChanged, this, &ThemeWizardPage::updateCat); - - updateIcons(); - updateCat(); -} -{ - ui->retranslateUi(this); -} From 49b238f384bdfdccf23f7b3fa3b072ef517a572e Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 19 Sep 2025 09:42:13 +0100 Subject: [PATCH 2/2] Properly remove gameoptions Signed-off-by: TheKodeToad --- launcher/InstancePageProvider.h | 1 - launcher/minecraft/MinecraftInstance.cpp | 9 --------- launcher/minecraft/MinecraftInstance.h | 3 --- 3 files changed, 13 deletions(-) diff --git a/launcher/InstancePageProvider.h b/launcher/InstancePageProvider.h index 258ed5aa5..ebbab0f3a 100644 --- a/launcher/InstancePageProvider.h +++ b/launcher/InstancePageProvider.h @@ -43,7 +43,6 @@ class InstancePageProvider : protected QObject, public BasePageProvider { values.append(new NotesPage(onesix.get())); values.append(new WorldListPage(onesix, onesix->worldList())); values.append(new ServersPage(onesix)); - // values.append(new GameOptionsPage(onesix.get())); values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots"))); values.append(new InstanceSettingsPage(onesix)); values.append(new OtherLogsPage("logs", tr("Other logs"), "Other-Logs", inst)); diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 7749d0f6b..403aeb4bb 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -85,7 +85,6 @@ #include "AssetsUtils.h" #include "MinecraftLoadAndCheck.h" #include "PackProfile.h" -#include "minecraft/gameoptions/GameOptions.h" #include "minecraft/update/FoldersTask.h" #include "tools/BaseProfiler.h" @@ -1287,14 +1286,6 @@ std::shared_ptr MinecraftInstance::worldList() return m_world_list; } -std::shared_ptr MinecraftInstance::gameOptionsModel() -{ - if (!m_game_options) { - m_game_options.reset(new GameOptions(FS::PathCombine(gameRoot(), "options.txt"))); - } - return m_game_options; -} - QList MinecraftInstance::getJarMods() const { auto profile = m_components->getProfile(); diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index a37164169..d4e0a8626 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -49,7 +49,6 @@ class ResourcePackFolderModel; class ShaderPackFolderModel; class TexturePackFolderModel; class WorldList; -class GameOptions; class LaunchStep; class PackProfile; @@ -121,7 +120,6 @@ class MinecraftInstance : public BaseInstance { std::shared_ptr dataPackList(); QList> resourceLists(); std::shared_ptr worldList(); - std::shared_ptr gameOptionsModel(); ////// Launch stuff ////// QList createUpdateTask() override; @@ -171,7 +169,6 @@ class MinecraftInstance : public BaseInstance { mutable std::shared_ptr m_texture_pack_list; mutable std::shared_ptr m_data_pack_list; mutable std::shared_ptr m_world_list; - mutable std::shared_ptr m_game_options; }; using MinecraftInstancePtr = std::shared_ptr;