Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6502 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 11, 2006, 10:49:27 PM (19 years ago)
Author:
patrick
Message:

network: the simple menu is a game world, that is a little more performant and much smaller

Location:
branches/network/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/defs/class_id.h

    r6455 r6502  
    7373
    7474  CL_STORY_ENTITY               =    0x02000000,
     75
     76  CL_GAME_WORLD                 =    0x50000000,
     77  CL_GAME_WORLD_DATA            =    0x60000000,
    7578
    7679  CL_PHYSICS_INTERFACE          =    0x04000000,
     
    148151  CL_CAMPAIGN                   =    0x00000101,
    149152  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,
    152155  CL_SINGLE_PLAYER_WORLD        =    0x00000105,
    153156  CL_SINGLE_PLAYER_WORLD_DATA   =    0x00000106,
    154157  CL_MULTI_PLAYER_WORLD         =    0x00000107,
    155158  CL_MULTI_PLAYER_WORLD_DATA    =    0x00000108,
     159
    156160
    157161  // WorldEntities (range from 0x00000200 to 0x000004ff)
  • branches/network/src/story_entities/simple_game_menu.cc

    r6501 r6502  
    1919#include "simple_game_menu.h"
    2020
     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
    2134using namespace std;
    2235
    2336
    24 /**
    25  * SimpleGameMenu constructor
    26  */
    27 SimpleGameMenu::SimpleGameMenu()
     37//! This creates a Factory to fabricate a SimpleGameMenu
     38CREATE_FACTORY(SimpleGameMenu, CL_SIMPLE_GAME_MENU);
     39
     40
     41
     42SimpleGameMenu::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 */
     60SimpleGameMenu::~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 */
     73void 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 */
     85void SimpleGameMenu::collide()
    2886{}
    2987
    3088
    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 */
     104SimpleGameMenuData::SimpleGameMenuData()
    34105{}
    35106
    36 
    37 /**
    38  * init the menu
    39  */
    40 ErrorMessage SimpleGameMenu::init()
     107/**
     108 * SimpleGameMenuData decontructor
     109 */
     110SimpleGameMenuData::~SimpleGameMenuData()
    41111{}
    42112
    43113
    44114/**
    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 */
     117ErrorMessage 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 */
     128ErrorMessage SimpleGameMenuData::loadGUI(TiXmlElement* root)
     129{
     130  /* call underlying function */
     131  GameWorldData::loadGUI(root);
     132}
     133
     134
     135/**
     136 *  unloads the GUI data
     137 */
     138ErrorMessage 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 */
     149ErrorMessage 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 */
     183ErrorMessage 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 */
     194ErrorMessage SimpleGameMenuData::loadScene(TiXmlElement* root)
     195{
     196  /* call underlying function */
     197  GameWorldData::loadScene(root);
     198}
     199
     200
     201/**
     202 *  unloads the scene data
     203 */
     204ErrorMessage 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  
    88
    99
    10 #include "story_entity.h"
    11 #include "data_tank.h"
     10#include "game_world.h"
     11#include "game_world_data.h"
    1212
    1313
    1414class SimpleGameMenuData;
     15class TiXmlElement;
    1516
    1617
     
    2021 * loadable and is exchangeable very easely :D
    2122 */
    22 class SimpleGameMenu : public StoryEntity
     23class SimpleGameMenu : public GameWorld
    2324{
    2425
    2526  public:
    26     SimpleGameMenu();
     27    SimpleGameMenu(const TiXmlElement* root = NULL);
    2728    virtual ~SimpleGameMenu();
    2829
     30    void loadParams(const TiXmlElement* root);
    2931
    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};
    4134
    4235
    43   private:
    44     SimpleGameMenuData*      simpleGameMenuData;
    4536
    46 };
     37//! the simple game menu data
     38class SimpleGameMenuData : public GameWorldData
     39{
    4740
    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();
    5056
    5157};
Note: See TracChangeset for help on using the changeset viewer.