summaryrefslogtreecommitdiffstats
path: root/pokemodr/MapWarpUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-27 17:57:32 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-27 17:57:32 +0000
commit0fa52c1f61c457c9b68bec53bcce3af858e5eb44 (patch)
treec5b10b77a01b417775097476029bcf67fac79975 /pokemodr/MapWarpUI.cpp
parent807071d35159de0660f9df31c48d5bf895ca3622 (diff)
[FIX] More header cleanliness
[FIX] UI classes now just use the ObjectUI pointers [FIX] Some miscellaneous qmake options git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@112 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/MapWarpUI.cpp')
-rw-r--r--pokemodr/MapWarpUI.cpp93
1 files changed, 46 insertions, 47 deletions
diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp
index 9eb84fe8..551d0202 100644
--- a/pokemodr/MapWarpUI.cpp
+++ b/pokemodr/MapWarpUI.cpp
@@ -20,29 +20,28 @@
// Pokemod includes
#include "../pokemod/Dialog.h"
-#include "../pokemod/Pokemod.h"
#include "../pokemod/Map.h"
+#include "../pokemod/MapWarp.h"
+#include "../pokemod/Pokemod.h"
// General includes
#include "../general/BugCatcher.h"
-#include "../general/Exception.h"
-
-// Qt includes
-#include <QListWidgetItem>
MapWarpUI::MapWarpUI(MapWarp* warp, QWidget* parent) :
ObjectUI(parent),
- m_lastMap(-1),
- m_warp(warp),
- m_warp_mod(new MapWarp(*warp))
+ m_lastMap(-1)
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
- setObjects(m_warp, m_warp_mod);
+ setObjects(warp, new MapWarp(*warp));
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool)));
init();
}
+MapWarpUI::~MapWarpUI()
+{
+}
+
void MapWarpUI::initGui()
{
varActivation->addItems(Pokemod::DirectionStr.mid(0, Pokemod::D_End));
@@ -52,16 +51,16 @@ void MapWarpUI::initGui()
void MapWarpUI::refreshGui()
{
varToMap->clear();
- for (int i = 0; i < static_cast<const Pokemod*>(m_warp->pokemod())->mapCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(static_cast<MapWarp*>(original())->pokemod())->mapCount(); ++i)
{
- const Map* map = static_cast<const Pokemod*>(m_warp->pokemod())->map(i);
+ const Map* map = static_cast<const Pokemod*>(static_cast<MapWarp*>(original())->pokemod())->map(i);
varToMap->addItem(map->name());
varToMap->setItemData(i, map->id());
}
varDialog->clear();
- for (int i = 0; i < static_cast<const Pokemod*>(m_warp->pokemod())->dialogCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(static_cast<MapWarp*>(original())->pokemod())->dialogCount(); ++i)
{
- const Dialog* dialog = static_cast<const Pokemod*>(m_warp->pokemod())->dialog(i);
+ const Dialog* dialog = static_cast<const Pokemod*>(static_cast<MapWarp*>(original())->pokemod())->dialog(i);
varDialog->addItem(dialog->dialog().mid(0, 25));
varDialog->setItemData(i, dialog->id());
}
@@ -69,27 +68,27 @@ void MapWarpUI::refreshGui()
void MapWarpUI::setGui()
{
- const bool resetWarps = (m_warp_mod->toMap() == m_lastMap);
- varName->setText(m_warp_mod->name());
- varCoordinate->setValue(m_warp_mod->coordinate());
+ const bool resetWarps = (static_cast<MapWarp*>(modified())->toMap() == m_lastMap);
+ varName->setText(static_cast<MapWarp*>(modified())->name());
+ varCoordinate->setValue(static_cast<MapWarp*>(modified())->coordinate());
for (int i = 0; i < varActivation->count(); ++i)
- varActivation->item(i)->setSelected(m_warp_mod->from(i));
- varDirectionOut->setCurrentIndex(m_warp_mod->directionOut());
- varType->setCurrentIndex(m_warp_mod->warpType());
- varBiking->setCheckState((m_warp_mod->isBiking() == Flag::On) ? Qt::Checked : ((m_warp_mod->isBiking() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
- varFlash->setCheckState((m_warp_mod->isFlash() == Flag::On) ? Qt::Checked : ((m_warp_mod->isFlash() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
- varFog->setCheckState((m_warp_mod->isFoggy() == Flag::On) ? Qt::Checked : ((m_warp_mod->isFoggy() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
- varToMap->setCurrentIndex(varToMap->findData(m_warp_mod->toMap()));
- m_lastMap = m_warp_mod->toMap();
+ varActivation->item(i)->setSelected(static_cast<MapWarp*>(modified())->from(i));
+ varDirectionOut->setCurrentIndex(static_cast<MapWarp*>(modified())->directionOut());
+ varType->setCurrentIndex(static_cast<MapWarp*>(modified())->warpType());
+ varBiking->setCheckState((static_cast<MapWarp*>(modified())->isBiking() == Flag::On) ? Qt::Checked : ((static_cast<MapWarp*>(modified())->isBiking() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
+ varFlash->setCheckState((static_cast<MapWarp*>(modified())->isFlash() == Flag::On) ? Qt::Checked : ((static_cast<MapWarp*>(modified())->isFlash() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
+ varFog->setCheckState((static_cast<MapWarp*>(modified())->isFoggy() == Flag::On) ? Qt::Checked : ((static_cast<MapWarp*>(modified())->isFoggy() == Flag::Off) ? Qt::Unchecked : Qt::PartiallyChecked));
+ varToMap->setCurrentIndex(varToMap->findData(static_cast<MapWarp*>(modified())->toMap()));
+ m_lastMap = static_cast<MapWarp*>(modified())->toMap();
if (resetWarps)
{
varToWarp->clear();
- int index = static_cast<const Pokemod*>(m_warp->pokemod())->mapIndex(m_warp_mod->toMap());
+ int index = static_cast<const Pokemod*>(static_cast<MapWarp*>(original())->pokemod())->mapIndex(static_cast<MapWarp*>(modified())->toMap());
if (index != INT_MAX)
{
try
{
- const Map* map = static_cast<const Pokemod*>(m_warp->pokemod())->map(index);
+ const Map* map = static_cast<const Pokemod*>(static_cast<MapWarp*>(original())->pokemod())->map(index);
for (int i = 0; i < map->warpCount(); ++i)
{
const MapWarp* warp = map->warp(i);
@@ -103,38 +102,38 @@ void MapWarpUI::setGui()
}
}
}
- varToWarp->setCurrentIndex(varToMap->findData(m_warp_mod->toWarp()));
- boxFlag->setChecked((m_warp_mod->workingFlag().status() == Flag::Ignore) ? Qt::Unchecked : Qt::Checked);
+ varToWarp->setCurrentIndex(varToMap->findData(static_cast<MapWarp*>(modified())->toWarp()));
+ boxFlag->setChecked((static_cast<MapWarp*>(modified())->workingFlag().status() == Flag::Ignore) ? Qt::Unchecked : Qt::Checked);
if (boxFlag->isChecked())
{
- varFlag->setValue(m_warp_mod->workingFlag().flag());
- varState->setCheckState((m_warp_mod->workingFlag().status() == Flag::On) ? Qt::Checked : Qt::Unchecked);
+ varFlag->setValue(static_cast<MapWarp*>(modified())->workingFlag().flag());
+ varState->setCheckState((static_cast<MapWarp*>(modified())->workingFlag().status() == Flag::On) ? Qt::Checked : Qt::Unchecked);
}
- varDialog->setCurrentIndex(varDialog->findData(m_warp_mod->dialog()));
+ varDialog->setCurrentIndex(varDialog->findData(static_cast<MapWarp*>(modified())->dialog()));
}
void MapWarpUI::on_buttonApply_clicked()
{
- *m_warp = *m_warp_mod;
+ *static_cast<MapWarp*>(original()) = *static_cast<MapWarp*>(modified());
emit(changed(false));
}
void MapWarpUI::on_buttonDiscard_clicked()
{
- *m_warp_mod = *m_warp;
+ *static_cast<MapWarp*>(modified()) = *static_cast<MapWarp*>(original());
setGui();
emit(changed(false));
}
void MapWarpUI::on_varName_textChanged(const QString& name)
{
- m_warp_mod->setName(name);
+ static_cast<MapWarp*>(modified())->setName(name);
emit(changed(true));
}
void MapWarpUI::on_varCoordinate_valueChanged(const Point& coordinate)
{
- m_warp_mod->setCoordinate(coordinate);
+ static_cast<MapWarp*>(modified())->setCoordinate(coordinate);
emit(changed(true));
}
@@ -143,7 +142,7 @@ void MapWarpUI::on_varActivation_itemSelectionChanged()
try
{
for (int i = 0; i < varActivation->count(); ++i)
- m_warp_mod->setFrom(i, varActivation->item(i)->isSelected());
+ static_cast<MapWarp*>(modified())->setFrom(i, varActivation->item(i)->isSelected());
emit(changed(true));
}
catch (BoundsException& exception)
@@ -157,7 +156,7 @@ void MapWarpUI::on_varDirectionOut_currentIndexChanged(const int directionOut)
{
try
{
- m_warp_mod->setDirectionOut(directionOut);
+ static_cast<MapWarp*>(modified())->setDirectionOut(directionOut);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -171,7 +170,7 @@ void MapWarpUI::on_varType_currentIndexChanged(const int type)
{
try
{
- m_warp_mod->setWarpType(type);
+ static_cast<MapWarp*>(modified())->setWarpType(type);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -185,7 +184,7 @@ void MapWarpUI::on_varBiking_stateChanged(const int biking)
{
try
{
- m_warp_mod->setIsBiking(biking);
+ static_cast<MapWarp*>(modified())->setIsBiking(biking);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -199,7 +198,7 @@ void MapWarpUI::on_varFlash_stateChanged(const int flash)
{
try
{
- m_warp_mod->setIsFlash(flash);
+ static_cast<MapWarp*>(modified())->setIsFlash(flash);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -213,7 +212,7 @@ void MapWarpUI::on_varFog_stateChanged(const int fog)
{
try
{
- m_warp_mod->setIsFoggy(fog);
+ static_cast<MapWarp*>(modified())->setIsFoggy(fog);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -227,7 +226,7 @@ void MapWarpUI::on_varToMap_currentIndexChanged(const int toMap)
{
try
{
- m_warp_mod->setToMap(toMap);
+ static_cast<MapWarp*>(modified())->setToMap(toMap);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -241,7 +240,7 @@ void MapWarpUI::on_varToWarp_currentIndexChanged(const int toWarp)
{
try
{
- m_warp_mod->setToWarp(toWarp);
+ static_cast<MapWarp*>(modified())->setToWarp(toWarp);
emit(changed(true));
}
catch (BoundsException& exception)
@@ -254,20 +253,20 @@ void MapWarpUI::on_varToWarp_currentIndexChanged(const int toWarp)
void MapWarpUI::on_boxFlag_toggled(const bool flagUsed)
{
if (!flagUsed)
- m_warp_mod->setWorkingFlag(Flag(varFlag->value(), Flag::Ignore));
+ static_cast<MapWarp*>(modified())->setWorkingFlag(Flag(varFlag->value(), Flag::Ignore));
emit(changed(true));
setGui();
}
void MapWarpUI::on_varFlag_valueChanged(const int flag)
{
- m_warp_mod->setWorkingFlag(Flag(flag, boxFlag->isChecked() ? Flag::Ignore : (varState->isChecked() ? Flag::On : Flag::Off)));
+ static_cast<MapWarp*>(modified())->setWorkingFlag(Flag(flag, boxFlag->isChecked() ? Flag::Ignore : (varState->isChecked() ? Flag::On : Flag::Off)));
emit(changed(true));
}
void MapWarpUI::on_varState_toggled(const bool status)
{
- m_warp_mod->setWorkingFlag(Flag(varFlag->value(), status ? Flag::On : Flag::Off));
+ static_cast<MapWarp*>(modified())->setWorkingFlag(Flag(varFlag->value(), status ? Flag::On : Flag::Off));
emit(changed(true));
}
@@ -275,7 +274,7 @@ void MapWarpUI::on_varDialog_currentIndexChanged(const int dialog)
{
try
{
- m_warp_mod->setDialog(dialog);
+ static_cast<MapWarp*>(modified())->setDialog(dialog);
emit(changed(true));
}
catch (BoundsException& exception)