Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow changing the image source of individual tiles
This only applies to tiles in an image collection tileset. Broken references to individual tile images are now no longer raised as an XML parsing error. Also, an "image-missing" icon was introduced which shows in the tileset view for tiles which images could not be loaded, and in the properties view for when the referenced file isn't found. Issue #913
- Loading branch information
Showing
20 changed files
with
280 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* changetileimagesource.cpp | ||
* Copyright 2015, Thorbjørn Lindeijer <bjorn@lindeijer.nl> | ||
* | ||
* This file is part of Tiled. | ||
* | ||
* 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 2 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/>. | ||
*/ | ||
|
||
#include "changetileimagesource.h" | ||
|
||
#include "mapdocument.h" | ||
#include "tile.h" | ||
|
||
#include <QCoreApplication> | ||
|
||
namespace Tiled { | ||
namespace Internal { | ||
|
||
ChangeTileImageSource::ChangeTileImageSource(MapDocument *mapDocument, | ||
Tile *tile, | ||
const QString &imageSource) | ||
: mMapDocument(mapDocument) | ||
, mTile(tile) | ||
, mOldImageSource(tile->imageSource()) | ||
, mNewImageSource(imageSource) | ||
{ | ||
setText(QCoreApplication::translate("Undo Commands", | ||
"Change Tile Image")); | ||
} | ||
|
||
void ChangeTileImageSource::apply(const QString &imageSource) | ||
{ | ||
mTile->tileset()->setTileImage(mTile->id(), | ||
QPixmap(imageSource), | ||
imageSource); | ||
|
||
emit mMapDocument->tileImageSourceChanged(mTile); | ||
} | ||
|
||
} // namespace Internal | ||
} // namespace Tiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* changetileimagesource.h | ||
* Copyright 2015, Thorbjørn Lindeijer <bjorn@lindeijer.nl> | ||
* | ||
* This file is part of Tiled. | ||
* | ||
* 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 2 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/>. | ||
*/ | ||
|
||
#ifndef TILED_INTERNAL_CHANGETILEIMAGESOURCE_H | ||
#define TILED_INTERNAL_CHANGETILEIMAGESOURCE_H | ||
|
||
#include <QUndoCommand> | ||
|
||
namespace Tiled { | ||
|
||
class Tile; | ||
|
||
namespace Internal { | ||
|
||
class MapDocument; | ||
|
||
class ChangeTileImageSource : public QUndoCommand | ||
{ | ||
public: | ||
ChangeTileImageSource(MapDocument *mapDocument, | ||
Tile *tile, | ||
const QString &imageSource); | ||
|
||
void undo() { apply(mOldImageSource); } | ||
void redo() { apply(mNewImageSource); } | ||
|
||
private: | ||
void apply(const QString &imageSource); | ||
|
||
MapDocument *mMapDocument; | ||
Tile *mTile; | ||
QString mOldImageSource; | ||
QString mNewImageSource; | ||
}; | ||
|
||
} // namespace Internal | ||
} // namespace Tiled | ||
|
||
#endif // TILED_INTERNAL_CHANGETILEIMAGESOURCE_H |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.