/* * 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 "NatureUI.h" // Pokemod includes #include "../pokemod/Nature.h" #include "../pokemod/Pokemod.h" NatureUI::NatureUI(Nature* nature, QWidget* parent) : ObjectUI(parent) { setupUi(this); QMetaObject::connectSlotsByName(this); setObjects(nature, new Nature(*nature)); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } NatureUI::~NatureUI() { } void NatureUI::initGui() { connect(varStat, SIGNAL(currentIndexChanged()), this, SLOT(setGui())); } void NatureUI::refreshGui() { varStat->clear(); const bool isSplit = static_cast(original()->pokemod())->rules()->specialSplit(); varStat->addItems((isSplit ? Pokemod::StatRBYStr : Pokemod::StatGSCStr).mid(0, isSplit ? Pokemod::ST_End_RBY : Pokemod::ST_End_GSC)); } void NatureUI::setGui() { varName->setText(static_cast(modified())->name()); varStatMultiplier->setValue(static_cast(modified())->stat(varStat->currentIndex())); varWeight->setValue(static_cast(modified())->weight()); } void NatureUI::apply() { *static_cast(original()) = *static_cast(modified()); emit(changed(false)); } void NatureUI::discard() { *static_cast(modified()) = *static_cast(original()); setGui(); emit(changed(false)); } void NatureUI::on_varName_textChanged(const QString& name) { static_cast(modified())->setName(name); } void NatureUI::on_varStatMultiplier_valueChanged(const Fraction& statMultiplier) { static_cast(modified())->setStat(varStat->currentIndex(), statMultiplier); } void NatureUI::on_varWeight_valueChanged(const int weight) { static_cast(modified())->setWeight(weight); }