Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 15, 2012, 11:51:58 PM (12 years ago)
Author:
jo
Message:

Merging presentation2011 branch to trunk. Please check for possible bugs.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pong/PongScore.cc

    r8108 r9016  
    6060        this->bShowLeftPlayer_ = false;
    6161        this->bShowRightPlayer_ = false;
     62        this->player1_ = NULL;
     63        this->player2_ = NULL;
    6264    }
    6365
     
    98100        if (this->owner_ != NULL)
    99101        {
    100             // Get the two players.
    101             PlayerInfo* player1 = this->owner_->getLeftPlayer();
    102             PlayerInfo* player2 = this->owner_->getRightPlayer();
    103 
    104             std::string name1;
    105             std::string name2;
    106 
    107             std::string score1("0");
    108             std::string score2("0");
    109 
    110             // Save the name and score of each player as a string.
    111             if (player1 != NULL)
     102            if(!this->owner_->hasEnded())
    112103            {
    113                 name1 = player1->getName();
    114                 score1 = multi_cast<std::string>(this->owner_->getScore(player1));
    115             }
    116             if (player2 != NULL)
    117             {
    118                 name2 = player2->getName();
    119                 score2 = multi_cast<std::string>(this->owner_->getScore(player2));
     104                //get the two players
     105                player1_ = this->owner_->getLeftPlayer();
     106                player2_ = this->owner_->getRightPlayer();
    120107            }
    121108
    122             // Assemble the strings, depending on what should all be displayed.
    123             std::string output1;
    124             if (this->bShowLeftPlayer_)
     109            if(this->owner_->hasStarted())
    125110            {
    126                 if (this->bShowName_ && this->bShowScore_ && player1 != NULL)
    127                     output1 = name1 + " - " + score1;
    128                 else if (this->bShowScore_)
    129                     output1 = score1;
    130                 else if (this->bShowName_)
    131                     output1 = name1;
    132             }
     111                // Get the two players.
    133112
    134             std::string output2;
    135             if (this->bShowRightPlayer_)
    136             {
    137                 if (this->bShowName_ && this->bShowScore_ && player2 != NULL)
     113                std::string name1;
     114                std::string name2;
     115
     116                std::string score1("0");
     117                std::string score2("0");
     118
     119                // Save the name and score of each player as a string.
     120                if (player1_ != NULL)
     121                {
     122                    name1 = player1_->getName();
     123                    score1 = multi_cast<std::string>(this->owner_->getScore(player1_));
     124                }
     125                if (player2_ != NULL)
     126                {
     127                    name2 = player2_->getName();
     128                    score2 = multi_cast<std::string>(this->owner_->getScore(player2_));
     129                }
     130
     131                // Assemble the strings, depending on what should all be displayed.
     132                std::string output1;
     133                if (this->bShowLeftPlayer_)
     134                {
     135                    if (this->bShowName_ && this->bShowScore_ && player1_ != NULL)
     136                         output1 = name1 + " - " + score1;
     137                    else if (this->bShowScore_)
     138                         output1 = score1;
     139                    else if (this->bShowName_)
     140                         output1 = name1;
     141                }
     142
     143                std::string output2;
     144                if (this->bShowRightPlayer_)
     145                {
     146                if (this->bShowName_ && this->bShowScore_ && player2_ != NULL)
    138147                    output2 = score2 + " - " + name2;
    139148                else if (this->bShowScore_)
     
    143152            }
    144153
    145             std::string output("PONG");
    146             if (this->bShowName_ || this->bShowScore_)
    147             {
    148                 if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
    149                     output = output1 + ':' + output2;
    150                 else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
    151                     output = output1 + output2;
     154                std::string output("PONG");
     155                if (this->bShowName_ || this->bShowScore_)
     156                {
     157                    if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
     158                        output = output1 + ':' + output2;
     159                    else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
     160                        output = output1 + output2;
     161                }
     162                this->setCaption(output);
    152163            }
    153 
    154             this->setCaption(output);
    155164        }
    156165    }
Note: See TracChangeset for help on using the changeset viewer.