Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8673 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 21, 2006, 3:43:44 PM (18 years ago)
Author:
bensch
Message:

added game_menu.cc

Location:
branches/gui/src
Files:
4 edited
2 copied

Legend:

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

    r8619 r8673  
    146146  CL_MOVIE_LOADER               =    0x00000109,
    147147
     148  CL_GAME_MENU                  =    0x00000110,
     149  CL_GAME_MENU_DATA             =    0x00000111,
     150
     151
    148152  CL_MULTIPLAYER_TEAM_DEATHMATCH=    0x00000121,
    149153  CL_SINGLEPLAYER_SHOOTEMUP     =    0x00000122,
  • branches/gui/src/lib/gui/gl/glgui_handler.cc

    r8672 r8673  
    102102  void GLGuiHandler::selectNext()
    103103  {
    104     printf("searching next Widget\n");
    105104    // retrieve Objects.
    106105    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
  • branches/gui/src/lib/gui/gl/glgui_widget.h

    r8667 r8673  
    4848    /** @returns true if the widget is focusable */
    4949    bool focusable() const { return this->_focusable; };
    50     /** @param focusable sets if the Widget should be focusable */
    51     void setFocusable(bool focusable = true) { this->_focusable = focusable; };
    5250    /** @returns true if the position is inside of the Widget. @param position the position to check */
    5351    bool focusOverWidget(const Vector2D& position) const;
     
    6361    /** @returns true if the Widget is selectable */
    6462    bool selectable() const { return this->_selectable; }
    65     /** @param selectable true if the widget should be selectable */
    66     void setSelectable(bool selectable) { this->_selectable = selectable; }
    6763
    6864    /** @returns the currently Selected Widget (NULL if none is selected). */
     
    7470    void release(const Vector2D& pos);
    7571    bool clickable() const { return this->_clickable; };
    76     void setClickable(bool clickable = true) { this->_clickable = clickable; };
    7772
    7873    static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor);
     
    238233
    239234  protected:
     235    /** @param focusable sets if the Widget should be focusable */
     236    void setFocusable(bool focusable = true) { this->_focusable = focusable; };
     237    /** @param selectable true if the widget should be selectable */
     238    void setSelectable(bool selectable) { this->_selectable = selectable; }
     239    /** @param focusable true if the widget should be focusable */
     240    void setClickable(bool clickable = true) { this->_clickable = clickable; };
     241
     242
    240243    /// RENDERING
    241244    inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
  • branches/gui/src/story_entities/Makefile.am

    r6634 r8673  
    1313                story_entities/multi_player_world_data.cc \
    1414                story_entities/movie_loader.cc \
     15                story_entities/game_menu.cc \
    1516                story_entities/simple_game_menu.cc
    1617
     
    2728                story_entities/multi_player_world_data.h \
    2829                story_entities/movie_loader.h \
     30                story_entities/game_menu.h \
    2931                story_entities/simple_game_menu.h
  • branches/gui/src/story_entities/game_menu.cc

    r8667 r8673  
    1717
    1818
    19 #include "simple_game_menu.h"
     19#include "game_menu.h"
    2020
    2121#include "event_handler.h"
     
    4444#include "gui/gl/specials/glgui_notifier.h"
    4545
    46 //! This creates a Factory to fabricate a SimpleGameMenu
    47 CREATE_FACTORY(SimpleGameMenu, CL_SIMPLE_GAME_MENU);
    48 
    49 
    50 
    51 SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root)
     46//! This creates a Factory to fabricate a GameMenu
     47CREATE_FACTORY(GameMenu, CL_GAME_MENU);
     48
     49
     50
     51GameMenu::GameMenu(const TiXmlElement* root)
    5252    : GameWorld()
    5353{
    54   this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu");
    55   this->setName("SimpleGameMenu uninitialized");
    56 
    57   this->dataTank = new SimpleGameMenuData();
     54  this->setClassID(CL_GAME_MENU, "GameMenu");
     55  this->setName("GameMenu uninitialized");
     56
     57  this->dataTank = new GameMenuData();
    5858
    5959  this->cameraVector = Vector(50.0, 0.0, 0.0);
    60   this->menuLayers.push_back(MenuLayer());
    61   this->menuLayers.push_back(MenuLayer());
    62 
    63   this->layerIndex = 0;
    64   this->menuSelectedIndex = 0;
    65   this->selectorSource = NULL;
    66 
    67 
    68   /// GUI
    69   ///(this is as modular as it is possible).
    70   OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME");
    71   //pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui));
    72   pb->connect(SIGNAL(pb, released), this, SLOT(SimpleGameMenu, enterGui));
    73   pb->show();
    74   pb->setAbsCoor2D(50, 50);
     60
    7561
    7662  OrxGui::GLGuiHandler::getInstance()->activateCursor();
    7763  OrxGui::GLGuiHandler::getInstance()->activate();
    7864  OrxGui::GLGuiHandler::getInstance()->cursor()->loadTextureSequence(ResourceManager::getInstance()->getDataDir() + "/" + "maps/reap_mouse/reap_mouse_##.png", 1, 49);
    79   /////
    8065
    8166  if (root != NULL)
     
    8671
    8772/// HACK only for testing.
    88 void SimpleGameMenu::enterGui()
    89 {
    90 
    91   OrxGui::GLGuiNotifier* notifier = new OrxGui::GLGuiNotifier();
    92   notifier->show();
    93   notifier->setAbsCoor2D(300, 300);
    94 
    95 
    96 
    97   OrxGui::GLGuiBox* box = new OrxGui::GLGuiBox();
    98   {
    99     ///
    100     OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
    101 
    102     box->pack(dnpb);
    103 
    104     OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
    105     rdnpb->connect(SIGNAL(rdnpb, released), this, SLOT(SimpleGameMenu, quitMenu));
    106 
    107     box->pack(rdnpb);
    108 
    109     OrxGui::GLGuiCheckButton* fullscreen = new OrxGui::GLGuiCheckButton("Fullscreen");
    110     fullscreen->connect(SIGNAL(fullscreen, toggled), GraphicsEngine::getInstance(), SLOT(GraphicsEngine, setFullscreen));
    111 
    112     box->pack(fullscreen);
    113 
    114     OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
    115     input->setText("input some text here");
    116     input->connect(SIGNAL(input, textChanged), notifier, SLOT(OrxGui::GLGuiNotifier, pushNotifyMessage));
    117 
    118     box->pack(input);
    119 
    120     OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
    121     slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, TEST));
    122     slider->setRange(0, 1);
    123     slider->setValue(slider->min());
    124     box->pack(slider);
    125 
    126 
    127     OrxGui::GLGuiTable* table = new OrxGui::GLGuiTable(3, 3);
    128     std::vector<std::string> headers;
    129     headers.push_back("1");
    130     headers.push_back("2");
    131     headers.push_back("3");
    132     table->setHeader(headers);
    133     table->setEntry(1, 2, "Test");
    134     table->setEntry(2, 1, "MultiLine SuperTest to see how it works");
    135 
    136 
    137     box->pack(table);
    138   }
    139   box->setAbsCoor2D(50, 200);
    140 
    141   box->showAll();
    142 
    143 
    144   OrxGui::GLGuiBox* imageSelector = new OrxGui::GLGuiBox();
    145   {
    146     image = new OrxGui::GLGuiImage();
    147     image->setWidgetSize(300, 300);
    148     image->setAbsCoor2D(300, 300);
    149     imageSelector->pack(image);
    150 
    151     imageName = new OrxGui::GLGuiInputLine();
    152     imageSelector->pack(imageName);
    153 
    154     OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
    155     slider->setWidgetSize(200, 30);
    156     slider->setRange(0, 100);
    157     slider->setStep(1);
    158     slider->setValue(slider->min());
    159     slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, setImage));
    160 
    161     imageSelector->pack(slider);
    162     slider->setValue(0);
    163   }
    164   imageSelector->showAll();
    165   imageSelector->setAbsCoor2D(400, 30);
    166 
    167 
    168   /////
    169 }
    170 
    171 
    172 #include "class_list.h"
    173 void SimpleGameMenu::setImage(int i)
    174 {
    175   const std::list<BaseObject*>* textures = ClassList::getList(CL_TEXTURE);
    176 
    177   if(textures)
    178   {
    179     std::list<BaseObject*>::const_iterator test = textures->begin();
    180     std::list<BaseObject*>::const_iterator lastOK = textures->begin();
    181     while (true)
    182     {
    183       if (--i == 0 || test == textures->end())
    184         break;
    185       if (dynamic_cast<Texture*>(*test)->getTexture() != 0)
    186         lastOK = test;
    187       test++;
    188     }
    189     this->image->loadImageFromTexture(*dynamic_cast<Texture*>(*lastOK));
    190     this->imageName->setText((*lastOK)->getName());
    191   }
    192 }
    193 
    194 
    195 #include "threading.h"
    196 void SimpleGameMenu::execURL() const
    197 {
    198   std::string URL = "http://www.orxonox.net";
    199   SDL_CreateThread(startURL, (void*)&URL);
    200 }
    201 
    202 #ifdef __OSX__
    203 #include <ApplicationServices/ApplicationServices.h>
    204 #elif defined __WIN32__
    205 //#include <shellapi.h>
    206 #endif
    207 
    208 int SimpleGameMenu::startURL(void* url)
    209 {
    210   std::string URL = *(std::string*)url;
    211 #ifdef __linux__
    212   system ((std::string("firefox ") + URL).c_str());
    213 #elif defined __OSX__
    214   CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
    215                         kCFStringEncodingASCII, NULL);
    216   LSOpenCFURLRef (url_handle, NULL);
    217   CFRelease (url_handle);
    218 #elif defined __WIN32__
    219   /*  ShellExecute(GetActiveWindow(),
    220                "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
    221                }*/
    222 #endif
    223   PRINTF(3)("loaded external webpage %s\n", URL.c_str());
    224 }
    225 
    226 /**
    227 *  @brief remove the SimpleGameMenu from memory
     73void GameMenu::enterGui()
     74{
     75}
     76
     77/**
     78*  @brief remove the GameMenu from memory
    22879*
    22980*  delete everything explicitly, that isn't contained in the parenting tree!
    23081*  things contained in the tree are deleted automaticaly
    23182*/
    232 SimpleGameMenu::~SimpleGameMenu ()
    233 {
    234   PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n");
     83GameMenu::~GameMenu ()
     84{
     85  PRINTF(3)("GameMenu::~GameMenu() - deleting current world\n");
    23586
    23687  if( this->dataTank)
     
    24192
    24293/**
    243 * @brief loads the parameters of a SimpleGameMenu from an XML-element
     94* @brief loads the parameters of a GameMenu from an XML-element
    24495* @param root the XML-element to load from
    24596*/
    246 void SimpleGameMenu::loadParams(const TiXmlElement* root)
     97void GameMenu::loadParams(const TiXmlElement* root)
    24798{
    24899  /* skip the GameWorld, since it does not define any useful loadParams for this class */
     
    250101  GameWorld::loadParams(root);
    251102
    252   PRINTF(4)("Loaded SimpleGameMenu specific stuff\n");
     103  PRINTF(4)("Loaded GameMenu specific stuff\n");
    253104}
    254105
     
    260111* before the load and after the proceeding storyentity has finished
    261112*/
    262 ErrorMessage SimpleGameMenu::init()
     113ErrorMessage GameMenu::init()
    263114{
    264115  /* call underlying init funciton */
     
    275126  GraphicsEngine::getInstance()->displayFPS(false);
    276127
    277   this->layerIndex = 0;
    278   this->menuSelectedIndex = 0;
    279128}
    280129
     
    283132* @brief load the data
    284133*/
    285 ErrorMessage SimpleGameMenu::loadData()
     134ErrorMessage GameMenu::loadData()
    286135{
    287136  GameWorld::loadData();
    288 
    289   if (this->dataXML != NULL)
    290   {
    291     LoadParam(dataXML, "selector-sound", this, SimpleGameMenu, setSelectorSound);
    292 
    293     TiXmlElement* element = this->dataXML->FirstChildElement("Elements");
    294 
    295 
    296     if( element == NULL)
    297     {
    298       PRINTF(1)("SimpleGameMenu is missing 'Elements'\n");
    299     }
    300     else
    301     {
    302       element = element->FirstChildElement();
    303       // load Players/Objects/Whatever
    304       PRINTF(4)("Loading Elements\n");
    305       while( element != NULL)
    306       {
    307         BaseObject* created = Factory::fabricate(element);
    308         if( created != NULL )
    309         {
    310           PRINTF(4)("Created a %s::%s\n", created->getClassName(), created->getName());
    311           if (!created->isA(CL_ELEMENT_2D))
    312             PRINTF(2)("Error the Created Entity is not an Element2D but an %s::%s\n", created->getClassName(), created->getName());
    313         }
    314         element = element->NextSiblingElement();
    315       }
    316       PRINTF(4)("Done loading Elements\n");
    317     }
    318   }
    319 
    320   /* get the menu list */
    321   const std::list<BaseObject*>* imageEntityList = ClassList::getList(CL_IMAGE_ENTITY);
    322   std::list<BaseObject*>::const_iterator entity;
    323   for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++)
    324   {
    325 
    326     if( !strcmp("Selector_Menu", (*entity)->getName()))
    327     {
    328       this->menuSelector = dynamic_cast<ImageEntity*>(*entity);
    329       this->menuSelector->setBindNode((const PNode*)NULL);
    330     }
    331   }
    332 
    333   imageEntityList = ClassList::getList(CL_TEXT_ELEMENT);
    334   for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++)
    335   {
    336     if( !strcmp( "StartGame_Menu", (*entity)->getName()))
    337     {
    338       this->menuStartGame = dynamic_cast<TextElement*>(*entity);
    339       this->menuStartGame->setBindNode((const PNode*)NULL);
    340       this->menuStartGame->setRelCoor2D(State::getResX() / 2.0f,
    341                                         State::getResY() / 2.0f - 60.0f);
    342       this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    343 
    344     }
    345     else if( !strcmp( "Multiplayer_Menu", (*entity)->getName()))
    346     {
    347       this->menuStartMultiplayerGame = dynamic_cast<TextElement*>(*entity);
    348       this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);
    349       this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,
    350           State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
    351       this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    352     }
    353     else if( !strcmp( "Quit_Menu", (*entity)->getName()))
    354     {
    355       this->menuQuitGame = dynamic_cast<TextElement*>(*entity);
    356       this->menuQuitGame->setBindNode((const PNode*)NULL);
    357       this->menuQuitGame->setRelCoor2D(State::getResX() / 2.0f,
    358                                        State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 )* 60.0f));
    359       this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    360     }
    361   }
    362   this->menuSelected->getNullElement()->update2D(0.1f);
    363   this->menuSelectedIndex = 0;
    364   this->menuSelected = this->menuLayers[0].menuList[this->menuSelectedIndex];
    365   this->sliderTo(this->menuSelected, 0.0f);
    366 
    367 
    368   // loading the storyentities submenu (singleplayer)
    369   const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY);
    370   std::list<BaseObject*>::const_iterator it;
    371   for( it = storyEntities->begin(); it != storyEntities->end(); it++)
    372   {
    373     StoryEntity* se = dynamic_cast<StoryEntity*>(*it);
    374     if( se->isContainedInMenu())
    375     {
    376       this->menuLayers[1].storyList.push_back(se);
    377 
    378       // generating menu item
    379       TextElement* te = new TextElement();
    380       te->setVisibility(false);
    381       te->setText(se->getName());
    382       te->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayers[1].menuList.size() - 2.0f) * 60.0f));
    383       this->menuLayers[1].menuList.push_back(te);
    384 
    385       // generating screenshoot item
    386       ImageEntity* ie = new ImageEntity();
    387       ie->setVisibility(false);
    388       ie->setBindNode((const PNode*)NULL);
    389       ie->setTexture(se->getMenuScreenshoot());
    390       ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f);
    391       ie->setSize2D(140.0f, 105.0f);
    392       this->menuLayers[1].screenshootList.push_back(ie);
    393     }
    394   }
    395137}
    396138
     
    399141* @param selectorSound the sound to load.
    400142*/
    401 void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)
     143void GameMenu::setSelectorSound(const std::string& selectorSound)
    402144{
    403145  this->selectorSource = OrxSound::SoundEngine::getInstance()->createSource(selectorSound, NULL);
    404146}
    405147
    406 ErrorMessage SimpleGameMenu::unloadData()
     148ErrorMessage GameMenu::unloadData()
    407149{
    408150  this->unsubscribeEvents(ES_MENU);
    409151
    410   std::vector<MenuLayer>::iterator mit;
    411   for(mit = this->menuLayers.begin(); mit != this->menuLayers.end(); mit++)
    412   {
    413     while(!(*mit).menuList.empty())
    414     {
    415       delete (*mit).menuList.back();
    416       (*mit).menuList.pop_back();
    417     }
    418 
    419     (*mit).menuList.clear();
    420     (*mit).storyList.clear();
    421     (*mit).screenshootList.clear();
    422   }
    423 
    424   // delete the SoundSource.
    425   if (this->selectorSource != NULL)
    426     delete this->selectorSource;
    427   this->selectorSource = NULL;
    428 
    429152  GameWorld::unloadData();
    430153}
     
    434157* @brief start the menu
    435158*/
    436 bool SimpleGameMenu::start()
     159bool GameMenu::start()
    437160{
    438161  EventHandler::getInstance()->pushState(ES_MENU);
     
    447170* stop the menu
    448171*/
    449 bool SimpleGameMenu::stop()
     172bool GameMenu::stop()
    450173{
    451174  EventHandler::getInstance()->popState();
     
    459182*  override the standard tick for more functionality
    460183*/
    461 void SimpleGameMenu::tick()
     184void GameMenu::tick()
    462185{
    463186  GameWorld::tick();
     
    473196* @brief no collision detection in the menu
    474197*/
    475 void SimpleGameMenu::collide()
     198void GameMenu::collide()
    476199{
    477200  //   this->dataTank->localCamera->
     
    482205* @brief animate the scene
    483206*/
    484 void SimpleGameMenu::animateScene(float dt)
     207void GameMenu::animateScene(float dt)
    485208{
    486209  Quaternion q(/*0.00005*/ dt * .1, Vector(0.0, 1.0, 0.0));
     
    490213}
    491214
    492 void SimpleGameMenu::quitMenu()
     215void GameMenu::quitMenu()
    493216{
    494217  this->setNextStoryID(WORLD_ID_GAMEEND);
     
    501224* @param event the incoming event
    502225*/
    503 void SimpleGameMenu::process(const Event &event)
    504 {
    505   /* ----------------- LAYER 1 ---------------*/
    506   if( this->layerIndex == 0)
    507   {
    508     if( event.type == SDLK_RETURN && event.bPressed == true)
    509     {
    510       if( this->menuSelected == this->menuQuitGame)
    511       {
    512         this->setNextStoryID(WORLD_ID_GAMEEND);
    513         this->stop();
    514       }
    515       if( this->menuSelected == this->menuStartGame)
    516       {
    517         // switch to first submenu
    518         if( this->menuLayers[1].menuList.size() == 0)
    519         {
    520           PRINTF(1)("Haven't got any StoryEntities to play!\n");
    521           return;
    522         }
    523 
    524         this->switchMenuLayer(this->layerIndex, 1);
    525       }
    526     }
    527     if( event.type == SDLK_ESCAPE && event.bPressed == true)
    528     {
    529       this->setNextStoryID(WORLD_ID_GAMEEND);
    530       this->stop();
    531     }
    532   }  /* ----------------- LAYER 2 ---------------*/
    533   else if( this->layerIndex == 1)
    534   {
    535     if( event.type == SDLK_RETURN && event.bPressed == true)
    536     {
    537       this->setNextStoryID( this->menuLayers[1].storyList[this->menuSelectedIndex]->getStoryID());
    538       this->stop();
    539     }
    540     if( event.type == SDLK_ESCAPE && event.bPressed == true)
    541     {
    542       this->switchMenuLayer(this->layerIndex, 0);
    543     }
    544   }
    545 
    546 
    547 
    548   // The menu selction cursor
    549   if( event.type == SDLK_DOWN && event.bPressed == true)
    550   {
    551     if(this->menuSelectedIndex < (this->menuLayers[this->layerIndex].menuList.size() - 1))
    552     {
    553       this->menuSelected = this->menuLayers[this->layerIndex].menuList[++this->menuSelectedIndex];
    554       this->sliderTo(this->menuSelected, 5.0f);
    555       if (this->selectorSource != NULL)
    556         this->selectorSource->play();
    557 
    558       if( this->layerIndex == 1)
    559       {
    560         this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true);
    561         this->menuLayers[1].screenshootList[this->menuSelectedIndex-1]->setVisibility(false);
    562       }
    563     }
    564   }
    565   else if( event.type == SDLK_UP && event.bPressed == true)
    566   {
    567     if(this->menuSelectedIndex > 0)
    568     {
    569       this->menuSelected = this->menuLayers[this->layerIndex].menuList[--this->menuSelectedIndex];
    570       this->sliderTo(this->menuSelected, 5.0f);
    571       if (this->selectorSource != NULL)
    572         this->selectorSource->play();
    573 
    574       if( this->layerIndex == 1)
    575       {
    576         this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true);
    577         this->menuLayers[1].screenshootList[this->menuSelectedIndex+1]->setVisibility(false);
    578       }
    579     }
    580   }
    581 }
    582 
    583 
    584 /**
    585 * @brief switches to from one meny layer to an other
    586 * @param layer1 from layer
    587 * @param layer2 to layer
    588 */
    589 void SimpleGameMenu::switchMenuLayer(int layer1, int layer2)
    590 {
    591   // wrong sizes
    592   if(layer1 >= this->menuLayers.size() || layer2 >= this->menuLayers.size())
    593     return;
    594 
    595 
    596   PRINTF(0)("Removing layer %i\n", layer1);
    597   std::vector<TextElement*>::iterator te;
    598   // fade old menu
    599   for( te = this->menuLayers[layer1].menuList.begin(); te != this->menuLayers[layer1].menuList.end(); te++)
    600   {
    601     (*te)->setVisibility(false);
    602   }
    603 
    604   std::vector<ImageEntity*>::iterator it;
    605 
    606   //also fade the screenshots if in level choosement mode
    607   for( it = this->menuLayers[layer1].screenshootList.begin(); it != this->menuLayers[layer1].screenshootList.end(); it++)
    608   {
    609     (*it)->setVisibility(false);
    610   }
    611 
    612 
    613   PRINTF(0)("Showing layer %i\n", layer1);
    614   // beam here the new menu
    615   for( te = this->menuLayers[layer2].menuList.begin(); te != this->menuLayers[layer2].menuList.end(); te++ )
    616   {
    617     (*te)->setVisibility(true);
    618   }
    619 
    620 
    621   this->layerIndex = layer2;
    622   this->menuSelected = this->menuLayers[layer2].menuList[0];
    623   this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D() + Vector2D(0, this->menuSelected->getSizeY2D() *.5));
    624   this->menuSelector->setSize2D(this->menuSelected->getSizeX2D()*.7, this->menuSelected->getSizeY2D());
    625   this->menuSelectedIndex = 0;
    626 
    627   if( layer2 == 1)
    628     this->menuLayers[layer2].screenshootList[0]->setVisibility(true);
    629 }
    630 
    631 void SimpleGameMenu::sliderTo(const Element2D* element, float bias)
    632 {
    633   if (bias > 0.0)
    634   {
    635     this->menuSelector->setAbsCoorSoft2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5), bias);
    636     this->menuSelector->setSizeSoft2D(element->getSizeX2D()*.7, element->getSizeY2D(), bias);
    637   }
    638   else
    639   {
    640     this->menuSelector->setAbsCoor2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5));
    641     this->menuSelector->setSize2D(element->getSizeX2D()*.7, element->getSizeY2D());
    642   }
     226void GameMenu::process(const Event &event)
     227{
    643228}
    644229
     
    646231
    647232/**********************************************************************************************
    648 SimpleGameMenuData
     233GameMenuData
    649234**********************************************************************************************/
    650235
    651236
    652237/**
    653 * SimpleGameMenuData constructor
    654 */
    655 SimpleGameMenuData::SimpleGameMenuData()
     238* GameMenuData constructor
     239*/
     240GameMenuData::GameMenuData()
    656241{}
    657242
    658243/**
    659 * SimpleGameMenuData decontructor
    660 */
    661 SimpleGameMenuData::~SimpleGameMenuData()
     244* GameMenuData decontructor
     245*/
     246GameMenuData::~GameMenuData()
    662247{}
    663248
     
    666251*  initialize the GameWorldDataData
    667252*/
    668 ErrorMessage SimpleGameMenuData::init()
     253ErrorMessage GameMenuData::init()
    669254{
    670255  /* call underlying function */
     
    677262* @param root reference to the xml root element
    678263*/
    679 ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root)
     264ErrorMessage GameMenuData::loadGUI(const TiXmlElement* root)
    680265{
    681266  /* call underlying function */
     
    687272*  unloads the GUI data
    688273*/
    689 ErrorMessage SimpleGameMenuData::unloadGUI()
     274ErrorMessage GameMenuData::unloadGUI()
    690275{
    691276  /* call underlying function */
     
    698283* @param root reference to the xml root parameter
    699284*/
    700 ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root)
     285ErrorMessage GameMenuData::loadWorldEntities(const TiXmlElement* root)
    701286{
    702287  GameWorldData::loadWorldEntities(root);
    703   /*
    704   const TiXmlElement* element = root->FirstChildElement("WorldEntities");
    705 
    706   if( element != NULL)
    707   {
    708   element = element->FirstChildElement();
    709   PRINTF(4)("Loading WorldEntities\n");
    710   while(element != NULL)
    711   {
    712   BaseObject* created = Factory::fabricate(element);
    713   if( created != NULL )
    714   printf("Created a %s: %s\n", created->getClassName(), created->getName());
    715 
    716   if( element->Value() == "SkyBox")
    717   this->sky = dynamic_cast<WorldEntity*>(created);
    718   if( element->Value() == "Terrain")
    719   this->terrain = dynamic_cast<Terrain*>(created);
    720   element = element->NextSiblingElement();
    721   }
    722 
    723   PRINTF(4)("Done loading WorldEntities\n");
    724   }
    725 
    726   // init the pnode tree
    727   PNode::getNullParent()->init();
    728   */
    729288}
    730289
     
    733292*  unloads the world entities from the xml file
    734293*/
    735 ErrorMessage SimpleGameMenuData::unloadWorldEntities()
     294ErrorMessage GameMenuData::unloadWorldEntities()
    736295{
    737296  /* call underlying function */
     
    744303* @param root reference to the xml root element
    745304*/
    746 ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root)
     305ErrorMessage GameMenuData::loadScene(const TiXmlElement* root)
    747306{
    748307  /* call underlying function */
     
    754313*  unloads the scene data
    755314*/
    756 ErrorMessage SimpleGameMenuData::unloadScene()
     315ErrorMessage GameMenuData::unloadScene()
    757316{
    758317  /* call underlying function */
  • branches/gui/src/story_entities/game_menu.h

    r8667 r8673  
    11/*!
    2  * @file simple_game_menu.h
     2 * @file game_menu.h
    33 *  a StoryEntity that contains a simple game menu
    44 */
    55
    6 #ifndef _SIMPLE_GAME_MENU_H
    7 #define _SIMPLE_GAME_MENU_H
     6#ifndef _GAME_MENU_H
     7#define _GAME_MENU_H
    88
    99
    1010#include "game_world.h"
    11 #include "event_listener.h"
    1211#include "game_world_data.h"
    1312#include <vector>
    14 #include "vector.h"
    15 
    16 
    17 #include "elements/text_element.h"
    18 
    1913#include "glgui.h"
    2014
    21 class SimpleGameMenuData;
    22 class TiXmlElement;
    23 class ImageEntity;
    24 
    2515namespace OrxSound { class SoundSource; }
    26 
    27 class MenuLayer
    28 {
    29   public:
    30     MenuLayer() {}
    31     virtual ~MenuLayer() {}
    32 
    33 
    34   public:
    35     std::vector<TextElement*>         menuList;                        //!< the list of the menu items
    36     std::vector<StoryEntity*>         storyList;                       //!< the list of the StoryEntities for the menu
    37     std::vector<ImageEntity*>         screenshootList;                 //!< list of the screen shoots FIXME: make a better structure for this stuff
    38 };
    39 
    4016
    4117//! a simple game menu based on a story entity
     
    4420 * loadable and is exchangeable very easely :D
    4521 */
    46 class SimpleGameMenu : virtual public GameWorld, virtual public EventListener
     22class GameMenu : virtual public GameWorld, virtual public EventListener
    4723{
    4824
    4925  public:
    50     SimpleGameMenu(const TiXmlElement* root = NULL);
    51     virtual ~SimpleGameMenu();
     26    GameMenu(const TiXmlElement* root = NULL);
     27    virtual ~GameMenu();
    5228
    5329    /// TODO TAKE THIS OUT
     
    7551    void quitMenu();
    7652
    77     void TEST(int val) { printf("TEST %d\n", val); }
    78 
    7953  protected:
    8054    virtual void tick();
     
    9064
    9165  private:
    92     std::vector<MenuLayer>            menuLayers;                      //!< the menu layer
    93     MenuLayer*                        selectedLayer;                   //!< the selected menu layer
    94     int                               layerIndex;
    95 
    96     //std::vector<ImageEntity*>         menuList;                        //!< the list of the menu items
    97     ImageEntity*                      menuSelector;                    //!< ref to the selector image
    98     TextElement*                      menuSelected;                    //!< ref to the selected menu entity
    99     TextElement*                      menuStartGame;
    100     TextElement*                      menuStartMultiplayerGame;
    101     TextElement*                      menuQuitGame;
    102     int                               menuSelectedIndex;
     66    OrxGui::GLGuiBox*                 mainMenu;
     67    OrxGui::GLGuiBox*                 audioBox;
     68    OrxGui::GLGuiBox*                 videoBox;
     69    OrxGui::GLGuiBox*                 controlBox;
     70    OrxGui::GLGuiBox*                 levelsBox;
    10371
    10472    Vector                            cameraVector;
     
    11078
    11179//! the simple game menu data
    112 class SimpleGameMenuData : public GameWorldData
     80class GameMenuData : public GameWorldData
    11381{
    11482
    11583  public:
    116     SimpleGameMenuData();
    117     virtual ~SimpleGameMenuData();
     84    GameMenuData();
     85    virtual ~GameMenuData();
    11886
    11987    virtual ErrorMessage init();
Note: See TracChangeset for help on using the changeset viewer.