Skip to content

Commit

Permalink
options panel complete
Browse files Browse the repository at this point in the history
  • Loading branch information
enderslash1010 committed Jan 2, 2025
1 parent bd93853 commit 3b64dda
Show file tree
Hide file tree
Showing 5 changed files with 796 additions and 49 deletions.
58 changes: 56 additions & 2 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -334,6 +349,35 @@ MainWindow::MainWindow(QWidget *parent)
std::unordered_map<QString, QRadioButton*> 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<QString, QRadioButton*> OPTDMinimapRotateMap = {{"0", ui->OPTDMinimapRotate0}, {"1", ui->OPTDMinimapRotate1}};
connect(OPTDMinimapRotate, ui->OPTDMinimapRotate, OPTDMinimapRotateMap);

std::unordered_map<QString, QRadioButton*> OPTDAutoEventScrollingMap = {{"0", ui->OPTDAutoEventScrolling0}, {"1", ui->OPTDAutoEventScrolling1}};
connect(OPTDAutoEventScrolling, ui->OPTDAutoEventScrolling, OPTDAutoEventScrollingMap);

std::unordered_map<QString, QRadioButton*> OPTDFastDialogueTextMap = {{"0", ui->OPTDFastDialogueText0}, {"1", ui->OPTDFastDialogueText1}};
connect(OPTDFastDialogueText, ui->OPTDFastDialogueText, OPTDFastDialogueTextMap);

for (int i = 0; i < LAST_INDEX; i++) setFieldEnabled((SaveFieldID)i, false);
}

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const Mapping*>& dynamicMapping);
void connect(SaveFieldID sfID, QExtendedRadioButtons* radioButtonFrame, std::unordered_map<QString, QRadioButton*>& rbs);
void connect(SaveFieldID sfID, QExtendedSlider* slider, int start, int spacing, int count);

void setField(SaveFieldID sfID);
QString getField(SaveFieldID sfID);
Expand All @@ -45,7 +46,8 @@ private slots:
void updateText();
void updateCheckBox();
void updateComboBox();
void updateRadioButton(int isChecked);
void updateRadioButton();
void updateSlider();

void updateChildMapping();
};
Expand Down
Loading

0 comments on commit 3b64dda

Please sign in to comment.