1 /*
2  * changetileanimation.cpp
3  * Copyright 2014, Thorbjørn Lindeijer <thorbjorn@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 "changetileanimation.h"
22 
23 #include "tilesetdocument.h"
24 #include "tilesetmanager.h"
25 
26 #include <QCoreApplication>
27 
28 namespace Tiled {
29 
ChangeTileAnimation(TilesetDocument * document,Tile * tile,const QVector<Frame> & frames,QUndoCommand * parent)30 ChangeTileAnimation::ChangeTileAnimation(TilesetDocument *document,
31                                          Tile *tile,
32                                          const QVector<Frame> &frames,
33                                          QUndoCommand *parent)
34     : QUndoCommand(QCoreApplication::translate(
35                        "Undo Commands", "Change Tile Animation"),
36                    parent)
37     , mTilesetDocument(document)
38     , mTile(tile)
39     , mFrames(frames)
40 {
41 }
42 
swap()43 void ChangeTileAnimation::swap()
44 {
45     const QVector<Frame> frames = mTile->frames();
46     mTile->setFrames(mFrames);
47     mFrames = frames;
48 
49     TilesetManager::instance()->resetTileAnimations();
50     emit mTilesetDocument->tileAnimationChanged(mTile);
51 }
52 
53 } // namespace Tiled
54