diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-02-06 05:02:11 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-02-06 05:02:11 +0000 |
| commit | b191a68ca2b1ec370fc1faafb078e4e201b2b459 (patch) | |
| tree | f0e7c4f261fc17cf2fc761dd4daba9436355166a | |
| parent | fa06bab5688417517e342b0b42a1b06e845aa778 (diff) | |
| download | sigen-b191a68ca2b1ec370fc1faafb078e4e201b2b459.tar.gz sigen-b191a68ca2b1ec370fc1faafb078e4e201b2b459.tar.xz sigen-b191a68ca2b1ec370fc1faafb078e4e201b2b459.zip | |
[ADD] Tilemap editing to the Map form
[ADD] MapUI.{h, cpp}, TilemapModel.{h, cpp}, TileDelegate.{h, cpp}
[FIX] Editing area of the main window now has scroll bars
[FIX] CoinListUI is now safer with its combobox creation for the values
[FIX] Minor fixes in Tile and Map classes
[FIX] Matrix cleaned up
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@57 6ecfd1a5-f3ed-3746-8530-beee90d26b22
| -rw-r--r-- | Changelog | 12 | ||||
| -rw-r--r-- | general/Matrix.h | 7 | ||||
| -rw-r--r-- | pokemod/Map.cpp | 10 | ||||
| -rw-r--r-- | pokemod/Map.h | 2 | ||||
| -rw-r--r-- | pokemod/Tile.cpp | 1 | ||||
| -rw-r--r-- | pokemod/Tile.h | 2 | ||||
| -rw-r--r-- | pokemodr/CoinListUI.cpp | 7 | ||||
| -rw-r--r-- | pokemodr/MapUI.cpp | 115 | ||||
| -rw-r--r-- | pokemodr/MapUI.h | 69 | ||||
| -rw-r--r-- | pokemodr/PokeModrUI.cpp | 30 | ||||
| -rw-r--r-- | pokemodr/TileDelegate.cpp | 53 | ||||
| -rw-r--r-- | pokemodr/TileDelegate.h | 47 | ||||
| -rw-r--r-- | pokemodr/TilemapModel.cpp | 115 | ||||
| -rw-r--r-- | pokemodr/TilemapModel.h | 60 | ||||
| -rw-r--r-- | pokemodr/gui/map.ui | 58 |
15 files changed, 560 insertions, 28 deletions
@@ -1,4 +1,16 @@ ----------------- +Rev: 57 +Date: 6 February 2008 +User: MathStuf +----------------- +[ADD] Tilemap editing to the Map form +[ADD] MapUI.{h, cpp}, TilemapModel.{h, cpp}, TileDelegate.{h, cpp} +[FIX] Editing area of the main window now has scroll bars +[FIX] CoinListUI is now safer with its combobox creation for the values +[FIX] Minor fixes in Tile and Map classes +[FIX] Matrix cleaned up + +----------------- Rev: 56 Date: 2 February 2008 User: MathStuf diff --git a/general/Matrix.h b/general/Matrix.h index c0d622bd..aa495692 100644 --- a/general/Matrix.h +++ b/general/Matrix.h @@ -136,8 +136,7 @@ template<class T> class Matrix { if ((height <= row) || (width <= col)) throw("Matrix: dimension out-of-bounds"); - matrix(row, col) = s; - return true; + (*this)(row, col) = s; } void resize(const int h, const int w, const T& d = T()) { @@ -194,9 +193,9 @@ template<class T> class Matrix height = rhs.getHeight(); width = rhs.getWidth(); resize(height, width); - for (unsigned i = 0; i < height; ++i) + for (int i = 0; i < height; ++i) { - for (unsigned j = 0; j < width; ++j) + for (int j = 0; j < width; ++j) matrix[i][j] = rhs(i, j); } return *this; diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp index 958f43f7..13b8ffd2 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -407,6 +407,16 @@ void Map::deleteRow(int y) tiles.deleteRow(y); } +const Matrix<int>& Map::getMap() const +{ + return tiles; +} + +Matrix<int>& Map::getMap() +{ + return tiles; +} + int Map::getTile(int x, int y) const { return tiles(x, y); diff --git a/pokemod/Map.h b/pokemod/Map.h index 03a3c4e3..716a44d2 100644 --- a/pokemod/Map.h +++ b/pokemod/Map.h @@ -71,6 +71,8 @@ class Map : public Object void deleteColumn(int x); void deleteRow(int y); + const Matrix<int>& getMap() const; + Matrix<int>& getMap(); int getTile(int x, int y) const; int getWidth() const; int getHeight() const; diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index 428e9ad3..8c0535d1 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -20,7 +20,6 @@ // with this program. If not, see <http://www.gnu.org/licenses/>. ///////////////////////////////////////////////////////////////////////////// -#include "../general/Ref.h" #include "Pokemod.h" #include "Tile.h" diff --git a/pokemod/Tile.h b/pokemod/Tile.h index 4a2866b6..241f8d27 100644 --- a/pokemod/Tile.h +++ b/pokemod/Tile.h @@ -26,6 +26,8 @@ #include <QString> #include <QStringList> #include "../general/Exception.h" +#include "../general/Frac.h" +#include "../general/Ref.h" #include "Object.h" class Pokemod; diff --git a/pokemodr/CoinListUI.cpp b/pokemodr/CoinListUI.cpp index f14bec0e..86115430 100644 --- a/pokemodr/CoinListUI.cpp +++ b/pokemodr/CoinListUI.cpp @@ -44,7 +44,10 @@ CoinListUI::CoinListUI(CoinList* c, QWidget* parent) : { const ItemEffect& effect = item.getEffect(j); if (effect.getEffect() == ItemEffect::E_CoinCase) - varValue->addItem(item.getName(), QVariant(effect.getVal1())); + { + varValue->addItem(item.getName()); + varValue->setItemData(varValue->count() - 1, QVariant(effect.getVal1())); + } } } setGui(); @@ -84,7 +87,7 @@ void CoinListUI::on_varValue_currentIndexChanged(const int v) { try { - coinList_mod->setValue(varValue->itemData(v, Qt::UserRole).toInt()); + coinList_mod->setValue(varValue->itemData(v).toInt()); emit(setChanged(true)); } catch (Exception& e) diff --git a/pokemodr/MapUI.cpp b/pokemodr/MapUI.cpp new file mode 100644 index 00000000..8f013f39 --- /dev/null +++ b/pokemodr/MapUI.cpp @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/MapUI.cpp +// Purpose: Map UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Sat Feb 2 00:50:25 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 +// MERCHANTMap 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 <QIcon> +#include <QMetaObject> +#include "../general/BugCatcher.h" +#include "../general/Exception.h" +#include "../pokemod/Pokemod.h" +#include "TileDelegate.h" +#include "TilemapModel.h" +#include "MapUI.h" + +MapUI::MapUI(Map* m, QWidget* parent) : + ObjectUI(parent), + map(m), + map_mod(new Map(m->getPokemod(), *m, m->getId())), + model(new TilemapModel(this, map_mod->getMap(), map->getPokemod())), + delegate(new TileDelegate(this)) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(map, map_mod); + for (int i = 0; i < map->getWarpCount(); ++i) + varFlyWarp->addItem(map->getWarp(i).getName()); + varType->addItems(Map::TypeStr); + varTilemap->setModel(model); + varTilemap->setItemDelegate(delegate); + setGui(); +} + +// KToolbar MapUI::getToolbar(QWidget* parent) +// { +// +// } + +void MapUI::setGui() +{ + varName->setText(map_mod->getName()); + boxFlyWarp->setChecked((map_mod->getFlyWarp() == -1) ? Qt::Unchecked : Qt::Checked); + varFlyWarp->setCurrentIndex(map_mod->getFlyWarp()); + varType->setCurrentIndex(map_mod->getType()); +} + +void MapUI::on_buttonApply_clicked() +{ + *map = *map_mod; + emit(setChanged(false)); +} + +void MapUI::on_buttonDiscard_clicked() +{ + *map_mod = *map; + emit(setChanged(false)); + setGui(); +} + +void MapUI::on_varName_textChanged(const QString& n) +{ + map_mod->setName(n); + emit(setChanged(true)); +} + +void MapUI::on_boxFlyWarp_toggled(const bool f) +{ + +} + +void MapUI::on_varFlyWarp_currentIndexChanged(const int f) +{ + +} + +void MapUI::on_varType_currentIndexChanged(const int t) +{ + +} + +void MapUI::on_buttonAddColumn_pressed() +{ + +} + +void MapUI::on_buttonAddRow_pressed() +{ + +} + +void MapUI::on_buttonDeleteColumn_pressed() +{ + +} + +void MapUI::on_buttonDeleteRow_pressed() +{ + +} diff --git a/pokemodr/MapUI.h b/pokemodr/MapUI.h new file mode 100644 index 00000000..32a6a2e0 --- /dev/null +++ b/pokemodr/MapUI.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/MapUI.h +// Purpose: Map UI form handling +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Sat Feb 2 00:50:25 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 +// MERCHANTMap 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_MAPUI__ +#define __POKEMODR_MAPUI__ + +#include <ktoolbar.h> +#include <QString> +#include "../pokemod/Map.h" +#include "ObjectUI.h" +#include "TileDelegate.h" +#include "TilemapModel.h" +#include "ui_map.h" + +class MapUI : public ObjectUI, private Ui::formMap +{ + Q_OBJECT + + public: + MapUI(Map* m, QWidget* parent); + ~MapUI() + { + delete model; + delete delegate; + delete map_mod; + } + +// KToolbar getToolbar(QWidget* parent); + public slots: + void on_buttonApply_clicked(); + void on_buttonDiscard_clicked(); + void on_varName_textChanged(const QString& n); + void on_boxFlyWarp_toggled(const bool f); + void on_varFlyWarp_currentIndexChanged(const int f); + void on_varType_currentIndexChanged(const int t); + void on_buttonAddColumn_pressed(); + void on_buttonAddRow_pressed(); + void on_buttonDeleteColumn_pressed(); + void on_buttonDeleteRow_pressed(); + private: + void setGui(); + + Map* map; + Map* map_mod; + + TilemapModel* model; + TileDelegate* delegate; +}; + +#endif diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index 258d6272..b2154acb 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -34,6 +34,7 @@ #include "CoinListUI.h" #include "CoinListObjectUI.h" #include "EggGroupUI.h" +#include "MapUI.h" #include "NatureUI.h" #include "ItemUI.h" #include "ItemTypeUI.h" @@ -58,23 +59,18 @@ PokeModrUI::PokeModrUI(KConfigGroup cfg, KConfigGroup history, QWidget* parent) // Testing pokemod = new Pokemod(); -// formPanel->setViewport(new AbilityUI(&pokemod->newAbility(), formPanel)); -// formPanel->setViewport(new AuthorUI(&pokemod->newAuthor(), formPanel)); -// formPanel->setViewport(new BadgeUI(&pokemod->newBadge(), formPanel)); -// formPanel->setViewport(new CoinListUI(&pokemod->newCoinList(), formPanel)); - pokemod->newItem().setName("foo"); - pokemod->newItem().setName("bar"); - pokemod->newItem().setName("baz"); - pokemod->newSpecies().setName("FOO"); - pokemod->newSpecies().setName("BAR"); - pokemod->newSpecies().setName("BAZ"); - formPanel->setViewport(new CoinListObjectUI(&pokemod->newCoinList().newItem(), formPanel)); -// formPanel->setViewport(new EggGroupUI(&pokemod->newEggGroup(), formPanel)); -// formPanel->setViewport(new ItemUI(&pokemod->newItem(), formPanel)); -// formPanel->setViewport(NatureUI(&pokemod->newNature(), formPanel)); -// formPanel->setViewport(new ItemTypeUI(&pokemod->newItemType(), formPanel)); -// formPanel->setViewport(new TimeUI(&pokemod->newTime(), formPanel)); -// formPanel->setViewport(new RulesUI(&foo.getRules(), formPanel)); +// formPanel->setWidget(new AbilityUI(&pokemod->newAbility(), formPanel)); +// formPanel->setWidget(new AuthorUI(&pokemod->newAuthor(), formPanel)); +// formPanel->setWidget(new BadgeUI(&pokemod->newBadge(), formPanel)); +// formPanel->setWidget(new CoinListUI(&pokemod->newCoinList(), formPanel)); +// 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 NatureUI(&pokemod->newNature(), formPanel)); +// formPanel->setWidget(new ItemTypeUI(&pokemod->newItemType(), formPanel)); +// formPanel->setWidget(new TimeUI(&pokemod->newTime(), formPanel)); +// formPanel->setWidget(new RulesUI(&foo.getRules(), formPanel)); } PokeModrUI::~PokeModrUI() diff --git a/pokemodr/TileDelegate.cpp b/pokemodr/TileDelegate.cpp new file mode 100644 index 00000000..1fb26541 --- /dev/null +++ b/pokemodr/TileDelegate.cpp @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TileDelegate.cpp +// Purpose: Provides an editor for tiles in the tilemap editor +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Sat Feb 2 01:31:30 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 +// MERCHANTMap 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 <kcombobox.h> +#include "../general/ImageCache.h" +#include "../pokemod/Pokemod.h" +#include "../pokemod/Tile.h" +#include "ObjectUI.h" +#include "MapUI.h" +#include "TileDelegate.h" +#include "TilemapModel.h" + +QWidget* TileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const +{ + KComboBox* editor = new KComboBox(parent); + return editor; +} + +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()); + 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()); +} + +void TileDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex&) const +{ + editor->setGeometry(option.rect); +} diff --git a/pokemodr/TileDelegate.h b/pokemodr/TileDelegate.h new file mode 100644 index 00000000..470370e1 --- /dev/null +++ b/pokemodr/TileDelegate.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TileDelegate.h +// Purpose: Provides an editor for tiles in the tilemap editor +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Sat Feb 2 01:28:27 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 +// MERCHANTMap 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_TILEDELEGATE__ +#define __POKEMODR_TILEDELEGATE__ + +#include <QItemDelegate> +#include <QObject> + +class TileDelegate : public QItemDelegate +{ + Q_OBJECT + + public: + TileDelegate(QObject* parent = 0) : + QItemDelegate(parent) + { + } + + QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const; + + void setEditorData(QWidget* editor, const QModelIndex& index) const; + void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const; + + void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex&) const; +}; + +#endif diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp new file mode 100644 index 00000000..6618f7d8 --- /dev/null +++ b/pokemodr/TilemapModel.cpp @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TilemapModel.cpp +// Purpose: Provides a model for tiles in the tilemap editor +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Feb 5 19:43:22 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 +// MERCHANTMap 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 <kcombobox.h> +#include "../general/ImageCache.h" +#include "../pokemod/Tile.h" +#include "ObjectUI.h" +#include "MapUI.h" +#include "TilemapModel.h" + +TilemapModel::TilemapModel(QObject* parent, Matrix<int>& tilemap, const Pokemod& mod) : + QAbstractTableModel(parent), + map(tilemap), + pokemod(mod) +{ + updateData(); +} + +void TilemapModel::updateData() +{ +} + +int TilemapModel::rowCount(const QModelIndex&) const +{ + return map.getHeight(); +} + +int TilemapModel::columnCount(const QModelIndex&) const +{ + return map.getWidth(); +} + +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; +} + +QVariant TilemapModel::headerData(int section, Qt::Orientation orientation, int role) const +{ +} + +bool TilemapModel::setData(const QModelIndex& index, const QVariant& value, int role) +{ + if (role != Qt::EditRole) + return false; + map.set(index.row(), index.column(), pokemod.getTile(value.toInt()).getId()); + return true; +} + +Qt::ItemFlags TilemapModel::flags(const QModelIndex&) const +{ + return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +bool TilemapModel::insertRows(int row, int count, const QModelIndex&) +{ + for (int i = 0; i < count; ++i) + map.insertRow(row); + return true; +} + +bool TilemapModel::insertColumns(int column, int count, const QModelIndex&) +{ + for (int i = 0; i < count; ++i) + map.insertCol(column); + return true; +} + +bool TilemapModel::removeRows(int row, int count, const QModelIndex&) +{ + for (int i = 0; i < count; ++i) + map.deleteRow(row); + return true; +} + +bool TilemapModel::removeColumns(int column, int count, const QModelIndex&) +{ + for (int i = 0; i < count; ++i) + map.deleteCol(column); + return true; +} diff --git a/pokemodr/TilemapModel.h b/pokemodr/TilemapModel.h new file mode 100644 index 00000000..cfb7444b --- /dev/null +++ b/pokemodr/TilemapModel.h @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokegen/TilemapModel.h +// Purpose: Provides a model for tiles in the tilemap editor +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Feb 5 18:40:57 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 +// MERCHANTMap 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_TILEMAPMODEL__ +#define __POKEMODR_TILEMAPMODEL__ + +#include <QAbstractTableModel> +#include <QObject> +#include <QVariant> +#include "../general/Matrix.h" +#include "../pokemod/Pokemod.h" + +class TilemapModel : public QAbstractTableModel +{ + Q_OBJECT + + public: + TilemapModel(QObject* parent, Matrix<int>& tilemap, const Pokemod& mod); + + void updateData(); + + int rowCount(const QModelIndex& = QModelIndex()) const; + int columnCount(const QModelIndex& = QModelIndex()) const; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); + + Qt::ItemFlags flags(const QModelIndex&) const; + + bool insertRows(int row, int count, const QModelIndex& = QModelIndex()); + bool insertColumns(int column, int count, const QModelIndex& = QModelIndex()); + bool removeRows(int row, int count, const QModelIndex& = QModelIndex()); + bool removeColumns(int column, int count, const QModelIndex& = QModelIndex()); + private: + Matrix<int>& map; + const Pokemod& pokemod; +}; + +#endif diff --git a/pokemodr/gui/map.ui b/pokemodr/gui/map.ui index beebbfd3..da951b2c 100644 --- a/pokemodr/gui/map.ui +++ b/pokemodr/gui/map.ui @@ -5,8 +5,8 @@ <rect> <x>0</x> <y>0</y> - <width>191</width> - <height>311</height> + <width>514</width> + <height>646</height> </rect> </property> <layout class="QVBoxLayout" > @@ -109,14 +109,64 @@ </widget> </item> <item> + <widget class="QGroupBox" name="boxTilemap" > + <property name="title" > + <string>Tilemap</string> + </property> + <layout class="QGridLayout" > + <item rowspan="4" row="0" column="0" > + <widget class="QTableView" name="varTilemap" > + <property name="minimumSize" > + <size> + <width>0</width> + <height>288</height> + </size> + </property> + <property name="wordWrap" > + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="KPushButton" name="buttonAddRow" > + <property name="text" > + <string>Add Row</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="KPushButton" name="buttonDeleteRow" > + <property name="text" > + <string>Delete Row</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="KPushButton" name="buttonAddColumn" > + <property name="text" > + <string>Add Column</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="KPushButton" name="buttonDeleteColumn" > + <property name="text" > + <string>Delete Column</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> <spacer> <property name="orientation" > <enum>Qt::Vertical</enum> </property> <property name="sizeHint" > <size> - <width>20</width> - <height>40</height> + <width>506</width> + <height>16</height> </size> </property> </spacer> |
