#include <maps_list.h>
Collaboration diagram for InfoMap:
Public Member Functions | |
InfoMap () | |
bool | Init (const std::string &nom, const std::string &repertoire) |
void | FreeData () |
const std::string & | ReadName () const |
const std::string & | ReadAuthorInfo () const |
Surface | ReadImgGround () |
Surface | ReadImgSky () |
const Surface & | ReadPreview () const |
uint | GetNbBarrel () const |
uint | GetNbMine () const |
const Profile *const | ResProfile () const |
bool | IsOpened () const |
bool | UseWater () const |
Public Attributes | |
std::string | m_directory |
InfoMap::s_wind | wind |
Private Member Functions | |
bool | ProcessXmlData (xmlpp::Element *xml) |
void | LoadData () |
Private Attributes | |
std::string | name |
std::string | author_info |
Surface | img_ground |
Surface | img_sky |
Surface | preview |
uint | nb_mine |
uint | nb_barrel |
bool | is_opened |
bool | use_water |
bool | is_data_loaded |
Profile * | res_profile |
Classes | |
struct | s_wind |
Definition at line 32 of file maps_list.h.
InfoMap::InfoMap | ( | ) |
Definition at line 34 of file maps_list.cpp.
00035 { 00036 is_data_loaded = false; 00037 nb_mine = 0; 00038 nb_barrel = 0; 00039 wind.nb_sprite = 0; 00040 wind.need_flip = false; 00041 }
void InfoMap::FreeData | ( | ) |
Definition at line 149 of file maps_list.cpp.
00150 { 00151 img_sky.Free(); 00152 img_ground.Free(); 00153 is_data_loaded = false; 00154 }
Here is the call graph for this function:
Here is the caller graph for this function:
uint InfoMap::GetNbBarrel | ( | ) | const [inline] |
Definition at line 73 of file maps_list.h.
00073 { return nb_barrel; }
Here is the caller graph for this function:
uint InfoMap::GetNbMine | ( | ) | const [inline] |
Definition at line 74 of file maps_list.h.
00074 { return nb_mine; }
Here is the caller graph for this function:
bool InfoMap::Init | ( | const std::string & | nom, | |
const std::string & | repertoire | |||
) |
Definition at line 43 of file maps_list.cpp.
00045 { 00046 std::string nomfich; 00047 00048 m_directory = directory; 00049 00050 res_profile = NULL; 00051 is_data_loaded = false; 00052 00053 try 00054 { 00055 nomfich = m_directory+"config.xml"; 00056 00057 // Load resources 00058 if (!IsFileExist(nomfich)) 00059 return false; 00060 res_profile = resource_manager.LoadXMLProfile( nomfich, true), 00061 // Load preview 00062 preview = resource_manager.LoadImage( res_profile, "preview"); 00063 // Load other informations 00064 XmlReader doc; 00065 if (!doc.Load(nomfich)) return false; 00066 if (!ProcessXmlData(doc.GetRoot())) return false; 00067 } 00068 catch (const xmlpp::exception &e) 00069 { 00070 std::cout << std::endl 00071 << Format(_("XML error during loading map '%s' :"), map_name.c_str()) 00072 << std::endl 00073 << e.what() << std::endl; 00074 return false; 00075 } 00076 00077 MSG_DEBUG("map.load", "Map loaded: %s", map_name.c_str()); 00078 00079 return true; 00080 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool InfoMap::IsOpened | ( | ) | const [inline] |
Definition at line 77 of file maps_list.h.
00077 { return is_opened; }
Here is the caller graph for this function:
void InfoMap::LoadData | ( | ) | [private] |
Definition at line 137 of file maps_list.cpp.
00138 { 00139 if (is_data_loaded) 00140 return; 00141 is_data_loaded = true; 00142 00143 MSG_DEBUG("map.load", "Map data loaded: %s", name.c_str()); 00144 00145 img_ground = resource_manager.LoadImage(res_profile, "map"); 00146 img_sky = resource_manager.LoadImage(res_profile,"sky"); 00147 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool InfoMap::ProcessXmlData | ( | xmlpp::Element * | xml | ) | [private] |
Definition at line 82 of file maps_list.cpp.
00083 { 00084 // Read author informations 00085 xmlpp::Element *author = XmlReader::GetMarker(xml, "author"); 00086 if (author != NULL) { 00087 std::string 00088 a_name, 00089 a_nickname, 00090 a_country, 00091 a_email; 00092 00093 XmlReader::ReadString(author, "name", a_name); 00094 XmlReader::ReadString(author, "nickname", a_nickname); 00095 if (!XmlReader::ReadString(author, "country", a_country)) 00096 a_country = "?"; 00097 if (!XmlReader::ReadString(author, "email", a_email)) 00098 a_email = "?"; 00099 00100 if (!a_nickname.empty()) 00101 author_info = Format 00102 (_("%s <%s> aka %s from %s"), 00103 a_name.c_str(), 00104 a_email.c_str(), 00105 a_nickname.c_str(), 00106 a_country.c_str()); 00107 else 00108 author_info = Format 00109 (_("%s <%s> from %s"), 00110 a_name.c_str(), 00111 a_email.c_str(), 00112 a_country.c_str()); 00113 } 00114 00115 XmlReader::ReadString(xml, "name", name); 00116 XmlReader::ReadBool(xml, "water", use_water); 00117 XmlReader::ReadUint(xml, "nb_mine", nb_mine); 00118 XmlReader::ReadUint(xml, "nb_barrel", nb_barrel); 00119 XmlReader::ReadBool(xml, "is_open", is_opened); 00120 00121 xmlpp::Element *xmlwind = XmlReader::GetMarker(xml, "wind"); 00122 if (xmlwind != NULL) 00123 { 00124 XmlReader::ReadUint(xmlwind, "nbr_sprite", wind.nb_sprite); 00125 XmlReader::ReadBool(xmlwind, "need_flip", wind.need_flip); 00126 00127 if (wind.nb_sprite > MAX_WIND_OBJECTS) 00128 wind.nb_sprite = MAX_WIND_OBJECTS ; 00129 } else { 00130 wind.nb_sprite = 0; 00131 } 00132 wind.default_nb_sprite = wind.nb_sprite; 00133 00134 return true; 00135 }
Here is the call graph for this function:
Here is the caller graph for this function:
const std::string& InfoMap::ReadAuthorInfo | ( | ) | const [inline] |
Definition at line 67 of file maps_list.h.
00067 { return author_info; }
Here is the caller graph for this function:
Surface InfoMap::ReadImgGround | ( | ) |
Definition at line 156 of file maps_list.cpp.
00157 { 00158 LoadData(); 00159 return img_ground; 00160 }
Here is the call graph for this function:
Here is the caller graph for this function:
Surface InfoMap::ReadImgSky | ( | ) |
Definition at line 162 of file maps_list.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
const std::string& InfoMap::ReadName | ( | ) | const [inline] |
const Surface& InfoMap::ReadPreview | ( | ) | const [inline] |
const Profile* const InfoMap::ResProfile | ( | ) | const [inline] |
bool InfoMap::UseWater | ( | ) | const [inline] |
Definition at line 78 of file maps_list.h.
00078 { return use_water; }
Here is the caller graph for this function:
std::string InfoMap::author_info [private] |
Definition at line 36 of file maps_list.h.
Surface InfoMap::img_ground [private] |
Definition at line 37 of file maps_list.h.
Surface InfoMap::img_sky [private] |
Definition at line 37 of file maps_list.h.
bool InfoMap::is_data_loaded [private] |
Definition at line 45 of file maps_list.h.
bool InfoMap::is_opened [private] |
Definition at line 43 of file maps_list.h.
std::string InfoMap::m_directory |
Definition at line 53 of file maps_list.h.
std::string InfoMap::name [private] |
Definition at line 35 of file maps_list.h.
uint InfoMap::nb_barrel [private] |
Definition at line 41 of file maps_list.h.
uint InfoMap::nb_mine [private] |
Definition at line 40 of file maps_list.h.
Surface InfoMap::preview [private] |
Definition at line 38 of file maps_list.h.
Profile* InfoMap::res_profile [private] |
Definition at line 47 of file maps_list.h.
bool InfoMap::use_water [private] |
Definition at line 44 of file maps_list.h.
struct InfoMap::s_wind InfoMap::wind |