From 0fa52c1f61c457c9b68bec53bcce3af858e5eb44 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 27 Apr 2008 17:57:32 +0000 Subject: [FIX] More header cleanliness [FIX] UI classes now just use the ObjectUI pointers [FIX] Some miscellaneous qmake options git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@112 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/RulesUI.cpp | 124 ++++++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 60 deletions(-) (limited to 'pokemodr/RulesUI.cpp') diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp index be5f7342..b63a935e 100644 --- a/pokemodr/RulesUI.cpp +++ b/pokemodr/RulesUI.cpp @@ -18,22 +18,26 @@ // Header include #include "RulesUI.h" +// Pokemod includes +#include "../pokemod/Rules.h" + // General includes #include "../general/BugCatcher.h" -#include "../general/Exception.h" RulesUI::RulesUI(Rules* rules, QWidget* parent) : - ObjectUI(parent), - m_rules(rules), - m_rules_mod(new Rules(*rules)) + ObjectUI(parent) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(m_rules, m_rules_mod); + setObjects(rules, new Rules(*rules)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } +RulesUI::~RulesUI() +{ +} + void RulesUI::initGui() { varMaxDV->addItems(Rules::DVStr); @@ -41,104 +45,104 @@ void RulesUI::initGui() void RulesUI::setGui() { - boxGenders->setChecked(m_rules_mod->genderAllowed() ? Qt::Checked : Qt::Unchecked); - varBreeding->setCheckState(m_rules_mod->breedingAllowed() ? Qt::Checked : Qt::Unchecked); - varHeldItems->setValue(m_rules_mod->holdItems()); - boxCriticalDomains->setChecked(m_rules_mod->criticalDomains() ? Qt::Checked : Qt::Unchecked); - boxAllowAbilities->setChecked(m_rules_mod->abilityAllowed() ? Qt::Checked : Qt::Unchecked); - boxAllowNatures->setChecked(m_rules_mod->natureAllowed() ? Qt::Checked : Qt::Unchecked); - varBoxes->setValue(m_rules_mod->numBoxes()); - if (m_rules_mod->numBoxes()) + boxGenders->setChecked(static_cast(modified())->genderAllowed() ? Qt::Checked : Qt::Unchecked); + varBreeding->setCheckState(static_cast(modified())->breedingAllowed() ? Qt::Checked : Qt::Unchecked); + varHeldItems->setValue(static_cast(modified())->holdItems()); + boxCriticalDomains->setChecked(static_cast(modified())->criticalDomains() ? Qt::Checked : Qt::Unchecked); + boxAllowAbilities->setChecked(static_cast(modified())->abilityAllowed() ? Qt::Checked : Qt::Unchecked); + boxAllowNatures->setChecked(static_cast(modified())->natureAllowed() ? Qt::Checked : Qt::Unchecked); + varBoxes->setValue(static_cast(modified())->numBoxes()); + if (static_cast(modified())->numBoxes()) varBoxSize->setEnabled(true); else varBoxSize->setEnabled(false); - varBoxSize->setValue(m_rules_mod->boxSize()); - varMaxParty->setValue(m_rules_mod->maxParty()); - varMaxFight->setMaximum(m_rules_mod->maxParty()); - varMaxFight->setValue(m_rules_mod->maxFight()); - varMaxMoves->setValue(m_rules_mod->maxMoves()); - varMaxLevel->setValue(m_rules_mod->maxLevel()); - varMaxMoney->setValue(m_rules_mod->maxMoney()); - boxHardCash->setChecked(m_rules_mod->hardCash() ? Qt::Checked : Qt::Unchecked); - boxSplitSpecial->setChecked(m_rules_mod->specialSplit() ? Qt::Checked : Qt::Unchecked); - varSplitSpecialDV->setCheckState(m_rules_mod->specialDVSplit() ? Qt::Checked : Qt::Unchecked); - varMaxDV->setCurrentIndex(m_rules_mod->maxDVValue()); - boxHappiness->setChecked(m_rules_mod->happiness() ? Qt::Checked : Qt::Unchecked); - varFaintLoss->setValue(m_rules_mod->happyFaintLoss()); - varLevelGain->setValue(m_rules_mod->happyLevelGain()); - varNumSteps->setValue(m_rules_mod->happySteps()); - boxEffortValues->setChecked(m_rules_mod->effortValuesAllowed() ? Qt::Checked : Qt::Unchecked); - varMaxEV->setValue(m_rules_mod->maxTotalEV()); - varMaxEVPerStat->setMaximum(m_rules_mod->maxTotalEV()); - varMaxEVPerStat->setValue(m_rules_mod->maxEVPerStat()); - varPokerus->setValue(m_rules_mod->pokerusChance()); + varBoxSize->setValue(static_cast(modified())->boxSize()); + varMaxParty->setValue(static_cast(modified())->maxParty()); + varMaxFight->setMaximum(static_cast(modified())->maxParty()); + varMaxFight->setValue(static_cast(modified())->maxFight()); + varMaxMoves->setValue(static_cast(modified())->maxMoves()); + varMaxLevel->setValue(static_cast(modified())->maxLevel()); + varMaxMoney->setValue(static_cast(modified())->maxMoney()); + boxHardCash->setChecked(static_cast(modified())->hardCash() ? Qt::Checked : Qt::Unchecked); + boxSplitSpecial->setChecked(static_cast(modified())->specialSplit() ? Qt::Checked : Qt::Unchecked); + varSplitSpecialDV->setCheckState(static_cast(modified())->specialDVSplit() ? Qt::Checked : Qt::Unchecked); + varMaxDV->setCurrentIndex(static_cast(modified())->maxDVValue()); + boxHappiness->setChecked(static_cast(modified())->happiness() ? Qt::Checked : Qt::Unchecked); + varFaintLoss->setValue(static_cast(modified())->happyFaintLoss()); + varLevelGain->setValue(static_cast(modified())->happyLevelGain()); + varNumSteps->setValue(static_cast(modified())->happySteps()); + boxEffortValues->setChecked(static_cast(modified())->effortValuesAllowed() ? Qt::Checked : Qt::Unchecked); + varMaxEV->setValue(static_cast(modified())->maxTotalEV()); + varMaxEVPerStat->setMaximum(static_cast(modified())->maxTotalEV()); + varMaxEVPerStat->setValue(static_cast(modified())->maxEVPerStat()); + varPokerus->setValue(static_cast(modified())->pokerusChance()); } void RulesUI::on_buttonApply_clicked() { - *m_rules = *m_rules_mod; + *static_cast(original()) = *static_cast(modified()); emit(changed(false)); } void RulesUI::on_buttonDiscard_clicked() { - *m_rules_mod = *m_rules; + *static_cast(modified()) = *static_cast(original()); setGui(); emit(changed(false)); } void RulesUI::on_boxGenders_toggled(const bool genders) { - m_rules_mod->setGenderAllowed(genders); + static_cast(modified())->setGenderAllowed(genders); emit(changed(true)); } void RulesUI::on_varBreeding_toggled(const bool breeding) { - m_rules_mod->setBreedingAllowed(breeding); + static_cast(modified())->setBreedingAllowed(breeding); emit(changed(true)); } void RulesUI::on_varHeldItems_valueChanged(const int heldItems) { - m_rules_mod->setHoldItems(heldItems); + static_cast(modified())->setHoldItems(heldItems); emit(changed(true)); } void RulesUI::on_boxCriticalDomains_toggled(const bool criticalDomains) { - m_rules_mod->setCriticalDomains(criticalDomains); + static_cast(modified())->setCriticalDomains(criticalDomains); emit(changed(true)); } void RulesUI::on_boxAllowAbilities_toggled(const bool allowAbilities) { - m_rules_mod->setAbilityAllowed(allowAbilities); + static_cast(modified())->setAbilityAllowed(allowAbilities); emit(changed(true)); } void RulesUI::on_boxAllowNatures_toggled(const bool allowNatures) { - m_rules_mod->setNatureAllowed(allowNatures); + static_cast(modified())->setNatureAllowed(allowNatures); emit(changed(true)); } void RulesUI::on_varBoxes_valueChanged(const int boxes) { - m_rules_mod->setNumBoxes(boxes); + static_cast(modified())->setNumBoxes(boxes); emit(changed(true)); setGui(); } void RulesUI::on_varBoxSize_valueChanged(const int boxSize) { - m_rules_mod->setBoxSize(boxSize); + static_cast(modified())->setBoxSize(boxSize); emit(changed(true)); } void RulesUI::on_varMaxParty_valueChanged(const int maxParty) { - m_rules_mod->setMaxParty(maxParty); + static_cast(modified())->setMaxParty(maxParty); emit(changed(true)); setGui(); } @@ -147,7 +151,7 @@ void RulesUI::on_varMaxFight_valueChanged(const int maxFight) { try { - m_rules_mod->setMaxFight(maxFight); + static_cast(modified())->setMaxFight(maxFight); emit(changed(true)); } catch (BoundsException& exception) @@ -161,7 +165,7 @@ void RulesUI::on_varMaxMoves_valueChanged(const int maxMoves) { try { - m_rules_mod->setMaxMoves(maxMoves); + static_cast(modified())->setMaxMoves(maxMoves); emit(changed(true)); } catch (BoundsException& exception) @@ -175,7 +179,7 @@ void RulesUI::on_varMaxLevel_valueChanged(const int maxLevel) { try { - m_rules_mod->setMaxLevel(maxLevel); + static_cast(modified())->setMaxLevel(maxLevel); emit(changed(true)); } catch (BoundsException& exception) @@ -187,25 +191,25 @@ void RulesUI::on_varMaxLevel_valueChanged(const int maxLevel) void RulesUI::on_varMaxMoney_valueChanged(const int maxMoney) { - m_rules_mod->setMaxMoney(maxMoney); + static_cast(modified())->setMaxMoney(maxMoney); emit(changed(true)); } void RulesUI::on_boxHardCash_toggled(const bool hardCash) { - m_rules_mod->setHardCash(hardCash); + static_cast(modified())->setHardCash(hardCash); emit(changed(true)); } void RulesUI::on_boxSplitSpecial_toggled(const bool splitSpecial) { - m_rules_mod->setSpecialSplit(splitSpecial); + static_cast(modified())->setSpecialSplit(splitSpecial); emit(changed(true)); } void RulesUI::on_varSplitSpecialDV_toggled(const bool splitSpecialDV) { - m_rules_mod->setSpecialDVSplit(splitSpecialDV); + static_cast(modified())->setSpecialDVSplit(splitSpecialDV); emit(changed(true)); } @@ -213,7 +217,7 @@ void RulesUI::on_varMaxDV_currentIndexChanged(const int maxDV) { try { - m_rules_mod->setMaxDVValue(maxDV); + static_cast(modified())->setMaxDVValue(maxDV); emit(changed(true)); } catch (BoundsException& exception) @@ -225,31 +229,31 @@ void RulesUI::on_varMaxDV_currentIndexChanged(const int maxDV) void RulesUI::on_boxHappiness_toggled(const bool happiness) { - m_rules_mod->setHappiness(happiness); + static_cast(modified())->setHappiness(happiness); emit(changed(true)); } void RulesUI::on_varFaintLoss_valueChanged(const int faintLoss) { - m_rules_mod->setHappyFaintLoss(faintLoss); + static_cast(modified())->setHappyFaintLoss(faintLoss); emit(changed(true)); } void RulesUI::on_varLevelGain_valueChanged(const int levelGain) { - m_rules_mod->setHappyLevelGain(levelGain); + static_cast(modified())->setHappyLevelGain(levelGain); emit(changed(true)); } void RulesUI::on_varNumSteps_valueChanged(const int numSteps) { - m_rules_mod->setHappySteps(numSteps); + static_cast(modified())->setHappySteps(numSteps); emit(changed(true)); } void RulesUI::on_boxEffortValues_toggled(const bool effortValues) { - m_rules_mod->setEffortValuesAllowed(effortValues); + static_cast(modified())->setEffortValuesAllowed(effortValues); emit(changed(true)); } @@ -257,7 +261,7 @@ void RulesUI::on_varMaxEV_valueChanged(const int maxEV) { try { - m_rules_mod->setMaxTotalEV(maxEV); + static_cast(modified())->setMaxTotalEV(maxEV); emit(changed(true)); } catch (BoundsException& exception) @@ -271,7 +275,7 @@ void RulesUI::on_varMaxEVPerStat_valueChanged(const int maxEVPerStat) { try { - m_rules_mod->setMaxEVPerStat(maxEVPerStat); + static_cast(modified())->setMaxEVPerStat(maxEVPerStat); emit(changed(true)); } catch (BoundsException& exception) @@ -285,7 +289,7 @@ void RulesUI::on_varPokerus_valueChanged(const Fraction& pokerusChance) { try { - m_rules_mod->setPokerusChance(pokerusChance); + static_cast(modified())->setPokerusChance(pokerusChance); emit(changed(true)); } catch (Exception& exception) -- cgit