diff options
Diffstat (limited to 'pokemodr/MoveUI.cpp')
| -rw-r--r-- | pokemodr/MoveUI.cpp | 189 |
1 files changed, 84 insertions, 105 deletions
diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp index 563bfc8f..c9d2ba76 100644 --- a/pokemodr/MoveUI.cpp +++ b/pokemodr/MoveUI.cpp @@ -1,43 +1,39 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokegen/MoveUI.cpp -// Purpose: Move UI form handling -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Mon Feb 18 23:52:48 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> - +/* + * 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/>. + */ + +// General includes #include <BugCatcher.h> #include <Exception.h> +// Pokemod includes #include <Pokemod.h> #include <Type.h> +// Header include #include "MoveUI.h" -MoveUI::MoveUI(Move* m, QWidget* parent) : +MoveUI::MoveUI(Move* move, QWidget* parent) : ObjectUI(parent), - move(m), - move_mod(new Move(m->getPokemod(), *m, m->getId())) + m_move(move), + m_move_mod(new Move(*move)) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(move, move_mod); + setObjects(m_move, m_move_mod); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } @@ -51,190 +47,173 @@ void MoveUI::initGui() void MoveUI::refreshGui() { varType->clear(); - for (int i = 0; i < move->getPokemod()->getTypeCount(); ++i) + for (int i = 0; i < m_move->pokemod()->typeCount(); ++i) { - const Type* t = move->getPokemod()->getType(i); - varType->addItem(t->getName()); - varType->setItemData(i, t->getId()); + const Type* type = m_move->pokemod()->type(i); + varType->addItem(type->name()); + varType->setItemData(i, type->id()); } - varNumTargets->setMaximum(move->getPokemod()->getRules()->getMaxFight()); + varNumTargets->setMaximum(m_move->pokemod()->rules()->maxFight()); } void MoveUI::setGui() { - varName->setText(move_mod->getName()); - varAccuracyNum->setValue(move_mod->getAccuracy().getNum()); - varAccuracyDenom->setValue(move_mod->getAccuracy().getDenom()); - varAccuracyNum->setMaximum(move_mod->getAccuracy().getDenom()); - varAccuracy->setText(QString::number(move_mod->getAccuracy(), 'g', DBL_PREC)); - varType->setCurrentIndex(varType->findData(move_mod->getType())); - varTarget->setCurrentIndex(move_mod->getTarget()); - varNumTargets->setValue(move_mod->getNumTargets()); - varTargetChoice->setCurrentIndex(move_mod->getTargetChoice()); - varSpecial->setChecked(move_mod->getSpecial() ? Qt::Checked : Qt::Unchecked); - varIgnoreAccuracy->setChecked(move_mod->getIgnoreAccuracy() ? Qt::Checked : Qt::Unchecked); - varCanFlinch->setChecked(move_mod->getCanFlinch() ? Qt::Checked : Qt::Unchecked); - varCanRandom->setChecked(move_mod->getCanRandom() ? Qt::Checked : Qt::Unchecked); - varCanSnatch->setChecked(move_mod->getCanSnatch() ? Qt::Checked : Qt::Unchecked); - varMakesSound->setChecked(move_mod->getSound() ? Qt::Checked : Qt::Unchecked); - varDescription->setText(move_mod->getDescription()); + varName->setText(m_move_mod->name()); + varAccuracy->setValue(m_move_mod->accuracy()); + varType->setCurrentIndex(varType->findData(m_move_mod->type())); + varTarget->setCurrentIndex(m_move_mod->target()); + varNumTargets->setValue(m_move_mod->numTargets()); + varTargetChoice->setCurrentIndex(m_move_mod->targetChoice()); + varSpecial->setChecked(m_move_mod->special() ? Qt::Checked : Qt::Unchecked); + varIgnoreAccuracy->setChecked(m_move_mod->ignoreAccuracy() ? Qt::Checked : Qt::Unchecked); + varCanFlinch->setChecked(m_move_mod->canFlinch() ? Qt::Checked : Qt::Unchecked); + varCanRandom->setChecked(m_move_mod->canRandom() ? Qt::Checked : Qt::Unchecked); + varCanSnatch->setChecked(m_move_mod->canSnatch() ? Qt::Checked : Qt::Unchecked); + varMakesSound->setChecked(m_move_mod->sound() ? Qt::Checked : Qt::Unchecked); + varDescription->setText(m_move_mod->description()); } void MoveUI::on_buttonApply_clicked() { - *move = *move_mod; + *m_move = *m_move_mod; emit(changed(false)); } void MoveUI::on_buttonDiscard_clicked() { - *move_mod = *move; + *m_move_mod = *m_move; setGui(); emit(changed(false)); } -void MoveUI::on_varName_textChanged(const QString& n) +void MoveUI::on_varName_textChanged(const QString& name) { - move_mod->setName(n); + m_move_mod->setName(name); emit(changed(true)); } -void MoveUI::on_varAccuracyNum_valueChanged(const int a) +void MoveUI::on_varAccuracy_valueChanged(const Fraction& accuracy) { try { - move_mod->setAccuracyNum(a); + m_move_mod->setAccuracy(accuracy); emit(changed(true)); } - catch (Exception& e) + catch (Exception& exception) { - BugCatcher::report(e); - } - setGui(); -} - -void MoveUI::on_varAccuracyDenom_valueChanged(const int a) -{ - try - { - move_mod->setAccuracyDenom(a); - emit(changed(true)); - } - catch (Exception& e) - { - BugCatcher::report(e); + BugCatcher::report(exception); + setGui(); } - setGui(); } -void MoveUI::on_varType_currentIndexChanged(const int t) +void MoveUI::on_varType_currentIndexChanged(const int type) { try { - move_mod->setType(varType->itemData(t).toInt()); + m_move_mod->setType(varType->itemData(type).toInt()); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MoveUI::on_varPowerPoints_valueChanged(const int p) +void MoveUI::on_varPowerPoints_valueChanged(const int powerPoints) { try { - move_mod->setPowerPoints(p); + m_move_mod->setPowerPoints(powerPoints); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MoveUI::on_varTarget_currentIndexChanged(const int t) +void MoveUI::on_varTarget_currentIndexChanged(const int target) { try { - move_mod->setTarget(t); + m_move_mod->setTarget(target); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MoveUI::on_varNumTargets_valueChanged(const int n) +void MoveUI::on_varNumTargets_valueChanged(const int numTargets) { try { - move_mod->setNumTargets(n); + m_move_mod->setNumTargets(numTargets); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MoveUI::on_varTargetChoice_currentIndexChanged(const int t) +void MoveUI::on_varTargetChoice_currentIndexChanged(const int targetChoice) { try { - move_mod->setTargetChoice(t); + m_move_mod->setTargetChoice(targetChoice); emit(changed(true)); } - catch (BoundsException& e) + catch (BoundsException& exception) { - BugCatcher::report(e); + BugCatcher::report(exception); setGui(); } } -void MoveUI::on_varSpecial_toggled(const bool s) +void MoveUI::on_varSpecial_toggled(const bool special) { - move_mod->setSpecial(s); + m_move_mod->setSpecial(special); emit(changed(true)); } -void MoveUI::on_varIgnoreAccuracy_toggled(const bool i) +void MoveUI::on_varIgnoreAccuracy_toggled(const bool ignoreAccuracy) { - move_mod->setIgnoreAccuracy(i); + m_move_mod->setIgnoreAccuracy(ignoreAccuracy); emit(changed(true)); } -void MoveUI::on_varCanFlinch_toggled(const bool c) +void MoveUI::on_varCanFlinch_toggled(const bool canFlinch) { - move_mod->setCanFlinch(c); + m_move_mod->setCanFlinch(canFlinch); emit(changed(true)); } -void MoveUI::on_varCanRandom_toggled(const bool c) +void MoveUI::on_varCanRandom_toggled(const bool canRandom) { - move_mod->setCanRandom(c); + m_move_mod->setCanRandom(canRandom); emit(changed(true)); } -void MoveUI::on_varCanSnatch_toggled(const bool c) +void MoveUI::on_varCanSnatch_toggled(const bool canSnatch) { - move_mod->setCanSnatch(c); + m_move_mod->setCanSnatch(canSnatch); emit(changed(true)); } -void MoveUI::on_varSound_toggled(const bool s) +void MoveUI::on_varSound_toggled(const bool sound) { - move_mod->setSound(s); + m_move_mod->setSound(sound); emit(changed(true)); } void MoveUI::on_varDescription_textChanged() { - move_mod->setDescription(varDescription->toPlainText()); + m_move_mod->setDescription(varDescription->toPlainText()); emit(changed(true)); } |
