1 /*
2 * replacetileset.cpp
3 * Copyright 2015, Thorbjørn Lindeijer <bjorn@lindeijer.nl>
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 #include "replacetileset.h"
22
23 #include "map.h"
24 #include "mapdocument.h"
25
26 #include <QCoreApplication>
27
28 namespace Tiled {
29
ReplaceTileset(MapDocument * mapDocument,int index,const SharedTileset & tileset)30 ReplaceTileset::ReplaceTileset(MapDocument *mapDocument,
31 int index,
32 const SharedTileset &tileset)
33 : QUndoCommand(QCoreApplication::translate("Undo Commands",
34 "Replace Tileset"))
35 , mMapDocument(mapDocument)
36 , mIndex(index)
37 , mTileset(tileset)
38 {
39 Q_ASSERT(mMapDocument->map()->tilesetAt(index) != tileset);
40 }
41
swap()42 void ReplaceTileset::swap()
43 {
44 mTileset = mMapDocument->replaceTileset(mIndex, mTileset);
45 }
46
47 } // namespace Tiled
48