Skip to content

Commit

Permalink
Event pages: Allow changing of event conditions
Browse files Browse the repository at this point in the history
The event conditions can be set now.
  • Loading branch information
rueter37 committed Nov 30, 2021
1 parent 8c0ea69 commit 9040d9b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 31 deletions.
6 changes: 6 additions & 0 deletions src/ui/common/rpg_combobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public slots:
QObject::connect(diag, SIGNAL(valueSelected(int)), this, SLOT(indexChanged(int)));
}

signals:
void currentIndexChanged(int);

protected:
QComboBox* m_comboBox;
};
Expand Down Expand Up @@ -101,6 +104,7 @@ class RpgComboBox : public RpgComboBoxBase

void indexChanged(int index) override {
m_comboBox->setCurrentIndex(index);
emit currentIndexChanged(index);
};

private:
Expand Down Expand Up @@ -144,6 +148,8 @@ RpgComboBox<LCF>::RpgComboBox(QWidget *parent, QAbstractItemModel *model) :
connect(dialog);
dialog->exec();
});

QObject::connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int)));
}

using ActorRpgComboBox = RpgComboBox<lcf::rpg::Actor>;
Expand Down
54 changes: 25 additions & 29 deletions src/ui/event/event_page_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ void EventPageWidget::setEventPage(lcf::rpg::EventPage *eventPage)
{
m_eventPage = eventPage;
ui->checkSwitchA->setChecked(eventPage->condition.flags.switch_a);
ui->comboSwitchA->setCurrentIndex(eventPage->condition.switch_a_id-1);
ui->checkSwitchB->setChecked(eventPage->condition.flags.switch_b);
ui->comboSwitchB->setCurrentIndex(eventPage->condition.switch_b_id-1);
ui->checkVar->setChecked(eventPage->condition.flags.variable);
ui->comboVariable->setCurrentIndex(eventPage->condition.variable_id-1);
ui->comboVarOperation->setCurrentIndex(eventPage->condition.compare_operator);
ui->spinVarValue->setValue(eventPage->condition.variable_value);
ui->checkItem->setChecked(eventPage->condition.flags.item);
Expand Down Expand Up @@ -112,51 +115,44 @@ void EventPageWidget::on_checkSwitchA_toggled(bool checked)
{
if (!m_eventPage)
return;
if (checked) {
//int switchId = m_eventPage->condition.switch_a_id-1;
//ui->lineSwitchA->setText(formatSwitchCondition(switchId));
}
else {
//ui->lineSwitchA->setText("");
}
m_eventPage->condition.flags.switch_a = checked;
}

void EventPageWidget::on_comboSwitchA_currentIndexChanged(int index)
{
if (!m_eventPage)
return;
m_eventPage->condition.switch_a_id = index+1;
}

void EventPageWidget::on_checkSwitchB_toggled(bool checked)
{
if (!m_eventPage)
return;
if (checked) {
//int switchId = m_eventPage->condition.switch_b_id-1;
//ui->lineSwitchB->setText(formatSwitchCondition(switchId));
}
else {
//ui->lineSwitchB->setText("");
}
m_eventPage->condition.flags.switch_b = checked;
}

void EventPageWidget::on_comboSwitchB_currentIndexChanged(int index)
{
if (!m_eventPage)
return;
m_eventPage->condition.switch_b_id = index+1;
}

void EventPageWidget::on_checkVar_toggled(bool checked)
{
if (!m_eventPage)
return;
/*if (checked) {
int varId = m_eventPage->condition.variable_id;
if (varId >= 1 && varId <= static_cast<int>(core().project()->database().variables.size())) {
ui->lineVar->setText(QString("%1: %2").arg(varId)
.arg(ToQString
(core().project()->database().variables[static_cast<size_t>(varId) - 1].name)));
}
else {
ui->lineVar->setText(QString("%1: ???").arg(varId));
}
}
else {
ui->lineVar->setText("");
}*/
m_eventPage->condition.flags.variable = checked;
}

void EventPageWidget::on_comboVariable_currentIndexChanged(int index)
{
if (!m_eventPage)
return;
m_eventPage->condition.variable_id = index+1;
}

void EventPageWidget::on_checkItem_toggled(bool checked)
{
if (!m_eventPage)
Expand Down Expand Up @@ -196,7 +192,7 @@ void EventPageWidget::on_checkHero_toggled(bool checked)
{
if (!m_eventPage)
return;
m_eventPage->condition.flags.item = checked;
m_eventPage->condition.flags.actor = checked;
}

void EventPageWidget::on_checkTimerA_toggled(bool checked)
Expand Down
6 changes: 6 additions & 0 deletions src/ui/event/event_page_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ private slots:

void on_checkSwitchA_toggled(bool checked);

void on_comboSwitchA_currentIndexChanged(int index);

void on_checkSwitchB_toggled(bool checked);

void on_comboSwitchB_currentIndexChanged(int index);

void on_checkVar_toggled(bool checked);

void on_comboVariable_currentIndexChanged(int index);

void on_checkItem_toggled(bool checked);

void on_comboVarOperation_currentIndexChanged(int index);
Expand Down
31 changes: 29 additions & 2 deletions src/ui/event/event_page_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
</item>
<item row="0" column="1">
<widget class="SwitchRpgComboBox" name="comboSwitchA">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -53,6 +56,9 @@
</item>
<item row="1" column="1">
<widget class="SwitchRpgComboBox" name="comboSwitchB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -77,6 +83,9 @@
</item>
<item row="2" column="1">
<widget class="VariableRpgComboBox" name="comboVariable">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -117,7 +126,7 @@
</item>
<item>
<property name="text">
<string>Greather than (&gt;)</string>
<string>Greater than (&gt;)</string>
</property>
</item>
<item>
Expand Down Expand Up @@ -226,7 +235,7 @@
<bool>false</bool>
</property>
<property name="suffix">
<string> seconds or less</string>
<string> seconds or less</string>
</property>
<property name="maximum">
<number>59</number>
Expand Down Expand Up @@ -729,6 +738,24 @@
</customwidgets>
<resources/>
<connections>
<connection>
<sender>checkSwitchA</sender>
<signal>toggled(bool)</signal>
<receiver>comboSwitchA</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>checkSwitchB</sender>
<signal>toggled(bool)</signal>
<receiver>comboSwitchB</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>checkVar</sender>
<signal>toggled(bool)</signal>
<receiver>comboVariable</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>checkVar</sender>
<signal>toggled(bool)</signal>
Expand Down

0 comments on commit 9040d9b

Please sign in to comment.