Implement custom widgets for edit delegate, always show edit delegate

Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
Tayou 2023-04-18 20:02:15 +02:00 committed by Tayou
parent 81435ee082
commit 3949f52f1d
No known key found for this signature in database
GPG Key ID: 02CA43C1CB6E9887
30 changed files with 1380 additions and 452 deletions

View File

@ -1015,6 +1015,21 @@ SET(LAUNCHER_SOURCES
ui/widgets/WideBar.cpp
ui/widgets/ThemeCustomizationWidget.h
ui/widgets/ThemeCustomizationWidget.cpp
ui/widgets/GameOptionWidget.h
ui/widgets/GameOptionWidgetSlider.h
ui/widgets/GameOptionWidgetSlider.cpp
ui/widgets/GameOptionWidgetComboBox.h
ui/widgets/GameOptionWidgetComboBox.cpp
ui/widgets/GameOptionWidgetCheckBox.h
ui/widgets/GameOptionWidgetCheckBox.cpp
ui/widgets/GameOptionWidgetSpinnerFloat.h
ui/widgets/GameOptionWidgetSpinnerFloat.cpp
ui/widgets/GameOptionWidgetSpinnerInt.h
ui/widgets/GameOptionWidgetSpinnerInt.cpp
ui/widgets/GameOptionWidgetText.h
ui/widgets/GameOptionWidgetText.cpp
ui/widgets/GameOptionWidgetKeyBind.h
ui/widgets/GameOptionWidgetKeyBind.cpp
# GUI - instance group view
ui/instanceview/InstanceProxyModel.cpp
@ -1068,6 +1083,13 @@ qt_wrap_ui(LAUNCHER_UI
ui/widgets/ModFilterWidget.ui
ui/widgets/SubTaskProgressBar.ui
ui/widgets/ThemeCustomizationWidget.ui
ui/widgets/GameOptionWidgetSlider.ui
ui/widgets/GameOptionWidgetComboBox.ui
ui/widgets/GameOptionWidgetCheckBox.ui
ui/widgets/GameOptionWidgetSpinnerFloat.ui
ui/widgets/GameOptionWidgetSpinnerInt.ui
ui/widgets/GameOptionWidgetText.ui
ui/widgets/GameOptionWidgetKeyBind.ui
ui/dialogs/CopyInstanceDialog.ui
ui/dialogs/ProfileSetupDialog.ui
ui/dialogs/ProgressDialog.ui

View File

@ -16,184 +16,82 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "GameOptionDelegate.h"
#include "ui/widgets/GameOptionWidget.h"
#include "ui/widgets/GameOptionWidgetCheckBox.h"
#include "ui/widgets/GameOptionWidgetComboBox.h"
#include "ui/widgets/GameOptionWidgetKeyBind.h"
#include "ui/widgets/GameOptionWidgetSlider.h"
#include "ui/widgets/GameOptionWidgetSpinnerFloat.h"
#include "ui/widgets/GameOptionWidgetSpinnerInt.h"
#include "ui/widgets/GameOptionWidgetText.h"
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox>
#include <QPushButton>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QSlider>
#include <QKeySequenceEdit>
#include <QDebug>
QWidget* GameOptionDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const {
std::shared_ptr<GameOption> knownOption = contents->at(index.row()).knownOption;
switch (contents->at(index.row()).type) {
case OptionType::String: {
if (knownOption != nullptr && !knownOption->validValues.isEmpty()) {
QComboBox* comboBox = new QComboBox(parent);
for (auto value : knownOption->validValues) {
comboBox->addItem(value);
}
comboBox->setGeometry(option.rect);
return comboBox;
} else {
QLineEdit* textField = new QLineEdit(parent);
textField->setGeometry(option.rect);
return textField;
}
}
case OptionType::Int: {
if (knownOption != nullptr && (knownOption->getIntRange().max != 0 || knownOption->getIntRange().min != 0)) {
QSlider* slider = new QSlider(parent);
slider->setMinimum(knownOption->getIntRange().min);
slider->setMaximum(knownOption->getIntRange().max);
slider->setOrientation(Qt::Horizontal);
slider->setGeometry(option.rect);
return slider;
} else {
QSpinBox* intInput = new QSpinBox(parent);
intInput->setGeometry(option.rect);
return intInput;
}
}
case OptionType::Bool: {
QCheckBox* checkBox = new QCheckBox(parent);
checkBox->setGeometry(option.rect);
return checkBox;
}
case OptionType::Float: {
if (knownOption != nullptr && (knownOption->getFloatRange().max != 0 || knownOption->getFloatRange().min != 0)) {
QSlider* slider = new QSlider(parent);
slider->setMinimum(knownOption->getFloatRange().min*100);
slider->setMaximum(knownOption->getFloatRange().max*100);
slider->setOrientation(Qt::Horizontal);
slider->setGeometry(option.rect);
return slider;
} else {
QDoubleSpinBox* floatInput = new QDoubleSpinBox(parent);
floatInput->setGeometry(option.rect);
return floatInput;
}
}
case OptionType::KeyBind: {
QKeySequenceEdit* keySequenceEdit = new QKeySequenceEdit(parent);
keySequenceEdit->setGeometry(option.rect);
return keySequenceEdit;
}
default:
break;
}
};
void GameOptionDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
QWidget* GameOptionDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
std::shared_ptr<GameOption> knownOption = contents->at(index.row()).knownOption;
switch (contents->at(index.row()).type) {
case OptionType::String: {
QComboBox* comboBox;
if ((comboBox = dynamic_cast<QComboBox*>(editor)) != nullptr) {
comboBox->setCurrentIndex(comboBox->findText(contents->at(index.row()).value));
if (knownOption != nullptr && !knownOption->validValues.isEmpty()) {
return new GameOptionWidgetComboBox(parent, knownOption);
} else {
((QLineEdit*)editor)->setText(contents->at(index.row()).value);
return new GameOptionWidgetText(parent, knownOption);
}
return;
}
case OptionType::Int: {
QSlider* slider;
if ((slider = dynamic_cast<QSlider*>(editor)) != nullptr) {
slider->setValue(contents->at(index.row()).intValue);
if (knownOption != nullptr && (knownOption->getIntRange().max != 0 || knownOption->getIntRange().min != 0)) {
return new GameOptionWidgetSlider(parent, knownOption);
} else {
((QSpinBox*)editor)->setValue(contents->at(index.row()).intValue);
return new GameOptionWidgetSpinnerInt(parent, knownOption);
}
return;
}
case OptionType::Bool: {
((QCheckBox*)editor)->setText(contents->at(index.row()).value);
((QCheckBox*)editor)->setChecked(contents->at(index.row()).boolValue);
return;
return new GameOptionWidgetCheckBox(parent, knownOption);
}
case OptionType::Float: {
QSlider* slider;
if ((slider = dynamic_cast<QSlider*>(editor)) != nullptr) {
slider->setValue(contents->at(index.row()).floatValue*100);
if (knownOption != nullptr && (knownOption->getFloatRange().max != 0 || knownOption->getFloatRange().min != 0)) {
return new GameOptionWidgetSlider(parent, knownOption);
} else {
((QDoubleSpinBox*)editor)->setValue(contents->at(index.row()).floatValue);
return new GameOptionWidgetSpinnerFloat(parent, knownOption);
}
return;
}
case OptionType::KeyBind: {
// TODO: fall back to QLineEdit if keybind can't be represented, like some mods do (by using another key input API)
// TODO: mouse binding? If not possible, fall back as well maybe?
Qt::Key key;
for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->minecraftKeyCode == contents->at(index.row()).value) {
key = keyBinding->qtKeyCode.keyboardKey;
}
}
((QKeySequenceEdit*)editor)->setKeySequence(QKeySequence(key));
return;
return new GameOptionWidgetKeyBind(parent, knownOption);
}
default:
return;
return nullptr;
}
}
void GameOptionDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
GameOptionWidget* widget = dynamic_cast<GameOptionWidget*>(editor);
GameOptionItem optionItem = contents->at(index.row());
if (widget != nullptr) {
widget->setEditorData(optionItem);
} else {
qDebug() << "[GameOptions] Setting widget data failed because widget was still null";
}
};
void GameOptionDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const {
editor->setGeometry(option.rect);
void GameOptionDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
GameOptionWidget* widget = dynamic_cast<GameOptionWidget*>(editor);
widget->setSize(option.rect);
};
void GameOptionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const {
std::shared_ptr<GameOption> knownOption = contents->at(index.row()).knownOption;
switch (contents->at(index.row()).type) {
case OptionType::String: {
QComboBox* comboBox;
if ((comboBox = dynamic_cast<QComboBox*>(editor)) != nullptr) {
contents->at(index.row()).value = comboBox->currentText();
} else {
contents->at(index.row()).value = ((QLineEdit*)editor)->text();
}
return;
}
case OptionType::Int: {
QSlider* slider;
if ((slider = dynamic_cast<QSlider*>(editor)) != nullptr) {
contents->at(index.row()).intValue = slider->value();
} else {
contents->at(index.row()).intValue = ((QSpinBox*)editor)->value();
}
return;
}
case OptionType::Bool: {
((QCheckBox*)editor)->setText(contents->at(index.row()).value);
contents->at(index.row()).boolValue = ((QCheckBox*)editor)->isChecked();
return;
}
case OptionType::Float: {
QSlider* slider;
if ((slider = dynamic_cast<QSlider*>(editor)) != nullptr) {
contents->at(index.row()).floatValue = slider->value()/100.0f;
} else {
contents->at(index.row()).floatValue = ((QDoubleSpinBox*)editor)->value();
}
return;
}
case OptionType::KeyBind: {
QKeySequenceEdit* keySequenceEdit = (QKeySequenceEdit*)editor;
void GameOptionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
GameOptionWidget* widget = dynamic_cast<GameOptionWidget*>(editor);
QString minecraftKeyCode;
for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->qtKeyCode.keyboardKey == keySequenceEdit->keySequence()[0].key() ||
keyBinding->qtKeyCode.mouseButton == keySequenceEdit->keySequence()[0].key()) {
minecraftKeyCode = keyBinding->minecraftKeyCode;
}
}
contents->at(index.row()).value = minecraftKeyCode;
return;
}
default:
return;
GameOptionItem optionItem = contents->at(index.row());
if (widget != nullptr) {
widget->saveEditorData(optionItem);
} else {
qDebug() << "[GameOptions] Saving widget data to Model failed because widget was null";
}
};
}

View File

@ -38,6 +38,8 @@ class GameOptionDelegate : public QStyledItemDelegate {
const QModelIndex& index) const override;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
enum GameOptionWidgetType { slider, text, keybind, number, comboBox };
private:
std::vector<GameOptionItem>* contents;
QList<std::shared_ptr<KeyBindData>>* keybindingOptions;

View File

@ -98,12 +98,12 @@ bool load(const QString& path,
item.type = OptionType::Float;
// qDebug() << "The value" << value << "is a float";
} else if (item.value == "true" || item.value == "false") {
item.boolValue = item.value == "true" ? true : false;
item.boolValue = item.value == "true";
item.type = OptionType::Bool;
qDebug() << "The value" << item.value << "is a bool";
} else if (item.value.endsWith("]") && item.value.startsWith("[")) {
qDebug() << "The value" << item.value << "is an array";
for (QString part : item.value.mid(1, item.value.size() - 2).split(",")) {
for (const QString& part : item.value.mid(1, item.value.size() - 2).split(",")) {
GameOptionChildItem child{ part, static_cast<int>(contents.size()) };
qDebug() << "Array has entry" << part;
item.children.append(child);
@ -154,17 +154,15 @@ QVariant GameOptions::headerData(int section, Qt::Orientation orientation, int r
if (role != Qt::DisplayRole) {
return QAbstractItemModel::headerData(section, orientation, role);
}
switch (section) {
case 0:
return tr("Key");
case 1:
return tr("Description");
case 2:
return tr("Value");
case 3:
return tr("Default Value");
switch ((Column)section) {
default:
return QVariant();
case Column::Key:
return tr("Key");
case Column::Description:
return tr("Description");
case Column::Value:
return tr("Value");
}
}
bool GameOptions::setData(const QModelIndex& index, const QVariant& value, int role)
@ -175,16 +173,22 @@ bool GameOptions::setData(const QModelIndex& index, const QVariant& value, int r
switch (contents[row].type) {
case OptionType::String: {
contents[row].value = value.toString();
return true;
}
case OptionType::Int: {
contents[row].intValue = value.toInt();
return true;
}
case OptionType::Bool: {
contents[row].boolValue = value.toBool();
return true;
}
case OptionType::Float: {
contents[row].floatValue = value.toFloat();
return true;
}
case OptionType::KeyBind:
break;
}
}
@ -193,34 +197,7 @@ bool GameOptions::setData(const QModelIndex& index, const QVariant& value, int r
Qt::ItemFlags GameOptions::flags(const QModelIndex& index) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
if (!index.isValid())
return flags;
Column column = (Column)index.column();
if (column == Column::Key) {
return flags;
}
if (index.parent().isValid()) {
return flags;
}
if (contents[index.row()].children.count() > 0) {
return flags;
}
flags = flags | Qt::ItemFlag::ItemIsEditable;
/*if (column == Column::Value || column == Column::DefaultValue) {
flags = flags | Qt::ItemFlag::ItemIsUserCheckable;
}*/
if (column == Column::DefaultValue) {
flags = flags & ~Qt::ItemFlag::ItemIsEnabled;
}
return flags;
return QAbstractItemModel::flags(index);
}
QVariant GameOptions::data(const QModelIndex& index, int role) const
@ -263,90 +240,6 @@ QVariant GameOptions::data(const QModelIndex& index, int role) const
return QVariant();
}
}
case Column::Value: {
switch (contents[row].type) {
case OptionType::String: {
return contents[row].value;
}
case OptionType::Int: {
return contents[row].intValue;
}
case OptionType::Bool: {
return contents[row].boolValue;
}
case OptionType::Float: {
return contents[row].floatValue;
}
case OptionType::KeyBind: {
for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->minecraftKeyCode == contents[row].value) {
return keyBinding->displayName; // + " (" + contents[row].value + ")";
}
}
return contents[row].value;
}
default: {
return QVariant();
}
}
}
case Column::DefaultValue: {
if (contents[row].knownOption != nullptr) {
switch (contents[row].type) {
case OptionType::String: {
return contents[row].knownOption->getDefaultString();
}
case OptionType::Int: {
return contents[row].knownOption->getDefaultInt();
}
case OptionType::Bool: {
return contents[row].knownOption->getDefaultBool();
}
case OptionType::Float: {
return contents[row].knownOption->getDefaultFloat();
}
case OptionType::KeyBind: {
for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->minecraftKeyCode == contents[row].knownOption->getDefaultString()) {
return keyBinding->displayName; // + " (" + contents[row].knownOption->getDefaultString() + ")";
}
}
return contents[row].knownOption->getDefaultString();
}
default: {
return QVariant();
}
}
} else {
return QVariant();
}
}
default: {
return QVariant();
}
}
}
case Qt::CheckStateRole: {
switch (column) {
case Column::Value: {
if (contents[row].type == OptionType::Bool) {
return boolToState(contents[row].boolValue);
} else {
return QVariant();
}
}
case Column::DefaultValue: {
if (contents[row].knownOption != nullptr && contents[row].type == OptionType::Bool) {
// checkboxes are tristate, this 1(true) needs to be 2 for fully checked
return contents[row].knownOption->getDefaultBool() * 2;
} else {
return QVariant();
}
}
default: {
return QVariant();
}
@ -371,7 +264,7 @@ QModelIndex GameOptions::index(int row, int column, const QModelIndex& parent) c
GameOptionItem* item = static_cast<GameOptionItem*>(parent.internalPointer());
return createIndex(row, column, &item->children[row]);
} else {
return createIndex(row, column, &contents[row]);
return createIndex(row, column, reinterpret_cast<quintptr>(&contents[row]));
}
}
@ -388,7 +281,7 @@ QModelIndex GameOptions::parent(const QModelIndex& index) const
return QModelIndex();
} else {
GameOptionChildItem* child = static_cast<GameOptionChildItem*>(index.internalPointer());
return createIndex(child->parentRow, 0, &contents[child->parentRow]);
return createIndex(child->parentRow, 0, reinterpret_cast<quintptr>(&contents[child->parentRow]));
}
}
@ -417,7 +310,7 @@ int GameOptions::columnCount(const QModelIndex& parent) const
if (parent.parent().isValid())
return 0;
return 4;
return 3;
}
bool GameOptions::isLoaded() const

View File

