00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "OSDLTileMap.h"
00028
00029 #include "Ceylan.h"
00030
00031 #include <list>
00032
00033
00034 using namespace Ceylan::Log ;
00035 using namespace Ceylan::System ;
00036
00037 using namespace OSDL::Rendering ;
00038 using namespace OSDL::Video ;
00039
00040 using std::string ;
00041
00042
00043 #ifdef OSDL_USES_CONFIG_H
00044 #include <OSDLConfig.h>
00045 #endif // OSDL_USES_CONFIG_H
00046
00047 #if OSDL_ARCH_NINTENDO_DS
00048 #include "OSDLConfigForNintendoDS.h"
00049 #endif // OSDL_ARCH_NINTENDO_DS
00050
00051
00052
00053
00054
00055 TileMapException::TileMapException( const string & message ) :
00056 VideoRenderingException( "TileMap exception: " + message )
00057 {
00058
00059 }
00060
00061
00062
00063 TileMapException::~TileMapException() throw()
00064 {
00065
00066 }
00067
00068
00069
00070
00071 TileMap::TileMap( TileCount width, TileCount height,
00072 Ceylan::System::File & mapFile ) :
00073 _width( width ),
00074 _height( height ),
00075 _size(_width*_height)
00076 {
00077
00078
00079 _map = new TileIndex[_size] ;
00080
00081 try
00082 {
00083
00084
00085 for ( TileNumber i = 0; i < _size; i++ )
00086 {
00087
00088 _map[i] = mapFile.readUint8() ;
00089
00090 }
00091
00092 }
00093 catch( const Ceylan::Exception & e )
00094 {
00095
00096 throw TileMapException(
00097 "TileMap constructor: reading of the map failed: "
00098 + e.toString() ) ;
00099 }
00100 }
00101
00102
00103
00104 TileMap::~TileMap() throw()
00105 {
00106
00107 if ( _map != 0 )
00108 delete [] _map ;
00109
00110 }
00111
00112
00113
00114 const string TileMap::toString( Ceylan::VerbosityLevels level ) const
00115 {
00116
00117 string res = "TileMap whose dimensions are " + Ceylan::toString( _width )
00118 + "x" + Ceylan::toString( _height ) ;
00119
00120 if ( level == Ceylan::low )
00121 return res ;
00122
00123 res += ". Map content is: " ;
00124
00125 std::list<string> l ;
00126
00127 for ( TileCount j = 0; j < _height; j++ )
00128 {
00129 for ( TileCount i = 0; i < _width; i++ )
00130 {
00131
00132
00133
00134 }
00135
00136
00137 }
00138
00139 return res + Ceylan::formatStringList( l ) ;
00140
00141 }
00142