summaryrefslogtreecommitdiffstats
path: root/sigmodr/SpeciesMoveUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/SpeciesMoveUI.cpp')
-rw-r--r--sigmodr/SpeciesMoveUI.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/sigmodr/SpeciesMoveUI.cpp b/sigmodr/SpeciesMoveUI.cpp
new file mode 100644
index 00000000..27221572
--- /dev/null
+++ b/sigmodr/SpeciesMoveUI.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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/>.
+ */
+
+// Header include
+#include "SpeciesMoveUI.h"
+
+// Pokemod includes
+#include "../pokemod/Move.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Rules.h"
+#include "../pokemod/SpeciesMove.h"
+
+Pokemodr::SpeciesMoveUI::SpeciesMoveUI(Pokemod::SpeciesMove* move, QWidget* parent) :
+ ObjectUI(parent)
+{
+ setupUi(this);
+ setObjects(move, new Pokemod::SpeciesMove(*move));
+}
+
+Pokemodr::SpeciesMoveUI::~SpeciesMoveUI()
+{
+}
+
+void Pokemodr::SpeciesMoveUI::refreshGui()
+{
+ varMove->clear();
+ for (int i = 0; i < pokemod()->moveCount(); ++i)
+ {
+ const Pokemod::Move* move = pokemod()->move(i);
+ varMove->addItem(move->name(), move->id());
+ }
+ varLevel->setMaximum(pokemod()->rules()->maxLevel());
+ varWildLevel->setMaximum(pokemod()->rules()->maxLevel());
+}
+
+void Pokemodr::SpeciesMoveUI::setGui()
+{
+ varMove->setCurrentIndex(varMove->findData(qobject_cast<Pokemod::SpeciesMove*>(modified())->move()));
+ varLevel->setValue(qobject_cast<Pokemod::SpeciesMove*>(modified())->level());
+ varWildLevel->setValue(qobject_cast<Pokemod::SpeciesMove*>(modified())->wild());
+}
+
+void Pokemodr::SpeciesMoveUI::apply()
+{
+ *qobject_cast<Pokemod::SpeciesMove*>(original()) = *qobject_cast<Pokemod::SpeciesMove*>(modified());
+ emit(changed(false));
+}
+
+void Pokemodr::SpeciesMoveUI::discard()
+{
+ *qobject_cast<Pokemod::SpeciesMove*>(modified()) = *qobject_cast<Pokemod::SpeciesMove*>(original());
+ setGui();
+ emit(changed(false));
+}
+
+void Pokemodr::SpeciesMoveUI::on_varMove_activated(const int move)
+{
+ qobject_cast<Pokemod::SpeciesMove*>(modified())->setMove(varMove->itemData(move).toInt());
+}
+
+void Pokemodr::SpeciesMoveUI::on_varLevel_valueChanged(const int level)
+{
+ qobject_cast<Pokemod::SpeciesMove*>(modified())->setLevel(level);
+}
+
+void Pokemodr::SpeciesMoveUI::on_varWildLevel_valueChanged(const int wildLevel)
+{
+ qobject_cast<Pokemod::SpeciesMove*>(modified())->setWild(wildLevel);
+}