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
142
143
144
145
146
147
148
149
150
151
152
|
/////////////////////////////////////////////////////////////////////////////
// Name: pokegen/CoinListObjectUI.cpp
// Purpose: CoinListObject UI form handling
// Author: Ben Boeckel
// Modified by: Ben Boeckel
// Created: Fri Feb 1 13:35:58 2008
// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions
// Licence:
// 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/>.
/////////////////////////////////////////////////////////////////////////////
#include <QMetaObject>
#include <QVariant>
#include <BugCatcher.h>
#include <Exception.h>
#include <Item.h>
#include <ItemEffect.h>
#include <Pokemod.h>
#include "CoinListObjectUI.h"
CoinListObjectUI::CoinListObjectUI(CoinListObject* c, QWidget* parent) :
ObjectUI(parent),
lastType(-1),
coinListObject(c),
coinListObject_mod(new CoinListObject(c->getPokemod(), *c, c->getId()))
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
setObjects(coinListObject, coinListObject_mod);
varType->addItems(CoinListObject::TypeStr);
setGui();
}
// KToolbar CoinListObjectUI::getToolbar(QWidget* parent)
// {
//
// }
void CoinListObjectUI::setGui()
{
bool resetObjects = (coinListObject_mod->getType() != lastType);
varType->setCurrentIndex(coinListObject_mod->getType());
if (resetObjects)
{
varObject->clear();
if (coinListObject_mod->getType() == CoinListObject::Item)
{
for (int i = 0; i < coinListObject->getPokemod()->getItemCount(); ++i)
{
const Item* it = coinListObject->getPokemod()->getItem(i);
varObject->addItem(it->getName());
varObject->setItemData(i, it->getId());
}
}
else
{
for (int i = 0; i < coinListObject->getPokemod()->getSpeciesCount(); ++i)
{
const Species* s = coinListObject->getPokemod()->getSpecies(i);
varObject->addItem(s->getName());
varObject->setItemData(i, s->getId());
}
}
lastType = coinListObject_mod->getType();
}
varObject->setCurrentIndex(varObject->findData(coinListObject_mod->getObject()));
varAmount->setValue(coinListObject_mod->getAmount());
varCost->setValue(coinListObject_mod->getCost());
}
void CoinListObjectUI::on_buttonApply_clicked()
{
*coinListObject = *coinListObject_mod;
emit(setChanged(false));
}
void CoinListObjectUI::on_buttonDiscard_clicked()
{
*coinListObject_mod = *coinListObject;
emit(setChanged(false));
setGui();
}
void CoinListObjectUI::on_varType_currentIndexChanged(const int t)
{
try
{
coinListObject_mod->setType(t);
emit(setChanged(true));
}
catch (BoundsException& e)
{
BugCatcher::report(e);
}
setGui();
}
void CoinListObjectUI::on_varObject_currentIndexChanged(const int o)
{
try
{
coinListObject_mod->setObject(varObject->itemData(o).toInt());
emit(setChanged(true));
}
catch (BoundsException& e)
{
BugCatcher::report(e);
setGui();
}
}
void CoinListObjectUI::on_varAmount_valueChanged(const int a)
{
try
{
coinListObject_mod->setAmount(a);
emit(setChanged(true));
}
catch (BoundsException& e)
{
BugCatcher::report(e);
setGui();
}
}
void CoinListObjectUI::on_varCost_valueChanged(const int c)
{
try
{
coinListObject_mod->setCost(c);
emit(setChanged(true));
}
catch (BoundsException& e)
{
BugCatcher::report(e);
setGui();
}
}
|