- Timestamp:
- Jul 3, 2006, 11:04:51 PM (18 years ago)
- Location:
- branches/presentation/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/lib/network/player_stats.cc
r8708 r9072 238 238 } 239 239 240 241 242 ScoreList PlayerStats::getScoreList( ) 243 { 244 ScoreList result; 245 246 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 247 248 if ( !list ) 249 { 250 return result; 251 } 252 253 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 254 { 255 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 256 257 TeamScoreList::iterator it = result[stats.getTeamId()].begin(); 258 259 while ( it != result[stats.getTeamId()].end() && stats.score > it->score ) 260 { 261 it++; 262 } 263 264 PlayerScore score; 265 score.name = stats.getNickName(); 266 score.score = stats.getScore(); 267 268 result[stats.getTeamId()].insert(it, score); 269 } 270 271 return result; 272 } -
branches/presentation/src/lib/network/player_stats.h
r8623 r9072 20 20 TEAM_SPECTATOR = -1 21 21 }; 22 23 struct PlayerScore 24 { 25 std::string name; 26 int score; 27 }; 28 typedef std::list<PlayerScore> TeamScoreList; 29 typedef std::map<int,TeamScoreList> ScoreList; 22 30 23 31 //! A class for storing player information … … 62 70 63 71 static void deleteAllPlayerStats(); 72 73 static ScoreList getScoreList(); 64 74 65 75 private: -
branches/presentation/src/util/multiplayer_team_deathmatch.cc
r9068 r9072 541 541 this->hideStats(); 542 542 } 543 if ( !this->statsBox && event.bPressed )543 else if ( !this->statsBox && event.bPressed ) 544 544 { 545 545 PRINTF(0)("show stats\n"); … … 616 616 { 617 617 statsBox = new OrxGui::GLGuiBox(); 618 statsBox->setAbsCoor2D( 300, 100 );619 620 this->table = new OrxGui::GLGuiTable( 5,5);618 statsBox->setAbsCoor2D( 100, 100 ); 619 620 this->table = new OrxGui::GLGuiTable(10,5); 621 621 622 622 statsBox->pack( this->table ); … … 646 646 647 647 std::vector<std::string> headers; 648 headers.push_back("Blue Team"); 649 headers.push_back(""); 650 headers.push_back(""); 648 651 headers.push_back("Red Team"); 649 652 headers.push_back(""); 650 headers.push_back("");651 headers.push_back("Blue Team");652 headers.push_back("");653 653 this->table->setHeader(headers); 654 654 655 std::map<int,std::string> fragsTeam0; 656 std::map<int,std::string> fragsTeam1; 657 658 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 659 660 if ( !list ) 661 return; 662 663 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 664 { 665 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 666 667 if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 ) 668 { 669 if ( stats.getTeamId() == 0 ) 670 fragsTeam0[stats.getScore()] = stats.getNickName(); 671 else 672 fragsTeam1[stats.getScore()] = stats.getNickName(); 673 } 674 } 655 ScoreList scoreList = PlayerStats::getScoreList(); 675 656 676 657 char st[10]; 677 658 int i = 0; 678 679 659 680 660 i = 2; 681 for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ )682 { 683 this->table->setEntry( 0, i, it->second);684 snprintf( st, 10, "%d", it-> first);685 this->table->setEntry( 1, i, st );686 this->table->setEntry( 2, i, "" );661 for ( TeamScoreList::const_iterator it = scoreList[0].begin(); it != scoreList[0].end(); it++ ) 662 { 663 this->table->setEntry( i, 0, it->name ); 664 snprintf( st, 10, "%d", it->score ); 665 this->table->setEntry( i, 1, st ); 666 this->table->setEntry( i, 2, "" ); 687 667 i++; 688 668 } 689 669 690 670 i = 2; 691 for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ )692 { 693 this->table->setEntry( 3, i, it->second);694 snprintf( st, 10, "%d", it-> first);695 this->table->setEntry( 4, i, st );671 for ( TeamScoreList::const_iterator it = scoreList[1].begin(); it != scoreList[1].end(); it++ ) 672 { 673 this->table->setEntry( i, 3, it->name ); 674 snprintf( st, 10, "%d", it->score ); 675 this->table->setEntry( i, 4, st ); 696 676 i++; 697 677 } 678 698 679 } 699 680
Note: See TracChangeset
for help on using the changeset viewer.