summaryrefslogtreecommitdiffstats
path: root/pokemodr/TileUI.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
commit6679f5cffa9d35a23b76605ddfbf3257f882b6ee (patch)
treec8e41854a60b64e8569939bca6b827807175ef9a /pokemodr/TileUI.cpp
parent05980e883719b1c8ebde1bd2fcbf4f8c16df7ad6 (diff)
[FIX] Frac -> Fraction
[FIX] ImageCache and Ini removed [FIX] Fraction/Point widgets moved to pokemodr [FIX] Copy ctors made for pokemod classes [FIX] Ctors in pokemod fixed [FIX] Copyright headers fixed in pokemodr [FIX] PokeModr updated to new API and fixed in some places git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@99 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/TileUI.cpp')
-rw-r--r--pokemodr/TileUI.cpp187
1 files changed, 81 insertions, 106 deletions
diff --git a/pokemodr/TileUI.cpp b/pokemodr/TileUI.cpp
index 7b910e17..46e1fc20 100644
--- a/pokemodr/TileUI.cpp
+++ b/pokemodr/TileUI.cpp
@@ -1,48 +1,46 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokegen/TileUI.cpp
-// Purpose: Tile UI form handling
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Wed Feb 6 14:22:36 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/>.
-/////////////////////////////////////////////////////////////////////////////
-
+/*
+ * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * 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/>.
+ */
+
+// Qt includes
#include <QList>
-#include <QListIterator>
#include <QListWidgetItem>
-#include <QMetaObject>
#include <QSize>
+// General includes
#include <BugCatcher.h>
#include <Exception.h>
-#include <ImageCache.h>
+// Pokemod includes
#include <Pokemod.h>
+// PokeModr includes
#include "FileDialog.h"
+
+// Header include
#include "TileUI.h"
-TileUI::TileUI(Tile* t, QWidget* parent) :
+TileUI::TileUI(Tile* tile, QWidget* parent) :
ObjectUI(parent),
- tile(t),
- tile_mod(new Tile(t->getPokemod(), *t, t->getId()))
+ m_tile(tile),
+ m_tile_mod(new Tile(*tile))
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
- setObjects(tile, tile_mod);
+ setObjects(m_tile, m_tile_mod);
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool)));
init();
}
@@ -58,103 +56,80 @@ void TileUI::initGui()
void TileUI::refreshGui()
{
varHMUnder->clear();
- for (int i = 0; i < tile->getPokemod()->getTileCount(); ++i)
+ for (int i = 0; i < m_tile->pokemod()->tileCount(); ++i)
{
- const Tile* t = tile->getPokemod()->getTile(i);
- if (t->getId() != tile->getId())
+ const Tile* tile = m_tile->pokemod()->tile(i);
+ if (tile->id() != m_tile->id())
{
- varHMUnder->addItem(ImageCache::open(t->getPic()), t->getName());
- varHMUnder->setItemData(varHMUnder->count() - 1, t->getId());
+ varHMUnder->addItem(tile->sprite(), tile->name());
+ varHMUnder->setItemData(varHMUnder->count() - 1, tile->id());
}
}
}
void TileUI::setGui()
{
- varName->setText(tile_mod->getName());
- try
- {
- varImage->setIcon(ImageCache::open(tile_mod->getPic()));
- }
- catch (OpenException& e)
- {
- }
+ varName->setText(m_tile_mod->name());
+ varImage->setIcon(m_tile_mod->sprite());
for (int i = 0; i < varAccessibility->count(); ++i)
- varAccessibility->item(i)->setSelected(tile_mod->getFrom(i));
- varWildNum->setValue(tile_mod->getWildChance().getNum());
- varWildDenom->setValue(tile_mod->getWildChance().getDenom());
- varWildNum->setMaximum(tile_mod->getWildChance().getDenom());
- varWild->setText(QString::number(tile_mod->getWildChance(), 'g', DBL_PREC));
- boxHMs->setChecked((tile_mod->getHMType() == INT_MAX) ? Qt::Unchecked : Qt::Checked);
- varHMType->setCurrentIndex(tile_mod->getHMType());
- varHMUnder->setCurrentIndex(varHMUnder->findData(tile_mod->getUnder()));
- varHMUnder->setEnabled((tile_mod->getHMType() == Pokemod::HM_Whirlpool) || (tile_mod->getHMType() == Pokemod::HM_Cut) || (tile_mod->getHMType() == Pokemod::HM_RockSmash));
- boxForces->setChecked((tile_mod->getForceType() == INT_MAX) ? Qt::Unchecked : Qt::Checked);
- varForce->setCurrentIndex(tile_mod->getForceType());
- varDirection->setCurrentIndex(tile_mod->getForceDirection());
- varDirection->setEnabled((tile_mod->getForceType() != Tile::Stop) && (tile_mod->getForceType() != Tile::Slip));
+ varAccessibility->item(i)->setSelected(m_tile_mod->from(i));
+ varWildChance->setValue(m_tile_mod->wildChance());
+ boxHMs->setChecked((m_tile_mod->hmType() == INT_MAX) ? Qt::Unchecked : Qt::Checked);
+ varHMType->setCurrentIndex(m_tile_mod->hmType());
+ varHMUnder->setCurrentIndex(varHMUnder->findData(m_tile_mod->under()));
+ varHMUnder->setEnabled((m_tile_mod->hmType() == Pokemod::HM_Whirlpool) || (m_tile_mod->hmType() == Pokemod::HM_Cut) || (m_tile_mod->hmType() == Pokemod::HM_RockSmash));
+ boxForces->setChecked((m_tile_mod->forceType() == INT_MAX) ? Qt::Unchecked : Qt::Checked);
+ varForce->setCurrentIndex(m_tile_mod->forceType());
+ varDirection->setCurrentIndex(m_tile_mod->forceDirection());
+ varDirection->setEnabled((m_tile_mod->forceType() != Tile::Stop) && (m_tile_mod->forceType() != Tile::Slip));
}
void TileUI::on_buttonApply_clicked()
{
- *tile = *tile_mod;
+ *m_tile = *m_tile_mod;
emit(changed(false));
}
void TileUI::on_buttonDiscard_clicked()
{
- *tile_mod = *tile;
+ *m_tile_mod = *m_tile;
setGui();
emit(changed(false));
}
-void TileUI::on_varName_textChanged(const QString& n)
+void TileUI::on_varName_textChanged(const QString& name)
{
- tile_mod->setName(n);
+ m_tile_mod->setName(name);
emit(changed(true));
}
void TileUI::on_varImage_pressed()
{
- FileDialog dlg("*.png", QSize(64, 64));
- if (dlg.show())
+ FileDialog dialog(QSize(64, 64));
+ if (dialog.exec())
{
try
{
- tile_mod->setPic(dlg.selectedUrl());
+ m_tile_mod->setSprite(QPixmap(dialog.selectedFile()));
}
- catch (SaveException& e)
+ catch (SaveException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
}
setGui();
}
}
-void TileUI::on_varWildNum_valueChanged(const int m)
-{
- try
- {
- tile_mod->setWildChanceNum(m);
- emit(changed(true));
- }
- catch (BoundsException& e)
- {
- BugCatcher::report(e);
- setGui();
- }
-}
-
-void TileUI::on_varWildDenom_valueChanged(const int m)
+void TileUI::on_varWild_valueChanged(const Fraction& wildChance)
{
try
{
- tile_mod->setWildChanceDenom(m);
+ m_tile_mod->setWildChance(wildChance);
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
@@ -165,21 +140,21 @@ void TileUI::on_varAccessibility_itemSelectionChanged()
{
for (int i = 0; i < varAccessibility->count(); ++i)
{
- const QListWidgetItem* lwi = varAccessibility->item(i);
- tile_mod->setFrom(lwi->data(Qt::UserRole).toInt(), lwi->isSelected());
+ const QListWidgetItem* widgetItem = varAccessibility->item(i);
+ m_tile_mod->setFrom(widgetItem->data(Qt::UserRole).toInt(), widgetItem->isSelected());
}
emit(changed(true));
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void TileUI::on_boxHMs_toggled(const bool h)
+void TileUI::on_boxHMs_toggled(const bool hm)
{
- if (!h)
+ if (!hm)
{
varHMType->setCurrentIndex(-1);
varHMUnder->setCurrentIndex(-1);
@@ -188,35 +163,35 @@ void TileUI::on_boxHMs_toggled(const bool h)
}
}
-void TileUI::on_varHMType_currentIndexChanged(const int h)
+void TileUI::on_varHMType_currentIndexChanged(const int hmType)
{
try
{
- tile_mod->setHMType(h);
+ m_tile_mod->setHMType(hmType);
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
}
setGui();
}
-void TileUI::on_varHMUnder_currentIndexChanged(const int h)
+void TileUI::on_varHMUnder_currentIndexChanged(const int hmUnder)
{
try
{
- tile_mod->setUnder(varHMUnder->itemData(h, Qt::UserRole).toInt());
+ m_tile_mod->setUnder(varHMUnder->itemData(hmUnder, Qt::UserRole).toInt());
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}
-void TileUI::on_boxForces_toggled(const bool f)
+void TileUI::on_boxForces_toggled(const bool forces)
{
- if (!f)
+ if (!forces)
{
varForce->setCurrentIndex(-1);
varDirection->setCurrentIndex(-1);
@@ -225,28 +200,28 @@ void TileUI::on_boxForces_toggled(const bool f)
}
}
-void TileUI::on_varForce_currentIndexChanged(const int f)
+void TileUI::on_varForce_currentIndexChanged(const int force)
{
try
{
- tile_mod->setForceType(f);
+ m_tile_mod->setForceType(force);
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
}
setGui();
}
-void TileUI::on_varDirection_currentIndexChanged(const int d)
+void TileUI::on_varDirection_currentIndexChanged(const int direction)
{
try
{
- tile_mod->setForceDirection(d);
+ m_tile_mod->setForceDirection(direction);
}
- catch (BoundsException& e)
+ catch (BoundsException& exception)
{
- BugCatcher::report(e);
+ BugCatcher::report(exception);
setGui();
}
}