Hosting courtesy of Sourceforge

SourceForge Logo
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TileSetEditor.cpp

Go to the documentation of this file.
00001 //
00002 //                                 TileSetEditor.cpp
00003 //                             -------------------
00004 //    begin                : Fri Mar 22 2002
00005 //    copyright           : (C) 2002 by Rob Renaud
00006 //    email                : rrenaud@eden.rutgers.edu
00007 //
00008 //   This program is free software; you can redistribute it and/or modify
00009 //   it under the terms of the GNU General Public License as published by
00010 //   the Free Software Foundation; either version 2 of the License, or
00011 //   (at your option) any later version.
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 //      cout << "TileSetEditor::drawAt() tileSet.numTiles() is " << tileSet.numTiles() << endl;
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         /* need to do something to handle alternating brackets.. only when the number of '}'
00043         is greater than the number of '{' should this function return */
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         // FIX crash here.. ugh.. it went away.. quite odd
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 }

Generated on Tue May 21 07:26:51 2002 for BomberLAN by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001