Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7918 in orxonox.OLD for branches/gui/src/story_entities


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

start ext url

Location:
branches/gui/src/story_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/story_entities/simple_game_menu.cc

    r7917 r7918  
    4848
    4949SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root)
    50   : GameWorld()
     50    : GameWorld()
    5151{
    5252  this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu");
     
    6767  ///(this is as modular as it is possible).
    6868  OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME");
     69  pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui));
    6970  pb->show();
    7071  pb->setAbsCoor2D(50, 50);
    7172
    72   OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("DO NOT PUSH ME");
     73  OrxGui::GLGuiHandler::getInstance()->activateCursor();
     74  OrxGui::GLGuiHandler::getInstance()->activate();
     75  /////
     76
     77  if (root != NULL)
     78    this->loadParams(root);
     79
     80  State::setMenuID(this->getNextStoryID());
     81}
     82
     83/// HACK only for testing.
     84void SimpleGameMenu::enterGui()
     85{
     86  ///
     87  OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
    7388  dnpb->show();
    7489  dnpb->setAbsCoor2D(350, 50);
    75 
    76   OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("REALLY DO NOT PUSH ME!!");
     90  dnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::execURL));
     91
     92  OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
    7793  rdnpb->show();
    7894  rdnpb->setAbsCoor2D(200, 180);
     
    84100  input->setAbsCoor2D(200, 230);
    85101
    86   OrxGui::GLGuiHandler::getInstance()->activateCursor();
    87   OrxGui::GLGuiHandler::getInstance()->activate();
     102
    88103  /////
    89 
    90   if (root != NULL)
    91     this->loadParams(root);
    92 
    93   State::setMenuID(this->getNextStoryID());
    94 }
    95 
    96 
    97 /**
    98  *  @brief remove the SimpleGameMenu from memory
    99  *
    100  *  delete everything explicitly, that isn't contained in the parenting tree!
    101  *  things contained in the tree are deleted automaticaly
    102  */
     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*/
    103144SimpleGameMenu::~SimpleGameMenu ()
    104145{
     
    112153
    113154/**
    114  * @brief loads the parameters of a SimpleGameMenu from an XML-element
    115  * @param root the XML-element to load from
    116  */
     155* @brief loads the parameters of a SimpleGameMenu from an XML-element
     156* @param root the XML-element to load from
     157*/
    117158void SimpleGameMenu::loadParams(const TiXmlElement* root)
    118159{
     
    126167
    127168/**
    128  * @brief this is executed just before load
    129  *
    130  * since the load function sometimes needs data, that has been initialized
    131  * before the load and after the proceeding storyentity has finished
    132  */
     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*/
    133174ErrorMessage SimpleGameMenu::init()
    134175{
     
    152193
    153194/**
    154  * @brief load the data
    155  */
     195* @brief load the data
     196*/
    156197ErrorMessage SimpleGameMenu::loadData()
    157198{
     
    172213    {
    173214      element = element->FirstChildElement();
    174     // load Players/Objects/Whatever
     215      // load Players/Objects/Whatever
    175216      PRINTF(4)("Loading Elements\n");
    176217      while( element != NULL)
     
    219260      this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);
    220261      this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,
    221                                                    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));
    222263      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    223264    }
     
    267308
    268309/**
    269  * @brief set the Sound to play when switching menu entry.
    270  * @param selectorSound the sound to load.
    271  */
     310* @brief set the Sound to play when switching menu entry.
     311* @param selectorSound the sound to load.
     312*/
    272313void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)
    273314{
     
    303344
    304345/**
    305  * @brief start the menu
    306  */
     346* @brief start the menu
     347*/
    307348bool SimpleGameMenu::start()
    308349{
     
    316357
    317358/**
    318  * stop the menu
    319  */
     359* stop the menu
     360*/
    320361bool SimpleGameMenu::stop()
    321362{
     
    328369
    329370/**
    330  *  override the standard tick for more functionality
    331  */
     371*  override the standard tick for more functionality
     372*/
    332373void SimpleGameMenu::tick()
    333374{
     
    342383
    343384/**
    344  * @brief no collision detection in the menu
    345  */
     385* @brief no collision detection in the menu
     386*/
    346387void SimpleGameMenu::collide()
    347388{
    348 //   this->dataTank->localCamera->
    349 }
    350 
    351 
    352 /**
    353  * @brief animate the scene
    354  */
     389  //   this->dataTank->localCamera->
     390}
     391
     392
     393/**
     394* @brief animate the scene
     395*/
    355396void SimpleGameMenu::animateScene(float dt)
    356397{
     
    369410
    370411/**
    371  * @brief event dispatcher funciton
    372  * @param event the incoming event
    373  */
     412* @brief event dispatcher funciton
     413* @param event the incoming event
     414*/
    374415void SimpleGameMenu::process(const Event &event)
    375416{
     
    454495
    455496/**
    456  * @brief switches to from one meny layer to an other
    457  * @param layer1 from layer
    458  * @param layer2 to layer
    459  */
     497* @brief switches to from one meny layer to an other
     498* @param layer1 from layer
     499* @param layer2 to layer
     500*/
    460501void SimpleGameMenu::switchMenuLayer(int layer1, int layer2)
    461502{
     
    517558
    518559/**********************************************************************************************
    519     SimpleGameMenuData
    520  **********************************************************************************************/
    521 
    522 
    523 /**
    524  * SimpleGameMenuData constructor
    525  */
     560SimpleGameMenuData
     561**********************************************************************************************/
     562
     563
     564/**
     565* SimpleGameMenuData constructor
     566*/
    526567SimpleGameMenuData::SimpleGameMenuData()
    527568{}
    528569
    529570/**
    530  * SimpleGameMenuData decontructor
    531  */
     571* SimpleGameMenuData decontructor
     572*/
    532573SimpleGameMenuData::~SimpleGameMenuData()
    533574{}
     
    535576
    536577/**
    537  *  initialize the GameWorldDataData
    538  */
     578*  initialize the GameWorldDataData
     579*/
    539580ErrorMessage SimpleGameMenuData::init()
    540581{
     
    545586
    546587/**
    547  *  loads the GUI data
    548  * @param root reference to the xml root element
    549  */
     588*  loads the GUI data
     589* @param root reference to the xml root element
     590*/
    550591ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root)
    551592{
     
    556597
    557598/**
    558  *  unloads the GUI data
    559  */
     599*  unloads the GUI data
     600*/
    560601ErrorMessage SimpleGameMenuData::unloadGUI()
    561602{
     
    566607
    567608/**
    568  *  overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff)
    569  * @param root reference to the xml root parameter
    570  */
     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*/
    571612ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root)
    572613{
     
    577618  if( element != NULL)
    578619  {
    579     element = element->FirstChildElement();
    580     PRINTF(4)("Loading WorldEntities\n");
    581     while(element != NULL)
    582     {
    583       BaseObject* created = Factory::fabricate(element);
    584       if( created != NULL )
    585         printf("Created a %s: %s\n", created->getClassName(), created->getName());
    586 
    587       if( element->Value() == "SkyBox")
    588         this->sky = dynamic_cast<WorldEntity*>(created);
    589       if( element->Value() == "Terrain")
    590         this->terrain = dynamic_cast<Terrain*>(created);
    591       element = element->NextSiblingElement();
    592     }
    593 
    594     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");
    595636  }
    596637
     
    602643
    603644/**
    604  *  unloads the world entities from the xml file
    605  */
     645*  unloads the world entities from the xml file
     646*/
    606647ErrorMessage SimpleGameMenuData::unloadWorldEntities()
    607648{
     
    612653
    613654/**
    614  *  loads the scene data
    615  * @param root reference to the xml root element
    616  */
     655*  loads the scene data
     656* @param root reference to the xml root element
     657*/
    617658ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root)
    618659{
     
    623664
    624665/**
    625  *  unloads the scene data
    626  */
     666*  unloads the scene data
     667*/
    627668ErrorMessage SimpleGameMenuData::unloadScene()
    628669{
  • branches/gui/src/story_entities/simple_game_menu.h

    r7884 r7918  
    4949    virtual ~SimpleGameMenu();
    5050
     51    /// TODO TAKE THIS OUT
     52    void enterGui();
     53    void execURL() const;
     54    static int startURL(void* data);
     55    ///
    5156    virtual void loadParams(const TiXmlElement* root);
    5257
Note: See TracChangeset for help on using the changeset viewer.