Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7919 in orxonox.OLD for trunk/src/story_entities/simple_game_menu.cc


Ignore:
Timestamp:
May 28, 2006, 3:48:13 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the gui branche back
merged with command:
https://svn.orxonox.net/orxonox/branches/gui
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/simple_game_menu.cc

    r7868 r7919  
    2828#include "util/loading/factory.h"
    2929
    30 #include "p_node.h"
    3130#include "world_entity.h"
    3231#include "elements/image_entity.h"
     
    4140#include "cd_engine.h"
    4241
    43 
    44 using namespace std;
    45 
     42#include "glgui.h"
    4643
    4744//! This creates a Factory to fabricate a SimpleGameMenu
     
    5148
    5249SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root)
    53   : GameWorld()
     50    : GameWorld()
    5451{
    5552  this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu");
     
    6663  this->selectorSource = NULL;
    6764
     65
     66  /// GUI
     67  ///(this is as modular as it is possible).
     68  OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME");
     69  pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui));
     70  pb->show();
     71  pb->setAbsCoor2D(50, 50);
     72
     73  OrxGui::GLGuiHandler::getInstance()->activateCursor();
     74  OrxGui::GLGuiHandler::getInstance()->activate();
     75  /////
     76
    6877  if (root != NULL)
    6978    this->loadParams(root);
     
    7281}
    7382
    74 
    75 /**
    76  *  @brief remove the SimpleGameMenu from memory
    77  *
    78  *  delete everything explicitly, that isn't contained in the parenting tree!
    79  *  things contained in the tree are deleted automaticaly
    80  */
     83/// HACK only for testing.
     84void SimpleGameMenu::enterGui()
     85{
     86  ///
     87  OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
     88  dnpb->show();
     89  dnpb->setAbsCoor2D(350, 50);
     90  dnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::execURL));
     91
     92  OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
     93  rdnpb->show();
     94  rdnpb->setAbsCoor2D(200, 180);
     95  rdnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::quitMenu));
     96
     97  OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
     98  input->setText("input some text here");
     99  input->show();
     100  input->setAbsCoor2D(200, 230);
     101
     102
     103  /////
     104}
     105
     106
     107#include "threading.h"
     108void SimpleGameMenu::execURL() const
     109{
     110  std::string URL = "http://www.orxonox.net";
     111  SDL_CreateThread(startURL, (void*)&URL);
     112}
     113
     114#ifdef __OSX__
     115#include <ApplicationServices/ApplicationServices.h>
     116#elif defined __WIN32__
     117#include <shellapi.h>
     118#endif
     119
     120int SimpleGameMenu::startURL(void* url)
     121{
     122  std::string URL = *(std::string*)url;
     123#ifdef __linux__
     124  system ((std::string("firefox ") + URL).c_str());
     125#elif defined __OSX__
     126    CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
     127                                         kCFStringEncodingASCII, NULL);
     128    LSOpenCFURLRef (url_handle, NULL);
     129    CFRelease (url_handle);
     130#elif defined __WIN32__
     131    ShellExecute(GetActiveWindow(),
     132                 "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
     133  }
     134#endif
     135  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
     136}
     137
     138/**
     139*  @brief remove the SimpleGameMenu from memory
     140*
     141*  delete everything explicitly, that isn't contained in the parenting tree!
     142*  things contained in the tree are deleted automaticaly
     143*/
    81144SimpleGameMenu::~SimpleGameMenu ()
    82145{
     
    85148  if( this->dataTank)
    86149    delete this->dataTank;
    87 }
    88 
    89 
    90 /**
    91  * @brief loads the parameters of a SimpleGameMenu from an XML-element
    92  * @param root the XML-element to load from
    93  */
     150  delete OrxGui::GLGuiHandler::getInstance( );
     151}
     152
     153
     154/**
     155* @brief loads the parameters of a SimpleGameMenu from an XML-element
     156* @param root the XML-element to load from
     157*/
    94158void SimpleGameMenu::loadParams(const TiXmlElement* root)
    95159{
     
    103167
    104168/**
    105  * @brief this is executed just before load
    106  *
    107  * since the load function sometimes needs data, that has been initialized
    108  * before the load and after the proceeding storyentity has finished
    109  */
     169* @brief this is executed just before load
     170*
     171* since the load function sometimes needs data, that has been initialized
     172* before the load and after the proceeding storyentity has finished
     173*/
    110174ErrorMessage SimpleGameMenu::init()
    111175{
     
    129193
    130194/**
    131  * @brief load the data
    132  */
     195* @brief load the data
     196*/
    133197ErrorMessage SimpleGameMenu::loadData()
    134198{
     
    149213    {
    150214      element = element->FirstChildElement();
    151     // load Players/Objects/Whatever
     215      // load Players/Objects/Whatever
    152216      PRINTF(4)("Loading Elements\n");
    153217      while( element != NULL)
     
    196260      this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);
    197261      this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,
    198                                                    State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
     262          State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
    199263      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    200264    }
     
    244308
    245309/**
    246  * @brief set the Sound to play when switching menu entry.
    247  * @param selectorSound the sound to load.
    248  */
     310* @brief set the Sound to play when switching menu entry.
     311* @param selectorSound the sound to load.
     312*/
    249313void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)
    250314{
     
    280344
    281345/**
    282  * @brief start the menu
    283  */
     346* @brief start the menu
     347*/
    284348bool SimpleGameMenu::start()
    285349{
     
    293357
    294358/**
    295  * stop the menu
    296  */
     359* stop the menu
     360*/
    297361bool SimpleGameMenu::stop()
    298362{
     
    305369
    306370/**
    307  *  override the standard tick for more functionality
    308  */
     371*  override the standard tick for more functionality
     372*/
    309373void SimpleGameMenu::tick()
    310374{
    311375  GameWorld::tick();
    312376
     377  // Make the GLGui tick.
     378  OrxGui::GLGuiHandler::getInstance()->tick(this->dtS);
     379
    313380  this->animateScene(this->dtS);
    314381}
     
    316383
    317384/**
    318  * @brief no collision detection in the menu
    319  */
     385* @brief no collision detection in the menu
     386*/
    320387void SimpleGameMenu::collide()
    321388{
    322 //   this->dataTank->localCamera->
    323 }
    324 
    325 
    326 /**
    327  * @brief animate the scene
    328  */
     389  //   this->dataTank->localCamera->
     390}
     391
     392
     393/**
     394* @brief animate the scene
     395*/
    329396void SimpleGameMenu::animateScene(float dt)
    330397{
     
    335402}
    336403
    337 
    338 /**
    339  * @brief event dispatcher funciton
    340  * @param event the incoming event
    341  */
     404void SimpleGameMenu::quitMenu()
     405{
     406  this->setNextStoryID(WORLD_ID_GAMEEND);
     407  this->stop();
     408}
     409
     410
     411/**
     412* @brief event dispatcher funciton
     413* @param event the incoming event
     414*/
    342415void SimpleGameMenu::process(const Event &event)
    343416{
     
    422495
    423496/**
    424  * @brief switches to from one meny layer to an other
    425  * @param layer1 from layer
    426  * @param layer2 to layer
    427  */
     497* @brief switches to from one meny layer to an other
     498* @param layer1 from layer
     499* @param layer2 to layer
     500*/
    428501void SimpleGameMenu::switchMenuLayer(int layer1, int layer2)
    429502{
     
    485558
    486559/**********************************************************************************************
    487     SimpleGameMenuData
    488  **********************************************************************************************/
    489 
    490 
    491 /**
    492  * SimpleGameMenuData constructor
    493  */
     560SimpleGameMenuData
     561**********************************************************************************************/
     562
     563
     564/**
     565* SimpleGameMenuData constructor
     566*/
    494567SimpleGameMenuData::SimpleGameMenuData()
    495568{}
    496569
    497570/**
    498  * SimpleGameMenuData decontructor
    499  */
     571* SimpleGameMenuData decontructor
     572*/
    500573SimpleGameMenuData::~SimpleGameMenuData()
    501574{}
     
    503576
    504577/**
    505  *  initialize the GameWorldDataData
    506  */
     578*  initialize the GameWorldDataData
     579*/
    507580ErrorMessage SimpleGameMenuData::init()
    508581{
     
    513586
    514587/**
    515  *  loads the GUI data
    516  * @param root reference to the xml root element
    517  */
     588*  loads the GUI data
     589* @param root reference to the xml root element
     590*/
    518591ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root)
    519592{
     
    524597
    525598/**
    526  *  unloads the GUI data
    527  */
     599*  unloads the GUI data
     600*/
    528601ErrorMessage SimpleGameMenuData::unloadGUI()
    529602{
     
    534607
    535608/**
    536  *  overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff)
    537  * @param root reference to the xml root parameter
    538  */
     609*  overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff)
     610* @param root reference to the xml root parameter
     611*/
    539612ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root)
    540613{
     
    545618  if( element != NULL)
    546619  {
    547     element = element->FirstChildElement();
    548     PRINTF(4)("Loading WorldEntities\n");
    549     while(element != NULL)
    550     {
    551       BaseObject* created = Factory::fabricate(element);
    552       if( created != NULL )
    553         printf("Created a %s: %s\n", created->getClassName(), created->getName());
    554 
    555       if( element->Value() == "SkyBox")
    556         this->sky = dynamic_cast<WorldEntity*>(created);
    557       if( element->Value() == "Terrain")
    558         this->terrain = dynamic_cast<Terrain*>(created);
    559       element = element->NextSiblingElement();
    560     }
    561 
    562     PRINTF(4)("Done loading WorldEntities\n");
     620  element = element->FirstChildElement();
     621  PRINTF(4)("Loading WorldEntities\n");
     622  while(element != NULL)
     623  {
     624  BaseObject* created = Factory::fabricate(element);
     625  if( created != NULL )
     626  printf("Created a %s: %s\n", created->getClassName(), created->getName());
     627
     628  if( element->Value() == "SkyBox")
     629  this->sky = dynamic_cast<WorldEntity*>(created);
     630  if( element->Value() == "Terrain")
     631  this->terrain = dynamic_cast<Terrain*>(created);
     632  element = element->NextSiblingElement();
     633  }
     634
     635  PRINTF(4)("Done loading WorldEntities\n");
    563636  }
    564637
     
    570643
    571644/**
    572  *  unloads the world entities from the xml file
    573  */
     645*  unloads the world entities from the xml file
     646*/
    574647ErrorMessage SimpleGameMenuData::unloadWorldEntities()
    575648{
     
    580653
    581654/**
    582  *  loads the scene data
    583  * @param root reference to the xml root element
    584  */
     655*  loads the scene data
     656* @param root reference to the xml root element
     657*/
    585658ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root)
    586659{
     
    591664
    592665/**
    593  *  unloads the scene data
    594  */
     666*  unloads the scene data
     667*/
    595668ErrorMessage SimpleGameMenuData::unloadScene()
    596669{
Note: See TracChangeset for help on using the changeset viewer.