Changeset 7221 in orxonox.OLD for trunk/src/story_entities
- Timestamp:
- Mar 15, 2006, 3:10:45 PM (19 years ago)
- Location:
- trunk/src/story_entities
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/game_world.cc
r7193 r7221 145 145 GameLoader* loader = GameLoader::getInstance(); 146 146 147 if( getLoadFile() == NULL)147 if( getLoadFile().empty()) 148 148 { 149 149 PRINTF(1)("GameWorld has no path specified for loading\n"); … … 155 155 if( !XMLDoc->LoadFile()) 156 156 { 157 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile() , XMLDoc->ErrorRow(), XMLDoc->ErrorCol());157 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile().c_str(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 158 158 delete XMLDoc; 159 159 return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"}; -
trunk/src/story_entities/game_world_data.cc
r7193 r7221 129 129 // load the parameters 130 130 // name 131 const char*string = grabParameter( root, "name");132 if( string == NULL)131 std::string string = grabParameter( root, "name"); 132 if( string.empty() ) 133 133 { 134 134 PRINTF(2)("GameWorld is missing a proper 'name'\n"); … … 136 136 } 137 137 else 138 this->setName(string );138 this->setName(string.c_str()); 139 139 140 140 this->loadGUI(root); … … 343 343 344 344 if (this->music != NULL) 345 this->setSoundTrack( NULL);345 this->setSoundTrack(""); 346 346 this->music = NULL; 347 347 /* stop the sound eninge */ … … 354 354 355 355 356 void GameWorldData::setSoundTrack(const char*name)356 void GameWorldData::setSoundTrack(const std::string& name) 357 357 { 358 358 if (this->music != NULL) … … 360 360 this->music = NULL; 361 361 362 if ( name != NULL)363 { 364 PRINTF(3)("Setting Sound Track to %s\n", name );365 char* oggFile = ResourceManager::getFullName(name); /// FIXME362 if (!name.empty()) 363 { 364 PRINTF(3)("Setting Sound Track to %s\n", name.c_str()); 365 std::string oggFile = ResourceManager::getFullName(name); 366 366 this->music = new OggPlayer(oggFile); 367 delete[] oggFile;368 367 369 368 //(OggPlayer*)ResourceManager::getInstance()->load(name, OGG, RP_LEVEL); -
trunk/src/story_entities/game_world_data.h
r7020 r7221 42 42 43 43 /* interface functions */ 44 void setSoundTrack(const char*name);44 void setSoundTrack(const std::string& name); 45 45 void loadGameRule(const TiXmlElement* root); 46 46 -
trunk/src/story_entities/movie_loader.cc
r7193 r7221 36 36 } 37 37 38 MovieLoader::~MovieLoader() 38 MovieLoader::~MovieLoader() 39 39 { 40 40 delete this->movie_player; … … 56 56 } 57 57 58 void MovieLoader::loadMovie(const char*filename)58 void MovieLoader::loadMovie(const std::string& filename) 59 59 { 60 60 movie_player->loadMovie(filename); … … 78 78 79 79 this->movie_player->start(0); 80 80 81 81 this->isRunning = true; 82 82 this->run(); … … 139 139 140 140 // calculate time difference in milliseconds (Uint32) 141 this->dt = currentFrame - this->lastFrame; 141 this->dt = currentFrame - this->lastFrame; 142 142 // calculate time difference in seconds (float) 143 143 this->dts = (float)this->dt / 1000.0f; -
trunk/src/story_entities/movie_loader.h
r7022 r7221 43 43 44 44 private: 45 void loadMovie(const char*filename);45 void loadMovie(const std::string& filename); 46 46 void setFPS(float fps); 47 47 void tick(); -
trunk/src/story_entities/simple_game_menu.cc
r7193 r7221 63 63 this->menuSelectedIndex = 0; 64 64 65 this->loadParams(root); 65 if (root != NULL) 66 this->loadParams(root); 66 67 67 68 State::setMenuID(this->getNextStoryID()); … … 70 71 71 72 /** 72 * remove the SimpleGameMenu from memory73 * @brief remove the SimpleGameMenu from memory 73 74 * 74 75 * delete everything explicitly, that isn't contained in the parenting tree! … … 85 86 86 87 /** 87 * loads the parameters of a SimpleGameMenu from an XML-element88 * @brief loads the parameters of a SimpleGameMenu from an XML-element 88 89 * @param root the XML-element to load from 89 90 */ … … 99 100 100 101 /** 101 * this is executed just before load102 * @brief this is executed just before load 102 103 * 103 104 * since the load function sometimes needs data, that has been initialized … … 125 126 126 127 /** 127 * load the data128 * @brief load the data 128 129 */ 129 130 ErrorMessage SimpleGameMenu::loadData() … … 265 266 266 267 /** 267 * start the menu268 * @brief start the menu 268 269 */ 269 270 bool SimpleGameMenu::start() -
trunk/src/story_entities/story_entity.cc
r7193 r7221 40 40 this->isRunning = false; 41 41 42 this->loadFile = NULL;42 this->loadFile = ""; 43 43 this->storyID = -1; 44 this->description = NULL;45 this->menuItemImage = NULL;46 this->menuScreenshoot = NULL;44 this->description = ""; 45 this->menuItemImage = ""; 46 this->menuScreenshoot = ""; 47 47 this->nextStoryID = WORLD_ID_GAMEEND; 48 48 this->bMenuEntry = false; … … 100 100 * @param name the name of the path 101 101 */ 102 void StoryEntity::setLoadFile(const char*fileName)102 void StoryEntity::setLoadFile(const std::string& fileName) 103 103 { 104 if (this->loadFile)105 delete this->loadFile;106 104 if (ResourceManager::isFile(fileName)) 107 105 { 108 this->loadFile = new char[strlen(fileName)+1]; 109 strcpy(this->loadFile, fileName); 106 this->loadFile = fileName; 110 107 } 111 108 else … … 120 117 * @param name name 121 118 */ 122 void StoryEntity::setDescription(const char*description)119 void StoryEntity::setDescription(const std::string& description) 123 120 { 124 if (this->description) 125 delete[] this->description; 126 if (description!= NULL) 127 { 128 this->description= new char[strlen(description)+1]; 129 strcpy(this->description, description); 130 } 131 else this->description= NULL; 121 this->description = description; 132 122 } 133 123 … … 149 139 { 150 140 PRINTF(3)("Grabbing the Worlds Settings\n", this->getLoadFile()); 151 if( getLoadFile() == NULL)152 return;141 if( getLoadFile().empty()) 142 return; 153 143 TiXmlDocument XMLDoc(this->getLoadFile()); 154 144 // load the xml world file for further loading 155 145 if( !XMLDoc.LoadFile()) 156 146 { 157 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile() , XMLDoc.ErrorRow(), XMLDoc.ErrorCol());147 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile().c_str(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol()); 158 148 return; 159 149 } … … 181 171 * @param name name 182 172 */ 183 void StoryEntity::setMenuItemImage(const char*image)173 void StoryEntity::setMenuItemImage(const std::string& image) 184 174 { 185 if (this->menuItemImage) 186 delete[] this->menuItemImage; 187 if (image != NULL) 188 { 189 this->menuItemImage = new char[strlen(image)+1]; 190 strcpy(this->menuItemImage, image); 191 } 192 else this->menuItemImage = NULL; 175 this->menuItemImage = image; 193 176 } 194 177 195 178 196 /** sets the menu screenshoot of this StoryEntity @param name name */ 197 void StoryEntity::setMenuScreenshoot(const char* image) 179 /** sets the menu screenshoot of this StoryEntity 180 * @param name name 181 */ 182 void StoryEntity::setMenuScreenshoot(const std::string& image) 198 183 { 199 if (this->menuScreenshoot) 200 delete[] this->menuScreenshoot; 201 if (image != NULL) 202 { 203 this->menuScreenshoot = new char[strlen(image)+1]; 204 strcpy(this->menuScreenshoot, image); 205 } 206 else this->menuScreenshoot = NULL; 184 this->menuScreenshoot = image; 207 185 } 208 186 -
trunk/src/story_entities/story_entity.h
r6993 r7221 61 61 inline int getStoryID() { return this->storyID; } 62 62 63 void setLoadFile( const char*fileName);63 void setLoadFile(const std::string& fileName); 64 64 /** @returns the Filename this StoryEntity was loaded with */ 65 const char*getLoadFile() const { return this->loadFile; }65 const std::string& getLoadFile() const { return this->loadFile; } 66 66 67 67 void setNextStoryID(int nextStoryID); 68 68 /** gets the story id of the current entity @returns story id */ 69 69 inline int getNextStoryID() const { return this->nextStoryID; } 70 inline void setDescription(const char*description);70 inline void setDescription(const std::string& description); 71 71 /** @returns the description of this StoryEntity */ 72 inline const char*getDescription() { return this->description; }72 inline const std::string& getDescription() { return this->description; } 73 73 74 74 void grabWorldInfo(); … … 78 78 inline bool isContainedInMenu() { return this->bMenuEntry; } 79 79 /** sets the menu item image of this StoryEntity @param name name */ 80 inline void setMenuItemImage(const char*image);80 inline void setMenuItemImage(const std::string& image); 81 81 /** @returns the menu item image of this StoryEntity */ 82 inline const char*getMenuItemImage() { return this->menuItemImage; }83 inline void setMenuScreenshoot(const char*image);82 inline const std::string& getMenuItemImage() { return this->menuItemImage; } 83 inline void setMenuScreenshoot(const std::string& image); 84 84 /** @returns the menu screenshoot of this StoryEntity */ 85 inline const char*getMenuScreenshoot() { return this->menuScreenshoot; }85 inline const std::string& getMenuScreenshoot() { return this->menuScreenshoot; } 86 86 87 87 protected: 88 bool isInit; //!< if the entity is initialized, this has to be true.89 bool isRunning; //!< is true if the entity is running90 bool isPaused; //!< is true if the entity is paused88 bool isInit; //!< if the entity is initialized, this has to be true. 89 bool isRunning; //!< is true if the entity is running 90 bool isPaused; //!< is true if the entity is paused 91 91 92 92 93 93 private: 94 int storyID; //!< this is the number of this entity, identifying it in a list/tree...95 int nextStoryID; //!< if this entity has finished, this entity shall be called96 char*loadFile; //!< The file from which this world is loaded94 int storyID; //!< this is the number of this entity, identifying it in a list/tree... 95 int nextStoryID; //!< if this entity has finished, this entity shall be called 96 std::string loadFile; //!< The file from which this world is loaded 97 97 98 char*description; //!< the description of the StoryEntity99 char*menuItemImage; //!< the item image of the StoryEntity100 char*menuScreenshoot; //!< the screenshoot of the StoryEntity101 bool bMenuEntry; //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific98 std::string description; //!< the description of the StoryEntity 99 std::string menuItemImage; //!< the item image of the StoryEntity 100 std::string menuScreenshoot; //!< the screenshoot of the StoryEntity 101 bool bMenuEntry; //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific 102 102 }; 103 103
Note: See TracChangeset
for help on using the changeset viewer.