00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TileSetEditor.h"
00015 #include <sstream>
00016 #include <string>
00017
00018 using namespace Editor;
00019
00020 TileSetEditor::TileSetEditor() { }
00021
00022 TileSetEditor::~TileSetEditor() { }
00023
00024 void TileSetEditor::drawAt(SDL_Surface* surf, SDL_Rect* rect) {
00025
00026 SDL_Rect r = *rect;
00027 for (int i = 0; i < tileSet.numTiles(); i++) {
00028 tileSet.getTile(i)->drawAt(surf, &r);
00029 r.y+=Game::Constants::TILE_HEIGHT;
00030 }
00031 }
00032
00033 Game::AbstractTile* TileSetEditor::copyTile(int index) const {
00034 return tileSet.copyTile(index);
00035 }
00036
00037 int TileSetEditor::numTiles() const {
00038 return tileSet.numTiles();
00039 }
00040
00041 std::istream& Editor::operator >> (std::istream& in, TileSetEditor & tse) {
00042
00043
00044 bool breakOnRightBrace=true;
00045 char currentChar;
00046 while (!in.eof()) {
00047 currentChar = in.get();
00048
00049 if (currentChar == '}') {
00050 if (breakOnRightBrace) break;
00051 else breakOnRightBrace=true;
00052 } else if (currentChar == '{') {
00053 breakOnRightBrace=false;
00054 }
00055 tse.dataFromFile+=currentChar;
00056 }
00057 cout << tse.dataFromFile;
00058 std::istringstream stringInput(tse.dataFromFile);
00059
00060 Parse::Parser* parser = tse.tileSet.makeParserToParseMe(stringInput);
00061
00062 parser->read();
00063 delete parser;
00064
00065 return in;
00066 }
00067
00068 std::ostream& Editor::operator << (std::ostream& out, const TileSetEditor& tse) {
00069 out << "TileSet {\n" << tse.dataFromFile << "\n}\n";
00070 return out;
00071 }