1 /* 2 * changewangsetdata.h 3 * Copyright 2017, Benjamin Trotter <bdtrotte@ucsc.edu> 4 * 5 * This file is part of Tiled. 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the Free 9 * Software Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * more details. 16 * 17 * You should have received a copy of the GNU General Public License along with 18 * this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #pragma once 22 23 #include "wangset.h" 24 25 #include <QUndoCommand> 26 27 namespace Tiled { 28 29 class Tileset; 30 class Tile; 31 32 class TilesetDocument; 33 34 class RenameWangSet : public QUndoCommand 35 { 36 public: 37 RenameWangSet(TilesetDocument *tilesetDocument, 38 WangSet *wangSet, 39 const QString &newName); 40 41 void undo() override; 42 void redo() override; 43 44 private: 45 TilesetDocument *mTilesetDocument; 46 WangSet *mWangSet; 47 QString mOldName; 48 QString mNewName; 49 }; 50 51 class ChangeWangSetType : public QUndoCommand 52 { 53 public: 54 ChangeWangSetType(TilesetDocument *tilesetDocument, 55 WangSet *wangSet, 56 WangSet::Type newType, 57 QUndoCommand *parent = nullptr); 58 59 void undo() override; 60 void redo() override; 61 62 private: 63 TilesetDocument *mTilesetDocument; 64 WangSet *mWangSet; 65 const WangSet::Type mOldType; 66 const WangSet::Type mNewType; 67 }; 68 69 class ChangeWangSetColorCount : public QUndoCommand 70 { 71 public: 72 ChangeWangSetColorCount(TilesetDocument *TilesetDocument, 73 WangSet *wangSet, 74 int newValue); 75 76 void undo() override; 77 void redo() override; 78 79 private: 80 struct WangColorChange { 81 QSharedPointer<WangColor> wangColor; 82 int index; 83 }; 84 85 TilesetDocument *mTilesetDocument; 86 WangSet *mWangSet; 87 const int mOldValue; 88 const int mNewValue; 89 QVector<WangColorChange> mRemovedWangColors; 90 }; 91 92 class RemoveWangSetColor : public QUndoCommand 93 { 94 public: 95 RemoveWangSetColor(TilesetDocument *tilesetDocumnet, 96 WangSet *wangSet, 97 int color); 98 99 void undo() override; 100 void redo() override; 101 102 private: 103 TilesetDocument *mTilesetDocument; 104 WangSet *mWangSet; 105 const int mColor; 106 QSharedPointer<WangColor> mRemovedWangColor; 107 }; 108 109 class SetWangSetImage : public QUndoCommand 110 { 111 public: 112 SetWangSetImage(TilesetDocument *tilesetDocument, 113 WangSet *wangSet, 114 int tileId, 115 QUndoCommand *parent = nullptr); 116 117 void undo() override; 118 void redo() override; 119 120 private: 121 TilesetDocument *mTilesetDocument; 122 WangSet *mWangSet; 123 const int mOldImageTileId; 124 const int mNewImageTileId; 125 }; 126 127 } // namespace Tiled 128