summaryrefslogtreecommitdiffstats
path: root/sigmodr/widgets/TrainerUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/widgets/TrainerUI.cpp')
-rw-r--r--sigmodr/widgets/TrainerUI.cpp141
1 files changed, 141 insertions, 0 deletions
diff --git a/sigmodr/widgets/TrainerUI.cpp b/sigmodr/widgets/TrainerUI.cpp
new file mode 100644
index 00000000..728429b3
--- /dev/null
+++ b/sigmodr/widgets/TrainerUI.cpp
@@ -0,0 +1,141 @@
+/*
+ * 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 "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<Sigmod::Trainer*>(modified())->name());
+ varMoneyFactor->setValue(qobject_cast<Sigmod::Trainer*>(modified())->moneyFactor());
+ varSkin->setCurrentIndex(varSkin->findData(qobject_cast<Sigmod::Trainer*>(modified())->skin()));
+ varDepth->setValue(qobject_cast<Sigmod::Trainer*>(modified())->depth());
+ varTeamIntel->setCurrentIndex(qobject_cast<Sigmod::Trainer*>(modified())->teamIntel());
+ varMoveIntel->setCurrentIndex(qobject_cast<Sigmod::Trainer*>(modified())->moveIntel());
+ varItemIntel->setCurrentIndex(qobject_cast<Sigmod::Trainer*>(modified())->itemIntel());
+ varAbilityIntel->setCurrentIndex(qobject_cast<Sigmod::Trainer*>(modified())->abilityIntel());
+ varStatIntel->setCurrentIndex(qobject_cast<Sigmod::Trainer*>(modified())->statIntel());
+}
+
+void Sigmodr::TrainerUI::apply()
+{
+ *qobject_cast<Sigmod::Trainer*>(original()) = *qobject_cast<Sigmod::Trainer*>(modified());
+ emit(changed(false));
+}
+
+void Sigmodr::TrainerUI::discard()
+{
+ *qobject_cast<Sigmod::Trainer*>(modified()) = *qobject_cast<Sigmod::Trainer*>(original());
+ emit(changed(false));
+}
+
+void Sigmodr::TrainerUI::on_varName_textChanged(const QString& name)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setName(name);
+}
+
+void Sigmodr::TrainerUI::on_varMoneyFactor_valueChanged(const int moneyFactor)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setMoneyFactor(moneyFactor);
+}
+
+void Sigmodr::TrainerUI::on_varSkin_currentIndexChanged(const int skin)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setSkin(varSkin->itemData(skin).toInt());
+}
+
+void Sigmodr::TrainerUI::on_varDepth_valueChanged(const int depth)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setDepth(depth);
+}
+
+void Sigmodr::TrainerUI::on_varTeamIntel_activated(const int teamIntel)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setTeamIntel(varTeamIntel->itemData(teamIntel).value<Sigmod::Trainer::Intelligence>());
+}
+
+void Sigmodr::TrainerUI::on_varMoveIntel_activated(const int moveIntel)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setMoveIntel(varMoveIntel->itemData(moveIntel).value<Sigmod::Trainer::Intelligence>());
+}
+
+void Sigmodr::TrainerUI::on_varItemIntel_activated(const int itemIntel)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setItemIntel(varItemIntel->itemData(itemIntel).value<Sigmod::Trainer::Intelligence>());
+}
+
+void Sigmodr::TrainerUI::on_varAbilityIntel_activated(const int abilityIntel)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setAbilityIntel(varAbilityIntel->itemData(abilityIntel).value<Sigmod::Trainer::Intelligence>());
+}
+
+void Sigmodr::TrainerUI::on_varStatIntel_activated(const int statIntel)
+{
+ qobject_cast<Sigmod::Trainer*>(modified())->setStatIntel(varStatIntel->itemData(statIntel).value<Sigmod::Trainer::Intelligence>());
+}