summaryrefslogtreecommitdiffstats
path: root/pokemodr/RulesUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
commit6679f5cffa9d35a23b76605ddfbf3257f882b6ee (patch)
treec8e41854a60b64e8569939bca6b827807175ef9a /pokemodr/RulesUI.cpp
parent05980e883719b1c8ebde1bd2fcbf4f8c16df7ad6 (diff)
[FIX] Frac -> Fraction
[FIX] ImageCache and Ini removed [FIX] Fraction/Point widgets moved to pokemodr [FIX] Copy ctors made for pokemod classes [FIX] Ctors in pokemod fixed [FIX] Copyright headers fixed in pokemodr [FIX] PokeModr updated to new API and fixed in some places git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@99 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/RulesUI.cpp')
-rw-r--r--pokemodr/RulesUI.cpp258
1 files changed, 118 insertions, 140 deletions
diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp
index 24b79ea0..ae66439f 100644
--- a/pokemodr/RulesUI.cpp
+++ b/pokemodr/RulesUI.cpp
@@ -1,40 +1,35 @@
-/////////////////////////////////////////////////////////////////////////////
-// 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>
-
+/*
+ * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * 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/>.
+ */
+
+// General includes
#include <BugCatcher.h>
#include <Exception.h>
+// Header include
#include "RulesUI.h"
-RulesUI::RulesUI(Rules* r, QWidget* parent) :
+RulesUI::RulesUI(Rules* rules, QWidget* parent) :
ObjectUI(parent),
- rules(r),
- rules_mod(new Rules(r->getPokemod(), *r))
+ m_rules(rules),
+ m_rules_mod(new Rules(*rules))
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
- setObjects(rules, rules_mod);
+ setObjects(m_rules, m_rules_mod);
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool)));
init();
}
@@ -46,273 +41,256 @@ void RulesUI::initGui()
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());
- if (rules_mod->getNumBoxes())
+ 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())
varBoxSize->setEnabled(true);
else
varBoxSize->setEnabled(false);
- varBoxSize->setValue(rules_mod->getBoxSize());
- varMaxParty->setValue(rules_mod->getMaxParty());
- varMaxFight->setMaximum(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->setCurrentIndex(rules_mod->getMaxDVValue());
- 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->setMaximum(rules_mod->getMaxTotalEV());
- varMaxEVPerStat->setValue(rules_mod->getMaxEVPerStat());
- varPokerusNum->setValue(rules_mod->getPokerusChance().getNum());
- varPokerusDenom->setValue(rules_mod->getPokerusChance().getDenom());
- varPokerusNum->setMaximum(rules_mod->getPokerusChance().getDenom() - 1);
- varPokerus->setText(QString::number(rules_mod->getPokerusChance(), 'g', DBL_PREC));
+ 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());
}
void RulesUI::on_buttonApply_clicked()
{
- *rules = *rules_mod;
+ *m_rules = *m_rules_mod;
emit(changed(false));
}
void RulesUI::on_buttonDiscard_clicked()
{
- *rules_mod = *rules;
+ *m_rules_mod = *m_rules;
setGui();
emit(changed(false));
}
-void RulesUI::on_boxGenders_toggled(const bool g)
+void RulesUI::on_boxGenders_toggled(const bool genders)
{
- rules_mod->setGenderAllowed(g);
+ m_rules_mod->setGenderAllowed(genders);
emit(changed(true));
}
-void RulesUI::on_varBreeding_toggled(const bool b)
+void RulesUI::on_varBreeding_toggled(const bool breeding)
{
- rules_mod->setBreedingAllowed(b);
+ m_rules_mod->setBreedingAllowed(breeding);
emit(changed(true));
}
-void RulesUI::on_varHeldItems_valueChanged(const int h)
+void RulesUI::on_varHeldItems_valueChanged(const int heldItems)
{
- rules_mod->setHoldItems(h);
+ m_rules_mod->setHoldItems(heldItems);
emit(changed(true));
}
-void RulesUI::on_boxCriticalDomains_toggled(const bool c)
+void RulesUI::on_boxCriticalDomains_toggled(const bool criticalDomains)
{
- rules_mod->setCriticalDomains(c);
+ m_rules_mod->setCriticalDomains(criticalDomains);
emit(changed(true));
}
-void RulesUI::on_boxAllowAbilities_toggled(const bool a)
+void RulesUI::on_boxAllowAbilities_toggled(const bool allowAbilities)
{
- rules_mod->setAbilityAllowed(a);
+ m_rules_mod->setAbilityAllowed(allowAbilities);
emit(changed(true));
}
-void RulesUI::on_boxAllowNatures_toggled(const bool a)
+void RulesUI::on_boxAllowNatures_toggled(const bool allowNatures)
{
- rules_mod->setNatureAllowed(a);
+ m_rules_mod->setNatureAllowed(allowNatures);
emit(changed(true));
}
-void RulesUI::on_varBoxes_valueChanged(const int b)
+void RulesUI::on_varBoxes_valueChanged(const int boxes)
{
- rules_mod->setNumBoxes(b);
+ m_rules_mod->setNumBoxes(boxes);
emit(changed(true));
setGui();
}
-void RulesUI::on_varBoxSize_valueChanged(const int b)
+void RulesUI::on_varBoxSize_valueChanged(const int boxSize)
{
- rules_mod->setBoxSize(b);
+ m_rules_mod->setBoxSize(boxSize);
emit(changed(true));
}
-void RulesUI::on_varMaxParty_valueChanged(const int m)
+void RulesUI::on_varMaxParty_valueChanged(const int maxParty)
{
- rules_mod->setMaxParty(m);
+ m_rules_mod->setMaxParty(maxParty);
emit(changed(true));
setGui();
}
-void RulesUI::on_varMaxFight_valueChanged(const int m)
+void RulesUI::on_varMaxFight_valueChanged(const int maxFight)
{
try
{
- rules_mod->setMaxFight(m);
+ m_rules_mod->setMaxFight(maxFight);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void RulesUI::on_varMaxMoves_valueChanged(const int m)
+void RulesUI::on_varMaxMoves_valueChanged(const int maxMoves)
{
try
{
- rules_mod->setMaxMoves(m);
+ m_rules_mod->setMaxMoves(maxMoves);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void RulesUI::on_varMaxLevel_valueChanged(const int m)
+void RulesUI::on_varMaxLevel_valueChanged(const int maxLevel)
{
try
{
- rules_mod->setMaxLevel(m);
+ m_rules_mod->setMaxLevel(maxLevel);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void RulesUI::on_varMaxMoney_valueChanged(const int m)
+void RulesUI::on_varMaxMoney_valueChanged(const int maxMoney)
{
- rules_mod->setMaxMoney(m);
+ m_rules_mod->setMaxMoney(maxMoney);
emit(changed(true));
}
-void RulesUI::on_boxHardCash_toggled(const bool h)
+void RulesUI::on_boxHardCash_toggled(const bool hardCash)
{
- rules_mod->setHardCash(h);
+ m_rules_mod->setHardCash(hardCash);
emit(changed(true));
}
-void RulesUI::on_boxSplitSpecial_toggled(const bool s)
+void RulesUI::on_boxSplitSpecial_toggled(const bool splitSpecial)
{
- rules_mod->setSpecialSplit(s);
+ m_rules_mod->setSpecialSplit(splitSpecial);
emit(changed(true));
}
-void RulesUI::on_varSplitSpecialDV_toggled(const bool s)
+void RulesUI::on_varSplitSpecialDV_toggled(const bool splitSpecialDV)
{
- rules_mod->setSpecialDVSplit(s);
+ m_rules_mod->setSpecialDVSplit(splitSpecialDV);
emit(changed(true));
}
-void RulesUI::on_varMaxDV_currentIndexChanged(const int m)
+void RulesUI::on_varMaxDV_currentIndexChanged(const int maxDV)
{
try
{
- rules_mod->setMaxDVValue(m);
+ m_rules_mod->setMaxDVValue(maxDV);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void RulesUI::on_boxHappiness_toggled(const bool h)
+void RulesUI::on_boxHappiness_toggled(const bool happiness)
{
- rules_mod->setHappiness(h);
+ m_rules_mod->setHappiness(happiness);
emit(changed(true));
}
-void RulesUI::on_varFaintLoss_valueChanged(const int f)
+void RulesUI::on_varFaintLoss_valueChanged(const int faintLoss)
{
- rules_mod->setHappyFaintLoss(f);
+ m_rules_mod->setHappyFaintLoss(faintLoss);
emit(changed(true));
}
-void RulesUI::on_varLevelGain_valueChanged(const int l)
+void RulesUI::on_varLevelGain_valueChanged(const int levelGain)
{
- rules_mod->setHappyLevelGain(l);
+ m_rules_mod->setHappyLevelGain(levelGain);
emit(changed(true));
}
-void RulesUI::on_varNumSteps_valueChanged(const int n)
+void RulesUI::on_varNumSteps_valueChanged(const int numSteps)
{
- rules_mod->setHappySteps(n);
+ m_rules_mod->setHappySteps(numSteps);
emit(changed(true));
}
-void RulesUI::on_boxEffortValues_toggled(const bool e)
+void RulesUI::on_boxEffortValues_toggled(const bool effortValues)
{
- rules_mod->setEffortValuesAllowed(e);
+ m_rules_mod->setEffortValuesAllowed(effortValues);
emit(changed(true));
}
-void RulesUI::on_varMaxEV_valueChanged(const int m)
+void RulesUI::on_varMaxEV_valueChanged(const int maxEV)
{
try
{
- rules_mod->setMaxTotalEV(m);
+ m_rules_mod->setMaxTotalEV(maxEV);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
}
setGui();
}
-void RulesUI::on_varMaxEVPerStat_valueChanged(const int m)
+void RulesUI::on_varMaxEVPerStat_valueChanged(const int maxEVPerStat)
{
try
{
- rules_mod->setMaxEVPerStat(m);
+ m_rules_mod->setMaxEVPerStat(maxEVPerStat);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void RulesUI::on_varPokerusNum_valueChanged(const int p)
+void RulesUI::on_varPokerus_valueChanged(const Fraction& pokerusChance)
{
try
{
- rules_mod->setPokerusChanceNum(p);
+ m_rules_mod->setPokerusChance(pokerusChance);
emit(changed(true));
}
- catch (Exception& e)
+ catch (Exception& exception)
{
- BugCatcher::report(e);
- }
- setGui();
-}
-
-void RulesUI::on_varPokerusDenom_valueChanged(const int p)
-{
- try
- {
- rules_mod->setPokerusChanceDenom(p);
- emit(changed(true));
- }
- catch (Exception& e)
- {
- BugCatcher::report(e);
+ BugCatcher::report(exception);
+ setGui();
}
- setGui();
}