00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "EditorTile.h"
00015
00016 using namespace Editor;
00017
00018 EditorTile::EditorTile(Game::AbstractTile* t, int i) :
00019 tile(t),
00020 curIndex(i)
00021 { }
00022
00023 EditorTile::~EditorTile() {
00024 if (tile != NULL) delete tile;
00025 }
00026
00027 void EditorTile::drawAt(SDL_Surface* surf, SDL_Rect* rect) {
00028 if (tile != NULL) tile->drawAt(surf, rect);
00029 }
00030
00031 void EditorTile::setAsTile(const TileSetEditor& ts, int index) {
00032 if (tile!= NULL) delete tile;
00033 tile = ts.copyTile(index);
00034 curIndex = index;
00035 }
00036
00037 void EditorTile::incrementTile(const TileSetEditor& ts) {
00038 curIndex = (curIndex + 1) % ts.numTiles();
00039 delete tile;
00040 tile = ts.copyTile(curIndex);
00041 }
00042
00043 void EditorTile::decrementTile(const TileSetEditor& ts) {
00044 curIndex = (curIndex - 1) % ts.numTiles();
00045 if (curIndex < 0) curIndex = ts.numTiles() - 1;
00046 delete tile;
00047 tile = ts.copyTile(curIndex);
00048 }
00049
00050 void EditorTile::reload(const TileSetEditor& ts) {
00051 delete tile;
00052 tile = ts.copyTile(curIndex);
00053 }
00054
00055 int EditorTile::getIndex() const {
00056 return curIndex;
00057 }