summaryrefslogtreecommitdiffstats
path: root/sigmodr/TrainerUI.cpp
blob: 728429b3da0c7941441aeccb61d4b3781cf59e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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>());
}