From 3b64ddaba2d77b139bd0932a7e91459a411b8434 Mon Sep 17 00:00:00 2001 From: enderslash1010 <64379743+enderslash1010@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:11:22 -0600 Subject: [PATCH] options panel complete --- gui/mainwindow.cpp | 58 +++- gui/mainwindow.h | 6 +- gui/mainwindow.ui | 689 ++++++++++++++++++++++++++++++++++++-- include/QExtendedWidget.h | 50 ++- include/SaveFile.h | 42 +-- 5 files changed, 796 insertions(+), 49 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 3a6de1e..276f715 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -166,7 +166,7 @@ inline void MainWindow::connect(SaveFieldID sfID, QExtendedLineEdit* lineEdit, T } // QCheckBox -inline void MainWindow::connect(SaveFieldID sfID, QExtendedCheckBox* checkBox) +inline void MainWindow::connect(SaveFieldID sfID, QExtendedCheckBox* checkBox, bool invert = false) { Q_ASSERT(QObject::connect(checkBox, &QCheckBox::stateChanged, this, &MainWindow::updateCheckBox)); @@ -175,6 +175,8 @@ inline void MainWindow::connect(SaveFieldID sfID, QExtendedCheckBox* checkBox) checkBox->setSaveFieldID(sfID); saveFieldMap.insert({sfID, {checkBox, Type::BOOL_T}}); + + checkBox->setInverted(invert); } // QComboBox @@ -234,6 +236,19 @@ void MainWindow::connect(SaveFieldID sfID, QExtendedRadioButtons* radioButtonFra saveFieldMap.insert({sfID, {radioButtonFrame, Type::UINT_T}}); } +// QSlider +void MainWindow::connect(SaveFieldID sfID, QExtendedSlider* slider, int start, int spacing, int count) +{ + QObject::connect(slider, &QSlider::valueChanged, this, &MainWindow::updateSlider); + + slider->setProperty(SAVE_FIELD_PROPERTY, sfID); + slider->setSaveFieldID(sfID); + + saveFieldMap.insert({sfID, {slider, Type::UINT_T}}); + + slider->setScaling(start, spacing, count); +} + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -334,6 +349,35 @@ MainWindow::MainWindow(QWidget *parent) std::unordered_map OPTDJapaneseVoiceMap = {{"0", ui->OPTDJapaneseVoice0}, {"1", ui->OPTDJapaneseVoice1}}; connect(OPTDJapaneseVoice, ui->OPTDJapaneseVoice, OPTDJapaneseVoiceMap); + connect(OPTDGamma, ui->OPTDGamma, 8, 2, 5); + connect(OPTDShowControls, ui->OPTDShowControls); + connect(OPTDShowArtDescriptions, ui->OPTDShowArtDescriptions); + connect(OPTDShowEnemyIcons, ui->OPTDShowEnemyIcons); + connect(OPTDShowBuffDebuffInfoEveryTime, ui->OPTDShowBuffDebuffInfoEveryTime); + connect(OPTDShowBuffDefbuffIndicator, ui->OPTDShowBuffDefbuffIndicator); + connect(OPTDShowDestinationMarker, ui->OPTDShowDestinationMarker); + + connect(OPTDXAxisSpeed, ui->OPTDXAxisSpeed, 4, -1, 5); + connect(OPTDNonInvertedXAxis, ui->OPTDNonInvertedXAxis, true); + connect(OPTDYAxisSpeed, ui->OPTDYAxisSpeed, 4, -1, 5); + connect(OPTDNonInvertedYAxis, ui->OPTDNonInvertedYAxis, true); + connect(OPTDZoomSpeed, ui->OPTDZoomSpeed, 4, -1, 5); + connect(OPTDPointOfView, ui->OPTDPointOfView, 2, -1, 3); + connect(OPTDAngleCorrection, ui->OPTDAngleCorrection); + connect(OPTDBattleCamera, ui->OPTDBattleCamera); + + connect(OPTDMinimapOn, ui->OPTDMinimapOn); + connect(OPTDShowSubtitles, ui->OPTDShowSubtitles); + + std::unordered_map OPTDMinimapRotateMap = {{"0", ui->OPTDMinimapRotate0}, {"1", ui->OPTDMinimapRotate1}}; + connect(OPTDMinimapRotate, ui->OPTDMinimapRotate, OPTDMinimapRotateMap); + + std::unordered_map OPTDAutoEventScrollingMap = {{"0", ui->OPTDAutoEventScrolling0}, {"1", ui->OPTDAutoEventScrolling1}}; + connect(OPTDAutoEventScrolling, ui->OPTDAutoEventScrolling, OPTDAutoEventScrollingMap); + + std::unordered_map OPTDFastDialogueTextMap = {{"0", ui->OPTDFastDialogueText0}, {"1", ui->OPTDFastDialogueText1}}; + connect(OPTDFastDialogueText, ui->OPTDFastDialogueText, OPTDFastDialogueTextMap); + for (int i = 0; i < LAST_INDEX; i++) setFieldEnabled((SaveFieldID)i, false); } @@ -529,7 +573,7 @@ void MainWindow::updateComboBox() } } -void MainWindow::updateRadioButton(int isChecked) +void MainWindow::updateRadioButton() { QObject* obj = sender(); SaveFieldID sfID = (SaveFieldID)obj->property(SAVE_FIELD_PROPERTY).toInt(); @@ -539,6 +583,16 @@ void MainWindow::updateRadioButton(int isChecked) this->setField(sfID); } +void MainWindow::updateSlider() +{ + QObject* obj = sender(); + SaveFieldID sfID = (SaveFieldID)obj->property(SAVE_FIELD_PROPERTY).toInt(); + QExtendedWidget* slider = saveFieldMap.at(sfID).first; + + saveFile->setValue(sfID, slider->getField().toUInt()); + this->setField(sfID); +} + void MainWindow::updateChildMapping() { QObject* obj = sender(); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 7c8ca40..9c06d55 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -27,10 +27,11 @@ class MainWindow : public QMainWindow SaveFile *saveFile = NULL; void connect(SaveFieldID sfID, QExtendedLineEdit* lineEdit, Type type); - void connect(SaveFieldID sfID, QExtendedCheckBox* checkBox); + void connect(SaveFieldID sfID, QExtendedCheckBox* checkBox, bool invert); void connect(SaveFieldID sfID, QExtendedComboBox* comboBox, const Mapping* mapping); void connect(SaveFieldID sfID, QExtendedComboBox* thisComboBox, QExtendedComboBox* sourceComboBox, std::vector& dynamicMapping); void connect(SaveFieldID sfID, QExtendedRadioButtons* radioButtonFrame, std::unordered_map& rbs); + void connect(SaveFieldID sfID, QExtendedSlider* slider, int start, int spacing, int count); void setField(SaveFieldID sfID); QString getField(SaveFieldID sfID); @@ -45,7 +46,8 @@ private slots: void updateText(); void updateCheckBox(); void updateComboBox(); - void updateRadioButton(int isChecked); + void updateRadioButton(); + void updateSlider(); void updateChildMapping(); }; diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index e4b656c..f38d29a 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -9,8 +9,8 @@ 0 0 - 958 - 557 + 1204 + 641 @@ -1572,19 +1572,6 @@ Options - - - - Qt::Orientation::Vertical - - - - 20 - 40 - - - - @@ -1606,7 +1593,7 @@ - Language: + Voice Language: @@ -1627,15 +1614,668 @@ - - + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Brighter + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + Dark + + + + + + + Normal + + + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter + + + + + + + Bright + + + Qt::AlignmentFlag::AlignCenter + + + + + + + Brightest + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + 0 + + + 4 + + + 1 + + + 0 + + + true + + + Qt::Orientation::Horizontal + + + false + + + QSlider::TickPosition::TicksBelow + + + 1 + + + + + + + Brightness: + + + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Display Controls + + + + + + + Show Art Descriptions + + + + + + + Show Enemy Icons + + + + + + + Always Show Buff/Debuff Info + + + + + + + Show Buff/Debuff Indicator + + + + + + + Show Destination Marker + + + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Rotate + + + + + + + Fixed + + + + + + + Rotation: + + + + + + + + + + + 0 + 0 + + + + Display Minimap + + + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Y-Axis Speed: + + + + + + + Slow + + + + + + + 4 + + + Qt::Orientation::Horizontal + + + QSlider::TickPosition::TicksBelow + + + + + + + Normal + + + Qt::AlignmentFlag::AlignCenter + + + + + + + Fast + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + Inverted + + + + + + + Slowest + + + + + + + Fastest + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + + + Battle Camera + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Fast + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + X-Axis Speed: + + + + + + + 4 + + + Qt::Orientation::Horizontal + + + QSlider::TickPosition::TicksBelow + + + + + + + Slowest + + + + + + + Normal + + + Qt::AlignmentFlag::AlignCenter + + + + + + + Slow + + + + + + + Inverted + + + + + + + Fastest + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + + + Angle Correction + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Point of View: + + + + + + + Normal + + + Qt::AlignmentFlag::AlignCenter + + + + + + + Low + + + + + + + High + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + 2 + + + Qt::Orientation::Horizontal + + + QSlider::TickPosition::TicksBelow + + + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Zoom Speed: + + + + + + + Normal + + + Qt::AlignmentFlag::AlignCenter + + + + + + + Fast + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + Slow + + + + + + + Slowest + + + + + + + Fastest + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + 4 + + + Qt::Orientation::Horizontal + + + QSlider::TickPosition::TicksBelow + + + + + + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Manual + + + + + + + Automatic + + + + + + + Event Scrolling: + + + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + Fast + + + + + + + Text Speed: + + + + + + + Normal + + + + + + + + + + Show Subtitles + + + + + + + + - Qt::Orientation::Horizontal + Qt::Orientation::Vertical - 40 - 20 + 20 + 40 @@ -1656,7 +2296,7 @@ 0 0 - 958 + 1204 25 @@ -1702,6 +2342,11 @@
QExtendedWidget.h
1 + + QExtendedSlider + QSlider +
QExtendedWidget.h
+
diff --git a/include/QExtendedWidget.h b/include/QExtendedWidget.h index 554ad14..bb4f00c 100644 --- a/include/QExtendedWidget.h +++ b/include/QExtendedWidget.h @@ -69,11 +69,19 @@ class QExtendedLineEdit : public QLineEdit, public QExtendedWidget class QExtendedCheckBox : public QCheckBox, public QExtendedWidget { Q_OBJECT + bool inverted = false; public: QExtendedCheckBox(QWidget* parent = nullptr) : QCheckBox(parent) { } - void setField(QString value) { this->setChecked(QString::compare(value, "0")); } - QString getField() { return this->isChecked() ? "1" : "0"; } + void setField(QString value) + { + inverted ? this->setChecked(!QString::compare(value, "0")) : this->setChecked(QString::compare(value, "0")); + } + QString getField() + { + return inverted ? (this->isChecked() ? "1" : "0") : (this->isChecked() ? "1" : "0"); + } void setFieldEnabled(bool enabled) { this->setEnabled(enabled); } + void setInverted(bool inverted) { this->inverted = inverted; } }; class QExtendedComboBox : public QComboBox, public QExtendedWidget @@ -152,3 +160,41 @@ class QExtendedRadioButtons : public QFrame, public QExtendedWidget for (auto i = valueToButtonMapping.begin(); i != valueToButtonMapping.end(); ++i) i->second->setEnabled(enabled); } }; + +class QExtendedSlider : public QSlider, public QExtendedWidget +{ + Q_OBJECT + std::vector sliderToRawValue; +public: + QExtendedSlider(QWidget* parent = nullptr) : QSlider(parent) { } + + void setField(QString value) + { + int rawValue = value.toInt(); + for (int i = 0; i < sliderToRawValue.size(); i++) + { + if (sliderToRawValue.at(i) == rawValue) + { + this->setSliderPosition(i); + break; + } + } + } + + QString getField() + { + return QString::number(sliderToRawValue.at(this->value())); + } + + void setFieldEnabled(bool enabled) { this->setEnabled(enabled); } + + void setScaling(int start, int spacing, int count) + { + sliderToRawValue.clear(); + while (count-- > 0) + { + sliderToRawValue.push_back(start); + start += spacing; + } + } +}; diff --git a/include/SaveFile.h b/include/SaveFile.h index cc6bd3b..12e0525 100644 --- a/include/SaveFile.h +++ b/include/SaveFile.h @@ -167,27 +167,27 @@ class SaveFile }), // OPTD - new DataObject(0x248B0, 1, BOOL_T), // OPTDNonInvertedYAxis - new DataObject(0x248B1, 1, BOOL_T), // OPTDNonInvertedXAxis - new DataObject(0x248B2, 1, UINT_T), // OPTDYAxisSpeed - new DataObject(0x248B3, 1, UINT_T), // OPTDXAxisSpeed - new DataObject(0x248B4, 1, UINT_T), // OPTDZoomSpeed - new DataObject(0x248B5, 1, UINT_T), // OPTDPointOfView - new DataObject(0x248B6, 1, BOOL_T), // OPTDAngleCorrection - new DataObject(0x248B7, 1, BOOL_T), // OPTDBattleCamera - new DataObject(0x248BF, 1, UINT_T), // OPTDGamma - new DataObject(0x248C0, 1, BOOL_T), // OPTDMinimapOn - new DataObject(0x248C1, 1, BOOL_T), // OPTDMinimapRotate - new DataObject(0x248CC, 1, BOOL_T), // OPTDJapaneseVoice - new DataObject(0x248D0, 1, BOOL_T), // OPTDShowControls - new DataObject(0x248D1, 1, BOOL_T), // OPTDShowArtDescriptions - new DataObject(0x248D2, 1, BOOL_T), // OPTDShowBuffDebuffInfoEveryTime - new DataObject(0x248D3, 1, BOOL_T), // OPTDShowEnemyIcons - new DataObject(0x248D4, 1, BOOL_T), // OPTDShowBuffDefbuffIndicator - new DataObject(0x248D5, 1, BOOL_T), // OPTDShowDestinationMarker - new DataObject(0x248E0, 1, BOOL_T), // OPTDAutoEventScrolling - new DataObject(0x248E1, 1, BOOL_T), // OPTDFastDialogueText - new DataObject(0x248E2, 1, BOOL_T) // OPTDShowSubtitles + new DataObject(0x248B0, 1, BOOL_T), // OPTDNonInvertedYAxis* + new DataObject(0x248B1, 1, BOOL_T), // OPTDNonInvertedXAxis* + new DataObject(0x248B2, 1, UINT_T), // OPTDYAxisSpeed* + new DataObject(0x248B3, 1, UINT_T), // OPTDXAxisSpeed* + new DataObject(0x248B4, 1, UINT_T), // OPTDZoomSpeed* + new DataObject(0x248B5, 1, UINT_T), // OPTDPointOfView* + new DataObject(0x248B6, 1, BOOL_T), // OPTDAngleCorrection* + new DataObject(0x248B7, 1, BOOL_T), // OPTDBattleCamera* + new DataObject(0x248BF, 1, UINT_T), // OPTDGamma* + new DataObject(0x248C0, 1, BOOL_T), // OPTDMinimapOn* + new DataObject(0x248C1, 1, BOOL_T), // OPTDMinimapRotate* + new DataObject(0x248CC, 1, BOOL_T), // OPTDJapaneseVoice* + new DataObject(0x248D0, 1, BOOL_T), // OPTDShowControls* + new DataObject(0x248D1, 1, BOOL_T), // OPTDShowArtDescriptions* + new DataObject(0x248D2, 1, BOOL_T), // OPTDShowBuffDebuffInfoEveryTime* + new DataObject(0x248D3, 1, BOOL_T), // OPTDShowEnemyIcons* + new DataObject(0x248D4, 1, BOOL_T), // OPTDShowBuffDefbuffIndicator* + new DataObject(0x248D5, 1, BOOL_T), // OPTDShowDestinationMarker* + new DataObject(0x248E0, 1, BOOL_T), // OPTDAutoEventScrolling* + new DataObject(0x248E1, 1, BOOL_T), // OPTDFastDialogueText* + new DataObject(0x248E2, 1, BOOL_T) // OPTDShowSubtitles* }; public: