Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8623 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Jun 20, 2006, 1:39:01 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network branche back here
merged with command:
svn merge -r8230:HEAD https://svn.orxonox.net/orxonox/branches/network .
conflicts resolved in favour of the network branche (conflicts were in network)

Location:
trunk/src/util
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/game_rules.h

    r8362 r8623  
    2020
    2121
    22 class GameRules : public BaseObject
     22class GameRules : virtual public BaseObject
    2323{
    2424
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r8147 r8623  
    6565  this->currentGameState = GAMESTATE_PRE_GAME;
    6666  this->gameStateTimer = 10.0f;
     67  this->bShowTeamChange = false;
    6768 
    6869  this->box = NULL;
     
    7778  if( root != NULL)
    7879    this->loadParams(root);
     80 
     81  subscribeEvent( ES_GAME, SDLK_o );
    7982}
    8083
     
    8689  if( this->deathScreen)
    8790    delete this->deathScreen;
     91 
     92  unsubscribeEvent( ES_GAME, SDLK_o );
    8893}
    8994
     
    150155    return;
    151156 
    152   if ( currentGameState == GAMESTATE_PRE_GAME )
     157  if ( currentGameState == GAMESTATE_PRE_GAME || currentGameState == GAMESTATE_GAME )
    153158  {
    154159    if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    155          && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM
    156160         && box == NULL
     161         &&  (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM
     162         || bShowTeamChange )
     163         
    157164       )
    158165    {
     
    180187      buttonTeam1->connect(SIGNAL(buttonTeam1, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam1));
    181188     
     189      if ( bShowTeamChange )
     190      {
     191        OrxGui::GLGuiPushButton * buttonCancel = new OrxGui::GLGuiPushButton("Cancel");
     192        box->pack( buttonCancel );
     193        buttonCancel->connect(SIGNAL(buttonCancel, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonCancel));
     194      }
     195     
    182196      OrxGui::GLGuiPushButton * buttonExit = new OrxGui::GLGuiPushButton("Exit");
    183197      box->pack( buttonExit );
     
    191205       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    192206       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM
     207       && !bShowTeamChange
    193208     )
    194209  {
     
    479494{
    480495  State::getCurrentStoryEntity()->stop();
     496  this->bShowTeamChange = false;
    481497}
    482498
     
    484500{
    485501  NetworkGameManager::getInstance()->prefereTeam( TEAM_RANDOM );
     502  this->bShowTeamChange = false;
    486503}
    487504
     
    489506{
    490507  NetworkGameManager::getInstance()->prefereTeam( 0 );
     508  this->bShowTeamChange = false;
    491509}
    492510
     
    494512{
    495513  NetworkGameManager::getInstance()->prefereTeam( 1 );
     514  this->bShowTeamChange = false;
    496515}
    497516
     
    499518{
    500519  NetworkGameManager::getInstance()->prefereTeam( TEAM_SPECTATOR );
     520  this->bShowTeamChange = false;
    501521}
    502522
     
    507527}
    508528
    509 
    510 
    511 
    512 
    513 
     529  /**
     530   * function that processes events from the handler
     531   * @param event: the event
     532   * @todo replace SDLK_o with something from KeyMapper
     533   */
     534void MultiplayerTeamDeathmatch::process( const Event & event )
     535{
     536  if ( event.type == SDLK_o )
     537  {
     538    if ( event.bPressed )
     539      this->bShowTeamChange = true;
     540  }
     541}
     542
     543void MultiplayerTeamDeathmatch::onButtonCancel( )
     544{
     545  this->bShowTeamChange = false;
     546}
     547
     548
     549
     550/**
     551 * this method is called by NetworkGameManger when he recieved a chat message
     552 * @param userId senders user id
     553 * @param message message string
     554 * @param messageType some int
     555 */
     556void MultiplayerTeamDeathmatch::handleChatMessage( int userId, const std::string & message, int messageType )
     557{
     558  std::string name = "unknown";
     559 
     560  if ( PlayerStats::getStats( userId ) )
     561  {
     562    name = PlayerStats::getStats( userId )->getNickName();
     563  }
     564 
     565  PRINTF(0)("CHATMESSAGE %s: %s\n", name.c_str(), message.c_str() );
     566}
     567
     568
     569
     570
  • trunk/src/util/multiplayer_team_deathmatch.h

    r8147 r8623  
    1212#include "network_game_rules.h"
    1313
    14 #include "glgui_box.h"
     14#include "glgui.h"
    1515
    1616class TiXmlElement;
     
    2727
    2828
    29 class MultiplayerTeamDeathmatch : public NetworkGameRules
     29class MultiplayerTeamDeathmatch : public NetworkGameRules, public EventListener
    3030{
    3131
     
    5555   
    5656    int getRandomTeam();
     57   
     58    virtual void process(const Event &event);
     59   
     60    virtual void handleChatMessage( int userId, const std::string & message, int messageType );
    5761
    5862  protected:
     
    7478    float              gameStateTimer;             //!< if less than 0 -> change game state
    7579
     80    bool               bShowTeamChange;            //!< if true -> show team change dialog
     81
    7682    OrxGui::GLGuiBox* box;
    77 
    78 
     83   
    7984    void calculateTeamScore();
    8085    void nextGameState();
     
    8792    void onButtonTeam0();
    8893    void onButtonTeam1();
     94    void onButtonCancel();
    8995    void onButtonExit();
    9096};
  • trunk/src/util/network_game_rules.cc

    r8147 r8623  
    1717
    1818#include "network_game_rules.h"
     19
     20#include "network_game_manager.h"
    1921
    2022using namespace std;
     
    5355}
    5456
     57
     58void NetworkGameRules::shellSay( const std::string & message )
     59{
     60  NetworkGameManager::getInstance()->sendChatMessage( message, 0 );
     61}
     62
     63
  • trunk/src/util/network_game_rules.h

    r8147 r8623  
    2525   
    2626    virtual PlayerStats * getNewPlayerStats( int userId ){ return new PlayerStats( userId ); }
     27   
     28    virtual void handleChatMessage( int userId, const std::string & message, int messageType ) = 0;
     29   
     30    void shellSay( const std::string & message );
    2731
    2832
  • trunk/src/util/signal_handler.h

    r8523 r8623  
    1717};
    1818
    19 typedef bool (*SignalCallback)( void * someData );
     19typedef int (*SignalCallback)( void * someData );
    2020
    2121#ifndef __WIN32__
     
    4444  public:
    4545    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
    46      
     46
    4747    void registerCallback( SignalCallback cb, void * someData );
    4848
     
    5555    void catchSignal( int sig );
    5656    SignalRecList sigRecList;
    57    
     57
    5858    SignalCallbackList callbackList;
    5959
Note: See TracChangeset for help on using the changeset viewer.