From 7aff48012c3040a675543a0ff3d23af6cb8a8638 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 23 Feb 2009 11:20:47 -0500 Subject: Started restructuring how sigmodr is built and moving things into libraries --- sigmodr/widgets/RulesUI.cpp | 197 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 sigmodr/widgets/RulesUI.cpp (limited to 'sigmodr/widgets/RulesUI.cpp') diff --git a/sigmodr/widgets/RulesUI.cpp b/sigmodr/widgets/RulesUI.cpp new file mode 100644 index 00000000..08f8ae60 --- /dev/null +++ b/sigmodr/widgets/RulesUI.cpp @@ -0,0 +1,197 @@ +/* + * Copyright 2008-2009 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() +{ + varGenders->setCheckState(qobject_cast(modified())->genderAllowed() ? Qt::Checked : Qt::Unchecked); + varBreeding->setCheckState(qobject_cast(modified())->breedingAllowed() ? Qt::Checked : Qt::Unchecked); + varBreeding->setEnabled(qobject_cast(modified())->genderAllowed()); + varCriticalDomains->setCheckState(qobject_cast(modified())->criticalDomains() ? Qt::Checked : Qt::Unchecked); + varSwitchStyle->setCheckState(qobject_cast(modified())->allowSwitchStyle() ? Qt::Checked : Qt::Unchecked); + varUseATB->setCheckState(qobject_cast(modified())->useATB() ? Qt::Checked : Qt::Unchecked); + varSplitSpecial->setCheckState(qobject_cast(modified())->specialSplit() ? Qt::Checked : Qt::Unchecked); + varSplitSpecialDV->setEnabled(qobject_cast(modified())->specialSplit()); + varSplitSpecialDV->setCheckState(qobject_cast(modified())->specialDVSplit() ? Qt::Checked : Qt::Unchecked); + varEffortValues->setCheckState(qobject_cast(modified())->effortValuesAllowed() ? Qt::Checked : Qt::Unchecked); + varMaxEV->setEnabled(qobject_cast(modified())->effortValuesAllowed()); + varMaxEV->setValue(qobject_cast(modified())->maxTotalEV()); + varMaxEVPerStat->setEnabled((0 < qobject_cast(modified())->maxTotalEV()) && qobject_cast(modified())->effortValuesAllowed()); + 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_varGenders_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_varUseATB_toggled(const bool useATB) +{ + qobject_cast(modified())->setUseATB(useATB); +} + +void Sigmodr::RulesUI::on_varSplitSpecial_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_varEffortValues_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); +} -- cgit