summaryrefslogtreecommitdiffstats
path: root/sigmodr/CoinListObjectUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-09-05 20:41:05 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-09-05 20:41:05 +0000
commitb81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7 (patch)
tree6609f31b1635d948cf7a216c7fea72cfb3c905a0 /sigmodr/CoinListObjectUI.cpp
parentb99ffef4aa68dd5f0af64de9aec0f610e267d8cc (diff)
downloadsigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.tar.gz
sigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.tar.xz
sigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.zip
[FIX] Moving stuff for the move to the new name, Sigma Game Engine (sigen for short)
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@249 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'sigmodr/CoinListObjectUI.cpp')
-rw-r--r--sigmodr/CoinListObjectUI.cpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/sigmodr/CoinListObjectUI.cpp b/sigmodr/CoinListObjectUI.cpp
new file mode 100644
index 00000000..81c57041
--- /dev/null
+++ b/sigmodr/CoinListObjectUI.cpp
@@ -0,0 +1,109 @@
+/*
+ * 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 "CoinListObjectUI.h"
+
+// Pokemod includes
+#include "../pokemod/CoinListObject.h"
+#include "../pokemod/Item.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Species.h"
+
+Pokemodr::CoinListObjectUI::CoinListObjectUI(Pokemod::CoinListObject* object, QWidget* parent) :
+ ObjectUI(parent),
+ m_lastType(-1)
+{
+ setupUi(this);
+ setObjects(object, new Pokemod::CoinListObject(*object));
+}
+
+Pokemodr::CoinListObjectUI::~CoinListObjectUI()
+{
+}
+
+void Pokemodr::CoinListObjectUI::initGui()
+{
+ connect(varType, SIGNAL(activated(const int)), this, SLOT(setGui()));
+ varType->addItem(Pokemod::CoinListObject::TypeStr[Pokemod::CoinListObject::Item], QVariant::fromValue(Pokemod::CoinListObject::Item));
+ varType->addItem(Pokemod::CoinListObject::TypeStr[Pokemod::CoinListObject::Species], QVariant::fromValue(Pokemod::CoinListObject::Species));
+}
+
+void Pokemodr::CoinListObjectUI::setGui()
+{
+ bool resetObjects = (qobject_cast<Pokemod::CoinListObject*>(modified())->type() != m_lastType);
+ varType->setCurrentIndex(qobject_cast<Pokemod::CoinListObject*>(modified())->type());
+ m_lastType = qobject_cast<Pokemod::CoinListObject*>(modified())->type();
+ if (resetObjects)
+ {
+ varObject->clear();
+ if (qobject_cast<Pokemod::CoinListObject*>(modified())->type() == Pokemod::CoinListObject::Item)
+ {
+ for (int i = 0; i < pokemod()->itemCount(); ++i)
+ {
+ const Pokemod::Item* item = pokemod()->item(i);
+ varObject->addItem(item->name(), item->id());
+ }
+ varAmount->setMaximum(INT_MAX);
+ }
+ else
+ {
+ for (int i = 0; i < pokemod()->speciesCount(); ++i)
+ {
+ const Pokemod::Species* species = pokemod()->species(i);
+ varObject->addItem(species->name(), species->id());
+ }
+ varAmount->setMaximum(1);
+ }
+ }
+ varObject->setCurrentIndex(varObject->findData(qobject_cast<Pokemod::CoinListObject*>(modified())->object()));
+ varAmount->setValue(qobject_cast<Pokemod::CoinListObject*>(modified())->amount());
+ varCost->setValue(qobject_cast<Pokemod::CoinListObject*>(modified())->cost());
+}
+
+void Pokemodr::CoinListObjectUI::apply()
+{
+ *qobject_cast<Pokemod::CoinListObject*>(original()) = *qobject_cast<Pokemod::CoinListObject*>(modified());
+ emit(changed(false));
+}
+
+void Pokemodr::CoinListObjectUI::discard()
+{
+ *qobject_cast<Pokemod::CoinListObject*>(modified()) = *qobject_cast<Pokemod::CoinListObject*>(original());
+ setGui();
+ emit(changed(false));
+}
+
+void Pokemodr::CoinListObjectUI::on_varType_activated(const int type)
+{
+ qobject_cast<Pokemod::CoinListObject*>(modified())->setType(varType->itemData(type).value<Pokemod::CoinListObject::Type>());
+}
+
+void Pokemodr::CoinListObjectUI::on_varObject_activated(const int obey)
+{
+ qobject_cast<Pokemod::CoinListObject*>(modified())->setObject(varObject->itemData(obey).toInt());
+}
+
+void Pokemodr::CoinListObjectUI::on_varAmount_valueChanged(const int amount)
+{
+ qobject_cast<Pokemod::CoinListObject*>(modified())->setAmount(amount);
+}
+
+void Pokemodr::CoinListObjectUI::on_varCost_valueChanged(const int cost)
+{
+ qobject_cast<Pokemod::CoinListObject*>(modified())->setCost(cost);
+}