diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-01-22 04:45:02 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-01-22 04:45:02 +0000 |
| commit | efa80ce427e40070e36e5ab86d2f6dbf4ad50648 (patch) | |
| tree | f7443dd268aa82e1819d00c141d98395b7a4a5a7 /pokemodr/RulesUI.cpp | |
| parent | a1fff27395d1930820e6c007fdedd8e9dc58f0b3 (diff) | |
| download | sigen-efa80ce427e40070e36e5ab86d2f6dbf4ad50648.tar.gz sigen-efa80ce427e40070e36e5ab86d2f6dbf4ad50648.tar.xz sigen-efa80ce427e40070e36e5ab86d2f6dbf4ad50648.zip | |
[FIX] Some linker errors in pokemod and general
[FIX] More enum char*[] to QStringList
[FIX] Widgets in PokéModr gui
[ADD] Rules GUI logic
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@39 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/RulesUI.cpp')
| -rw-r--r-- | pokemodr/RulesUI.cpp | 279 |
1 files changed, 279 insertions, 0 deletions
diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp new file mode 100644 index 00000000..9742fbe4 --- /dev/null +++ b/pokemodr/RulesUI.cpp @@ -0,0 +1,279 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/RulesUI.cpp +// Purpose: Rules UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Mon Jan 21 13:04:20 2008 +// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions +// Licence: +// 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, either version 3 of the License, or +// (at your option) any later version. +// +// 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 <http://www.gnu.org/licenses/>. +///////////////////////////////////////////////////////////////////////////// + +#include <QMetaObject> +#include "../general/BugCatcher.h" +#include "RulesUI.h" + +extern BugCatcher bugs; + +RulesUI::RulesUI(Rules& r, QWidget* parent) : + QWidget(parent), + rules(r.getPokemod(), r), + rules_mod(r.getPokemod(), r) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + varMaxDV->addItems(Rules::DVStr); + setGui(); +} + +void RulesUI::setGui() +{ + boxGenders->setChecked(rules_mod.getGenderAllowed() ? Qt::Checked : Qt::Unchecked); + varBreeding->setCheckState(rules_mod.getBreedingAllowed() ? Qt::Checked : Qt::Unchecked); + varHeldItems->setValue(rules_mod.getHoldItems()); + boxCriticalDomains->setChecked(rules_mod.getCriticalDomains() ? Qt::Checked : Qt::Unchecked); + boxAllowAbilities->setChecked(rules_mod.getAbilityAllowed() ? Qt::Checked : Qt::Unchecked); + boxAllowNatures->setChecked(rules_mod.getNatureAllowed() ? Qt::Checked : Qt::Unchecked); + varBoxes->setValue(rules_mod.getNumBoxes()); + varBoxSize->setValue(rules_mod.getBoxSize()); + varMaxParty->setValue(rules_mod.getMaxParty()); + varMaxFight->setValue(rules_mod.getMaxFight()); + varMaxMoves->setValue(rules_mod.getMaxMoves()); + varMaxLevel->setValue(rules_mod.getMaxLevel()); + varMaxMoney->setValue(rules_mod.getMaxMoney()); + boxHardCash->setChecked(rules_mod.getHardCash() ? Qt::Checked : Qt::Unchecked); + boxSplitSpecial->setChecked(rules_mod.getSpecialSplit() ? Qt::Checked : Qt::Unchecked); + varSplitSpecialDV->setCheckState(rules_mod.getSpecialDVSplit() ? Qt::Checked : Qt::Unchecked); + varMaxDV->setCurrentItem(Rules::DVStr[rules_mod.getMaxDVValue() >> 5]); + boxHappiness->setChecked(rules_mod.getHappiness() ? Qt::Checked : Qt::Unchecked); + varFaintLoss->setValue(rules_mod.getHappyFaintLoss()); + varLevelGain->setValue(rules_mod.getHappyLevelGain()); + varNumSteps->setValue(rules_mod.getHappySteps()); + boxEffortValues->setChecked(rules_mod.getEffortValuesAllowed() ? Qt::Checked : Qt::Unchecked); + varMaxEV->setValue(rules_mod.getMaxTotalEV()); + varMaxEVPerStat->setValue(rules_mod.getMaxEVPerStat()); + varPokerusNum->setValue(rules_mod.getPokerusChance().getNum()); + varPokerusDenom->setValue(rules_mod.getPokerusChance().getDenom()); +} + +void RulesUI::on_buttonApply_clicked() +{ + rules = rules_mod; +} + +void RulesUI::on_buttonDiscard_clicked() +{ + rules_mod = rules; +} + +void RulesUI::on_boxGenders_toggled(const bool g) +{ + rules_mod.setGenderAllowed(g); + if (!g) + varBreeding->setCheckState(Qt::Unchecked); +} + +void RulesUI::on_varBreeding_toggled(const bool b) throw(Exception) +{ + try + { + rules_mod.setBreedingAllowed(b); + } + catch (Exception& e) + { + bugs.report(e); + setGui(); + } +} + +void RulesUI::on_varHeldItems_valueChanged(const int h) +{ + rules_mod.setHoldItems(h); +} + +void RulesUI::on_boxCriticalDomains_toggled(const bool c) +{ + rules_mod.setCriticalDomains(c); +} + +void RulesUI::on_boxAllowAbilities_toggled(const bool a) +{ + rules_mod.setAbilityAllowed(a); +} + +void RulesUI::on_boxAllowNatures_toggled(const bool a) +{ + rules_mod.setNatureAllowed(a); +} + +void RulesUI::on_varBoxes_valueChanged(const int b) +{ + rules_mod.setNumBoxes(b); +} + +void RulesUI::on_varBoxSize_valueChanged(const int b) +{ + rules_mod.setBoxSize(b); +} + +void RulesUI::on_varMaxPartySize_valueChanged(const int m) throw(BoundsException) +{ + if (rules_mod.getMaxFight() < unsigned(m)) + varMaxFight->setValue(m); + rules_mod.setMaxParty(m); + varMaxFight->setMaximum(m); +} + +void RulesUI::on_varMaxFight_valueChanged(const int m) throw(BoundsException) +{ + try + { + rules_mod.setMaxFight(m); + } + catch (BoundsException& e) + { + setGui(); + } +} + +void RulesUI::on_varMaxMoves_valueChanged(const int m) throw(BoundsException) +{ + try + { + rules_mod.setMaxMoves(m); + } + catch (BoundsException& e) + { + bugs.report(e); + setGui(); + } +} + +void RulesUI::on_varMaxLevel_valueChanged(const int m) throw(BoundsException) +{ + try + { + rules_mod.setMaxLevel(m); + } + catch (BoundsException& e) + { + bugs.report(e); + setGui(); + } +} + +void RulesUI::on_varMaxMoney_valueChanged(const int m) +{ + rules_mod.setMaxMoney(m); +} + +void RulesUI::on_boxHardCash_toggled(const int h) +{ + rules_mod.setHardCash(h); +} + +void RulesUI::on_boxSplitSpecial_toggled(const bool s) +{ + rules_mod.setSpecialSplit(s); + if (!s) + varSplitSpecialDV->setCheckState(Qt::Unchecked); +} + +void RulesUI::on_varSplitSpecialDV_toggled(const bool s) +{ + rules_mod.setSpecialDVSplit(s); +} + +void RulesUI::on_varMaxDV_currentIndexChanged(const QString& m) throw(BoundsException) +{ + try + { + if (Rules::DVStr.contains(m)) + rules_mod.setMaxDVValue((Rules::DVStr.indexOf(m) << 4) + 16); + else + throw(BoundsException("RulesUI", "maxDVValue")); + } + catch (BoundsException& e) + { + bugs.report(e); + setGui(); + } +} + +void RulesUI::on_boxHappiness_toggled(const bool h) +{ + rules_mod.setHappiness(h); +} + +void RulesUI::on_varFaintLoss_valueChanged(const int f) +{ + rules_mod.setHappyFaintLoss(f); +} + +void RulesUI::on_varLevelGain_valueChanged(const int l) +{ + rules_mod.setHappyLevelGain(l); +} + +void RulesUI::on_varNumSteps_valueChanged(const int n) +{ + rules_mod.setHappySteps(n); +} + +void RulesUI::on_boxEffortValues_toggled(const int e) +{ + rules_mod.setEffortValuesAllowed(e); +} + +void RulesUI::on_varMaxEV_valueChanged(const int m) throw(Exception) +{ + if (rules_mod.getMaxEVPerStat() < unsigned(m)) + varMaxEVPerStat->setValue(m); + rules_mod.setMaxTotalEV(m); + varMaxEVPerStat->setMaximum(m); +} + +void RulesUI::on_varMaxEVPerStat_valueChanged(const int m) throw(Exception) +{ + rules_mod.setMaxEVPerStat(m); +} + +void RulesUI::on_varPokerusNum_valueChanged(const int p) throw(Exception) +{ + try + { + rules_mod.setPokerusChanceNum(p); + varPokerus->setText(QString::number(rules_mod.getPokerusChance())); + } + catch (Exception& e) + { + bugs.report(e); + setGui(); + } +} + +void RulesUI::on_varPokerusDenom_valueChanged(const int p) throw(Exception) +{ + try + { + rules_mod.setPokerusChanceDenom(p); + varPokerusNum->setMaximum(p - 1); + varPokerus->setText(QString::number(rules_mod.getPokerusChance())); + } + catch (Exception& e) + { + bugs.report(e); + setGui(); + } +} |
