/* * 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" // Sigmod includes #include "../sigmod/Rules.h" Sigmodr::RulesUI::RulesUI(Sigmod::Rules* rules, QWidget* parent) : ObjectUI(parent) { setupUi(this); setObjects(rules, new Sigmod::Rules(*rules)); } Sigmodr::RulesUI::~RulesUI() { } void Sigmodr::RulesUI::setGui() { boxGenders->setChecked(qobject_cast(modified())->genderAllowed() ? Qt::Checked : Qt::Unchecked); varBreeding->setCheckState(qobject_cast(modified())->breedingAllowed() ? Qt::Checked : Qt::Unchecked); varCriticalDomains->setChecked(qobject_cast(modified())->criticalDomains() ? Qt::Checked : Qt::Unchecked); varSwitchStyle->setChecked(qobject_cast(modified())->allowSwitchStyle() ? Qt::Checked : Qt::Unchecked); varUseTurns->setChecked(qobject_cast(modified())->useTurns() ? Qt::Checked : Qt::Unchecked); varPausedATB->setDisabled(qobject_cast(modified())->useTurns()); varPausedATB->setChecked(qobject_cast(modified())->pausedATB() ? Qt::Checked : Qt::Unchecked); boxSplitSpecial->setChecked(qobject_cast(modified())->specialSplit() ? Qt::Checked : Qt::Unchecked); varSplitSpecialDV->setCheckState(qobject_cast(modified())->specialDVSplit() ? Qt::Checked : Qt::Unchecked); boxEffortValues->setChecked(qobject_cast(modified())->effortValuesAllowed() ? Qt::Checked : Qt::Unchecked); varMaxEV->setValue(qobject_cast(modified())->maxTotalEV()); varMaxEVPerStat->setEnabled(0 < qobject_cast(modified())->maxTotalEV()); varMaxEVPerStat->setMaximum(qobject_cast(modified())->maxTotalEV()); varMaxEVPerStat->setValue(qobject_cast(modified())->maxEVPerStat()); varBoxes->setValue(qobject_cast(modified())->numBoxes()); varBoxSize->setEnabled(0 < qobject_cast(modified())->numBoxes()); varBoxSize->setValue(qobject_cast(modified())->boxSize()); varMaxParty->setValue(qobject_cast(modified())->maxParty()); varMaxFight->setMaximum(qobject_cast(modified())->maxParty()); varMaxFight->setValue(qobject_cast(modified())->maxFight()); varMaxPlayers->setValue(qobject_cast(modified())->maxPlayers()); varMaxMoves->setValue(qobject_cast(modified())->maxMoves()); varMaxLevel->setValue(qobject_cast(modified())->maxLevel()); varMaxHeldItems->setValue(qobject_cast(modified())->maxHeldItems()); varMaxNatures->setValue(qobject_cast(modified())->maxNatures()); varMaxAbilities->setValue(qobject_cast(modified())->maxAbilities()); varMaxStages->setValue(qobject_cast(modified())->maxStages()); varMaxMoney->setValue(qobject_cast(modified())->maxMoney()); varMaxTotalWeight->setValue(qobject_cast(modified())->maxTotalWeight()); } void Sigmodr::RulesUI::apply() { *qobject_cast(original()) = *qobject_cast(modified()); emit(changed(false)); } void Sigmodr::RulesUI::discard() { *qobject_cast(modified()) = *qobject_cast(original()); setGui(); emit(changed(false)); } void Sigmodr::RulesUI::on_boxGenders_toggled(const bool genders) { qobject_cast(modified())->setGenderAllowed(genders); } void Sigmodr::RulesUI::on_varBreeding_toggled(const bool breeding) { qobject_cast(modified())->setBreedingAllowed(breeding); } void Sigmodr::RulesUI::on_varCriticalDomains_toggled(const bool criticalDomains) { qobject_cast(modified())->setCriticalDomains(criticalDomains); } void Sigmodr::RulesUI::on_varSwitchStyle_toggled(const bool switchStyle) { qobject_cast(modified())->setAllowSwitchStyle(switchStyle); } void Sigmodr::RulesUI::on_varUseTurns_toggled(const bool useTurns) { qobject_cast(modified())->setUseTurns(useTurns); } void Sigmodr::RulesUI::on_varPausedATB_toggled(const bool pausedATB) { qobject_cast(modified())->setPausedATB(pausedATB); } void Sigmodr::RulesUI::on_boxSplitSpecial_toggled(const bool splitSpecial) { qobject_cast(modified())->setSpecialSplit(splitSpecial); if (!splitSpecial) qobject_cast(modified())->setSpecialDVSplit(false); } void Sigmodr::RulesUI::on_varSplitSpecialDV_toggled(const bool splitSpecialDV) { qobject_cast(modified())->setSpecialDVSplit(splitSpecialDV); } void Sigmodr::RulesUI::on_boxEffortValues_toggled(const bool effortValues) { qobject_cast(modified())->setEffortValuesAllowed(effortValues); } void Sigmodr::RulesUI::on_varMaxEV_valueChanged(const int maxEV) { qobject_cast(modified())->setMaxTotalEV(maxEV); } void Sigmodr::RulesUI::on_varMaxEVPerStat_valueChanged(const int maxEVPerStat) { qobject_cast(modified())->setMaxEVPerStat(maxEVPerStat); } void Sigmodr::RulesUI::on_varBoxes_valueChanged(const int boxes) { qobject_cast(modified())->setNumBoxes(boxes); } void Sigmodr::RulesUI::on_varBoxSize_valueChanged(const int boxSize) { qobject_cast(modified())->setBoxSize(boxSize); } void Sigmodr::RulesUI::on_varMaxParty_valueChanged(const int maxParty) { qobject_cast(modified())->setMaxParty(maxParty); } void Sigmodr::RulesUI::on_varMaxFight_valueChanged(const int maxFight) { qobject_cast(modified())->setMaxFight(maxFight); } void Sigmodr::RulesUI::on_varMaxPlayers_valueChanged(const int maxPlayers) { qobject_cast(modified())->setMaxPlayers(maxPlayers); } void Sigmodr::RulesUI::on_varMaxMoves_valueChanged(const int maxMoves) { qobject_cast(modified())->setMaxMoves(maxMoves); } void Sigmodr::RulesUI::on_varMaxLevel_valueChanged(const int maxLevel) { qobject_cast(modified())->setMaxLevel(maxLevel); } void Sigmodr::RulesUI::on_varMaxHeldItems_valueChanged(const int maxHeldItems) { qobject_cast(modified())->setMaxHeldItems(maxHeldItems); } void Sigmodr::RulesUI::on_varMaxNatures_valueChanged(const int maxNatures) { qobject_cast(modified())->setMaxNatures(maxNatures); } void Sigmodr::RulesUI::on_varMaxAbilities_valueChanged(const int maxAbilities) { qobject_cast(modified())->setMaxAbilities(maxAbilities); } void Sigmodr::RulesUI::on_varMaxStages_valueChanged(const int maxStages) { qobject_cast(modified())->setMaxStages(maxStages); } void Sigmodr::RulesUI::on_varMaxMoney_valueChanged(const int maxMoney) { qobject_cast(modified())->setMaxMoney(maxMoney); } void Sigmodr::RulesUI::on_varMaxTotalWeight_valueChanged(const int maxTotalWeight) { qobject_cast(modified())->setMaxTotalWeight(maxTotalWeight); }