/* * 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 "TrainerUI.h" // Sigmod includes #include "../sigmod/Rules.h" #include "../sigmod/Sigmod.h" #include "../sigmod/Skin.h" #include "../sigmod/Trainer.h" Sigmodr::TrainerUI::TrainerUI(Sigmod::Trainer* trainer, QWidget* parent) : ObjectUI(parent) { setupUi(this); setObjects(trainer, new Sigmod::Trainer(*trainer)); } Sigmodr::TrainerUI::~TrainerUI() { } void Sigmodr::TrainerUI::initGui() { varTeamIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Ignorant], QVariant::fromValue(Sigmod::Trainer::Ignorant)); varTeamIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Determine], QVariant::fromValue(Sigmod::Trainer::Determine)); varTeamIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Remember], QVariant::fromValue(Sigmod::Trainer::Remember)); varTeamIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Cheating], QVariant::fromValue(Sigmod::Trainer::Cheating)); varMoveIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Ignorant], QVariant::fromValue(Sigmod::Trainer::Ignorant)); varMoveIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Determine], QVariant::fromValue(Sigmod::Trainer::Determine)); varMoveIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Remember], QVariant::fromValue(Sigmod::Trainer::Remember)); varMoveIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Cheating], QVariant::fromValue(Sigmod::Trainer::Cheating)); varItemIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Ignorant], QVariant::fromValue(Sigmod::Trainer::Ignorant)); varItemIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Determine], QVariant::fromValue(Sigmod::Trainer::Determine)); varItemIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Remember], QVariant::fromValue(Sigmod::Trainer::Remember)); varItemIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Cheating], QVariant::fromValue(Sigmod::Trainer::Cheating)); varAbilityIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Ignorant], QVariant::fromValue(Sigmod::Trainer::Ignorant)); varAbilityIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Determine], QVariant::fromValue(Sigmod::Trainer::Determine)); varAbilityIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Remember], QVariant::fromValue(Sigmod::Trainer::Remember)); varAbilityIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Cheating], QVariant::fromValue(Sigmod::Trainer::Cheating)); varStatIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Ignorant], QVariant::fromValue(Sigmod::Trainer::Ignorant)); varStatIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Determine], QVariant::fromValue(Sigmod::Trainer::Determine)); varStatIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Remember], QVariant::fromValue(Sigmod::Trainer::Remember)); varStatIntel->addItem(Sigmod::Trainer::IntelligenceStr[Sigmod::Trainer::Cheating], QVariant::fromValue(Sigmod::Trainer::Cheating)); } void Sigmodr::TrainerUI::refreshGui() { for (int i = 0; i < sigmod()->skinCount(); ++i) { const Sigmod::Skin* skin = sigmod()->skin(i); varSkin->addItem(skin->name(), skin->id()); } varItemIntel->setEnabled(sigmod()->rules()->maxHeldItems()); varAbilityIntel->setEnabled(sigmod()->rules()->maxAbilities()); } void Sigmodr::TrainerUI::setGui() { varName->setText(qobject_cast(modified())->name()); varMoneyFactor->setValue(qobject_cast(modified())->moneyFactor()); varSkin->setCurrentIndex(varSkin->findData(qobject_cast(modified())->skin())); varDepth->setValue(qobject_cast(modified())->depth()); varTeamIntel->setCurrentIndex(qobject_cast(modified())->teamIntel()); varMoveIntel->setCurrentIndex(qobject_cast(modified())->moveIntel()); varItemIntel->setCurrentIndex(qobject_cast(modified())->itemIntel()); varAbilityIntel->setCurrentIndex(qobject_cast(modified())->abilityIntel()); varStatIntel->setCurrentIndex(qobject_cast(modified())->statIntel()); } void Sigmodr::TrainerUI::apply() { *qobject_cast(original()) = *qobject_cast(modified()); emit(changed(false)); } void Sigmodr::TrainerUI::discard() { *qobject_cast(modified()) = *qobject_cast(original()); emit(changed(false)); } void Sigmodr::TrainerUI::on_varName_textChanged(const QString& name) { qobject_cast(modified())->setName(name); } void Sigmodr::TrainerUI::on_varMoneyFactor_valueChanged(const int moneyFactor) { qobject_cast(modified())->setMoneyFactor(moneyFactor); } void Sigmodr::TrainerUI::on_varSkin_currentIndexChanged(const int skin) { qobject_cast(modified())->setSkin(varSkin->itemData(skin).toInt()); } void Sigmodr::TrainerUI::on_varDepth_valueChanged(const int depth) { qobject_cast(modified())->setDepth(depth); } void Sigmodr::TrainerUI::on_varTeamIntel_activated(const int teamIntel) { qobject_cast(modified())->setTeamIntel(varTeamIntel->itemData(teamIntel).value()); } void Sigmodr::TrainerUI::on_varMoveIntel_activated(const int moveIntel) { qobject_cast(modified())->setMoveIntel(varMoveIntel->itemData(moveIntel).value()); } void Sigmodr::TrainerUI::on_varItemIntel_activated(const int itemIntel) { qobject_cast(modified())->setItemIntel(varItemIntel->itemData(itemIntel).value()); } void Sigmodr::TrainerUI::on_varAbilityIntel_activated(const int abilityIntel) { qobject_cast(modified())->setAbilityIntel(varAbilityIntel->itemData(abilityIntel).value()); } void Sigmodr::TrainerUI::on_varStatIntel_activated(const int statIntel) { qobject_cast(modified())->setStatIntel(varStatIntel->itemData(statIntel).value()); }