summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-02-07 15:33:44 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-02-07 15:33:44 +0000
commit3c03cc795ce5620eb88e04bef70acc162ba2f339 (patch)
treeec99b36244e6c2a14a74554dd9d6f822b20b1dfd
parentb191a68ca2b1ec370fc1faafb078e4e201b2b459 (diff)
downloadsigen-3c03cc795ce5620eb88e04bef70acc162ba2f339.tar.gz
sigen-3c03cc795ce5620eb88e04bef70acc162ba2f339.tar.xz
sigen-3c03cc795ce5620eb88e04bef70acc162ba2f339.zip
[FIX] Tile UI form fixes
[FIX] BadgeUI logic cleaned up [FIX] Tilemap editing Model and Delegate fleshed out [ADD] TileUI.{h, cpp} and TypeUI.{h, cpp} [FIX] Default path for Pokemod added [FIX] Tile HM and Force setting git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@58 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog12
-rw-r--r--pokemod/Pokemod.cpp3
-rw-r--r--pokemod/Tile.cpp28
-rw-r--r--pokemod/Tile.h15
-rw-r--r--pokemodr/BadgeUI.cpp5
-rw-r--r--pokemodr/BadgeUI.h3
-rw-r--r--pokemodr/PokeModrUI.cpp6
-rw-r--r--pokemodr/TileDelegate.cpp8
-rw-r--r--pokemodr/TileUI.cpp244
-rw-r--r--pokemodr/TileUI.h66
-rw-r--r--pokemodr/TilemapModel.cpp43
-rw-r--r--pokemodr/TilemapModel.h5
-rw-r--r--pokemodr/TypeUI.cpp100
-rw-r--r--pokemodr/TypeUI.h57
-rw-r--r--pokemodr/gui/tile.ui41
15 files changed, 570 insertions, 66 deletions
diff --git a/Changelog b/Changelog
index d4df6fa7..afb76e09 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,16 @@
-----------------
+Rev: 58
+Date: 7 February 2008
+User: MathStuf
+-----------------
+[FIX] Tile UI form fixes
+[FIX] BadgeUI logic cleaned up
+[FIX] Tilemap editing Model and Delegate fleshed out
+[ADD] TileUI.{h, cpp} and TypeUI.{h, cpp}
+[FIX] Default path for Pokemod added
+[FIX] Tile HM and Force setting
+
+-----------------
Rev: 57
Date: 6 February 2008
User: MathStuf
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index cd8d121f..f097b662 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -43,7 +43,8 @@ Pokemod::Pokemod() :
superPCUname(""),
superPCPasswd(""),
typeChart(1, 1, Frac(1, 1, Frac::Improper)),
- rules(*this)
+ rules(*this),
+ path("~/.kde/share/apps/pokegen/mods")
{
}
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp
index 8c0535d1..2c8e1c34 100644
--- a/pokemod/Tile.cpp
+++ b/pokemod/Tile.cpp
@@ -23,7 +23,7 @@
#include "Pokemod.h"
#include "Tile.h"
-const QStringList Tile::ForceStr = QStringList() << "None" << "Slip" << "Stop" << "Force" << "Push";
+const QStringList Tile::ForceStr = QStringList() << "Slip" << "Stop" << "Force" << "Push";
Tile::Tile(const Pokemod& par, const int _id) :
Object("Tile", par, _id),
@@ -169,12 +169,12 @@ void Tile::setWildChance(const int n, const int d) throw(Exception)
wildChance.set(n, d);
}
-void Tile::setWildChanceNumerator(const int n) throw(Exception)
+void Tile::setWildChanceNum(const int n) throw(Exception)
{
wildChance.setNum(n);
}
-void Tile::setWildChanceDenominator(const int d) throw(Exception)
+void Tile::setWildChanceDenom(const int d) throw(Exception)
{
wildChance.setDenom(d);
}
@@ -189,10 +189,13 @@ void Tile::setHMType(const int h) throw(BoundsException)
void Tile::setUnder(const int u) throw(Exception)
{
- if ((hmType != HM_Whirlpool) || (hmType != HM_Cut) || (hmType != HM_RockSmash))
- throw(UnusedException(className, "under"));
- if ((u == id) || (pokemod.getTileIndex(u) == -1))
- throw(BoundsException(className, "under"));
+ if (hmType != -1)
+ {
+ if ((hmType != HM_Whirlpool) || (hmType != HM_Cut) || (hmType != HM_RockSmash))
+ throw(UnusedException(className, "under"));
+ if ((u == id) || (pokemod.getTileIndex(u) == -1))
+ throw(BoundsException(className, "under"));
+ }
under = u;
}
@@ -205,10 +208,13 @@ void Tile::setForceType(const int f) throw(BoundsException)
void Tile::setForceDirection(const int f) throw(Exception)
{
- if ((forceType == None) || (forceType == Stop))
- throw(UnusedException(className, "forceDirection"));
- if (D_End <= f)
- throw(BoundsException(className, "forceDirection"));
+ if (forceType != -1)
+ {
+ if (forceType == Stop)
+ throw(UnusedException(className, "forceDirection"));
+ if (D_End <= f)
+ throw(BoundsException(className, "forceDirection"));
+ }
forceDirection = f;
}
diff --git a/pokemod/Tile.h b/pokemod/Tile.h
index 241f8d27..27a26977 100644
--- a/pokemod/Tile.h
+++ b/pokemod/Tile.h
@@ -37,12 +37,11 @@ class Tile : public Object
public:
enum Force
{
- None = 0,
- Slip = 1,
- Stop = 2,
- Force = 3,
- Push = 4,
- End = 5
+ Slip = 0,
+ Stop = 1,
+ Force = 2,
+ Push = 3,
+ End = 4
};
static const QStringList ForceStr;
@@ -57,8 +56,8 @@ class Tile : public Object
void setPic(const QString& p) throw(OpenException);
void setFrom(const int d, const bool f) throw(BoundsException);
void setWildChance(const int n, const int d) throw(Exception);
- void setWildChanceNumerator(const int n) throw(Exception);
- void setWildChanceDenominator(const int d) throw(Exception);
+ void setWildChanceNum(const int n) throw(Exception);
+ void setWildChanceDenom(const int d) throw(Exception);
void setHMType(const int h) throw(BoundsException);
void setUnder(const int u) throw(Exception);
void setForceType(const int f) throw(BoundsException);
diff --git a/pokemodr/BadgeUI.cpp b/pokemodr/BadgeUI.cpp
index 97edb6e6..4eb62294 100644
--- a/pokemodr/BadgeUI.cpp
+++ b/pokemodr/BadgeUI.cpp
@@ -20,7 +20,6 @@
// with this program. If not, see <http://www.gnu.org/licenses/>.
/////////////////////////////////////////////////////////////////////////////
-#include <QList>
#include <QListWidgetItem>
#include <QMetaObject>
#include "../general/BugCatcher.h"
@@ -180,8 +179,8 @@ void BadgeUI::on_varHMs_itemSelectionChanged()
{
try
{
- for (QListIterator<QListWidgetItem*> i(varHMs->selectedItems()); i.hasNext(); i.next())
- badge_mod->setHm(i.peekNext()->data(QListWidgetItem::UserType).toInt(), i.peekNext()->isSelected());
+ for (int i = 0; i < varHMs->count(); ++i)
+ badge_mod->setHm(i, varHMs->item(i)->isSelected());
emit(setChanged(true));
}
catch (BoundsException& e)
diff --git a/pokemodr/BadgeUI.h b/pokemodr/BadgeUI.h
index d1c73e64..6ed72f6e 100644
--- a/pokemodr/BadgeUI.h
+++ b/pokemodr/BadgeUI.h
@@ -24,7 +24,6 @@
#define __POKEMODR_BADGEUI__
#include <ktoolbar.h>
-#include <QListIterator>
#include <QString>
#include "../pokemod/Badge.h"
#include "../pokemod/Pokemod.h"
@@ -57,7 +56,7 @@ class BadgeUI : public ObjectUI, private Ui::formBadge
private:
void setGui();
- unsigned curStat;
+ int curStat;
Badge* badge;
Badge* badge_mod;
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index b2154acb..9917b7d0 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -39,7 +39,9 @@
#include "ItemUI.h"
#include "ItemTypeUI.h"
#include "RulesUI.h"
+#include "TileUI.h"
#include "TimeUI.h"
+#include "TypeUI.h"
#include <iostream>
@@ -66,10 +68,12 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent)
// formPanel->setWidget(new CoinListObjectUI(&pokemod->newCoinList().newItem(), formPanel));
// formPanel->setWidget(new EggGroupUI(&pokemod->newEggGroup(), formPanel));
// formPanel->setWidget(new ItemUI(&pokemod->newItem(), formPanel));
- formPanel->setWidget(new MapUI(&pokemod->newMap(), formPanel));
+// formPanel->setWidget(new MapUI(&pokemod->newMap(), formPanel));
// formPanel->setWidget(new NatureUI(&pokemod->newNature(), formPanel));
// formPanel->setWidget(new ItemTypeUI(&pokemod->newItemType(), formPanel));
+ formPanel->setWidget(new TileUI(&pokemod->newTile(), formPanel));
// formPanel->setWidget(new TimeUI(&pokemod->newTime(), formPanel));
+// formPanel->setWidget(new TypeUI(&pokemod->newType(), formPanel));
// formPanel->setWidget(new RulesUI(&foo.getRules(), formPanel));
}
diff --git a/pokemodr/TileDelegate.cpp b/pokemodr/TileDelegate.cpp
index 1fb26541..ce6a67eb 100644
--- a/pokemodr/TileDelegate.cpp
+++ b/pokemodr/TileDelegate.cpp
@@ -38,13 +38,17 @@ QWidget* TileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&
void TileDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
for (int i = 0; i < static_cast<ObjectUI*>(editor->parent())->getOriginal()->getPokemod().getTileCount(); ++i)
- static_cast<KComboBox*>(editor)->addItem(ImageCache::open(static_cast<ObjectUI*>(editor->parent())->getOriginal()->getPokemod().getTile(i).getPic()), static_cast<MapUI*>(editor->parent())->getOriginal()->getPokemod().getTile(i).getName());
+ {
+ const Tile& t = static_cast<ObjectUI*>(editor->parent())->getOriginal()->getPokemod().getTile(i);
+ static_cast<KComboBox*>(editor)->addItem(ImageCache::open(t.getPic()), t.getName());
+ static_cast<KComboBox*>(editor)->setItemData(i, QVariant(t.getId()));
+ }
static_cast<KComboBox*>(editor)->setCurrentIndex(index.data(Qt::EditRole).toInt());
}
void TileDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
- static_cast<TilemapModel*>(model)->setData(index, static_cast<KComboBox*>(editor)->currentIndex());
+ static_cast<TilemapModel*>(model)->setData(index, static_cast<KComboBox*>(editor)->itemData(static_cast<KComboBox*>(editor)->currentIndex()));
}
void TileDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex&) const
diff --git a/pokemodr/TileUI.cpp b/pokemodr/TileUI.cpp
new file mode 100644
index 00000000..2b13ca87
--- /dev/null
+++ b/pokemodr/TileUI.cpp
@@ -0,0 +1,244 @@
+/////////////////////////////////////////////////////////////////////////////
+// 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/>.
+/////////////////////////////////////////////////////////////////////////////
+
+#include <QList>
+#include <QListIterator>
+#include <QListWidgetItem>
+#include <QMetaObject>
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+#include "../general/ImageCache.h"
+#include "../general/Ref.h"
+#include "../pokemod/Pokemod.h"
+#include "ImageDialog.h"
+#include "TileUI.h"
+
+TileUI::TileUI(Tile* t, QWidget* parent) :
+ ObjectUI(parent),
+ tile(t),
+ tile_mod(new Tile(t->getPokemod(), *t, t->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(tile, tile_mod);
+ varAccessibility->addItems(DirectionStr.mid(0, 4));
+ varHMType->addItems(HMStr);
+ for (int i = 0; i < tile->getPokemod().getTileCount(); ++i)
+ {
+ const Tile& tl = tile->getPokemod().getTile(i);
+ if (tl.getId() != t->getId())
+ {
+ varHMUnder->addItem(ImageCache::open(tl.getPic()), tl.getName());
+ varHMUnder->setItemData(i, tl.getId());
+ }
+ }
+ varForce->addItems(Tile::ForceStr);
+ varDirection->addItems(DirectionStr.mid(0, 4));
+ setGui();
+}
+
+// KToolbar getToolbar(QWidget* parent)
+// {
+//
+// }
+
+void TileUI::setGui()
+{
+ varName->setText(tile_mod->getName());
+ try
+ {
+ varImage->setIcon(ImageCache::open(tile_mod->getPic()));
+ }
+ catch (OpenException& e)
+ {
+ BugCatcher::report(e);
+ }
+ for (unsigned i = 0; i < D_End; ++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', 15));
+ boxHMs->setChecked((tile_mod->getHMType() == -1) ? Qt::Unchecked : Qt::Checked);
+ varHMType->setCurrentIndex(tile_mod->getHMType());
+ varHMUnder->setCurrentIndex(tile_mod->getUnder());
+ varHMUnder->setEnabled((tile_mod->getHMType() == HM_Whirlpool) || (tile_mod->getHMType() == HM_Cut) || (tile_mod->getHMType() == HM_RockSmash));
+ boxForces->setChecked((tile_mod->getForceType() == -1) ? Qt::Unchecked : Qt::Checked);
+ varForce->setCurrentIndex(tile_mod->getForceType());
+ varDirection->setCurrentIndex(tile_mod->getForceDirection());
+ varDirection->setEnabled(tile_mod->getForceType() != Tile::Stop);
+}
+
+void TileUI::on_buttonApply_clicked()
+{
+ *tile = *tile_mod;
+ emit(setChanged(false));
+}
+
+void TileUI::on_buttonDiscard_clicked()
+{
+ *tile_mod = *tile;
+ emit(setChanged(false));
+ setGui();
+}
+
+void TileUI::on_varName_textChanged(const QString& n)
+{
+ tile_mod->setName(n);
+ emit(setChanged(true));
+}
+
+void TileUI::on_varImage_pressed()
+{
+ if (ImageDialog::exec())
+ {
+ try
+ {
+ tile_mod->setPic(ImageDialog::selectedUrl());
+ }
+ catch (SaveException& e)
+ {
+ BugCatcher::report(e);
+ }
+ setGui();
+ }
+}
+
+void TileUI::on_varWildNum_valueChanged(const int m)
+{
+ try
+ {
+ tile_mod->setWildChanceNum(m);
+ varWild->setText(QString::number(tile_mod->getWildChance(), 'g', 15));
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void TileUI::on_varWildDenom_valueChanged(const int m)
+{
+ try
+ {
+ tile_mod->setWildChanceDenom(m);
+ varWildNum->setMaximum(m);
+ varWild->setText(QString::number(tile_mod->getWildChance(), 'g', 15));
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void TileUI::on_varAccessibility_itemSelectionChanged()
+{
+ try
+ {
+ for (QListIterator<QListWidgetItem*> i(varAccessibility->selectedItems()); i.hasNext(); i.next())
+ tile_mod->setFrom(i.peekNext()->data(QListWidgetItem::UserType).toInt(), i.peekNext()->isSelected());
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void TileUI::on_boxHMs_toggled(const bool h)
+{
+ if (!h)
+ {
+ varHMType->setCurrentIndex(-1);
+ varHMUnder->setCurrentIndex(-1);
+ setGui();
+ emit(setChanged(true));
+ }
+}
+
+void TileUI::on_varHMType_currentIndexChanged(const int h)
+{
+ try
+ {
+ tile_mod->setHMType(h);
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ }
+ setGui();
+}
+
+void TileUI::on_varHMUnder_currentIndexChanged(const int h)
+{
+ try
+ {
+ tile_mod->setUnder(varHMUnder->itemData(h, Qt::UserRole).toInt());
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void TileUI::on_boxForces_toggled(const bool f)
+{
+ if (!f)
+ {
+ varForce->setCurrentIndex(-1);
+ varDirection->setCurrentIndex(-1);
+ setGui();
+ emit(setChanged(true));
+ }
+}
+
+void TileUI::on_varForce_currentIndexChanged(const int f)
+{
+ try
+ {
+ tile_mod->setForceType(f);
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ }
+ setGui();
+}
+
+void TileUI::on_varDirection_currentIndexChanged(const int d)
+{
+ try
+ {
+ tile_mod->setForceDirection(d);
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
diff --git a/pokemodr/TileUI.h b/pokemodr/TileUI.h
new file mode 100644
index 00000000..1c428d36
--- /dev/null
+++ b/pokemodr/TileUI.h
@@ -0,0 +1,66 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/TileUI.h
+// Purpose: Tile UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sun Jan 27 12:52:44 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/>.
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __POKEMODR_TILEUI__
+#define __POKEMODR_TILEUI__
+
+#include <ktoolbar.h>
+#include <QListIterator>
+#include <QString>
+#include "../pokemod/Tile.h"
+#include "ObjectUI.h"
+#include "ui_tile.h"
+
+class TileUI : public ObjectUI, private Ui::formTile
+{
+ Q_OBJECT
+
+ public:
+ TileUI(Tile* t, QWidget* parent);
+ ~TileUI()
+ {
+ delete tile_mod;
+ }
+
+// KToolbar getToolbar(QWidget* parent);
+ public slots:
+ void on_buttonApply_clicked();
+ void on_buttonDiscard_clicked();
+ void on_varName_textChanged(const QString& n);
+ void on_varImage_pressed();
+ void on_varAccessibility_itemSelectionChanged();
+ void on_varWildNum_valueChanged(const int w);
+ void on_varWildDenom_valueChanged(const int w);
+ void on_boxHMs_toggled(const bool h);
+ void on_varHMType_currentIndexChanged(const int h);
+ void on_varHMUnder_currentIndexChanged(const int h);
+ void on_boxForces_toggled(const bool f);
+ void on_varForce_currentIndexChanged(const int f);
+ void on_varDirection_currentIndexChanged(const int d);
+ private:
+ void setGui();
+
+ Tile* tile;
+ Tile* tile_mod;
+};
+
+#endif
diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp
index 6618f7d8..9d0c6a81 100644
--- a/pokemodr/TilemapModel.cpp
+++ b/pokemodr/TilemapModel.cpp
@@ -32,10 +32,10 @@ TilemapModel::TilemapModel(QObject* parent, Matrix<int>& tilemap, const Pokemod&
map(tilemap),
pokemod(mod)
{
- updateData();
+ setGui();
}
-void TilemapModel::updateData()
+void TilemapModel::setGui()
{
}
@@ -51,26 +51,22 @@ int TilemapModel::columnCount(const QModelIndex&) const
QVariant TilemapModel::data(const QModelIndex& index, int role) const
{
- QVariant ret;
- switch (role)
- {
- case Qt::DisplayRole:
- ret = QVariant(ImageCache::open(pokemod.getTileByID(map.at(index.row(), index.column())).getPic()));
- break;
- case Qt::EditRole:
- ret = QVariant(map.at(index.row(), index.column()));
- break;
- case Qt::ToolTipRole:
- ret = QVariant(pokemod.getTileByID(map.at(index.row(), index.column())).getName());
- break;
- default:
- break;
- }
- return ret;
+ if (!index.isValid())
+ return QVariant();
+ if (role == Qt::DisplayRole)
+ return ImageCache::open(pokemod.getTileByID(map.at(index.row(), index.column())).getPic());
+ if (role == Qt::EditRole)
+ map.at(index.row(), index.column());
+ if (role == Qt::ToolTipRole)
+ return pokemod.getTileByID(map.at(index.row(), index.column())).getName();
+ return QVariant();
}
-QVariant TilemapModel::headerData(int section, Qt::Orientation orientation, int role) const
+QVariant TilemapModel::headerData(int section, Qt::Orientation, int role) const
{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+ return QString::number(section);
}
bool TilemapModel::setData(const QModelIndex& index, const QVariant& value, int role)
@@ -78,6 +74,7 @@ bool TilemapModel::setData(const QModelIndex& index, const QVariant& value, int
if (role != Qt::EditRole)
return false;
map.set(index.row(), index.column(), pokemod.getTile(value.toInt()).getId());
+ emit(dataChanged(index, index));
return true;
}
@@ -88,28 +85,36 @@ Qt::ItemFlags TilemapModel::flags(const QModelIndex&) const
bool TilemapModel::insertRows(int row, int count, const QModelIndex&)
{
+ emit(beginInsertRows(QModelIndex(), row, row + count - 1));
for (int i = 0; i < count; ++i)
map.insertRow(row);
+ emit(endInsertRows());
return true;
}
bool TilemapModel::insertColumns(int column, int count, const QModelIndex&)
{
+ emit(beginInsertColumns(QModelIndex(), column, column + count - 1));
for (int i = 0; i < count; ++i)
map.insertCol(column);
+ emit(endInsertColumns());
return true;
}
bool TilemapModel::removeRows(int row, int count, const QModelIndex&)
{
+ emit(beginRemoveRows(QModelIndex(), row, row + count - 1));
for (int i = 0; i < count; ++i)
map.deleteRow(row);
+ emit(endRemoveRows());
return true;
}
bool TilemapModel::removeColumns(int column, int count, const QModelIndex&)
{
+ emit(beginRemoveColumns(QModelIndex(), column, column + count - 1));
for (int i = 0; i < count; ++i)
map.deleteCol(column);
+ emit(endRemoveColumns());
return true;
}
diff --git a/pokemodr/TilemapModel.h b/pokemodr/TilemapModel.h
index cfb7444b..9cfe4900 100644
--- a/pokemodr/TilemapModel.h
+++ b/pokemodr/TilemapModel.h
@@ -36,7 +36,8 @@ class TilemapModel : public QAbstractTableModel
public:
TilemapModel(QObject* parent, Matrix<int>& tilemap, const Pokemod& mod);
- void updateData();
+ void apply();
+ void discard();
int rowCount(const QModelIndex& = QModelIndex()) const;
int columnCount(const QModelIndex& = QModelIndex()) const;
@@ -53,6 +54,8 @@ class TilemapModel : public QAbstractTableModel
bool removeRows(int row, int count, const QModelIndex& = QModelIndex());
bool removeColumns(int column, int count, const QModelIndex& = QModelIndex());
private:
+ void setGui();
+
Matrix<int>& map;
const Pokemod& pokemod;
};
diff --git a/pokemodr/TypeUI.cpp b/pokemodr/TypeUI.cpp
new file mode 100644
index 00000000..a7de8ca1
--- /dev/null
+++ b/pokemodr/TypeUI.cpp
@@ -0,0 +1,100 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/TypeUI.cpp
+// Purpose: Type UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Wed Feb 6 14:09:47 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 <QMetaObject>
+#include <QStringList>
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+#include "TypeUI.h"
+
+TypeUI::TypeUI(Type* t, QWidget* parent) :
+ ObjectUI(parent),
+ type(t),
+ type_mod(new Type(t->getPokemod(), *t, t->getId()))
+{
+ setupUi(this);
+ QMetaObject::connectSlotsByName(this);
+ setObjects(type, type_mod);
+ setGui();
+}
+
+// KToolbar TypeUI::getToolbar(QWidget* parent)
+// {
+// }
+
+void TypeUI::setGui()
+{
+ varName->setText(type_mod->getName());
+ varSTABNum->setValue(type_mod->getStab().getNum());
+ varSTABDenom->setValue(type_mod->getStab().getDenom());
+ varSTABNum->setMaximum(type_mod->getStab().getDenom());
+ varSTAB->setText(QString::number(type_mod->getStab(), 'g', 15));
+}
+
+void TypeUI::on_buttonApply_clicked()
+{
+ *type = *type_mod;
+ emit(setChanged(false));
+}
+
+void TypeUI::on_buttonDiscard_clicked()
+{
+ *type_mod = *type;
+ emit(setChanged(false));
+ setGui();
+}
+
+void TypeUI::on_varName_textChanged(const QString& n)
+{
+ type_mod->setName(n);
+}
+
+void TypeUI::on_varSTABNum_valueChanged(const int s)
+{
+ try
+ {
+ type_mod->setStabNum(s);
+ varSTAB->setText(QString::number(type_mod->getStab(), 'g', 15));
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
+
+void TypeUI::on_varSTABDenom_valueChanged(const int s)
+{
+ try
+ {
+ type_mod->setStabDenom(s);
+ varSTABNum->setMaximum(s);
+ varSTAB->setText(QString::number(type_mod->getStab(), 'g', 15));
+ emit(setChanged(true));
+ }
+ catch (BoundsException& e)
+ {
+ BugCatcher::report(e);
+ setGui();
+ }
+}
diff --git a/pokemodr/TypeUI.h b/pokemodr/TypeUI.h
new file mode 100644
index 00000000..221d9121
--- /dev/null
+++ b/pokemodr/TypeUI.h
@@ -0,0 +1,57 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/TypeUI.h
+// Purpose: Type UI form handling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Wed Feb 6 14:03:01 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/>.
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __POKEMODR_TYPEUI__
+#define __POKEMODR_TYPEUI__
+
+#include <ktoolbar.h>
+#include <QString>
+#include "../pokemod/Type.h"
+#include "ObjectUI.h"
+#include "ui_type.h"
+
+class TypeUI : public ObjectUI, private Ui::formType
+{
+ Q_OBJECT
+
+ public:
+ TypeUI(Type* t, QWidget* parent);
+ ~TypeUI()
+ {
+ delete type_mod;
+ }
+
+// KToolbar getToolbar(QWidget* parent);
+ public slots:
+ void on_buttonApply_clicked();
+ void on_buttonDiscard_clicked();
+ void on_varName_textChanged(const QString& n);
+ void on_varSTABNum_valueChanged(const int s);
+ void on_varSTABDenom_valueChanged(const int s);
+ private:
+ void setGui();
+
+ Type* type;
+ Type* type_mod;
+};
+
+#endif
diff --git a/pokemodr/gui/tile.ui b/pokemodr/gui/tile.ui
index 8198b4e6..4c0b0371 100644
--- a/pokemodr/gui/tile.ui
+++ b/pokemodr/gui/tile.ui
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>226</width>
- <height>953</height>
+ <width>236</width>
+ <height>941</height>
</rect>
</property>
<layout class="QVBoxLayout" >
@@ -68,13 +68,7 @@
</property>
<layout class="QHBoxLayout" >
<item>
- <widget class="QGraphicsView" name="varImage" >
- <property name="maximumSize" >
- <size>
- <width>64</width>
- <height>64</height>
- </size>
- </property>
+ <widget class="KPushButton" name="varImage" >
<property name="toolTip" >
<string>Image of the tile</string>
</property>
@@ -90,13 +84,7 @@
</property>
<layout class="QHBoxLayout" >
<item>
- <widget class="QListView" name="varAccessibility" >
- <property name="maximumSize" >
- <size>
- <width>150</width>
- <height>75</height>
- </size>
- </property>
+ <widget class="KListWidget" name="varAccessibility" >
<property name="toolTip" >
<string>Directions into the tile</string>
</property>
@@ -112,13 +100,13 @@
</widget>
</item>
<item>
- <widget class="QGroupBox" name="varWild" >
+ <widget class="QGroupBox" name="boxWild" >
<property name="title" >
<string>Wild</string>
</property>
<layout class="QVBoxLayout" >
<item>
- <widget class="KLineEdit" name="varWildChance" >
+ <widget class="KLineEdit" name="varWild" >
<property name="toolTip" >
<string>Chacne of having a wild encounter on the tile</string>
</property>
@@ -155,6 +143,12 @@
<property name="title" >
<string>HMs</string>
</property>
+ <property name="checkable" >
+ <bool>true</bool>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="boxType" >
@@ -208,6 +202,12 @@
<property name="title" >
<string>Forces</string>
</property>
+ <property name="checkable" >
+ <bool>true</bool>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="boxForceType" >
@@ -288,6 +288,11 @@
<header>klineedit.h</header>
</customwidget>
<customwidget>
+ <class>KListWidget</class>
+ <extends>QListWidget</extends>
+ <header>klistwidget.h</header>
+ </customwidget>
+ <customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>