summaryrefslogtreecommitdiffstats
path: root/application/pages
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-07-09 02:37:04 +0200
committerPetr Mrázek <peterix@gmail.com>2019-07-09 02:37:04 +0200
commit497d9bec029247f202befb34cc3d5da6e810fa73 (patch)
treebb09f943d3ecca1c2954b9af901d8f117a30237c /application/pages
parentc01d020afc044e50ec3af0799572b42fa96f28fc (diff)
downloadMultiMC-497d9bec029247f202befb34cc3d5da6e810fa73.tar
MultiMC-497d9bec029247f202befb34cc3d5da6e810fa73.tar.gz
MultiMC-497d9bec029247f202befb34cc3d5da6e810fa73.tar.lz
MultiMC-497d9bec029247f202befb34cc3d5da6e810fa73.tar.xz
MultiMC-497d9bec029247f202befb34cc3d5da6e810fa73.zip
NOISSUE simple/stupid default game options, UI only
Diffstat (limited to 'application/pages')
-rw-r--r--application/pages/global/DefaultGameOptionsPage.cpp110
-rw-r--r--application/pages/global/DefaultGameOptionsPage.h73
-rw-r--r--application/pages/global/DefaultGameOptionsPage.ui96
3 files changed, 279 insertions, 0 deletions
diff --git a/application/pages/global/DefaultGameOptionsPage.cpp b/application/pages/global/DefaultGameOptionsPage.cpp
new file mode 100644
index 00000000..ce97907f
--- /dev/null
+++ b/application/pages/global/DefaultGameOptionsPage.cpp
@@ -0,0 +1,110 @@
+#include "DefaultGameOptionsPage.h"
+#include "ui_DefaultGameOptionsPage.h"
+#include "minecraft/MinecraftInstance.h"
+#include "minecraft/gameoptions/GameOptions.h"
+#include <QTabBar>
+#include "MultiMC.h"
+namespace {
+enum Mode {
+ NoDefault = 0,
+ NoAutojump = 1,
+ Fulltext = 2
+};
+}
+
+DefaultGameOptionsPage::DefaultGameOptionsPage(QWidget* parent) : QWidget(parent), ui(new Ui::DefaultGameOptionsPage)
+{
+ ui->setupUi(this);
+ ui->tabWidget->tabBar()->hide();
+ ui->defaultOptionsMode->setId(ui->radioDisabled, NoDefault);
+ ui->defaultOptionsMode->setId(ui->radioNoAutojump, NoAutojump);
+ ui->defaultOptionsMode->setId(ui->radioFullText, Fulltext);
+ loadSettings();
+ updateEnabledWidgets();
+ connect(ui->defaultOptionsMode, SIGNAL(buttonClicked(int)), SLOT(radioChanged(int)));
+}
+
+bool DefaultGameOptionsPage::apply()
+{
+ applySettings();
+ return true;
+}
+
+void DefaultGameOptionsPage::updateEnabledWidgets()
+{
+ auto id = ui->defaultOptionsMode->checkedId();
+ switch(id) {
+ case NoDefault:
+ default:
+ case NoAutojump: {
+ ui->textEdit->setEnabled(false);
+ break;
+ }
+ case Fulltext: {
+ ui->textEdit->setEnabled(true);
+ break;
+ }
+ }
+}
+
+void DefaultGameOptionsPage::radioChanged(int)
+{
+ updateEnabledWidgets();
+}
+
+
+void DefaultGameOptionsPage::applySettings()
+{
+ auto s = MMC->settings();
+
+ auto id = ui->defaultOptionsMode->checkedId();
+ switch(id) {
+ case NoDefault: {
+ s->set("DefaultOptionsMode", "NoDefault");
+ break;
+ }
+ default:
+ case NoAutojump: {
+ s->set("DefaultOptionsMode", "NoAutojump");
+ break;
+ }
+ case Fulltext: {
+ s->set("DefaultOptionsMode", "Fulltext");
+ break;
+ }
+ }
+
+ s->set("DefaultOptionsText", ui->textEdit->toPlainText());
+}
+
+void DefaultGameOptionsPage::loadSettings()
+{
+ auto s = MMC->settings();
+ auto modeStr = s->get("DefaultOptionsMode").toString();
+ if(modeStr == "NoDefault") {
+ ui->radioDisabled->setChecked(true);
+ } else if(modeStr == "Fulltext") {
+ ui->radioFullText->setChecked(true);
+ } else {
+ ui->radioNoAutojump->setChecked(true);
+ }
+ ui->textEdit->setText(s->get("DefaultOptionsText").toString());
+}
+
+
+DefaultGameOptionsPage::~DefaultGameOptionsPage()
+{
+ delete ui;
+}
+
+void DefaultGameOptionsPage::openedImpl()
+{
+}
+
+void DefaultGameOptionsPage::closedImpl()
+{
+}
+
+#include "DefaultGameOptionsPage.moc"
+
+
diff --git a/application/pages/global/DefaultGameOptionsPage.h b/application/pages/global/DefaultGameOptionsPage.h
new file mode 100644
index 00000000..d6142c34
--- /dev/null
+++ b/application/pages/global/DefaultGameOptionsPage.h
@@ -0,0 +1,73 @@
+/* Copyright 2013-2019 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 <QWidget>
+#include <QString>
+
+#include "pages/BasePage.h"
+#include <MultiMC.h>
+
+namespace Ui
+{
+class DefaultGameOptionsPage;
+}
+
+class GameOptions;
+class MinecraftInstance;
+
+class DefaultGameOptionsPage : public QWidget, public BasePage
+{
+ Q_OBJECT
+
+public:
+ explicit DefaultGameOptionsPage(QWidget *parent = 0);
+ virtual ~DefaultGameOptionsPage();
+
+ void openedImpl() override;
+ void closedImpl() override;
+
+ virtual QString displayName() const override
+ {
+ return tr("Game Options");
+ }
+ virtual QIcon icon() const override
+ {
+ return MMC->getThemedIcon("settings");
+ }
+ virtual QString id() const override
+ {
+ return "defaultgameoptions";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Default-Game-Options";
+ }
+
+ bool apply() override;
+
+private:
+ void applySettings();
+ void loadSettings();
+ void updateEnabledWidgets();
+
+private slots:
+ void radioChanged(int);
+
+private: // data
+ Ui::DefaultGameOptionsPage *ui = nullptr;
+};
+
diff --git a/application/pages/global/DefaultGameOptionsPage.ui b/application/pages/global/DefaultGameOptionsPage.ui
new file mode 100644
index 00000000..2ccde7ce
--- /dev/null
+++ b/application/pages/global/DefaultGameOptionsPage.ui
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DefaultGameOptionsPage</class>
+ <widget class="QWidget" name="DefaultGameOptionsPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>706</width>
+ <height>575</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <attribute name="title">
+ <string notr="true">Tab 1</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="0">
+ <widget class="QRadioButton" name="radioDisabled">
+ <property name="text">
+ <string>No Default</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">defaultOptionsMode</string>
+ </attribute>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QRadioButton" name="radioNoAutojump">
+ <property name="text">
+ <string>No Autojump</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">defaultOptionsMode</string>
+ </attribute>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QRadioButton" name="radioFullText">
+ <property name="text">
+ <string>Full Text</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">defaultOptionsMode</string>
+ </attribute>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="3">
+ <widget class="QTextEdit" name="textEdit"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>tabWidget</tabstop>
+ <tabstop>radioDisabled</tabstop>
+ <tabstop>radioNoAutojump</tabstop>
+ <tabstop>radioFullText</tabstop>
+ <tabstop>textEdit</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+ <buttongroups>
+ <buttongroup name="defaultOptionsMode"/>
+ </buttongroups>
+</ui>