diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-17 23:34:36 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-17 23:34:36 +0000 |
| commit | 6679f5cffa9d35a23b76605ddfbf3257f882b6ee (patch) | |
| tree | c8e41854a60b64e8569939bca6b827807175ef9a /pokemodr/NatureUI.cpp | |
| parent | 05980e883719b1c8ebde1bd2fcbf4f8c16df7ad6 (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/NatureUI.cpp')
| -rw-r--r-- | pokemodr/NatureUI.cpp | 101 |
1 files changed, 41 insertions, 60 deletions
diff --git a/pokemodr/NatureUI.cpp b/pokemodr/NatureUI.cpp index 09275220..775ba15a 100644 --- a/pokemodr/NatureUI.cpp +++ b/pokemodr/NatureUI.cpp @@ -1,43 +1,41 @@ -///////////////////////////////////////////////////////////////////////////// -// 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/>. -///////////////////////////////////////////////////////////////////////////// +/* + * 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/>. + */ -#include <QMetaObject> +// Qt includes #include <QStringList> +// General includes #include <BugCatcher.h> #include <Exception.h> +// Pokemod includes #include <Pokemod.h> +// Header include #include "NatureUI.h" -NatureUI::NatureUI(Nature* n, QWidget* parent) : +NatureUI::NatureUI(Nature* nature, QWidget* parent) : ObjectUI(parent), - nature(n), - nature_mod(new Nature(n->getPokemod(), *n, n->getId())) + m_nature(nature), + m_nature_mod(new Nature(*nature)) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(nature, nature_mod); + setObjects(m_nature, m_nature_mod); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } @@ -45,36 +43,33 @@ NatureUI::NatureUI(Nature* n, QWidget* parent) : void NatureUI::refreshGui() { varStat->clear(); - const bool isSplit = nature->getPokemod()->getRules()->getSpecialSplit(); + const bool isSplit = m_nature->pokemod()->rules()->specialSplit(); varStat->addItems((isSplit ? Pokemod::StatRBYStr : Pokemod::StatGSCStr).mid(0, isSplit ? Pokemod::ST_End_RBY : Pokemod::ST_End_GSC)); } void NatureUI::setGui() { - varName->setText(nature_mod->getName()); - varStatMultiplierNum->setValue(nature_mod->getStat(varStat->currentIndex()).getNum()); - varStatMultiplierDenom->setValue(nature_mod->getStat(varStat->currentIndex()).getDenom()); - varStatMultiplierNum->setMaximum(nature_mod->getStat(varStat->currentIndex()).getDenom()); - varStatMultiplier->setText(QString::number(nature_mod->getStat(varStat->currentIndex()), 'g', DBL_PREC)); - varWeight->setValue(nature_mod->getWeight()); + varName->setText(m_nature_mod->name()); + varStatMultiplier->setValue(m_nature_mod->stat(varStat->currentIndex())); + varWeight->setValue(m_nature_mod->weight()); } void NatureUI::on_buttonApply_clicked() { - *nature = *nature_mod; + *m_nature = *m_nature_mod; emit(changed(false)); } void NatureUI::on_buttonDiscard_clicked() { - *nature_mod = *nature; + *m_nature_mod = *m_nature; setGui(); emit(changed(false)); } -void NatureUI::on_varName_textChanged(const QString& n) +void NatureUI::on_varName_textChanged(const QString& name) { - nature_mod->setName(n); + m_nature_mod->setName(name); emit(changed(true)); } @@ -84,44 +79,30 @@ void NatureUI::on_varStat_currentIndexChanged() emit(changed(true)); } -void NatureUI::on_varStatMultiplierNum_valueChanged(const int s) +void NatureUI::on_varStatMultiplier_valueChanged(const Fraction& statMultiplier) { try { - nature_mod->setStatNum(varStat->currentIndex(), s); + m_nature_mod->setStat(varStat->currentIndex(), statMultiplier); emit(changed(true)); } - catch (Exception& e) + catch (Exception& exception) { - BugCatcher::report(e); - } - setGui(); -} - -void NatureUI::on_varStatMultiplierDenom_valueChanged(const int s) -{ - try - { - nature_mod->setStatDenom(varStat->currentIndex(), s); - emit(changed(true)); - } - catch (Exception& e) - { - BugCatcher::report(e); + BugCatcher::report(exception); + setGui(); } - setGui(); } -void NatureUI::on_varWeight_valueChanged(const int w) +void NatureUI::on_varWeight_valueChanged(const int weight) { try { - nature_mod->setWeight(w); + m_nature_mod->setWeight(weight); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } |
