Changeset 11005
- Timestamp:
- Dec 30, 2015, 10:31:43 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/modules/overlays/OverlayText.cc
r10999 r11005 111 111 void OverlayText::sizeChanged() 112 112 { 113 if (this->rotState_ == Horizontal)113 if (this->rotState_ == RotationState::Horizontal) 114 114 this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y); 115 else if (this->rotState_ == Vertical)115 else if (this->rotState_ == RotationState::Vertical) 116 116 this->overlay_->setScale(size_.y / (sizeCorrection_.y * sizeCorrection_.y), size_.y * sizeCorrection_.y); 117 117 else -
code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.h
r10817 r11005 45 45 namespace orxonox 46 46 { 47 namespace PlayerState 48 { 49 enum Value 50 { 51 Uninitialized, 52 Joined, 53 Alive, 54 Dead 55 }; 56 } 47 enum class PlayerState 48 { 49 Uninitialized, 50 Joined, 51 Alive, 52 Dead 53 }; 57 54 58 55 struct Player 59 56 { 60 57 PlayerInfo* info_; 61 PlayerState ::Valuestate_;58 PlayerState state_; 62 59 int frags_; 63 60 int killed_; -
code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc
r10919 r11005 124 124 this->state_ = 0; 125 125 if (this->getShip()->isBoosting() && forward) 126 this->state_ = Boost;126 this->state_ = EngineState::Boost; 127 127 else if (forward && !this->state_) // this->state_ == Boost 128 this->state_ = Normal;128 this->state_ = EngineState::Normal; 129 129 else if (direction.z > 0.0 && velocity.z < 0.0) 130 this->state_ = Brake;130 this->state_ = EngineState::Brake; 131 131 else 132 this->state_ = Idle;133 134 if (this->state_ == Idle && this->getSpeedAdd() > 0)135 this->state_ = Normal;132 this->state_ = EngineState::Idle; 133 134 if (this->state_ == EngineState::Idle && this->getSpeedAdd() > 0) 135 this->state_ = EngineState::Normal; 136 136 } 137 137 … … 141 141 142 142 float pitch = velocity.length(); 143 if (this->state_ & Normal)143 if (this->state_ & EngineState::Normal) 144 144 defEngineSndNormal_->setPitch(clamp(pitch/MAX_VELOCITY_NORMAL + 1, 0.5f, 2.0f)); 145 if (this->state_ & Boost)145 if (this->state_ & EngineState::Boost) 146 146 defEngineSndBoost_->setPitch(clamp(pitch/MAX_VELOCITY_BOOST + 1, 0.5f, 2.0f)); 147 147 148 if (changes & Idle)149 { 150 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Idle);148 if (changes & EngineState::Idle) 149 { 150 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Idle); 151 151 lua_setglobal(this->lua_->getInternalLuaState(), "idle"); 152 152 } 153 if (changes & Normal)154 { 155 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Normal);153 if (changes & EngineState::Normal) 154 { 155 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Normal); 156 156 lua_setglobal(this->lua_->getInternalLuaState(), "normal"); 157 if (this->state_ & Normal)157 if (this->state_ & EngineState::Normal) 158 158 defEngineSndNormal_->play(); 159 159 else 160 160 defEngineSndNormal_->stop(); 161 161 } 162 if (changes & Brake)163 { 164 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Brake);162 if (changes & EngineState::Brake) 163 { 164 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Brake); 165 165 lua_setglobal(this->lua_->getInternalLuaState(), "brake"); 166 166 } 167 if (changes & Boost)168 { 169 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Boost);167 if (changes & EngineState::Boost) 168 { 169 lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Boost); 170 170 lua_setglobal(this->lua_->getInternalLuaState(), "boost"); 171 if (this->state_ & Boost)171 if (this->state_ & EngineState::Boost) 172 172 defEngineSndBoost_->play(); 173 173 else -
code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.h
r10817 r11005 41 41 { 42 42 public: 43 enumEngineState43 struct EngineState 44 44 { 45 Idle = 1,46 Normal = 2,47 Brake = 4,48 Boost = 845 static constexpr int Idle = 1; 46 static constexpr int Normal = 2; 47 static constexpr int Brake = 4; 48 static constexpr int Boost = 8; 49 49 }; 50 50 -
code/branches/cpp11_v2/src/orxonox/items/PartDestructionEvent.cc
r10262 r11005 98 98 { 99 99 switch (this->targetParam_) { 100 case shieldhealth:100 case TargetParam::shieldhealth: 101 101 this->parent_->getParent()->setShieldHealth(operate(this->parent_->getParent()->getShieldHealth())); 102 102 break; 103 case boostpower:103 case TargetParam::boostpower: 104 104 this->parent_->getParent()->setInitialBoostPower(operate(this->parent_->getParent()->getInitialBoostPower())); 105 105 break; 106 case boostpowerrate:106 case TargetParam::boostpowerrate: 107 107 this->parent_->getParent()->setBoostPowerRate(operate(this->parent_->getParent()->getBoostPowerRate())); 108 108 break; 109 case rotationthrust:109 case TargetParam::rotationthrust: 110 110 this->parent_->getParent()->setRotationThrust(operate(this->parent_->getParent()->getRotationThrust())); 111 111 break; … … 120 120 { 121 121 switch (this->targetParam_) { 122 case null:122 case TargetParam::null: 123 123 this->parent_->getParent()->getEngineByName(targetName_)->destroy(); 124 124 break; 125 case boostfactor:125 case TargetParam::boostfactor: 126 126 this->parent_->getParent()->getEngineByName(targetName_)->setBoostFactor(operate(this->parent_->getParent()->getEngineByName(targetName_)->getBoostFactor())); 127 127 break; 128 case speedfront:128 case TargetParam::speedfront: 129 129 this->parent_->getParent()->getEngineByName(targetName_)->setMaxSpeedFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getMaxSpeedFront())); 130 130 break; 131 case accelerationfront:131 case TargetParam::accelerationfront: 132 132 this->parent_->getParent()->getEngineByName(targetName_)->setAccelerationFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getAccelerationFront())); 133 133 break; … … 142 142 { 143 143 switch (this->targetParam_) { 144 case null:144 case TargetParam::null: 145 145 if (!this->parent_->getParent()->getShipPartByName(targetName_)) 146 146 return; … … 214 214 if (param == "NULL") 215 215 { 216 this->targetParam_ = null;216 this->targetParam_ = TargetParam::null; 217 217 return; 218 218 } 219 219 if (param == "boostfactor") 220 220 { 221 this->targetParam_ = boostfactor;221 this->targetParam_ = TargetParam::boostfactor; 222 222 return; 223 223 } 224 224 if (param == "speedfront") 225 225 { 226 this->targetParam_ = speedfront;226 this->targetParam_ = TargetParam::speedfront; 227 227 return; 228 228 } 229 229 if (param == "accelerationfront") 230 230 { 231 this->targetParam_ = accelerationfront;231 this->targetParam_ = TargetParam::accelerationfront; 232 232 return; 233 233 } … … 244 244 if (param == "shieldhealth") 245 245 { 246 this->targetParam_ = shieldhealth;246 this->targetParam_ = TargetParam::shieldhealth; 247 247 return; 248 248 } 249 249 if (param == "boostpower") 250 250 { 251 this->targetParam_ = boostpower;251 this->targetParam_ = TargetParam::boostpower; 252 252 return; 253 253 } 254 254 if (param == "boostpowerrate") 255 255 { 256 this->targetParam_ = boostpowerrate;256 this->targetParam_ = TargetParam::boostpowerrate; 257 257 return; 258 258 } 259 259 if (param == "rotationthrust") 260 260 { 261 this->targetParam_ = rotationthrust;261 this->targetParam_ = TargetParam::rotationthrust; 262 262 return; 263 263 } … … 271 271 if (param == "NULL") 272 272 { 273 this->targetParam_ = null;273 this->targetParam_ = TargetParam::null; 274 274 return; 275 275 } -
code/branches/cpp11_v2/src/orxonox/items/PartDestructionEvent.h
r10817 r11005 82 82 List of all allowed parameters. 83 83 */ 84 enum TargetParam84 enum class TargetParam 85 85 { 86 86 shieldhealth, -
code/branches/cpp11_v2/src/orxonox/overlays/OrxonoxOverlay.cc
r10768 r11005 94 94 this->angle_ = Degree(0.0); 95 95 this->bCorrectAspect_ = false; 96 this->rotState_ = Horizontal;96 this->rotState_ = RotationState::Horizontal; 97 97 this->angleChanged(); // updates all other values as well 98 98 … … 259 259 { 260 260 tempAspect = 1.0f / this->windowAspectRatio_; 261 rotState_ = Vertical;261 rotState_ = RotationState::Vertical; 262 262 } 263 263 else if (angle > 179 || angle < 1) 264 264 { 265 265 tempAspect = this->windowAspectRatio_; 266 rotState_ = Horizontal;266 rotState_ = RotationState::Horizontal; 267 267 } 268 268 else 269 269 { 270 270 tempAspect = 1.0f; 271 rotState_ = Inbetween;271 rotState_ = RotationState::Inbetween; 272 272 } 273 273 -
code/branches/cpp11_v2/src/orxonox/overlays/OrxonoxOverlay.h
r10845 r11005 79 79 and in between is everything else. 80 80 */ 81 enum RotationState81 enum class RotationState 82 82 { 83 83 Horizontal, -
code/branches/cpp11_v2/src/orxonox/sound/BaseSound.cc
r10765 r11005 49 49 , volume_(0.7) 50 50 , bLooping_(false) 51 , state_(St opped)51 , state_(State::Stopped) 52 52 , pitch_ (1.0) 53 53 { … … 63 63 BaseSound::~BaseSound() 64 64 { 65 if (this->state_ != St opped)65 if (this->state_ != State::Stopped) 66 66 this->stop(); 67 67 // Release buffer … … 83 83 void BaseSound::doPlay() 84 84 { 85 this->state_ = Playing;85 this->state_ = State::Playing; 86 86 if (GameMode::playsSound() && this->getSourceState() != AL_PLAYING && this->soundBuffer_ != nullptr) 87 87 { … … 102 102 bool BaseSound::doStop() 103 103 { 104 this->state_ = St opped;104 this->state_ = State::Stopped; 105 105 if (alIsSource(this->audioSource_)) 106 106 { … … 123 123 if (this->isStopped()) 124 124 return; 125 this->state_ = Paused;125 this->state_ = State::Paused; 126 126 if (alIsSource(this->audioSource_)) 127 127 alSourcePause(this->audioSource_); … … 256 256 else // No source acquired so far, but might be set to playing or paused 257 257 { 258 State state = static_cast<State>(this->state_); // save258 State state = this->state_; // save 259 259 if (this->isPlaying() || this->isPaused()) 260 260 doPlay(); 261 if (state == Paused)262 { 263 this->state_ = Paused;261 if (state == State::Paused) 262 { 263 this->state_ = State::Paused; 264 264 doPause(); 265 265 } … … 271 271 switch (this->state_) 272 272 { 273 case Playing:273 case State::Playing: 274 274 this->play(); 275 275 break; 276 case Paused:276 case State::Paused: 277 277 this->pause(); 278 278 break; 279 case St opped:279 case State::Stopped: 280 280 default: 281 281 this->stop(); -
code/branches/cpp11_v2/src/orxonox/sound/BaseSound.h
r10771 r11005 54 54 virtual void pause() { this->doPause(); } 55 55 56 bool isPlaying() const { return this->state_ == Playing; }57 bool isPaused() const { return this->state_ == Paused; }58 bool isStopped() const { return this->state_ == St opped; }56 bool isPlaying() const { return this->state_ == State::Playing; } 57 bool isPaused() const { return this->state_ == State::Paused; } 58 bool isStopped() const { return this->state_ == State::Stopped; } 59 59 60 60 virtual void setSource(const std::string& source); … … 76 76 77 77 protected: 78 enum State78 enum class State 79 79 { 80 80 Stopped, … … 111 111 float volume_; 112 112 bool bLooping_; 113 uint8_tstate_; // This Variable is actually of type State113 State state_; // This Variable is actually of type State 114 114 float pitch_; 115 115 -
code/branches/cpp11_v2/src/orxonox/sound/WorldSound.cc
r9939 r11005 58 58 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::loopingChanged)); 59 59 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::pitchChanged)); 60 registerVariable( (uint8_t&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::stateChanged));60 registerVariable(BaseSound::state_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::stateChanged)); 61 61 } 62 62 -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.h
r9667 r11005 36 36 namespace orxonox 37 37 { 38 namespaceBaseState38 enum class BaseState 39 39 { 40 enum Value 41 { 42 Uncontrolled, 43 ControlTeam1, 44 ControlTeam2, 45 }; 46 } 40 Uncontrolled, 41 ControlTeam1, 42 ControlTeam2, 43 }; 47 44 48 45 … … 58 55 59 56 // Set the state of a base to whatever the argument of the function is 60 void setState(BaseState ::Valuestate)57 void setState(BaseState state) 61 58 { 62 59 this->state_ = state; … … 66 63 67 64 // Get the state of a base as a return value 68 BaseState ::ValuegetState() const65 BaseState getState() const 69 66 { 70 67 return this->state_; … … 75 72 void changeTeamColour(); 76 73 77 BaseState ::Valuestate_;74 BaseState state_; 78 75 }; 79 76 }
Note: See TracChangeset
for help on using the changeset viewer.