Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 22, 2006, 2:04:28 PM (19 years ago)
Author:
bensch
Message:

merged the gui back

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r8708 r8717  
    6868  this->gameStateTimer = 10.0f;
    6969  this->bShowTeamChange = false;
    70  
     70
    7171  this->box = NULL;
    7272
     
    8080  if( root != NULL)
    8181    this->loadParams(root);
    82  
     82
    8383  subscribeEvent( ES_GAME, SDLK_o );
    8484  subscribeEvent( ES_GAME, SDLK_TAB );
    85  
     85
    8686  this->notifier = new OrxGui::GLGuiNotifier();
    8787  this->notifier->show();
     
    101101  if( this->deathScreen)
    102102    delete this->deathScreen;
    103  
     103
    104104  unsubscribeEvent( ES_GAME, SDLK_o );
    105105  unsubscribeEvent( ES_GAME, SDLK_TAB );
    106  
     106
    107107  if ( this->notifier )
    108108  {
     
    110110    this->notifier = NULL;
    111111  }
    112  
     112
    113113  if ( this->input )
    114114  {
     
    132132  LoadParam(root, "death-screen-image", this, MultiplayerTeamDeathmatch, setDeathScreen)
    133133      .describe("sets the death screen image");
    134  
     134
    135135  LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams)
    136136      .describe("sets number of teams");
     
    179179  if ( SharedNetworkData::getInstance()->getHostID() < 0 )
    180180    return;
    181  
     181
    182182  if ( currentGameState == GAMESTATE_PRE_GAME || currentGameState == GAMESTATE_GAME )
    183183  {
    184184    if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    185185         && box == NULL
    186          &&  (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM 
     186         &&  (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM
    187187         || bShowTeamChange )
    188          
     188
    189189       )
    190190    {
    191191      EventHandler::getInstance()->pushState( ES_MENU );
    192      
     192
    193193      OrxGui::GLGuiHandler::getInstance()->activateCursor();
    194      
     194
    195195      box = new OrxGui::GLGuiBox();
    196196      box->setAbsCoor2D( 300, 100 );
    197      
     197
    198198      OrxGui::GLGuiPushButton * buttonSpectator = new OrxGui::GLGuiPushButton("Spectator");
    199199      box->pack( buttonSpectator );
    200200      buttonSpectator->connect(SIGNAL(buttonSpectator, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonSpectator));
    201      
     201
    202202      OrxGui::GLGuiPushButton * buttonRandom = new OrxGui::GLGuiPushButton("Random");
    203203      box->pack( buttonRandom );
    204204      buttonRandom->connect(SIGNAL(buttonRandom, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonRandom));
    205      
     205
    206206      OrxGui::GLGuiPushButton * buttonTeam0 = new OrxGui::GLGuiPushButton("Blue Team");
    207207      box->pack( buttonTeam0 );
    208208      buttonTeam0->connect(SIGNAL(buttonTeam0, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam0));
    209      
     209
    210210      OrxGui::GLGuiPushButton * buttonTeam1 = new OrxGui::GLGuiPushButton("Red Team");
    211211      box->pack( buttonTeam1 );
    212212      buttonTeam1->connect(SIGNAL(buttonTeam1, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam1));
    213      
     213
    214214      if ( bShowTeamChange )
    215215      {
     
    218218        buttonCancel->connect(SIGNAL(buttonCancel, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonCancel));
    219219      }
    220      
     220
    221221      OrxGui::GLGuiPushButton * buttonExit = new OrxGui::GLGuiPushButton("Exit");
    222222      box->pack( buttonExit );
    223223      buttonExit->connect(SIGNAL(buttonExit, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonExit));
    224      
     224
    225225      box->showAll();
    226226    }
     
    229229  if ( box != NULL
    230230       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    231        && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM 
     231       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM
    232232       && !bShowTeamChange
    233233     )
     
    235235    delete box;
    236236    box = NULL;
    237      
     237
    238238    OrxGui::GLGuiHandler::getInstance()->deactivateCursor( true );
    239      
     239
    240240    EventHandler::getInstance()->popState();
    241241  }
    242  
     242
    243243  if ( box != NULL )
    244244  {
    245245    OrxGui::GLGuiHandler::getInstance()->tick( dt );
    246246  }
    247  
     247
    248248  assignPlayable();
    249  
     249
    250250  if ( !SharedNetworkData::getInstance()->isGameServer() )
    251251    return;
    252  
     252
    253253  gameStateTimer -= dt;
    254254  //PRINTF(0)("TICK %f\n", gameStateTimer);
    255  
     255
    256256  if ( currentGameState != GAMESTATE_GAME && gameStateTimer < 0 )
    257257    nextGameState();
    258  
     258
    259259  this->currentGameState = NetworkGameManager::getInstance()->getGameState();
    260  
     260
    261261  if ( currentGameState == GAMESTATE_GAME )
    262262  {
    263263    handleTeamChanges();
    264264  }
    265  
     265
    266266  this->calculateTeamScore();
    267  
     267
    268268  this->checkGameRules();
    269269
     
    304304  if ( !SharedNetworkData::getInstance()->isGameServer() )
    305305    return;
    306  
     306
    307307  // check for max killing count
    308308  for ( int i = 0; i<numTeams; i++ )
     
    329329  if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR )
    330330    return CL_SPECTATOR;
    331  
     331
    332332  if ( team == 0 || team == 1 )
    333333    return CL_SPACE_SHIP;
    334  
     334
    335335  assert( false );
    336336}
     
    352352{
    353353  teamScore.clear();
    354  
     354
    355355  for ( int i = 0; i<numTeams; i++ )
    356356    teamScore[i] = 0;
    357  
    358    
     357
     358
    359359  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    360  
     360
    361361  if ( !list )
    362362    return;
    363  
     363
    364364  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    365365  {
     
    380380{
    381381  std::map<int,int> playersInTeam;
    382  
     382
    383383  for ( int i = 0; i<numTeams; i++ )
    384384    playersInTeam[i] = 0;
    385  
     385
    386386  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    387  
     387
    388388  if ( !list )
    389389    return 0;
    390  
     390
    391391  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    392392  {
     
    398398    }
    399399  }
    400  
    401  
     400
     401
    402402  int minPlayers = 0xFFFF;
    403403  int minTeam = -1;
    404  
     404
    405405  for ( int i = 0; i<numTeams; i++ )
    406406  {
     
    411411    }
    412412  }
    413  
     413
    414414  assert( minTeam != -1 );
    415  
     415
    416416  return minTeam;
    417417}
     
    422422  {
    423423    NetworkGameManager::getInstance()->setGameState( GAMESTATE_GAME );
    424    
    425     return;
    426   }
    427  
     424
     425    return;
     426  }
     427
    428428  if ( currentGameState == GAMESTATE_GAME )
    429429  {
    430430    NetworkGameManager::getInstance()->setGameState( GAMESTATE_POST_GAME );
    431    
    432     return;
    433   }
    434  
     431
     432    return;
     433  }
     434
    435435  if ( currentGameState == GAMESTATE_POST_GAME )
    436436  {
    437437    //TODO end game
    438    
     438
    439439    return;
    440440  }
     
    444444{
    445445  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    446  
     446
    447447  if ( !list )
    448448    return;
    449  
     449
    450450  //first server players with choices
    451451  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     
    461461    }
    462462  }
    463  
     463
    464464  //now serve player who want join a random team
    465465  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     
    482482  assert( PlayerStats::getStats( userId ) );
    483483  PlayerStats & stats = *(PlayerStats::getStats( userId ));
    484  
     484
    485485  stats.setTeamId( stats.getPreferedTeamId() );
    486  
     486
    487487  Playable * oldPlayable = stats.getPlayable();
    488  
    489  
     488
     489
    490490  ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );
    491491  std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
    492  
     492
    493493  BaseObject * bo = Factory::fabricate( playableClassId );
    494  
     494
    495495  assert( bo != NULL );
    496496  assert( bo->isA( CL_PLAYABLE ) );
    497  
     497
    498498  Playable & playable = *(dynamic_cast<Playable*>(bo));
    499  
     499
    500500  playable.loadModel( playableModel );
    501501  playable.setOwner( userId );
    502502  playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    503503  playable.setSynchronized( true );
    504  
     504
    505505  stats.setTeamId( stats.getPreferedTeamId() );
    506506  stats.setPlayableClassId( playableClassId );
    507507  stats.setPlayableUniqueId( playable.getUniqueID() );
    508508  stats.setModelFileName( playableModel );
    509  
     509
    510510  if ( oldPlayable )
    511511  {
     
    572572      OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
    573573      input->show();
    574       input->giveFocus();
     574      input->giveMouseFocus();
    575575      input->setText("say ");
    576576    }
     
    594594{
    595595  std::string name = "unknown";
    596  
     596
    597597  if ( PlayerStats::getStats( userId ) )
    598598  {
    599599    name = PlayerStats::getStats( userId )->getNickName();
    600600  }
    601  
     601
    602602  PRINTF(0)("CHATMESSAGE %s (%d): %s\n", name.c_str(), userId, message.c_str() );
    603603  notifier->pushNotifyMessage(name + ": " + message);
     
    607607{
    608608  EventHandler::getInstance()->popState();
    609   input->breakFocus();
     609  input->breakMouseFocus();
    610610  input->hide();
    611611  input->setText("");
    612612
    613613  std::string command = text;
    614  
     614
    615615  //HACK insert " in say commands so user doesn't have to type them
    616616  if ( command.length() >= 4 && command[0] == 's' && command[1] == 'a' && command[2] == 'y' && command[3] == ' ' )
Note: See TracChangeset for help on using the changeset viewer.