@ -60,7 +60,7 @@ struct GameOptionItem {
class GameOptions : public QAbstractItemModel {
Q_OBJECT
public:
enum class Column { Key, Description, Value, DefaultValue };
enum class Column { Key, Description, Value };
explicit GameOptions(const QString& path);
virtual ~GameOptions() = default;
@ -86,6 +86,6 @@ class GameOptions : public QAbstractItemModel {
QString path;
int version = 0;
QMap<QString, std::shared_ptr<GameOption>>* knownOptions;
QList<std::shared_ptr<KeyBindData>>* keybindingOptions;
QMap<QString, std::shared_ptr<GameOption>>* knownOptions{};
QList<std::shared_ptr<KeyBindData>>* keybindingOptions{};
};

View File

@ -17,6 +17,7 @@
*/
#include "GameOptionsSchema.h"
#include <QObject>
#include <memory>
QMap<QString, std::shared_ptr<GameOption>> GameOptionsSchema::knownOptions;
QList<std::shared_ptr<KeyBindData>> GameOptionsSchema::keyboardButtons;
@ -46,154 +47,154 @@ void GameOptionsSchema::populateInternalOptionList()
// clang-format off
// data version
knownOptions["version"] = std::shared_ptr<GameOption>(new GameOption(0, "Data version of the client version this file was last saved in; used for upgrading default settings. (numeric)", true));
knownOptions["version"] = std::make_shared<GameOption>(0, "Data version of the client version this file was last saved in; used for upgrading default settings. (numeric)", true);
// general options
knownOptions["autoJump"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether auto-jump is enabled"));
knownOptions["autoSuggestions"] = std::shared_ptr<GameOption>(new GameOption(true, "True if brigadier's command suggestion UI should always be shown, instead of just when pressing tab"));
knownOptions["chatColors"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether colored chat is allowed"));
knownOptions["chatLinks"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether links show as links or just text in the chat"));
knownOptions["chatLinksPrompt"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether clicking on links in chat needs confirmation before opening them"));
knownOptions["enableVsync"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether v-sync (vertical synchronization) is enabled"));
knownOptions["entityShadows"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether to display entity shadows"));
knownOptions["forceUnicodeFont"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether Unicode font should be used"));
knownOptions["discrete_mouse_scroll"] = std::shared_ptr<GameOption>(new GameOption(false, "Ignores scrolling set by operating system"));
knownOptions["invertYMouse"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether mouse is inverted or not"));
knownOptions["realmsNotifications"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether Realms invites are alerted on the main menu"));
knownOptions["reducedDebugInfo"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether to show reduced information on the Debug screen"));
knownOptions["showSubtitles"] = std::shared_ptr<GameOption>(new GameOption(false, "If subtitles are shown"));
knownOptions["directionalAudio"] = std::shared_ptr<GameOption>(new GameOption(false, "If Directional Audio is enabled"));
knownOptions["touchscreen"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether touchscreen controls are used"));
knownOptions["fullscreen"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether the game attempts to go fullscreen at startup"));
knownOptions["bobView"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether or not the camera bobs up and down as the player walks"));
knownOptions["toggleCrouch"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether the sneak key must be pressed or held to activate sneaking"));
knownOptions["toggleSprint"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether the sprint key must be pressed or held to activate sprinting"));
knownOptions["darkMojangStudiosBackground"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether the Mojang Studios loading screen will appear monochrome"));
knownOptions["hideLightningFlashes"] = std::shared_ptr<GameOption>(new GameOption(false, "Hide lightning flashes (visual effect)"));
knownOptions["autoJump"] = std::make_shared<GameOption>(false, "Whether auto-jump is enabled");
knownOptions["autoSuggestions"] = std::make_shared<GameOption>(true, "True if brigadier's command suggestion UI should always be shown, instead of just when pressing tab");
knownOptions["chatColors"] = std::make_shared<GameOption>(true, "Whether colored chat is allowed");
knownOptions["chatLinks"] = std::make_shared<GameOption>(true, "Whether links show as links or just text in the chat");
knownOptions["chatLinksPrompt"] = std::make_shared<GameOption>(true, "Whether clicking on links in chat needs confirmation before opening them");
knownOptions["enableVsync"] = std::make_shared<GameOption>(true, "Whether v-sync (vertical synchronization) is enabled");
knownOptions["entityShadows"] = std::make_shared<GameOption>(true, "Whether to display entity shadows");
knownOptions["forceUnicodeFont"] = std::make_shared<GameOption>(false, "Whether Unicode font should be used");
knownOptions["discrete_mouse_scroll"] = std::make_shared<GameOption>(false, "Ignores scrolling set by operating system");
knownOptions["invertYMouse"] = std::make_shared<GameOption>(false, "Whether mouse is inverted or not");
knownOptions["realmsNotifications"] = std::make_shared<GameOption>(true, "Whether Realms invites are alerted on the main menu");
knownOptions["reducedDebugInfo"] = std::make_shared<GameOption>(false, "Whether to show reduced information on the Debug screen");
knownOptions["showSubtitles"] = std::make_shared<GameOption>(false, "If subtitles are shown");
knownOptions["directionalAudio"] = std::make_shared<GameOption>(false, "If Directional Audio is enabled");
knownOptions["touchscreen"] = std::make_shared<GameOption>(false, "Whether touchscreen controls are used");
knownOptions["fullscreen"] = std::make_shared<GameOption>(false, "Whether the game attempts to go fullscreen at startup");
knownOptions["bobView"] = std::make_shared<GameOption>(true, "Whether or not the camera bobs up and down as the player walks");
knownOptions["toggleCrouch"] = std::make_shared<GameOption>(false, "Whether the sneak key must be pressed or held to activate sneaking");
knownOptions["toggleSprint"] = std::make_shared<GameOption>(false, "Whether the sprint key must be pressed or held to activate sprinting");
knownOptions["darkMojangStudiosBackground"] = std::make_shared<GameOption>(false, "Whether the Mojang Studios loading screen will appear monochrome");
knownOptions["hideLightningFlashes"] = std::make_shared<GameOption>(false, "Hide lightning flashes (visual effect)");
knownOptions["mouseSensitivity"] = std::shared_ptr<GameOption>(new GameOption(0.5, "How much a mouse movement changes the position of the camera", Range<float>{ 0.0, 1.0 }));
knownOptions["mouseSensitivity"] = std::make_shared<GameOption>(0.5, "How much a mouse movement changes the position of the camera", Range<float>{ 0.0, 1.0 });
// FOV: The in-game value is counted in degrees, however, the options.txt isn't. The value is converted into degrees with the following formula: degrees = 40 * value + 70
knownOptions["fov"] = std::shared_ptr<GameOption>(new GameOption(0.0, "How large the field of view is", Range<float>{ -1.0, 1.0 }));
knownOptions["screenEffectScale"] = std::shared_ptr<GameOption>(new GameOption(1.0, "Distortion Effects (how intense the effects of Nausea and nether portals are)", Range<float>{ 0.0, 1.0 }));
knownOptions["fovEffectScale"] = std::shared_ptr<GameOption>(new GameOption(1.0, "FOV Effects (how much the field of view changes when sprinting, having Speed or Slowness etc.)", Range<float>{ 0.0, 1.0 }));
knownOptions["darknessEffectScale"] = std::shared_ptr<GameOption>(new GameOption(1.0, "Darkness Pulsing (how much the Darkness effect pulses)", Range<float>{ 0.0, 1.0 }));
knownOptions["gamma"] = std::shared_ptr<GameOption>(new GameOption(0.5, "Brightness", Range<float>{ 0.0, 1.0 }));
knownOptions["renderDistance"] = std::shared_ptr<GameOption>(new GameOption(12, "The render distance in the chunk radius from the player - Note: The Maximum and default in vanilla is 32 and 12, 16 and 8 on 32bit machines", Range<int>{ 2, 64 }));
knownOptions["simulationDistance"] = std::shared_ptr<GameOption>(new GameOption(12, "The simulation distance in the chunk radius from the player - Note: The Maximum and default in vanilla is 32 and 12, 16 and 8 on 32bit machines", Range<int>{ 5, 32 }));
knownOptions["entityDistanceScaling"] = std::shared_ptr<GameOption>(new GameOption(1.0, "The maximum distance from the player that entities render", Range<float>{ 0.5, 5.0 }));
knownOptions["guiScale"] = std::shared_ptr<GameOption>(new GameOption(0, "Size of interfaces - Note: 0 (Auto) or 1+ for size. Upper limit based on window resolution"));
knownOptions["particles"] = std::shared_ptr<GameOption>(new GameOption(0, "Amount of particles (such as rain, potion effects, etc.)", Range<int>{ 0, 2 }));
knownOptions["maxFps"] = std::shared_ptr<GameOption>(new GameOption(120, "The maximum framerate", Range<int>{ 10, 260 }));
knownOptions["difficulty"] = std::shared_ptr<GameOption>(new GameOption(2, "Has no effect after 1.7.2", Range<int>{ 0, 3 }));
knownOptions["graphicsMode"] = std::shared_ptr<GameOption>(new GameOption(1, "Whether Fast (less detailed), Fancy (more detailed), or Fabulous! (most detailed) graphics are turned on", Range<int>{ 0, 2 }));
knownOptions["ao"] = std::shared_ptr<GameOption>(new GameOption(true, "Smooth lighting (Ambient Occlusion)"));
knownOptions["prioritizeChunkUpdates"] = std::shared_ptr<GameOption>(new GameOption(0, "Chunk section update strategy", Range<int>{ 0, 2 }));
knownOptions["biomeBlendRadius"] = std::shared_ptr<GameOption>(new GameOption(2, "Radius for which biome blending should happen", Range<int>{ 0, 7 }));
knownOptions["renderClouds"] = std::shared_ptr<GameOption>(new GameOption("true", "Whether to display clouds", QStringList{ "true", "false", "fast" }));
knownOptions["fov"] = std::make_shared<GameOption>(0.0, "How large the field of view is", Range<float>{ -1.0, 1.0 });
knownOptions["screenEffectScale"] = std::make_shared<GameOption>(1.0, "Distortion Effects (how intense the effects of Nausea and nether portals are)", Range<float>{ 0.0, 1.0 });
knownOptions["fovEffectScale"] = std::make_shared<GameOption>(1.0, "FOV Effects (how much the field of view changes when sprinting, having Speed or Slowness etc.)", Range<float>{ 0.0, 1.0 });
knownOptions["darknessEffectScale"] = std::make_shared<GameOption>(1.0, "Darkness Pulsing (how much the Darkness effect pulses)", Range<float>{ 0.0, 1.0 });
knownOptions["gamma"] = std::make_shared<GameOption>(0.5, "Brightness", Range<float>{ 0.0, 1.0 });
knownOptions["renderDistance"] = std::make_shared<GameOption>(12, "The render distance in the chunk radius from the player - Note: The Maximum and default in vanilla is 32 and 12, 16 and 8 on 32bit machines", Range<int>{ 2, 64 });
knownOptions["simulationDistance"] = std::make_shared<GameOption>(12, "The simulation distance in the chunk radius from the player - Note: The Maximum and default in vanilla is 32 and 12, 16 and 8 on 32bit machines", Range<int>{ 5, 32 });
knownOptions["entityDistanceScaling"] = std::make_shared<GameOption>(1.0, "The maximum distance from the player that entities render", Range<float>{ 0.5, 5.0 });
knownOptions["guiScale"] = std::make_shared<GameOption>(0, "Size of interfaces - Note: 0 (Auto) or 1+ for size. Upper limit based on window resolution");
knownOptions["particles"] = std::make_shared<GameOption>(0, "Amount of particles (such as rain, potion effects, etc.)", Range<int>{ 0, 2 });
knownOptions["maxFps"] = std::make_shared<GameOption>(120, "The maximum framerate", Range<int>{ 10, 260 });
knownOptions["difficulty"] = std::make_shared<GameOption>(2, "Has no effect after 1.7.2", Range<int>{ 0, 3 });
knownOptions["graphicsMode"] = std::make_shared<GameOption>(1, "Whether Fast (less detailed), Fancy (more detailed), or Fabulous! (most detailed) graphics are turned on", Range<int>{ 0, 2 });
knownOptions["ao"] = std::make_shared<GameOption>(true, "Smooth lighting (Ambient Occlusion)");
knownOptions["prioritizeChunkUpdates"] = std::make_shared<GameOption>(0, "Chunk section update strategy", Range<int>{ 0, 2 });
knownOptions["biomeBlendRadius"] = std::make_shared<GameOption>(2, "Radius for which biome blending should happen", Range<int>{ 0, 7 });
knownOptions["renderClouds"] = std::make_shared<GameOption>("true", "Whether to display clouds", QStringList{ "true", "false", "fast" });
knownOptions["resourcePacks"] = std::shared_ptr<GameOption>(new GameOption("[]", "A list of active resource packs", QStringList(), false));
knownOptions["incompatibleResourcePacks"] = std::shared_ptr<GameOption>(new GameOption("[]", "A list of active resource packs that are marked as incompatible with the current Minecraft version.", QStringList(), false));
knownOptions["resourcePacks"] = std::make_shared<GameOption>("[]", "A list of active resource packs", QStringList(), false);
knownOptions["incompatibleResourcePacks"] = std::make_shared<GameOption>("[]", "A list of active resource packs that are marked as incompatible with the current Minecraft version.", QStringList(), false);
knownOptions["lastServer"] = std::shared_ptr<GameOption>(new GameOption("", "Address of last server used with Direct Connection"));
knownOptions["lang"] = std::shared_ptr<GameOption>(new GameOption("en_us", "Language to be used"));
knownOptions["soundDevice"] = std::shared_ptr<GameOption>(new GameOption("", "Sound device to be used"));
knownOptions["chatVisibility"] = std::shared_ptr<GameOption>(new GameOption(0, "What is seen in chat", Range<int>{ 0, 2 }));
knownOptions["chatOpacity"] = std::shared_ptr<GameOption>(new GameOption(1.0, "Opacity of the chat", Range<float>{ 0, 1 }));
knownOptions["chatLineSpacing"] = std::shared_ptr<GameOption>(new GameOption(0.0, "Spacing between text in chat", Range<float>{ 0, 1 }));
knownOptions["textBackgroundOpacity"] = std::shared_ptr<GameOption>(new GameOption(0.5, "Opacity of text background", Range<float>{ 0, 1 }));
knownOptions["backgroundForChatOnly"] = std::shared_ptr<GameOption>(new GameOption(true, "Toggles if the background is only in chat or if it's everywhere"));
knownOptions["hideServerAddress"] = std::shared_ptr<GameOption>(new GameOption(false, "Has no effect in modern versions"));
knownOptions["advancedItemTooltips"] = std::shared_ptr<GameOption>(new GameOption(false, "Whether hovering over items in the inventory shows its ID and durability; toggled by pressing F3+H"));
knownOptions["pauseOnLostFocus"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether switching out of Minecraft without pressing Esc or opening an in-game interface automatically pauses the game; toggled by pressing F3+P"));
knownOptions["overrideWidth"] = std::shared_ptr<GameOption>(new GameOption(0, "Width to open Minecraft with in pixels (0 means default to the Minecraft settings); no in-game control"));
knownOptions["overrideHeight"] = std::shared_ptr<GameOption>(new GameOption(0, "Height to open Minecraft with in pixels (0 means default to the Minecraft settings); no in-game control"));
knownOptions["heldItemTooltips"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether switching between items shows the name of the item; no in-game control"));
knownOptions["chatHeightFocused"] = std::shared_ptr<GameOption>(new GameOption(1.0, "How tall the chat span is", Range<float>{ 0, 1 }));
knownOptions["chatDelay"] = std::shared_ptr<GameOption>(new GameOption(0.0, "How much delay there is between text", Range<float>{ 0, 6 }));
knownOptions["chatHeightUnfocused"] = std::shared_ptr<GameOption>(new GameOption(0.4375, "How tall the maximum chat span is, when the chat button is not pressed", Range<float>{ 0, 1 }));
knownOptions["chatScale"] = std::shared_ptr<GameOption>(new GameOption(1.0, "The scale/size of the text in the chat", Range<float>{ 0, 1 }));
knownOptions["chatWidth"] = std::shared_ptr<GameOption>(new GameOption(1.0, "The span width of the chat", Range<float>{ 0, 1 }));
knownOptions["mipmapLevels"] = std::shared_ptr<GameOption>(new GameOption(4, "Amount by which distant textures are smoothed", Range<int>{0, 4}));
knownOptions["useNativeTransport"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether to use a Netty EpollSocketChannel for connections to servers instead of a NioSocketChannel (only applies if EPOLL is available on the user's system)"));
knownOptions["mainHand"] = std::shared_ptr<GameOption>(new GameOption("right", "Whether the main hand appears as left or right", QStringList{ "left", "right" }));
knownOptions["attackIndicator"] = std::shared_ptr<GameOption>(new GameOption(1, "When hitting, how the attack indicator is shown on screen", Range<int>{ 0, 2 }));
knownOptions["narrator"] = std::shared_ptr<GameOption>(new GameOption(0, "Setting of the Narrator", Range<int>{ 0, 3 }));
knownOptions["tutorialStep"] = std::shared_ptr<GameOption>(new GameOption("movement", "Next stage of tutorial hints to display",
QStringList{ "movement", "find_tree", "punch_tree", "open_inventory", "craft_planks", "none" }));
knownOptions["mouseWheelSensitivity"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "Allows making the mouse wheel more sensitive (see MC-123773)", Range<float>{ 1.0f, 10.0f }));
knownOptions["rawMouseInput"] = std::shared_ptr<GameOption>(new GameOption(true, "Ignores acceleration set by the operating system"));
knownOptions["glDebugVerbosity"] = std::shared_ptr<GameOption>(new GameOption(1, "LWJGL log info level (only on some machines)", Range<int>{ 0, 4 }));
knownOptions["skipMultiplayerWarning"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether to skip the legal disclaimer when entering the multiplayer screen"));
knownOptions["skipRealms32bitWarning"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether to skip the 32-bit environment warning when entering the Realms screen"));
knownOptions["hideMatchedNames"] = std::shared_ptr<GameOption>(new GameOption(true, "Some servers send chat messages in non-standard formats. With this option on, the game will attempt to apply chat hiding anyway by matching the text in messages."));
knownOptions["joinedFirstServer"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the player has joined a server before. If false, the Social Interactions tutorial hint will appear when joining a server."));
knownOptions["hideBundleTutorial"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the player has seen the bundle tutorial hint when trying to use a bundle."));
knownOptions["syncChunkWrites"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether to open region files in synchronous mode"));
knownOptions["showAutosaveIndicator"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether to show autosave indicator on the right-bottom of the screen"));
knownOptions["allowServerListing"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether to allow player's ID to be shown in the player list shown on the multiplayer screen"));
knownOptions["lastServer"] = std::make_shared<GameOption>("", "Address of last server used with Direct Connection");
knownOptions["lang"] = std::make_shared<GameOption>("en_us", "Language to be used");
knownOptions["soundDevice"] = std::make_shared<GameOption>("", "Sound device to be used");
knownOptions["chatVisibility"] = std::make_shared<GameOption>(0, "What is seen in chat", Range<int>{ 0, 2 });
knownOptions["chatOpacity"] = std::make_shared<GameOption>(1.0, "Opacity of the chat", Range<float>{ 0, 1 });
knownOptions["chatLineSpacing"] = std::make_shared<GameOption>(0.0, "Spacing between text in chat", Range<float>{ 0, 1 });
knownOptions["textBackgroundOpacity"] = std::make_shared<GameOption>(0.5, "Opacity of text background", Range<float>{ 0, 1 });
knownOptions["backgroundForChatOnly"] = std::make_shared<GameOption>(true, "Toggles if the background is only in chat or if it's everywhere");
knownOptions["hideServerAddress"] = std::make_shared<GameOption>(false, "Has no effect in modern versions");
knownOptions["advancedItemTooltips"] = std::make_shared<GameOption>(false, "Whether hovering over items in the inventory shows its ID and durability; toggled by pressing F3+H");
knownOptions["pauseOnLostFocus"] = std::make_shared<GameOption>(true, "Whether switching out of Minecraft without pressing Esc or opening an in-game interface automatically pauses the game; toggled by pressing F3+P");
knownOptions["overrideWidth"] = std::make_shared<GameOption>(0, "Width to open Minecraft with in pixels (0 means default to the Minecraft settings); no in-game control");
knownOptions["overrideHeight"] = std::make_shared<GameOption>(0, "Height to open Minecraft with in pixels (0 means default to the Minecraft settings); no in-game control");
knownOptions["heldItemTooltips"] = std::make_shared<GameOption>(true, "Whether switching between items shows the name of the item; no in-game control");
knownOptions["chatHeightFocused"] = std::make_shared<GameOption>(1.0, "How tall the chat span is", Range<float>{ 0, 1 });
knownOptions["chatDelay"] = std::make_shared<GameOption>(0.0, "How much delay there is between text", Range<float>{ 0, 6 });
knownOptions["chatHeightUnfocused"] = std::make_shared<GameOption>(0.4375, "How tall the maximum chat span is, when the chat button is not pressed", Range<float>{ 0, 1 });
knownOptions["chatScale"] = std::make_shared<GameOption>(1.0, "The scale/size of the text in the chat", Range<float>{ 0, 1 });
knownOptions["chatWidth"] = std::make_shared<GameOption>(1.0, "The span width of the chat", Range<float>{ 0, 1 });
knownOptions["mipmapLevels"] = std::make_shared<GameOption>(4, "Amount by which distant textures are smoothed", Range<int>{0, 4});
knownOptions["useNativeTransport"] = std::make_shared<GameOption>(true, "Whether to use a Netty EpollSocketChannel for connections to servers instead of a NioSocketChannel (only applies if EPOLL is available on the user's system)");
knownOptions["mainHand"] = std::make_shared<GameOption>("right", "Whether the main hand appears as left or right", QStringList{ "left", "right" });
knownOptions["attackIndicator"] = std::make_shared<GameOption>(1, "When hitting, how the attack indicator is shown on screen", Range<int>{ 0, 2 });
knownOptions["narrator"] = std::make_shared<GameOption>(0, "Setting of the Narrator", Range<int>{ 0, 3 });
knownOptions["tutorialStep"] = std::make_shared<GameOption>("movement", "Next stage of tutorial hints to display",
QStringList{ "movement", "find_tree", "punch_tree", "open_inventory", "craft_planks", "none" });
knownOptions["mouseWheelSensitivity"] = std::make_shared<GameOption>(1.0f, "Allows making the mouse wheel more sensitive (see MC-123773)", Range<float>{ 1.0f, 10.0f });
knownOptions["rawMouseInput"] = std::make_shared<GameOption>(true, "Ignores acceleration set by the operating system");
knownOptions["glDebugVerbosity"] = std::make_shared<GameOption>(1, "LWJGL log info level (only on some machines)", Range<int>{ 0, 4 });
knownOptions["skipMultiplayerWarning"] = std::make_shared<GameOption>(true, "Whether to skip the legal disclaimer when entering the multiplayer screen");
knownOptions["skipRealms32bitWarning"] = std::make_shared<GameOption>(true, "Whether to skip the 32-bit environment warning when entering the Realms screen");
knownOptions["hideMatchedNames"] = std::make_shared<GameOption>(true, "Some servers send chat messages in non-standard formats. With this option on, the game will attempt to apply chat hiding anyway by matching the text in messages.");
knownOptions["joinedFirstServer"] = std::make_shared<GameOption>(true, "Whether the player has joined a server before. If false, the Social Interactions tutorial hint will appear when joining a server.");
knownOptions["hideBundleTutorial"] = std::make_shared<GameOption>(true, "Whether the player has seen the bundle tutorial hint when trying to use a bundle.");
knownOptions["syncChunkWrites"] = std::make_shared<GameOption>(true, "Whether to open region files in synchronous mode");
knownOptions["showAutosaveIndicator"] = std::make_shared<GameOption>(true, "Whether to show autosave indicator on the right-bottom of the screen");
knownOptions["allowServerListing"] = std::make_shared<GameOption>(true, "Whether to allow player's ID to be shown in the player list shown on the multiplayer screen");
// Keys Binds
knownOptions["key_key.attack"] = std::shared_ptr<GameOption>(new GameOption("key.mouse.left", "Attack control", OptionType::KeyBind));
knownOptions["key_key.use"] = std::shared_ptr<GameOption>(new GameOption("key.mouse.right", "Use Item control", OptionType::KeyBind));
knownOptions["key_key.forward"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.w", "Forward control ", OptionType::KeyBind));
knownOptions["key_key.left"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.a", "Left control", OptionType::KeyBind));
knownOptions["key_key.back"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.s", "Back control", OptionType::KeyBind));
knownOptions["key_key.right"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.d", "Right control", OptionType::KeyBind));
knownOptions["key_key.jump"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.space", "Jump control", OptionType::KeyBind));
knownOptions["key_key.sneak"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.left.shift", "Sneak control", OptionType::KeyBind));
knownOptions["key_key.sprint"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.left.control", "Sprint control ", OptionType::KeyBind));
knownOptions["key_key.drop"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.q", "Drop control ", OptionType::KeyBind));
knownOptions["key_key.inventory"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.e", "Inventory control", OptionType::KeyBind));
knownOptions["key_key.chat"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.t", "Chat control", OptionType::KeyBind));
knownOptions["key_key.playerlist"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.tab", "List Players control", OptionType::KeyBind));
knownOptions["key_key.pickItem"] = std::shared_ptr<GameOption>(new GameOption("key.mouse.middle", "Pick Block control", OptionType::KeyBind));
knownOptions["key_key.command"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.slash", "Command control", OptionType::KeyBind));
knownOptions["key_key.socialInteractions"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.p", "Social Interaction control", OptionType::KeyBind));
knownOptions["key_key.screenshot"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.f2", "Screenshot control", OptionType::KeyBind));
knownOptions["key_key.togglePerspective"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.f5", "Perspective control", OptionType::KeyBind));
knownOptions["key_key.smoothCamera"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.unknown", "Mouse Smoothing control", OptionType::KeyBind));
knownOptions["key_key.fullscreen"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.f11", "Fullscreen control", OptionType::KeyBind));
knownOptions["key_key.spectatorOutlines"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.unknown", "Visibility of player outlines in Spectator Mode control", OptionType::KeyBind));
knownOptions["key_key.swapOffhand"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.f", "Swapping of items between both hands control", OptionType::KeyBind));
knownOptions["key_key.saveToolbarActivator"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.c", "Save current toolbar to a slot (in Creative Mode)", OptionType::KeyBind));
knownOptions["key_key.loadToolbarActivator"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.x", "Load toolbar from a slot (in Creative Mode)", OptionType::KeyBind));
knownOptions["key_key.advancements"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.l", "Open the Advancements screen", OptionType::KeyBind));
knownOptions["key_key.hotbar.1"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.1", "Hotbar Slot 1 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.2"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.2", "Hotbar Slot 2 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.3"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.3", "Hotbar Slot 3 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.4"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.4", "Hotbar Slot 4 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.5"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.5", "Hotbar Slot 5 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.6"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.6", "Hotbar Slot 6 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.7"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.7", "Hotbar Slot 7 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.8"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.8", "Hotbar Slot 8 control", OptionType::KeyBind));
knownOptions["key_key.hotbar.9"] = std::shared_ptr<GameOption>(new GameOption("key.keyboard.9", "Hotbar Slot 9 control", OptionType::KeyBind));
knownOptions["key_key.attack"] = std::make_shared<GameOption>("key.mouse.left", "Attack control");
knownOptions["key_key.use"] = std::make_shared<GameOption>("key.mouse.right", "Use Item control");
knownOptions["key_key.forward"] = std::make_shared<GameOption>("key.keyboard.w", "Forward control ");
knownOptions["key_key.left"] = std::make_shared<GameOption>("key.keyboard.a", "Left control");
knownOptions["key_key.back"] = std::make_shared<GameOption>("key.keyboard.s", "Back control");
knownOptions["key_key.right"] = std::make_shared<GameOption>("key.keyboard.d", "Right control");
knownOptions["key_key.jump"] = std::make_shared<GameOption>("key.keyboard.space", "Jump control");
knownOptions["key_key.sneak"] = std::make_shared<GameOption>("key.keyboard.left.shift", "Sneak control");
knownOptions["key_key.sprint"] = std::make_shared<GameOption>("key.keyboard.left.control", "Sprint control ");
knownOptions["key_key.drop"] = std::make_shared<GameOption>("key.keyboard.q", "Drop control ");
knownOptions["key_key.inventory"] = std::make_shared<GameOption>("key.keyboard.e", "Inventory control");
knownOptions["key_key.chat"] = std::make_shared<GameOption>("key.keyboard.t", "Chat control");
knownOptions["key_key.playerlist"] = std::make_shared<GameOption>("key.keyboard.tab", "List Players control");
knownOptions["key_key.pickItem"] = std::make_shared<GameOption>("key.mouse.middle", "Pick Block control");
knownOptions["key_key.command"] = std::make_shared<GameOption>("key.keyboard.slash", "Command control");
knownOptions["key_key.socialInteractions"] = std::make_shared<GameOption>("key.keyboard.p", "Social Interaction control");
knownOptions["key_key.screenshot"] = std::make_shared<GameOption>("key.keyboard.f2", "Screenshot control");
knownOptions["key_key.togglePerspective"] = std::make_shared<GameOption>("key.keyboard.f5", "Perspective control");
knownOptions["key_key.smoothCamera"] = std::make_shared<GameOption>("key.keyboard.unknown", "Mouse Smoothing control");
knownOptions["key_key.fullscreen"] = std::make_shared<GameOption>("key.keyboard.f11", "Fullscreen control");
knownOptions["key_key.spectatorOutlines"] = std::make_shared<GameOption>("key.keyboard.unknown", "Visibility of player outlines in Spectator Mode control");
knownOptions["key_key.swapOffhand"] = std::make_shared<GameOption>("key.keyboard.f", "Swapping of items between both hands control");
knownOptions["key_key.saveToolbarActivator"] = std::make_shared<GameOption>("key.keyboard.c", "Save current toolbar to a slot (in Creative Mode)");
knownOptions["key_key.loadToolbarActivator"] = std::make_shared<GameOption>("key.keyboard.x", "Load toolbar from a slot (in Creative Mode)");
knownOptions["key_key.advancements"] = std::make_shared<GameOption>("key.keyboard.l", "Open the Advancements screen");
knownOptions["key_key.hotbar.1"] = std::make_shared<GameOption>("key.keyboard.1", "Hotbar Slot 1 control");
knownOptions["key_key.hotbar.2"] = std::make_shared<GameOption>("key.keyboard.2", "Hotbar Slot 2 control");
knownOptions["key_key.hotbar.3"] = std::make_shared<GameOption>("key.keyboard.3", "Hotbar Slot 3 control");
knownOptions["key_key.hotbar.4"] = std::make_shared<GameOption>("key.keyboard.4", "Hotbar Slot 4 control");
knownOptions["key_key.hotbar.5"] = std::make_shared<GameOption>("key.keyboard.5", "Hotbar Slot 5 control");
knownOptions["key_key.hotbar.6"] = std::make_shared<GameOption>("key.keyboard.6", "Hotbar Slot 6 control");
knownOptions["key_key.hotbar.7"] = std::make_shared<GameOption>("key.keyboard.7", "Hotbar Slot 7 control");
knownOptions["key_key.hotbar.8"] = std::make_shared<GameOption>("key.keyboard.8", "Hotbar Slot 8 control");
knownOptions["key_key.hotbar.9"] = std::make_shared<GameOption>("key.keyboard.9", "Hotbar Slot 9 control");
// Sound
knownOptions["soundCategory_master"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of all sounds", Range<float>{ 0, 1 }));
knownOptions["soundCategory_music"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of gameplay music", Range<float>{ 0, 1 }));
knownOptions["soundCategory_record"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of music/sounds from Jukeboxes and Note Blocks", Range<float>{ 0, 1 }));
knownOptions["soundCategory_weather"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of rain and thunder", Range<float>{ 0, 1 }));
knownOptions["soundCategory_block"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of blocks", Range<float>{ 0, 1 }));
knownOptions["soundCategory_hostile"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of hostile and neutral mobs", Range<float>{ 0, 1 }));
knownOptions["soundCategory_neutral"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of passive mobs", Range<float>{ 0, 1 }));
knownOptions["soundCategory_player"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of players", Range<float>{ 0, 1 }));
knownOptions["soundCategory_ambient"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of cave sounds and fireworks", Range<float>{ 0, 1 }));
knownOptions["soundCategory_voice"] = std::shared_ptr<GameOption>(new GameOption(1.0f, "The volume of voices", Range<float>{ 0, 1 }));
knownOptions["soundCategory_master"] = std::make_shared<GameOption>(1.0f, "The volume of all sounds", Range<float>{ 0, 1 });
knownOptions["soundCategory_music"] = std::make_shared<GameOption>(1.0f, "The volume of gameplay music", Range<float>{ 0, 1 });
knownOptions["soundCategory_record"] = std::make_shared<GameOption>(1.0f, "The volume of music/sounds from Jukeboxes and Note Blocks", Range<float>{ 0, 1 });
knownOptions["soundCategory_weather"] = std::make_shared<GameOption>(1.0f, "The volume of rain and thunder", Range<float>{ 0, 1 });
knownOptions["soundCategory_block"] = std::make_shared<GameOption>(1.0f, "The volume of blocks", Range<float>{ 0, 1 });
knownOptions["soundCategory_hostile"] = std::make_shared<GameOption>(1.0f, "The volume of hostile and neutral mobs", Range<float>{ 0, 1 });
knownOptions["soundCategory_neutral"] = std::make_shared<GameOption>(1.0f, "The volume of passive mobs", Range<float>{ 0, 1 });
knownOptions["soundCategory_player"] = std::make_shared<GameOption>(1.0f, "The volume of players", Range<float>{ 0, 1 });
knownOptions["soundCategory_ambient"] = std::make_shared<GameOption>(1.0f, "The volume of cave sounds and fireworks", Range<float>{ 0, 1 });
knownOptions["soundCategory_voice"] = std::make_shared<GameOption>(1.0f, "The volume of voices", Range<float>{ 0, 1 });
// Model Parts
knownOptions["modelPart_cape"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the cape is shown"));
knownOptions["modelPart_jacket"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the \"Jacket\" skin layer is shown"));
knownOptions["modelPart_left_sleeve"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the \"Left Sleeve\" skin layer is shown"));
knownOptions["modelPart_right_sleeve"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the \"Right Sleeve\" skin layer is shown"));
knownOptions["modelPart_left_pants_leg"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the \"Left Pants Leg\" skin layer is shown"));
knownOptions["modelPart_right_pants_leg"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the \"Right Pants Leg\" skin layer is shown"));
knownOptions["modelPart_hat"] = std::shared_ptr<GameOption>(new GameOption(true, "Whether the \"Hat\" skin layer is shown"));
knownOptions["modelPart_cape"] = std::make_shared<GameOption>(true, "Whether the cape is shown");
knownOptions["modelPart_jacket"] = std::make_shared<GameOption>(true, "Whether the \"Jacket\" skin layer is shown");
knownOptions["modelPart_left_sleeve"] = std::make_shared<GameOption>(true, "Whether the \"Left Sleeve\" skin layer is shown");
knownOptions["modelPart_right_sleeve"] = std::make_shared<GameOption>(true, "Whether the \"Right Sleeve\" skin layer is shown");
knownOptions["modelPart_left_pants_leg"] = std::make_shared<GameOption>(true, "Whether the \"Left Pants Leg\" skin layer is shown");
knownOptions["modelPart_right_pants_leg"] = std::make_shared<GameOption>(true, "Whether the \"Right Pants Leg\" skin layer is shown");
knownOptions["modelPart_hat"] = std::make_shared<GameOption>(true, "Whether the \"Hat\" skin layer is shown");
// Misc
knownOptions["fullscreenResolution"] = std::shared_ptr<GameOption>(new GameOption("", "Changes the resolution of the game when in fullscreen mode. The only values allowed are the values supported by the user's monitor, shown when changing the screen resolution in the operating system settings. Setting this option to a value not supported by the monitor resets the option to \"Current\". When set to \"Current\", this option is absent from options.txt. "));
knownOptions["fullscreenResolution"] = std::make_shared<GameOption>("", "Changes the resolution of the game when in fullscreen mode. The only values allowed are the values supported by the user's monitor, shown when changing the screen resolution in the operating system settings. Setting this option to a value not supported by the monitor resets the option to \"Current\". When set to \"Current\", this option is absent from options.txt. ");
// Not vanilla - from mods or modloaders
knownOptions["quilt_available_resourcepacks"] = std::shared_ptr<GameOption>(new GameOption{"[]", "Quilt Internal Available Resource Packs", QStringList(), false});
knownOptions["quilt_available_resourcepacks"] = std::make_shared<GameOption>("[]", "Quilt Internal Available Resource Packs", QStringList(), false);
}
@ -238,7 +239,7 @@ void GameOptionsSchema::populateInternalKeyBindList() {
addMouseBind( "key.mouse.26", 0, QObject::tr("Mouse Button 26"), Qt::MouseButton::ExtraButton22 );
addMouseBind( "key.mouse.27", 0, QObject::tr("Mouse Button 27"), Qt::MouseButton::ExtraButton23 );
addMouseBind( "key.mouse.28", 0, QObject::tr("Mouse Button 28"), Qt::MouseButton::ExtraButton24 );
// not sure if it makes sense to go this far, but its how far Qt can count.
// not sure if it makes sense to go this far, but it's how far Qt can count.
// Number Row
addKeyboardBind("key.keyboard.0", 11, QObject::tr("0"), Qt::Key::Key_0 );
@ -376,3 +377,5 @@ void GameOptionsSchema::populateInternalKeyBindList() {
// clang-format on
};
QString GameOption::getDefaultString()
{ return defaultString; }

View File

@ -21,11 +21,12 @@
#include <QList>
#include <QMap>
#include <memory>
#include <utility>
enum class OptionType { String, Int, Float, Bool, KeyBind };
template <class T> struct Range {
typename T min, max;
T min, max;
};
union UniversalRange {
@ -46,10 +47,9 @@ class GameOption {
/// @brief Bool variant
/// @param defaultValue Default Value
/// @param description The Description for this Option
/// @param readOnly wether or not this option should be editable
GameOption(bool defaultValue, QString description = "", bool readOnly = false)
: description(description)
, type(OptionType::Bool), readOnly(readOnly) {
/// @param readOnly whether or not this option should be editable
explicit GameOption(bool defaultValue, QString description = "", bool readOnly = false)
: description(std::move(description)), type(OptionType::Bool), readOnly(readOnly) {
GameOption::defaultValue.boolValue = defaultValue;
};
@ -57,31 +57,31 @@ class GameOption {
/// @param defaultValue Default Value
/// @param description The Description for this Option
/// @param validValues List of possible options for this field, if empty any input will be possible
/// @param readOnly wether or not this option should be editable
GameOption(QString defaultValue = "", QString description = "", QList<QString> validValues = QList<QString>(), bool readOnly = false)
: description(description), type(OptionType::String), readOnly(readOnly), defaultString(defaultValue), validValues(validValues){};
/// @param readOnly whether or not this option should be editable
explicit GameOption(QString defaultValue = "", QString description = "", QList<QString> validValues = QList<QString>(), bool readOnly = false)
: description(std::move(description)), type(OptionType::String), readOnly(readOnly), defaultString(std::move(defaultValue)), validValues(std::move(validValues)){};
/// @brief KeyBind variant
/// @param defaultValue Default Value
/// @param description The Description for this Option
GameOption(QString defaultValue = "", QString description = "", OptionType type = OptionType::KeyBind)
: description(description), type(OptionType::KeyBind), defaultString(defaultValue){};
explicit GameOption(QString defaultValue = "", QString description = "")
: description(std::move(description)), type(OptionType::KeyBind), defaultString(std::move(defaultValue)){};
/// @brief Float variant
/// @param defaultValue Default Value
/// @param description The Description for this Option
/// @param range if left empty (0,0) no limits are assumed
/// @param readOnly wether or not this option should be editable
GameOption(float defaultValue = 0.0f, QString description = "", Range<float> range = Range<float>{ 0.0f, 0.0f }, bool readOnly = false)
: description(description), type(OptionType::Float), readOnly(readOnly), range{ range }, defaultValue{ defaultValue } {};
/// @param readOnly whether or not this option should be editable
explicit GameOption(float defaultValue = 0.0f, QString description = "", Range<float> range = Range<float>{ 0.0f, 0.0f }, bool readOnly = false)
: description(std::move(description)), type(OptionType::Float), readOnly(readOnly), range{ range }, defaultValue{ defaultValue } {};
/// @brief Int variant
/// @param defaultValue Default Value
/// @param description Description for this Option
/// @param range if left empty (0,0) no limits are assumed
/// @param readOnly wether or not this option should be editable
GameOption(int defaultValue = 0, QString description = "", Range<int> range = Range<int>{ 0, 0 }, bool readOnly = false)
: description(description), type(OptionType::Int), readOnly(readOnly)
/// @param readOnly whether or not this option should be editable
explicit GameOption(int defaultValue = 0, QString description = "", Range<int> range = Range<int>{ 0, 0 }, bool readOnly = false)
: description(std::move(description)), type(OptionType::Int), readOnly(readOnly)
{
GameOption::range.intRange = range;
GameOption::defaultValue.intValue = defaultValue;
@ -94,13 +94,13 @@ class GameOption {
//int introducedVersion;
//int removedVersion;
int getDefaultInt() { return defaultValue.intValue; };
bool getDefaultBool() { return defaultValue.boolValue; };
float getDefaultFloat() { return defaultValue.floatValue; };
QString getDefaultString() { return defaultString; };
int getDefaultInt() const { return defaultValue.intValue; };
bool getDefaultBool() const { return defaultValue.boolValue; };
float getDefaultFloat() const { return defaultValue.floatValue; };
QString getDefaultString();;
Range<int> getIntRange() { return range.intRange; };
Range<float> getFloatRange() { return range.floatRange; };
Range<int> getIntRange() const { return range.intRange; };
Range<float> getFloatRange() const { return range.floatRange; };
private:
OptionValue defaultValue = { 0.0f };
@ -109,12 +109,6 @@ class GameOption {
};
union a {
QList<QString> enumValues;
struct BoolMarker {
} boolean;
};
union mouseOrKeyboardButton {
Qt::Key keyboardKey;
Qt::MouseButton mouseButton;
@ -123,13 +117,13 @@ union mouseOrKeyboardButton {
class KeyBindData {
public:
KeyBindData(QString minecraftKeyCode, int glfwCode, QString displayName, Qt::MouseButton mouseButton) :
minecraftKeyCode(minecraftKeyCode), glfwCode(glfwCode), displayName(displayName)
minecraftKeyCode(std::move(minecraftKeyCode)), glfwCode(glfwCode), displayName(std::move(displayName))
{
qtKeyCode.mouseButton = mouseButton;
}
KeyBindData(QString minecraftKeyCode, int glfwCode, QString displayName, Qt::Key keyboardKey)
: minecraftKeyCode(minecraftKeyCode), glfwCode(glfwCode), displayName(displayName)
: minecraftKeyCode(std::move(minecraftKeyCode)), glfwCode(glfwCode), displayName(std::move(displayName))
{
qtKeyCode.keyboardKey = keyboardKey;
}
@ -154,13 +148,13 @@ class GameOptionsSchema {
static void populateInternalOptionList();
static void populateInternalKeyBindList();
static void addKeyboardBind(QString minecraftKeyCode, int glfwCode, QString displayName, Qt::Key keyboardKey)
static void addKeyboardBind(const QString& minecraftKeyCode, int glfwCode, const QString& displayName, Qt::Key keyboardKey)
{
keyboardButtons.append(std::shared_ptr<KeyBindData>(new KeyBindData(minecraftKeyCode, glfwCode, displayName, keyboardKey)));
keyboardButtons.append(std::make_shared<KeyBindData>(minecraftKeyCode, glfwCode, displayName, keyboardKey));
};
static void addMouseBind(QString minecraftKeyCode, int glfwCode, QString displayName, Qt::MouseButton mouseButton)
static void addMouseBind(const QString& minecraftKeyCode, int glfwCode, const QString& displayName, Qt::MouseButton mouseButton)
{
keyboardButtons.append(std::shared_ptr<KeyBindData>(new KeyBindData(minecraftKeyCode, glfwCode, displayName, mouseButton)));
keyboardButtons.append(std::make_shared<KeyBindData>(minecraftKeyCode, glfwCode, displayName, mouseButton));
};
};

View File

@ -37,8 +37,9 @@
#include "GameOptionsPage.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/gameoptions/GameOptions.h"
#include "minecraft/gameoptions/GameOptionDelegate.h"
#include "minecraft/gameoptions/GameOptions.h"
#include "ui_GameOptionsPage.h"
GameOptionsPage::GameOptionsPage(MinecraftInstance* inst, QWidget* parent) : QWidget(parent), ui(new Ui::GameOptionsPage)
{
@ -48,13 +49,16 @@ GameOptionsPage::GameOptionsPage(MinecraftInstance* inst, QWidget* parent) : QWi
ui->optionsView->setModel(m_model.get());
ui->optionsView->setItemDelegateForColumn(2, new GameOptionDelegate(ui->optionsView, m_model->getContents()));
ui->optionsView->setEditTriggers(QAbstractItemView::AllEditTriggers);
for (int i = 0; i < m_model->getContents()->size(); ++i) {
ui->optionsView->openPersistentEditor(m_model->index(i, 2));
}
auto head = ui->optionsView->header();
head->setDefaultSectionSize(250);
head->setDefaultSectionSize(350);
if (head->count()) {
for (int i = 1; i < head->count(); i++) {
head->setSectionResizeMode(i, QHeaderView::Stretch);
head->setSectionResizeMode(i, QHeaderView::Interactive);
}
head->setSectionResizeMode(head->count() -1, QHeaderView::Stretch);
head->setSectionResizeMode(head->count() - 1, QHeaderView::Stretch);
}
connect(ui->optionsView, &QTreeView::doubleClicked, this, &GameOptionsPage::OptionDoubleClicked);
}

View File

@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QStyledItemDelegate>
#include <QWidget>
#include <QPushButton>
#include "minecraft/gameoptions/GameOptions.h"
class GameOptionWidget : public QWidget {
public:
GameOptionWidget(QWidget* parent) : QWidget(parent){};
virtual void setEditorData(GameOptionItem optionItem) = 0;
virtual void saveEditorData(GameOptionItem optionItem) = 0;
void setSize(QRect size) {
setGeometry(size);
sizeHintData = QSize(size.height(), size.width());
}
QSize sizeHint() const override { return sizeHintData; }
protected:
QSize sizeHintData;
};

View File

@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetCheckBox.h"
#include "ui_GameOptionWidgetCheckBox.h"
GameOptionWidgetCheckBox::GameOptionWidgetCheckBox(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetCheckBox)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultBool() ? "true" : "false"));
}
}
GameOptionWidgetCheckBox::~GameOptionWidgetCheckBox()
{
delete ui;
}
void GameOptionWidgetCheckBox::setEditorData(GameOptionItem optionItem) {
ui->checkBox->setText(optionItem.boolValue ? "true" : "false");
ui->checkBox->setChecked(optionItem.boolValue);
}
void GameOptionWidgetCheckBox::saveEditorData(GameOptionItem optionItem) {
optionItem.boolValue = ui->checkBox->isChecked();
}

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetCheckBox;
}
class GameOptionWidgetCheckBox : public GameOptionWidget {
public:
explicit GameOptionWidgetCheckBox(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetCheckBox() override;
void setEditorData(GameOptionItem optionItem) override;
void saveEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetCheckBox* ui;
};

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetCheckBox</class>
<widget class="QWidget" name="GameOptionWidgetCheckBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>42</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetComboBox.h"
#include "ui_GameOptionWidgetComboBox.h"
GameOptionWidgetComboBox::GameOptionWidgetComboBox(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetComboBox)
{
ui->setupUi(this);
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultString()));
for (const auto& value : knownOption->validValues) {
ui->comboBox->addItem(value);
}
}
GameOptionWidgetComboBox::~GameOptionWidgetComboBox()
{
delete ui;
}
void GameOptionWidgetComboBox::setEditorData(GameOptionItem optionItem) {
ui->comboBox->setCurrentIndex(ui->comboBox->findText(optionItem.value));
}
void GameOptionWidgetComboBox::saveEditorData(GameOptionItem optionItem) {
optionItem.value = ui->comboBox->currentText();
}

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetComboBox;
}
class GameOptionWidgetComboBox : public GameOptionWidget {
public:
explicit GameOptionWidgetComboBox(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetComboBox() override;
void setEditorData(GameOptionItem optionItem) override;
void saveEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetComboBox* ui;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetComboBox</class>
<widget class="QWidget" name="GameOptionWidgetComboBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>45</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,61 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetKeyBind.h"
#include "ui_GameOptionWidgetKeyBind.h"
GameOptionWidgetKeyBind::GameOptionWidgetKeyBind(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetKeyBind)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultString()));
}
}
GameOptionWidgetKeyBind::~GameOptionWidgetKeyBind()
{
delete ui;
}
void GameOptionWidgetKeyBind::setEditorData(GameOptionItem optionItem) {
/*for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->minecraftKeyCode == contents[row].knownOption->getDefaultString()) {
return keyBinding->displayName; // + " (" + contents[row].knownOption->getDefaultString() + ")";
}
}
return contents[row].knownOption->getDefaultString();*/
ui->keySequenceEdit->setKeySequence(optionItem.value);
}
void GameOptionWidgetKeyBind::saveEditorData(GameOptionItem optionItem) {
QString minecraftKeyCode;
/*for (auto& keyBinding : *keybindingOptions) {
// this could become a std::find_if eventually, if someone wants to bother making it that.
if (keyBinding->qtKeyCode.keyboardKey == ui->keySequenceEdit->keySequence()[0].key() ||
keyBinding->qtKeyCode.mouseButton == ui->keySequenceEdit->keySequence()[0].key()) {
minecraftKeyCode = keyBinding->minecraftKeyCode;
}
}*/
optionItem.value = minecraftKeyCode;
}

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetKeyBind;
}
class GameOptionWidgetKeyBind : public GameOptionWidget {
public:
explicit GameOptionWidgetKeyBind(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetKeyBind() override;
void setEditorData(GameOptionItem optionItem) override;
void saveEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetKeyBind* ui;
};

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetKeyBind</class>
<widget class="QWidget" name="GameOptionWidgetKeyBind">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>63</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QKeySequenceEdit" name="keySequenceEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Bind Mouse Button</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,91 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetSlider.h"
#include "Application.h"
#include "minecraft/gameoptions/GameOptions.h"
#include "ui_GameOptionWidgetSlider.h"
#include <QString>
#include <QStyledItemDelegate>
#include <QWidget>
GameOptionWidgetSlider::GameOptionWidgetSlider(QWidget* parent, std::shared_ptr<GameOption> knownOption)
: GameOptionWidget(parent), ui(new Ui::GameOptionWidgetSlider)
{
ui->setupUi(this);
ui->resetButton->setMaximumWidth(ui->resetButton->height());
if (knownOption->type == OptionType::Float) {
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultFloat()));
ui->slider->setMinimum(knownOption->getFloatRange().min * 100);
ui->slider->setMaximum(knownOption->getFloatRange().max * 100);
// QLocale((QString)APPLICATION->settings()->get("Language"))
ui->maxLabel->setText(QString("%1").arg(knownOption->getFloatRange().max));
ui->minLabel->setText(QString("%1").arg(knownOption->getFloatRange().min));
connect(ui->slider, QOverload<int>::of(&QSlider::valueChanged), this, [&](int value) { ui->spinBox->setValue(value); });
connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [&](int value) { ui->slider->setValue(value); });
} else { // Int slider
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultInt()));
ui->slider->setMinimum(knownOption->getIntRange().min);
ui->slider->setMaximum(knownOption->getIntRange().max);
ui->maxLabel->setText(QString("%1").arg(knownOption->getIntRange().max));
ui->minLabel->setText(QString("%1").arg(knownOption->getIntRange().min));
connect(ui->slider, QOverload<int>::of(&QSlider::valueChanged), this, [&](int value) { ui->spinBox->setValue(value / 100.0f); });
connect(ui->spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [&](int value) { ui->slider->setValue(value * 100.0f); });
}
}
void GameOptionWidgetSlider::setEditorData(GameOptionItem optionItem) {
switch (optionItem.type) {
case OptionType::Int: {
ui->slider->setValue(optionItem.intValue);
break;
}
case OptionType::Float: {
ui->slider->setValue(optionItem.floatValue * 100);
break;
}
default:
break;
}
}
GameOptionWidgetSlider::~GameOptionWidgetSlider() {
destroy(ui);
}
void GameOptionWidgetSlider::saveEditorData(GameOptionItem optionItem) {
switch (optionItem.type) {
case OptionType::Int: {
optionItem.intValue = ui->slider->value();
break;
}
case OptionType::Float: {
optionItem.floatValue = ui->slider->value() / 100.0f;
break;
}
default:
break;
}
}

View File

@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetSlider;
}
class GameOptionWidgetSlider : public GameOptionWidget {
public:
GameOptionWidgetSlider(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetSlider() override;
void setEditorData(GameOptionItem optionItem);
void saveEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetSlider* ui;
};

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetSlider</class>
<widget class="QWidget" name="GameOptionWidgetSlider">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>60</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSlider" name="slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="minLabel">
<property name="text">
<string>[min]</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="maxLabel">
<property name="text">
<string>[max]</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetSpinnerFloat.h"
#include "ui_GameOptionWidgetSpinnerFloat.h"
GameOptionWidgetSpinnerFloat::GameOptionWidgetSpinnerFloat(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetSpinnerFloat)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultFloat()));
}
}
GameOptionWidgetSpinnerFloat::~GameOptionWidgetSpinnerFloat()
{
delete ui;
}
void GameOptionWidgetSpinnerFloat::setEditorData(GameOptionItem optionItem) {
ui->doubleSpinBox->setValue(optionItem.floatValue);
}
void GameOptionWidgetSpinnerFloat::saveEditorData(GameOptionItem optionItem) {
optionItem.floatValue = ui->doubleSpinBox->value();
}

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetSpinnerFloat;
}
class GameOptionWidgetSpinnerFloat : public GameOptionWidget {
public:
explicit GameOptionWidgetSpinnerFloat(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetSpinnerFloat() override;
void setEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetSpinnerFloat* ui;
public:
void saveEditorData(GameOptionItem optionItem) override;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetSpinnerFloat</class>
<widget class="QWidget" name="GameOptionWidgetSpinnerFloat">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetSpinnerInt.h"
#include "ui_GameOptionWidgetSpinnerInt.h"
GameOptionWidgetSpinnerInt::GameOptionWidgetSpinnerInt(QWidget* parent, std::shared_ptr<GameOption> knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetSpinnerInt)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultInt()));
}
}
GameOptionWidgetSpinnerInt::~GameOptionWidgetSpinnerInt()
{
delete ui;
}
void GameOptionWidgetSpinnerInt::setEditorData(GameOptionItem optionItem) {
ui->spinBox->setValue(optionItem.intValue);
}
void GameOptionWidgetSpinnerInt::saveEditorData(GameOptionItem optionItem) {
optionItem.intValue = ui->spinBox->value();
}

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetSpinnerInt;
}
class GameOptionWidgetSpinnerInt : public GameOptionWidget {
public:
explicit GameOptionWidgetSpinnerInt(QWidget* parent, std::shared_ptr<GameOption> knownOption);
~GameOptionWidgetSpinnerInt() override;
void setEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetSpinnerInt* ui;
public:
void saveEditorData(GameOptionItem optionItem) override;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetSpinnerInt</class>
<widget class="QWidget" name="GameOptionWidgetSpinnerInt">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="spinBox"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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 "GameOptionWidgetText.h"
#include "ui_GameOptionWidgetText.h"
GameOptionWidgetText::GameOptionWidgetText(QWidget* parent, const std::shared_ptr<GameOption>& knownOption) : GameOptionWidget(parent), ui(new Ui::GameOptionWidgetText)
{
ui->setupUi(this);
if (knownOption == nullptr) {
ui->horizontalLayout->removeWidget(ui->resetButton);
delete ui->resetButton;
} else {
ui->resetButton->setMaximumWidth(ui->resetButton->height());
ui->resetButton->setToolTip(QString(tr("Default Value: %1")).arg(knownOption->getDefaultString()));
}
}
GameOptionWidgetText::~GameOptionWidgetText()
{
delete ui;
}
void GameOptionWidgetText::setEditorData(GameOptionItem optionItem) {
ui->lineEdit->setText(optionItem.value);
}
void GameOptionWidgetText::saveEditorData(GameOptionItem optionItem) {
optionItem.value = ui->lineEdit->text();
}

View File

@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2023 Tayou <tayou@gmx.net>
*
* 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/>.
*/
#pragma once
#include <QString>
#include <QWidget>
#include "GameOptionWidget.h"
namespace Ui {
class GameOptionWidgetText;
}
class GameOptionWidgetText : public GameOptionWidget {
public:
void saveEditorData(GameOptionItem optionItem) override;
public:
explicit GameOptionWidgetText(QWidget* parent, const std::shared_ptr<GameOption>& knownOption);
~GameOptionWidgetText() override;
void setEditorData(GameOptionItem optionItem) override;
private:
Ui::GameOptionWidgetText* ui;
};

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameOptionWidgetText</class>
<widget class="QWidget" name="GameOptionWidgetText">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>55</height>
</rect>
</property>
<property name="windowTitle">
<string>GameOptionWidgetComboBox</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>↺</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>