summaryrefslogtreecommitdiffstats
path: root/pokemodr/MapTrainerTeamMemberUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-02-23 19:54:49 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-02-23 19:54:49 +0000
commite4f17883b6c71645933f1930d2dabf338d65a5ba (patch)
tree5c3ff474012f0fc0432f220888259e2b879e16aa /pokemodr/MapTrainerTeamMemberUI.cpp
parent327cb610e065d9e02f176078b064c2780bb1ec03 (diff)
[FIX] Errors with MapWarpUI and MapWildListEncounterUI
[ADD] MapTrainerTeamMemberUI.{h, cpp} git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@77 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/MapTrainerTeamMemberUI.cpp')
-rw-r--r--pokemodr/MapTrainerTeamMemberUI.cpp164
1 files changed, 164 insertions, 0 deletions
diff --git a/pokemodr/MapTrainerTeamMemberUI.cpp b/pokemodr/MapTrainerTeamMemberUI.cpp
new file mode 100644
index 00000000..3b3ec52e
--- /dev/null
+++ b/pokemodr/MapTrainerTeamMemberUI.cpp
@@ -0,0 +1,164 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/MapTrainerTeamMemberUI.cpp
+// Purpose: MapTrainerTeamMember UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sun Jan 27 13:39:26 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 <QListWidgetItem>
+#include <QMetaObject>
+
+#include <BugCatcher.h>
+#include <Exception.h>
+
+#include <Nature.h>
+#include <Pokemod.h>
+#include <Species.h>
+
+#include "MapTrainerTeamMemberUI.h"
+
+MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* t, QWidget* parent) :
+ ObjectUI(parent),
+ mapTrainerTeamMember(t),
+ mapTrainerTeamMember_mod(new MapTrainerTeamMember(t->getPokemod(), *t, t->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(mapTrainerTeamMember, mapTrainerTeamMember_mod);
+ connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setDisabled(bool)));
+ for (int i = 0; i < mapTrainerTeamMember->getPokemod()->getSpeciesCount(); ++i)
+ {
+ const Species* s = mapTrainerTeamMember->getPokemod()->getSpecies(i);
+ varSpecies->addItem(s->getName());
+ varSpecies->setItemData(i, s->getId());
+ }
+ varLevel->setMaximum(mapTrainerTeamMember->getPokemod()->getRules()->getMaxLevel());
+ if (mapTrainerTeamMember->getPokemod()->getRules()->getNatureAllowed())
+ {
+ for (int i = 0; i < mapTrainerTeamMember->getPokemod()->getNatureCount(); ++i)
+ {
+ const Nature* n = mapTrainerTeamMember->getPokemod()->getNature(i);
+ varNature->addItem(n->getName());
+ varNature->setItemData(i, n->getId());
+ }
+ }
+ else
+ boxNature->setEnabled(false);
+ if (mapTrainerTeamMember->getPokemod()->getRules()->getHoldItems())
+ {
+ for (int i = 0; i < mapTrainerTeamMember->getPokemod()->getItemCount(); ++i)
+ {
+ const Item* it = mapTrainerTeamMember->getPokemod()->getItem(i);
+ QListWidgetItem* lwi = new QListWidgetItem(it->getName(), varItems);
+ lwi->setData(Qt::UserRole, it->getId());
+ }
+ }
+ else
+ boxItems->setEnabled(false);
+ setGui();
+}
+
+// KToolbar getToolbar(QWidget* parent)
+// {
+//
+// }
+
+void MapTrainerTeamMemberUI::setGui()
+{
+ varSpecies->setCurrentIndex(varSpecies->findData(mapTrainerTeamMember_mod->getSpecies()));
+ varLevel->setValue(mapTrainerTeamMember_mod->getLevel());
+ varNature->setCurrentIndex(varNature->findData(mapTrainerTeamMember_mod->getNature()));
+ for (int i = 0; i < varItems->count(); ++i)
+ {
+ QListWidgetItem* lwi = varItems->item(i);
+ lwi->setSelected(mapTrainerTeamMember_mod->getItem(lwi->data(Qt::UserRole).toInt()));
+ }
+}
+
+void MapTrainerTeamMemberUI::on_buttonApply_clicked()
+{
+ *mapTrainerTeamMember = *mapTrainerTeamMember_mod;
+ emit(changed(false));
+}
+
+void MapTrainerTeamMemberUI::on_buttonDiscard_clicked()
+{
+ *mapTrainerTeamMember_mod = *mapTrainerTeamMember;
+ emit(changed(false));
+ setGui();
+}
+
+void MapTrainerTeamMemberUI::on_varSpecies_currentIndexChanged(const int s)
+{
+ try
+ {
+ mapTrainerTeamMember_mod->setSpecies(varSpecies->itemData(s).toInt());
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapTrainerTeamMemberUI::on_varLevel_valueChanged(const int l)
+{
+ try
+ {
+ mapTrainerTeamMember_mod->setLevel(l);
+ emit(changed(true));
+ }
+ catch (Exception& e)
+ {
+ BugCatcher::report(e);
+ }
+ setGui();
+}
+
+void MapTrainerTeamMemberUI::on_varNature_currentIndexChanged(const int n)
+{
+ try
+ {
+ mapTrainerTeamMember_mod->setNature(varNature->itemData(n).toInt());
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapTrainerTeamMemberUI::on_varItems_itemSelectionChanged()
+{
+ try
+ {
+ for (int i = 0; i < varItems->count(); ++i)
+ {
+ const QListWidgetItem* lwi = varItems->item(i);
+ mapTrainerTeamMember_mod->setItem(lwi->data(Qt::UserRole).toInt(), lwi->isSelected());
+ }
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}