summaryrefslogtreecommitdiffstats
path: root/pokemodr/MapWarpUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/MapWarpUI.cpp')
-rw-r--r--pokemodr/MapWarpUI.cpp286
1 files changed, 286 insertions, 0 deletions
diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp
new file mode 100644
index 00000000..eb4fc0f6
--- /dev/null
+++ b/pokemodr/MapWarpUI.cpp
@@ -0,0 +1,286 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/MapWarpUI.cpp
+// Purpose: MapWarp UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sat Feb 23 03:31:28 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 <Ref.h>
+
+#include <Dialog.h>
+#include <Map.h>
+#include <Pokemod.h>
+
+#include "MapWarpUI.h"
+
+MapWarpUI::MapWarpUI(MapWarp* w, QWidget* parent) :
+ ObjectUI(parent),
+ mapWarp(w),
+ mapWarp_mod(new MapWarp(w->getPokemod(), *w, w->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(mapWarp, mapWarp_mod);
+ connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setDisabled(bool)));
+ varActivation->addItems(DirectionStr.mid(0, D_End));
+ varType->addItems(MapWarp::TypeStr);
+ for (int i = 0; i < mapWarp->getPokemod()->getMapCount(); ++i)
+ {
+ const Map* m = mapWarp->getPokemod()->getMap(i);
+ varToMap->addItem(m->getName());
+ varToMap->setItemData(i, m->getId());
+ }
+ for (int i = 0; i < mapWarp->getPokemod()->getDialogCount(); ++i)
+ {
+ const Dialog* d = mapWarp->getPokemod()->getDialog(i);
+ varDialog->addItem(d->getDialog().mid(0, 25));
+ varDialog->setItemData(i, d->getId());
+ }
+ setGui();
+}
+
+// KToolbar getToolbar(QWidget* parent)
+// {
+//
+// }
+
+void MapWarpUI::setGui()
+{
+ const bool resetWarps = (mapWarp_mod->getToMap() == lastMap);
+ varName->setText(mapWarp_mod->getName());
+ varCoordinateX->setValue(mapWarp_mod->getCoordinate().getX());
+ varCoordinateY->setValue(mapWarp_mod->getCoordinate().getY());
+ for (unsigned i = 0; i < D_End; ++i)
+ varActivation->item(i)->setSelected(mapWarp_mod->getFrom(i));
+ varDirectionOut->setCurrentIndex(mapWarp_mod->getDirectionOut());
+ varType->setCurrentIndex(mapWarp_mod->getWarpType());
+ varBiking->setCheckState((mapWarp_mod->getIsBiking() == Flag::On) ? Qt::Checked : ((mapWarp_mod->getIsBiking() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
+ varFlash->setCheckState((mapWarp_mod->getIsFlash() == Flag::On) ? Qt::Checked : ((mapWarp_mod->getIsFlash() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
+ varFog->setCheckState((mapWarp_mod->getIsFoggy() == Flag::On) ? Qt::Checked : ((mapWarp_mod->getIsFoggy() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
+ varToMap->setCurrentIndex(varToMap->findData(mapWarp_mod->getToMap()));
+ lastMap = mapWarp_mod->getToMap();
+ if (resetWarps)
+ {
+ varToWarp->clear();
+ try
+ {
+ const Map* m = mapWarp->getPokemod()->getMapByID(mapWarp_mod->getToMap());
+ for (int i = 0; i < m->getWarpCount(); ++i)
+ {
+ const MapWarp* w = m->getWarp(i);
+ varToWarp->addItem(w->getName());
+ varToWarp->setItemData(i, w->getId());
+ }
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ }
+ }
+ varToWarp->setCurrentIndex(varToMap->findData(mapWarp_mod->getToWarp()));
+ boxFlag->setCheckState((mapWarp_mod->getWorkingFlag().getStatus() == Flag::Ignore) ? Qt::Unchecked : Qt::Checked);
+ if (boxFlag->isChecked())
+ {
+ varFlag->setValue(mapWarp_mod->getWorkingFlag().getFlag());
+ varState->setCheckState((mapWarp_mod->getWorkingFlag().getStatus() == Flag::On) ? Qt::Checked : Qt::Unchecked);
+ }
+ varDialog->setCurrentIndex(varDialog->findData(mapWarp_mod->getDialog()));
+}
+
+void MapWarpUI::on_buttonApply_clicked()
+{
+ *mapWarp = *mapWarp_mod;
+ emit(changed(false));
+}
+
+void MapWarpUI::on_buttonDiscard_clicked()
+{
+ *mapWarp_mod = *mapWarp;
+ emit(changed(false));
+ setGui();
+}
+
+void MapWarpUI::on_varName_textChanged(const QString& n)
+{
+ mapWarp_mod->setName(n);
+ emit(changed(true));
+}
+
+void MapWarpUI::on_varCoordinateX_valueChanged(const int x)
+{
+ mapWarp_mod->setCoordinateX(x);
+ emit(changed(true));
+}
+
+void MapWarpUI::on_varCoordinateY_valueChanged(const int y)
+{
+ mapWarp_mod->setCoordinateY(y);
+ emit(changed(true));
+}
+
+void MapWarpUI::on_varActivation_itemSelectionChanged()
+{
+ try
+ {
+ for (int i = 0; i < varActivation->count(); ++i)
+ mapWarp_mod->setFrom(i, varActivation->item(i)->isSelected());
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapWarpUI::on_varDirectionOut_currentIndexChanged(const int d)
+{
+ try
+ {
+ mapWarp_mod->setDirectionOut(d);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapWarpUI::on_varType_currentIndexChanged(const int t)
+{
+ try
+ {
+ mapWarp_mod->setWarpType(t);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapWarpUI::on_varBiking_stateChanged(const int b)
+{
+ try
+ {
+ mapWarp_mod->setIsBiking(b);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapWarpUI::on_varFlash_stateChanged(const int f)
+{
+ try
+ {
+ mapWarp_mod->setIsFlash(f);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapWarpUI::on_varFog_stateChanged(const int f)
+{
+ try
+ {
+ mapWarp_mod->setIsFoggy(f);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void MapWarpUI::on_varToMap_currentIndexChanged(const int m)
+{
+ try
+ {
+ mapWarp_mod->setToMap(m);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ }
+ setGui();
+}
+
+void MapWarpUI::on_varToWarp_currentIndexChanged(const int w)
+{
+ try
+ {
+ mapWarp_mod->setToWarp(w);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void on_boxFlag_toggled(const bool f)
+{
+ if (f)
+ mapWarp_mod->setWorkingFlagStatus(Flag::Ignore);
+ emit(changed(true));
+ setGui();
+}
+
+void MapWarpUI::on_varFlag_valueChanged(const int f)
+{
+ mapWarp_mod->setWorkingFlagFlag(f);
+ emit(changed(true));
+}
+
+void MapWarpUI::on_varState_toggled(const bool s)
+{
+ mapWarp_mod->setWorkingFlagStatus(s ? Flag::On : Flag::Off);
+ emit(changed(true));
+}
+
+void MapWarpUI::on_varDialog_currentIndexChanged(const int d)
+{
+ try
+ {
+ mapWarp_mod->setDialog(d);
+ emit(changed(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}