diff options
Diffstat (limited to 'pokemodr/MoveUI.cpp')
| -rw-r--r-- | pokemodr/MoveUI.cpp | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp index 13603648..38a526c5 100644 --- a/pokemodr/MoveUI.cpp +++ b/pokemodr/MoveUI.cpp @@ -19,25 +19,27 @@ #include "MoveUI.h" // Pokemod includes -#include "../pokemod/Pokemod.h" +#include "../pokemod/Move.h" #include "../pokemod/Type.h" +#include "../pokemod/Pokemod.h" // General includes #include "../general/BugCatcher.h" -#include "../general/Exception.h" MoveUI::MoveUI(Move* move, QWidget* parent) : - ObjectUI(parent), - m_move(move), - m_move_mod(new Move(*move)) + ObjectUI(parent) { setupUi(this); QMetaObject::connectSlotsByName(this); - setObjects(m_move, m_move_mod); + setObjects(move, new Move(*move)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); init(); } +MoveUI::~MoveUI() +{ +} + void MoveUI::initGui() { varTarget->addItems(Move::TargetStr); @@ -47,48 +49,48 @@ void MoveUI::initGui() void MoveUI::refreshGui() { varType->clear(); - for (int i = 0; i < static_cast<const Pokemod*>(m_move->pokemod())->typeCount(); ++i) + for (int i = 0; i < static_cast<const Pokemod*>(static_cast<Move*>(original())->pokemod())->typeCount(); ++i) { - const Type* type = static_cast<const Pokemod*>(m_move->pokemod())->type(i); + const Type* type = static_cast<const Pokemod*>(static_cast<Move*>(original())->pokemod())->type(i); varType->addItem(type->name()); varType->setItemData(i, type->id()); } - varNumTargets->setMaximum(static_cast<const Pokemod*>(m_move->pokemod())->rules()->maxFight()); + varNumTargets->setMaximum(static_cast<const Pokemod*>(static_cast<Move*>(original())->pokemod())->rules()->maxFight()); } void MoveUI::setGui() { - 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()); + varName->setText(static_cast<Move*>(modified())->name()); + varAccuracy->setValue(static_cast<Move*>(modified())->accuracy()); + varType->setCurrentIndex(varType->findData(static_cast<Move*>(modified())->type())); + varTarget->setCurrentIndex(static_cast<Move*>(modified())->target()); + varNumTargets->setValue(static_cast<Move*>(modified())->numTargets()); + varTargetChoice->setCurrentIndex(static_cast<Move*>(modified())->targetChoice()); + varSpecial->setChecked(static_cast<Move*>(modified())->special() ? Qt::Checked : Qt::Unchecked); + varIgnoreAccuracy->setChecked(static_cast<Move*>(modified())->ignoreAccuracy() ? Qt::Checked : Qt::Unchecked); + varCanFlinch->setChecked(static_cast<Move*>(modified())->canFlinch() ? Qt::Checked : Qt::Unchecked); + varCanRandom->setChecked(static_cast<Move*>(modified())->canRandom() ? Qt::Checked : Qt::Unchecked); + varCanSnatch->setChecked(static_cast<Move*>(modified())->canSnatch() ? Qt::Checked : Qt::Unchecked); + varMakesSound->setChecked(static_cast<Move*>(modified())->sound() ? Qt::Checked : Qt::Unchecked); + varDescription->setText(static_cast<Move*>(modified())->description()); } void MoveUI::on_buttonApply_clicked() { - *m_move = *m_move_mod; + *static_cast<Move*>(original()) = *static_cast<Move*>(modified()); emit(changed(false)); } void MoveUI::on_buttonDiscard_clicked() { - *m_move_mod = *m_move; + *static_cast<Move*>(modified()) = *static_cast<Move*>(original()); setGui(); emit(changed(false)); } void MoveUI::on_varName_textChanged(const QString& name) { - m_move_mod->setName(name); + static_cast<Move*>(modified())->setName(name); emit(changed(true)); } @@ -96,7 +98,7 @@ void MoveUI::on_varAccuracy_valueChanged(const Fraction& accuracy) { try { - m_move_mod->setAccuracy(accuracy); + static_cast<Move*>(modified())->setAccuracy(accuracy); emit(changed(true)); } catch (Exception& exception) @@ -110,7 +112,7 @@ void MoveUI::on_varType_currentIndexChanged(const int type) { try { - m_move_mod->setType(varType->itemData(type).toInt()); + static_cast<Move*>(modified())->setType(varType->itemData(type).toInt()); emit(changed(true)); } catch (BoundsException& exception) @@ -124,7 +126,7 @@ void MoveUI::on_varPowerPoints_valueChanged(const int powerPoints) { try { - m_move_mod->setPowerPoints(powerPoints); + static_cast<Move*>(modified())->setPowerPoints(powerPoints); emit(changed(true)); } catch (BoundsException& exception) @@ -138,7 +140,7 @@ void MoveUI::on_varTarget_currentIndexChanged(const int target) { try { - m_move_mod->setTarget(target); + static_cast<Move*>(modified())->setTarget(target); emit(changed(true)); } catch (BoundsException& exception) @@ -152,7 +154,7 @@ void MoveUI::on_varNumTargets_valueChanged(const int numTargets) { try { - m_move_mod->setNumTargets(numTargets); + static_cast<Move*>(modified())->setNumTargets(numTargets); emit(changed(true)); } catch (BoundsException& exception) @@ -166,7 +168,7 @@ void MoveUI::on_varTargetChoice_currentIndexChanged(const int targetChoice) { try { - m_move_mod->setTargetChoice(targetChoice); + static_cast<Move*>(modified())->setTargetChoice(targetChoice); emit(changed(true)); } catch (BoundsException& exception) @@ -178,42 +180,42 @@ void MoveUI::on_varTargetChoice_currentIndexChanged(const int targetChoice) void MoveUI::on_varSpecial_toggled(const bool special) { - m_move_mod->setSpecial(special); + static_cast<Move*>(modified())->setSpecial(special); emit(changed(true)); } void MoveUI::on_varIgnoreAccuracy_toggled(const bool ignoreAccuracy) { - m_move_mod->setIgnoreAccuracy(ignoreAccuracy); + static_cast<Move*>(modified())->setIgnoreAccuracy(ignoreAccuracy); emit(changed(true)); } void MoveUI::on_varCanFlinch_toggled(const bool canFlinch) { - m_move_mod->setCanFlinch(canFlinch); + static_cast<Move*>(modified())->setCanFlinch(canFlinch); emit(changed(true)); } void MoveUI::on_varCanRandom_toggled(const bool canRandom) { - m_move_mod->setCanRandom(canRandom); + static_cast<Move*>(modified())->setCanRandom(canRandom); emit(changed(true)); } void MoveUI::on_varCanSnatch_toggled(const bool canSnatch) { - m_move_mod->setCanSnatch(canSnatch); + static_cast<Move*>(modified())->setCanSnatch(canSnatch); emit(changed(true)); } void MoveUI::on_varSound_toggled(const bool sound) { - m_move_mod->setSound(sound); + static_cast<Move*>(modified())->setSound(sound); emit(changed(true)); } void MoveUI::on_varDescription_textChanged() { - m_move_mod->setDescription(varDescription->toPlainText()); + static_cast<Move*>(modified())->setDescription(varDescription->toPlainText()); emit(changed(true)); } |
