From b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 5 Sep 2008 20:41:05 +0000 Subject: [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 --- sigmodr/CoinListObjectUI.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 sigmodr/CoinListObjectUI.cpp (limited to 'sigmodr/CoinListObjectUI.cpp') 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 + * + * 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 . + */ + +// 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(modified())->type() != m_lastType); + varType->setCurrentIndex(qobject_cast(modified())->type()); + m_lastType = qobject_cast(modified())->type(); + if (resetObjects) + { + varObject->clear(); + if (qobject_cast(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(modified())->object())); + varAmount->setValue(qobject_cast(modified())->amount()); + varCost->setValue(qobject_cast(modified())->cost()); +} + +void Pokemodr::CoinListObjectUI::apply() +{ + *qobject_cast(original()) = *qobject_cast(modified()); + emit(changed(false)); +} + +void Pokemodr::CoinListObjectUI::discard() +{ + *qobject_cast(modified()) = *qobject_cast(original()); + setGui(); + emit(changed(false)); +} + +void Pokemodr::CoinListObjectUI::on_varType_activated(const int type) +{ + qobject_cast(modified())->setType(varType->itemData(type).value()); +} + +void Pokemodr::CoinListObjectUI::on_varObject_activated(const int obey) +{ + qobject_cast(modified())->setObject(varObject->itemData(obey).toInt()); +} + +void Pokemodr::CoinListObjectUI::on_varAmount_valueChanged(const int amount) +{ + qobject_cast(modified())->setAmount(amount); +} + +void Pokemodr::CoinListObjectUI::on_varCost_valueChanged(const int cost) +{ + qobject_cast(modified())->setCost(cost); +} -- cgit