/* * Copyright 2008 Ben Boeckel * * 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 . */ // Header include #include "RulesUI.h" // Pokemod includes #include "../pokemod/Rules.h" RulesUI::RulesUI(Rules* rules, QWidget* parent) : ObjectUI(parent) { setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(rules, new Rules(*rules)); init(); } RulesUI::~RulesUI() { } void RulesUI::initGui() { varMaxDV->addItems(Rules::DVStr); } void RulesUI::setGui() { 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()); varBoxSize->setEnabled(0 < static_cast(modified())->numBoxes()); 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->setEnabled(0 < static_cast(modified())->maxTotalEV()); varMaxEVPerStat->setMaximum(static_cast(modified())->maxTotalEV()); varMaxEVPerStat->setValue(static_cast(modified())->maxEVPerStat()); varPokerus->setValue(static_cast(modified())->pokerusChance()); } void RulesUI::apply() { *static_cast(original()) = *static_cast(modified()); emit(changed(false)); } void RulesUI::discard() { *static_cast(modified()) = *static_cast(original()); setGui(); emit(changed(false)); } void RulesUI::on_boxGenders_toggled(const bool genders) { static_cast(modified())->setGenderAllowed(genders); } void RulesUI::on_varBreeding_toggled(const bool breeding) { static_cast(modified())->setBreedingAllowed(breeding); } void RulesUI::on_varHeldItems_valueChanged(const int heldItems) { static_cast(modified())->setHoldItems(heldItems); } void RulesUI::on_boxCriticalDomains_toggled(const bool criticalDomains) { static_cast(modified())->setCriticalDomains(criticalDomains); } void RulesUI::on_boxAllowAbilities_toggled(const bool allowAbilities) { static_cast(modified())->setAbilityAllowed(allowAbilities); } void RulesUI::on_boxAllowNatures_toggled(const bool allowNatures) { static_cast(modified())->setNatureAllowed(allowNatures); } void RulesUI::on_varBoxes_valueChanged(const int boxes) { static_cast(modified())->setNumBoxes(boxes); } void RulesUI::on_varBoxSize_valueChanged(const int boxSize) { static_cast(modified())->setBoxSize(boxSize); } void RulesUI::on_varMaxParty_valueChanged(const int maxParty) { static_cast(modified())->setMaxParty(maxParty); } void RulesUI::on_varMaxFight_valueChanged(const int maxFight) { static_cast(modified())->setMaxFight(maxFight); } void RulesUI::on_varMaxMoves_valueChanged(const int maxMoves) { static_cast(modified())->setMaxMoves(maxMoves); } void RulesUI::on_varMaxLevel_valueChanged(const int maxLevel) { static_cast(modified())->setMaxLevel(maxLevel); } void RulesUI::on_varMaxMoney_valueChanged(const int maxMoney) { static_cast(modified())->setMaxMoney(maxMoney); } void RulesUI::on_boxHardCash_toggled(const bool hardCash) { static_cast(modified())->setHardCash(hardCash); } void RulesUI::on_boxSplitSpecial_toggled(const bool splitSpecial) { static_cast(modified())->setSpecialSplit(splitSpecial); } void RulesUI::on_varSplitSpecialDV_toggled(const bool splitSpecialDV) { static_cast(modified())->setSpecialDVSplit(splitSpecialDV); } void RulesUI::on_varMaxDV_currentIndexChanged(const int maxDV) { static_cast(modified())->setMaxDVValue(maxDV); } void RulesUI::on_boxHappiness_toggled(const bool happiness) { static_cast(modified())->setHappiness(happiness); } void RulesUI::on_varFaintLoss_valueChanged(const int faintLoss) { static_cast(modified())->setHappyFaintLoss(faintLoss); } void RulesUI::on_varLevelGain_valueChanged(const int levelGain) { static_cast(modified())->setHappyLevelGain(levelGain); } void RulesUI::on_varNumSteps_valueChanged(const int numSteps) { static_cast(modified())->setHappySteps(numSteps); } void RulesUI::on_boxEffortValues_toggled(const bool effortValues) { static_cast(modified())->setEffortValuesAllowed(effortValues); } void RulesUI::on_varMaxEV_valueChanged(const int maxEV) { static_cast(modified())->setMaxTotalEV(maxEV); } void RulesUI::on_varMaxEVPerStat_valueChanged(const int maxEVPerStat) { static_cast(modified())->setMaxEVPerStat(maxEVPerStat); } void RulesUI::on_varPokerus_valueChanged(const Fraction& pokerusChance) { static_cast(modified())->setPokerusChance(pokerusChance); }