diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-01-25 22:57:54 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-01-25 22:57:54 +0000 |
| commit | 404d1e3419e85ad06cf4d1cdef185877f4a57771 (patch) | |
| tree | 7979c422e3a82285e9ac442b84f50f8d590841ab /pokemodr/NatureUI.cpp | |
| parent | 2d8ee00f42b980d8351c810062d17271b3a65cf6 (diff) | |
| download | sigen-404d1e3419e85ad06cf4d1cdef185877f4a57771.tar.gz sigen-404d1e3419e85ad06cf4d1cdef185877f4a57771.tar.xz sigen-404d1e3419e85ad06cf4d1cdef185877f4a57771.zip | |
[ADD] win32 support (KDE) into .pro files
[FIX] Ref.h extern variables
[FIX] Nature include
[FIX[ GUI fixes
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@48 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/NatureUI.cpp')
| -rw-r--r-- | pokemodr/NatureUI.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/pokemodr/NatureUI.cpp b/pokemodr/NatureUI.cpp new file mode 100644 index 00000000..ce975772 --- /dev/null +++ b/pokemodr/NatureUI.cpp @@ -0,0 +1,141 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/NatureUI.cpp +// Purpose: Nature UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Fri Jan 25 15:19:04 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> +#include <QStringList> +#include "../general/BugCatcher.h" +#include "../general/Exception.h" +#include "../general/Ref.h" +#include "../pokemod/Pokemod.h" +#include "NatureUI.h" + +NatureUI::NatureUI(Nature* n, QWidget* parent) : + ObjectUI(parent), + curStat(ST_HP), + nature(n), + nature_mod(new Nature(n->getPokemod(), *n, n->getId())) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(nature, nature_mod); + setGui(); +} + +// KToolbar NatureUI::getToolbar(QWidget* parent) +// { +// } + +void NatureUI::setGui() +{ + const bool isSplit = nature_mod->getPokemod().getRules().getSpecialSplit(); + const QStringList& statList = isSplit ? StatRBYStr : StatGSCStr; + varName->setText(nature_mod->getName()); + varStat->clear(); + varStat->addItems(statList.mid(0, isSplit ? ST_End_RBY : ST_End_GSC)); + varStat->setCurrentItem(statList[curStat]); + varStatMultiplierNum->setValue(nature_mod->getStat(curStat).getNum()); + varStatMultiplierDenom->setValue(nature_mod->getStat(curStat).getDenom()); + varStatMultiplierNum->setMaximum(nature_mod->getStat(curStat).getDenom()); + varStatMultiplier->setText(QString::number(nature_mod->getStat(curStat), 'g', 15)); + varWeight->setValue(nature_mod->getWeight()); +} + +void NatureUI::on_buttonApply_clicked() +{ + *nature = *nature_mod; + emit(setChanged(false)); +} + +void NatureUI::on_buttonDiscard_clicked() +{ + *nature_mod = *nature; + emit(setChanged(false)); + setGui(); +} + +void NatureUI::on_varName_textChanged(const QString& n) +{ + nature_mod->setName(n); +} + +void NatureUI::on_varStat_currentIndexChanged(const QString& s) +{ + try + { + const QStringList& statList = nature_mod->getPokemod().getRules().getSpecialSplit() ? StatRBYStr : StatGSCStr; + if (statList.contains(s)) + curStat = statList.indexOf(s); + else + throw(BoundsException("NatureUI", "stat")); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void NatureUI::on_varStatMultiplierNum_valueChanged(const int s) +{ + try + { + nature_mod->setStatNum(curStat, s); + varStatMultiplier->setText(QString::number(nature_mod->getStat(curStat), 'g', 15)); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void NatureUI::on_varStatMultiplierDenom_valueChanged(const int s) +{ + try + { + nature_mod->setStatDenom(curStat, s); + varStatMultiplierNum->setMaximum(s); + varStatMultiplier->setText(QString::number(nature_mod->getStat(curStat), 'g', 15)); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} + +void NatureUI::on_varWeight_valueChanged(const int w) +{ + try + { + nature_mod->setWeight(w); + emit(setChanged(true)); + } + catch (BoundsException& e) + { + BugCatcher::report(e); + setGui(); + } +} |
