summaryrefslogtreecommitdiffstats
path: root/pokemodr/PokemodUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/PokemodUI.cpp')
-rw-r--r--pokemodr/PokemodUI.cpp101
1 files changed, 14 insertions, 87 deletions
diff --git a/pokemodr/PokemodUI.cpp b/pokemodr/PokemodUI.cpp
index a4ab4495..788df1b4 100644
--- a/pokemodr/PokemodUI.cpp
+++ b/pokemodr/PokemodUI.cpp
@@ -28,9 +28,6 @@
#include "../pokemod/MapWarp.h"
#include "../pokemod/Pokemod.h"
-// General includes
-#include "../general/BugCatcher.h"
-
PokemodUI::PokemodUI(Pokemod* pokemod, QWidget* parent) :
ObjectUI(parent),
m_lastMap(-1)
@@ -39,6 +36,10 @@ PokemodUI::PokemodUI(Pokemod* pokemod, QWidget* parent) :
QMetaObject::connectSlotsByName(this);
setObjects(pokemod, new Pokemod(*pokemod));
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool)));
+ connect(modified(), SIGNAL(error()), this, SLOT(setGui()));
+ connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&)));
+ connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&)));
+ connect(modified(), SIGNAL(changed()), this, SIGNAL(changed(true)));
init();
}
@@ -84,9 +85,9 @@ void PokemodUI::setGui()
int index = static_cast<Pokemod*>(original())->mapIndex(static_cast<Pokemod*>(modified())->startMap());
if (index != INT_MAX)
{
- try
+ const Map* map = static_cast<Pokemod*>(original())->map(index);
+ if (map)
{
- const Map* map = static_cast<Pokemod*>(original())->map(index);
for (int i = 0; i < map->warpCount(); ++i)
{
const MapWarp* warp = map->warp(i);
@@ -94,10 +95,6 @@ void PokemodUI::setGui()
varWarp->setItemData(i, warp->id());
}
}
- catch (BoundsException& exception)
- {
- BugCatcher::report(exception);
- }
}
}
varWarp->setCurrentIndex(varWarp->findData(static_cast<Pokemod*>(modified())->startWarp()));
@@ -127,59 +124,36 @@ void PokemodUI::on_buttonDiscard_clicked()
void PokemodUI::on_varTitle_textChanged(const QString& title)
{
static_cast<Pokemod*>(modified())->setTitle(title);
- emit(changed(true));
}
void PokemodUI::on_varVersion_textChanged(const QString& version)
{
static_cast<Pokemod*>(modified())->setVersion(version);
- emit(changed(true));
}
void PokemodUI::on_varDescription_textChanged()
{
static_cast<Pokemod*>(modified())->setDescription(varDescription->toPlainText());
- emit(changed(true));
}
void PokemodUI::on_varMap_currentIndexChanged(const int map)
{
- try
- {
- static_cast<Pokemod*>(modified())->setStartMap(map);
- emit(changed(true));
- }
- catch (BoundsException& exception)
- {
- BugCatcher::report(exception);
- setGui();
- }
+ static_cast<Pokemod*>(modified())->setStartMap(map);
}
void PokemodUI::on_varWarp_currentIndexChanged(const int warp)
{
- try
- {
- static_cast<Pokemod*>(modified())->setStartWarp(warp);
- emit(changed(true));
- }
- catch (BoundsException& exception)
- {
- BugCatcher::report(exception);
- setGui();
- }
+ static_cast<Pokemod*>(modified())->setStartWarp(warp);
}
void PokemodUI::on_varSuperPCUsername_textChanged(const QString& username)
{
static_cast<Pokemod*>(modified())->setSuperPCUname(username);
- emit(changed(true));
}
void PokemodUI::on_varSuperPCPassword_textChanged(const QString& password)
{
static_cast<Pokemod*>(modified())->setSuperPCPasswd(password);
- emit(changed(true));
}
void PokemodUI::on_varWalkSkin_pressed()
@@ -187,14 +161,7 @@ void PokemodUI::on_varWalkSkin_pressed()
FileDialog dialog(QSize(192, 168));
if (dialog.exec())
{
- try
- {
- static_cast<Pokemod*>(original())->setWalkSkin(QPixmap(dialog.selectedFile()));
- }
- catch (SaveException& exception)
- {
- BugCatcher::report(exception);
- }
+ static_cast<Pokemod*>(original())->setWalkSkin(QPixmap(dialog.selectedFile()));
setGui();
}
}
@@ -204,14 +171,7 @@ void PokemodUI::on_varBikeSkin_pressed()
FileDialog dialog(QSize(192, 168));
if (dialog.exec())
{
- try
- {
- static_cast<Pokemod*>(original())->setBikeSkin(QPixmap(dialog.selectedFile()));
- }
- catch (SaveException& exception)
- {
- BugCatcher::report(exception);
- }
+ static_cast<Pokemod*>(original())->setBikeSkin(QPixmap(dialog.selectedFile()));
setGui();
}
}
@@ -221,14 +181,7 @@ void PokemodUI::on_varFlySkin_pressed()
FileDialog dialog(QSize(192, 168));
if (dialog.exec())
{
- try
- {
- static_cast<Pokemod*>(original())->setFlySkin(QPixmap(dialog.selectedFile()));
- }
- catch (SaveException& exception)
- {
- BugCatcher::report(exception);
- }
+ static_cast<Pokemod*>(original())->setFlySkin(QPixmap(dialog.selectedFile()));
setGui();
}
}
@@ -238,14 +191,7 @@ void PokemodUI::on_varSurfSkin_pressed()
FileDialog dialog(QSize(192, 168));
if (dialog.exec())
{
- try
- {
- static_cast<Pokemod*>(original())->setSurfSkin(QPixmap(dialog.selectedFile()));
- }
- catch (SaveException& exception)
- {
- BugCatcher::report(exception);
- }
+ static_cast<Pokemod*>(original())->setSurfSkin(QPixmap(dialog.selectedFile()));
setGui();
}
}
@@ -255,14 +201,7 @@ void PokemodUI::on_varFishSkin_pressed()
FileDialog dialog(QSize(192, 168));
if (dialog.exec())
{
- try
- {
- static_cast<Pokemod*>(original())->setFishSkin(QPixmap(dialog.selectedFile()));
- }
- catch (SaveException& exception)
- {
- BugCatcher::report(exception);
- }
+ static_cast<Pokemod*>(original())->setFishSkin(QPixmap(dialog.selectedFile()));
setGui();
}
}
@@ -272,14 +211,7 @@ void PokemodUI::on_varSurfFishSkin_pressed()
FileDialog dialog(QSize(192, 168));
if (dialog.exec())
{
- try
- {
- static_cast<Pokemod*>(original())->setSurfFishSkin(QPixmap(dialog.selectedFile()));
- }
- catch (SaveException& exception)
- {
- BugCatcher::report(exception);
- }
+ static_cast<Pokemod*>(original())->setSurfFishSkin(QPixmap(dialog.selectedFile()));
setGui();
}
}
@@ -291,8 +223,3 @@ void PokemodUI::on_varTypechart_currentItemChanged(QTableWidgetItem* current, QT
// varEffectiveness->setValue(widgetItem->data(Qt::EditRole).value<Fraction>());
connect(varEffectiveness, SIGNAL(valueChanged(Fraction)), widgetItem, SLOT(setValue(Fraction)));
}
-
-void PokemodUI::on_varEffectiveness_valueChanged()
-{
- emit(changed(true));
-}