Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9059 in orxonox.OLD for trunk/src/story_entities/menu


Ignore:
Timestamp:
Jul 3, 2006, 6:30:42 PM (18 years ago)
Author:
patrick
Message:

merged the network branche with the trunk

Location:
trunk/src/story_entities/menu
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/menu/game_menu.cc

    r9015 r9059  
    3636#include "glgui.h"
    3737#include "menu/glgui_imagebutton.h"
     38
     39#include "glgui_text.h"
     40
     41#include "network_manager.h"
    3842
    3943//! This creates a Factory to fabricate a GameMenu
     
    122126  this->levelsBox = NULL;
    123127  this->networkBox = NULL;
     128 
     129  this->clientNetworkBox = NULL;
     130  this->serverNetworkBox = NULL;
    124131
    125132  this->optionsBox = NULL;
     
    233240      OrxGui::GLGuiButton* clientButton = new OrxGui::GLGuiPushButton("Client");
    234241      networkBox->pack(clientButton);
     242      clientButton->connect(SIGNAL(clientButton, released), this, SLOT(GameMenu, showClientMenu));
    235243
    236244      OrxGui::GLGuiButton* serverButton = new OrxGui::GLGuiPushButton("Server");
    237245      networkBox->pack(serverButton);
     246      serverButton->connect(SIGNAL(serverButton, released), this, SLOT(GameMenu, showServerMenu));
    238247
    239248
     
    495504}
    496505
    497 
    498 
     506/**
     507 * show controls to join network game
     508 */
     509void GameMenu::showClientMenu( )
     510{
     511  if ( this->serverNetworkBox )
     512  {
     513    delete this->serverNetworkBox;
     514    this->serverNetworkBox = NULL;
     515  }
     516 
     517  if ( !this->clientNetworkBox )
     518  {
     519    this->clientNetworkBox = new OrxGui::GLGuiBox();
     520    {
     521      OrxGui::GLGuiText * text = new OrxGui::GLGuiText();
     522      text->setText( "Host:" );
     523      this->clientNetworkBox->pack( text );
     524     
     525      this->ipInputLine = new OrxGui::GLGuiInputLine( );
     526      this->ipInputLine->setText( "tardis-d08" );
     527      this->clientNetworkBox->pack( this->ipInputLine );
     528      this->ipInputLine->connect(SIGNAL(ipInputLine, enterPushed), this, SLOT(GameMenu, connectToServer));
     529      this->ipInputLine->select();
     530     
     531      OrxGui::GLGuiButton* connectButton = new OrxGui::GLGuiPushButton("Connect");
     532      clientNetworkBox->pack(connectButton);
     533      connectButton->connect(SIGNAL(connectButton, released), this, SLOT(GameMenu, connectToServer));
     534    }
     535  }
     536 
     537  this->clientNetworkBox->showAll();
     538 
     539  this->clientNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
     540}
     541
     542/**
     543 * show controls to create new network game
     544 */
     545void GameMenu::showServerMenu( )
     546{
     547  if ( this->clientNetworkBox )
     548  {
     549    delete this->clientNetworkBox;
     550    this->clientNetworkBox = NULL;
     551  }
     552 
     553  if ( !this->serverNetworkBox )
     554  {
     555    this->serverNetworkBox = new OrxGui::GLGuiBox();
     556    {
     557      OrxGui::GLGuiText * text = new OrxGui::GLGuiText();
     558      text->setText( "Map:" );
     559      this->serverNetworkBox->pack( text );
     560     
     561      OrxGui::GLGuiText * text2 = new OrxGui::GLGuiText();
     562      text2->setText( "Multiplayer TeamDeathMatch Arena" );
     563      this->serverNetworkBox->pack( text2 );
     564     
     565      OrxGui::GLGuiButton* createButton = new OrxGui::GLGuiPushButton("Create Server");
     566      serverNetworkBox->pack(createButton);
     567      createButton->connect(SIGNAL(createButton, released), this, SLOT(GameMenu, createServer));
     568    }
     569  }
     570 
     571  this->serverNetworkBox->showAll();
     572 
     573  this->serverNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
     574}
     575
     576/**
     577 * connect to host
     578 */
     579void GameMenu::connectToServer( )
     580{
     581  PRINTF(0)("Connecting to %s\n", this->ipInputLine->_getText().c_str() );
     582 
     583  State::setOnline(true);
     584  NetworkManager::getInstance()->establishConnection( this->ipInputLine->_getText(), 9999 );
     585 
     586  this->startLevel( 5 );
     587}
     588
     589void GameMenu::createServer( )
     590{
     591  PRINTF(0)("Create server\n" );
     592 
     593  State::setOnline(true);
     594  NetworkManager::getInstance()->createServer( 9999 );
     595 
     596  this->startLevel( 5 );
     597}
     598
     599
     600
  • trunk/src/story_entities/menu/game_menu.h

    r8717 r9059  
    4545    void showMultiPlayer();
    4646    void showOptionsMenu();
     47   
     48    void showClientMenu();
     49    void connectToServer();
     50   
     51    void showServerMenu();
     52    void createServer();
    4753
    4854
     
    6369    void setSelectorSound(const std::string& selectorSound);
    6470
     71   
     72
    6573
    6674  private:
     
    6876    OrxGui::GLGuiBox*                 levelsBox;
    6977    OrxGui::GLGuiBox*                 networkBox;
     78   
     79    OrxGui::GLGuiBox*                 clientNetworkBox;
     80    OrxGui::GLGuiInputLine*           ipInputLine;
     81   
     82    OrxGui::GLGuiBox*                 serverNetworkBox;
    7083
    7184    OrxGui::GLGuiBox*                 optionsBox;
Note: See TracChangeset for help on using the changeset viewer.