- Timestamp:
- Jan 11, 2006, 10:49:27 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/defs/class_id.h
r6455 r6502 73 73 74 74 CL_STORY_ENTITY = 0x02000000, 75 76 CL_GAME_WORLD = 0x50000000, 77 CL_GAME_WORLD_DATA = 0x60000000, 75 78 76 79 CL_PHYSICS_INTERFACE = 0x04000000, … … 148 151 CL_CAMPAIGN = 0x00000101, 149 152 CL_CAMPAIGN_DATA = 0x00000102, 150 CL_ GAME_WORLD= 0x00000103,151 CL_ GAME_WORLD_DATA= 0x00000104,153 CL_SIMPLE_GAME_MENU = 0x00000103, 154 CL_SIMPLE_GAME_MENU_DATA = 0x00000104, 152 155 CL_SINGLE_PLAYER_WORLD = 0x00000105, 153 156 CL_SINGLE_PLAYER_WORLD_DATA = 0x00000106, 154 157 CL_MULTI_PLAYER_WORLD = 0x00000107, 155 158 CL_MULTI_PLAYER_WORLD_DATA = 0x00000108, 159 156 160 157 161 // WorldEntities (range from 0x00000200 to 0x000004ff) -
branches/network/src/story_entities/simple_game_menu.cc
r6501 r6502 19 19 #include "simple_game_menu.h" 20 20 21 #include "state.h" 22 #include "class_list.h" 23 24 #include "load_param.h" 25 #include "fast_factory.h" 26 #include "factory.h" 27 28 #include "world_entity.h" 29 #include "terrain.h" 30 31 #include "cd_engine.h" 32 33 21 34 using namespace std; 22 35 23 36 24 /** 25 * SimpleGameMenu constructor 26 */ 27 SimpleGameMenu::SimpleGameMenu() 37 //! This creates a Factory to fabricate a SimpleGameMenu 38 CREATE_FACTORY(SimpleGameMenu, CL_SIMPLE_GAME_MENU); 39 40 41 42 SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root) 43 : GameWorld(root) 44 { 45 this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu"); 46 this->setName("SimpleGameMenu uninitialized"); 47 48 this->dataTank = new SimpleGameMenuData(); 49 50 this->loadParams(root); 51 } 52 53 54 /** 55 * remove the SimpleGameMenu from memory 56 * 57 * delete everything explicitly, that isn't contained in the parenting tree! 58 * things contained in the tree are deleted automaticaly 59 */ 60 SimpleGameMenu::~SimpleGameMenu () 61 { 62 PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n"); 63 64 if( this->dataTank) 65 delete this->dataTank; 66 } 67 68 69 /** 70 * loads the parameters of a SimpleGameMenu from an XML-element 71 * @param root the XML-element to load from 72 */ 73 void SimpleGameMenu::loadParams(const TiXmlElement* root) 74 { 75 /* skip the GameWorld, since it does not define any useful loadParams for this class */ 76 static_cast<StoryEntity*>(this)->loadParams(root); 77 78 PRINTF(4)("Loaded SimpleGameMenu specific stuff\n"); 79 } 80 81 82 /** 83 * no collision detection in the menu 84 */ 85 void SimpleGameMenu::collide() 28 86 {} 29 87 30 88 31 /** SimpleGameMenu deconstructor 32 */ 33 SimpleGameMenu::~SimpleGameMenu() 89 90 91 92 93 94 95 96 /********************************************************************************************** 97 SimpleGameMenuData 98 **********************************************************************************************/ 99 100 101 /** 102 * SimpleGameMenuData constructor 103 */ 104 SimpleGameMenuData::SimpleGameMenuData() 34 105 {} 35 106 36 37 /** 38 * init the menu 39 */ 40 ErrorMessage SimpleGameMenu::init() 107 /** 108 * SimpleGameMenuData decontructor 109 */ 110 SimpleGameMenuData::~SimpleGameMenuData() 41 111 {} 42 112 43 113 44 114 /** 45 * load the data 46 */ 47 ErrorMessage SimpleGameMenu::loadData() 48 {} 49 50 51 /** 52 * unload the data again 53 */ 54 ErrorMessage SimpleGameMenu::unloadData() 55 {} 56 57 58 /** 59 * start the menu 60 */ 61 bool SimpleGameMenu::start() 62 {} 63 64 65 /** 66 * stop the menu 67 */ 68 bool SimpleGameMenu::stop() 69 {} 70 71 72 /** 73 * menu running function 74 */ 75 void SimpleGameMenu::run() 76 {} 115 * initialize the GameWorldDataData 116 */ 117 ErrorMessage SimpleGameMenuData::init() 118 { 119 /* call underlying function */ 120 GameWorldData::init(); 121 } 122 123 124 /** 125 * loads the GUI data 126 * @param root reference to the xml root element 127 */ 128 ErrorMessage SimpleGameMenuData::loadGUI(TiXmlElement* root) 129 { 130 /* call underlying function */ 131 GameWorldData::loadGUI(root); 132 } 133 134 135 /** 136 * unloads the GUI data 137 */ 138 ErrorMessage SimpleGameMenuData::unloadGUI() 139 { 140 /* call underlying function */ 141 GameWorldData::unloadGUI(); 142 } 143 144 145 /** 146 * overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff) 147 * @param root reference to the xml root parameter 148 */ 149 ErrorMessage SimpleGameMenuData::loadWorldEntities(TiXmlElement* root) 150 { 151 TiXmlElement* element = root->FirstChildElement("WorldEntities"); 152 153 if( element != NULL) 154 { 155 element = element->FirstChildElement(); 156 PRINTF(4)("Loading WorldEntities\n"); 157 while( element != NULL) 158 { 159 BaseObject* created = Factory::fabricate(element); 160 if( created != NULL ) 161 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 162 163 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 164 this->sky = dynamic_cast<WorldEntity*>(created); 165 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 166 { 167 this->terrain = dynamic_cast<Terrain*>(created); 168 CDEngine::getInstance()->setTerrain(terrain); 169 } 170 element = element->NextSiblingElement(); 171 } 172 PRINTF(4)("Done loading WorldEntities\n"); 173 } 174 175 /* init the pnode tree */ 176 PNode::getNullParent()->init(); 177 } 178 179 180 /** 181 * unloads the world entities from the xml file 182 */ 183 ErrorMessage SimpleGameMenuData::unloadWorldEntities() 184 { 185 /* call underlying function */ 186 GameWorldData::unloadWorldEntities(); 187 } 188 189 190 /** 191 * loads the scene data 192 * @param root reference to the xml root element 193 */ 194 ErrorMessage SimpleGameMenuData::loadScene(TiXmlElement* root) 195 { 196 /* call underlying function */ 197 GameWorldData::loadScene(root); 198 } 199 200 201 /** 202 * unloads the scene data 203 */ 204 ErrorMessage SimpleGameMenuData::unloadScene() 205 { 206 /* call underlying function */ 207 GameWorldData::unloadScene(); 208 } 209 210 211 -
branches/network/src/story_entities/simple_game_menu.h
r6501 r6502 8 8 9 9 10 #include " story_entity.h"11 #include " data_tank.h"10 #include "game_world.h" 11 #include "game_world_data.h" 12 12 13 13 14 14 class SimpleGameMenuData; 15 class TiXmlElement; 15 16 16 17 … … 20 21 * loadable and is exchangeable very easely :D 21 22 */ 22 class SimpleGameMenu : public StoryEntity23 class SimpleGameMenu : public GameWorld 23 24 { 24 25 25 26 public: 26 SimpleGameMenu( );27 SimpleGameMenu(const TiXmlElement* root = NULL); 27 28 virtual ~SimpleGameMenu(); 28 29 30 void loadParams(const TiXmlElement* root); 29 31 30 /* initialisation and loading */ 31 virtual ErrorMessage init(); 32 virtual ErrorMessage loadData(); 33 virtual ErrorMessage unloadData(); 34 35 /* running, stopping and pausing */ 36 virtual bool start(); 37 virtual bool stop(); 38 virtual bool pause() {} 39 virtual bool resume() {} 40 virtual void run(); 32 virtual void collide(); 33 }; 41 34 42 35 43 private:44 SimpleGameMenuData* simpleGameMenuData;45 36 46 }; 37 //! the simple game menu data 38 class SimpleGameMenuData : public GameWorldData 39 { 47 40 48 class SimpleGameMenuData : public DataTank 49 { 41 public: 42 SimpleGameMenuData(); 43 virtual ~SimpleGameMenuData(); 44 45 virtual ErrorMessage init(); 46 47 48 protected: 49 virtual ErrorMessage loadGUI(TiXmlElement* root); 50 virtual ErrorMessage loadWorldEntities(TiXmlElement* root); 51 virtual ErrorMessage loadScene(TiXmlElement* root); 52 53 virtual ErrorMessage unloadGUI(); 54 virtual ErrorMessage unloadWorldEntities(); 55 virtual ErrorMessage unloadScene(); 50 56 51 57 };
Note: See TracChangeset
for help on using the changeset viewer.