diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-11-08 06:15:08 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-11-08 06:15:08 +0000 |
| commit | 8bad37e82371bd41864903ac0d6f49808ad119bf (patch) | |
| tree | 77f0cb46059654cefb357d6eb4064c5740edf3d4 /sigmodr/TilemapModel.cpp | |
| parent | c127c0dae65a7600e0ab30b634f25d4915c61d16 (diff) | |
| download | sigen-8bad37e82371bd41864903ac0d6f49808ad119bf.tar.gz sigen-8bad37e82371bd41864903ac0d6f49808ad119bf.tar.xz sigen-8bad37e82371bd41864903ac0d6f49808ad119bf.zip | |
[FIX] No more asserts in sigmod
[FIX] Moved to using *ById instead of *Index methods in sigmod
[FIX] Tilemaps are now collaged (not completely done on the editing side yet)
[FIX] Removed the resource files (drawn natively instead)
[FIX] ATBTimer now uses the built-in QTimer in a QObject
[FIX] Coordinates are now edited on the map for warps, trainers, and effects
[FIX] Tiles are now completely scripted
[FIX] Config is now thread-safe
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@308 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'sigmodr/TilemapModel.cpp')
| -rw-r--r-- | sigmodr/TilemapModel.cpp | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/sigmodr/TilemapModel.cpp b/sigmodr/TilemapModel.cpp deleted file mode 100644 index 093b2389..00000000 --- a/sigmodr/TilemapModel.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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/>. - */ - -// Header include -#include "TilemapModel.h" - -// Sigmod includes -#include "../sigmod/Sigmod.h" -#include "../sigmod/Sprite.h" -#include "../sigmod/Tile.h" - -// Qt includes -#include <QtGui/QPixmap> - -Sigmodr::TilemapModel::TilemapModel(Sigcore::Matrix<int>* tilemap, const Sigmod::Sigmod* sigmod) : - QAbstractTableModel(), - m_tilemap(*tilemap), - m_sigmod(sigmod) -{ -} - -QVariant Sigmodr::TilemapModel::data(const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - if (role == Qt::DisplayRole) - { - const int tileIndex = m_sigmod->tileIndex(m_tilemap(index.row(), index.column())); - if (tileIndex != INT_MAX) - { - const Sigmod::Tile* tile = m_sigmod->tile(tileIndex); - if (m_sigmod->spriteIndex(tile->sprite()) == INT_MAX) - return QPixmap(); - else - { - QPixmap icon; - icon.loadFromData(m_sigmod->spriteById(tile->sprite())->sprite()); - return icon; - } - } - } - else if (role == Qt::EditRole) - return m_tilemap(index.row(), index.column()); - return QVariant(); -} - -QVariant Sigmodr::TilemapModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_UNUSED(orientation) - if (role == Qt::DisplayRole) - return section; - return QVariant(); -} - -int Sigmodr::TilemapModel::rowCount(const QModelIndex& parent) const -{ - Q_UNUSED(parent) - return m_tilemap.height(); -} - -int Sigmodr::TilemapModel::columnCount(const QModelIndex& parent) const -{ - Q_UNUSED(parent) - return m_tilemap.width(); -} - -bool Sigmodr::TilemapModel::insertRows(int row, int count, const QModelIndex& parent) -{ - emit(beginInsertRows(parent, row, row + count - 1)); - for (int i = 0; i < count; ++i) - m_tilemap.insertRow(row); - emit(endInsertRows()); - if (m_tilemap.height() == 1) - reset(); - return true; -} - -bool Sigmodr::TilemapModel::insertColumns(int column, int count, const QModelIndex& parent) -{ - emit(beginInsertColumns(parent, column, column + count - 1)); - for (int i = 0; i < count; ++i) - m_tilemap.insertColumn(column); - emit(endInsertColumns()); - if (m_tilemap.width() == 1) - reset(); - return true; -} - -bool Sigmodr::TilemapModel::removeRows(int row, int count, const QModelIndex& parent) -{ - emit(beginRemoveRows(parent, row, row + count - 1)); - for (int i = 0; i < count; ++i) - m_tilemap.deleteRow(row); - emit(endRemoveRows()); - if (!m_tilemap.height()) - reset(); - return true; -} - -bool Sigmodr::TilemapModel::removeColumns(int column, int count, const QModelIndex& parent) -{ - emit(beginRemoveColumns(parent, column, column + count - 1)); - for (int i = 0; i < count; ++i) - m_tilemap.deleteColumn(column); - emit(endRemoveColumns()); - if (!m_tilemap.width()) - reset(); - return true; -} - -Qt::ItemFlags Sigmodr::TilemapModel::flags(const QModelIndex& index) const -{ - if (!index.isValid()) - return 0; - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} - -bool Sigmodr::TilemapModel::setData(const QModelIndex& index, const QVariant& value, int role) -{ - if (!index.isValid()) - return false; - if (role == Qt::EditRole) - { - m_tilemap(index.row(), index.column()) = value.toInt(); - emit(dataChanged(index, index)); - return true; - } - return false; -} |
