Changeset 7862
- Timestamp:
- Feb 12, 2011, 11:57:28 AM (14 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/controllers/HumanController.cc
r7533 r7862 40 40 namespace orxonox 41 41 { 42 extern const std::string __CC_fire_name = "fire"; 43 42 44 SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand(); 43 45 SetConsoleCommand("HumanController", "moveRightLeft", &HumanController::moveRightLeft ).addShortcut().setAsInputCommand(); … … 46 48 SetConsoleCommand("HumanController", "rotatePitch", &HumanController::rotatePitch ).addShortcut().setAsInputCommand(); 47 49 SetConsoleCommand("HumanController", "rotateRoll", &HumanController::rotateRoll ).addShortcut().setAsInputCommand(); 48 SetConsoleCommand("HumanController", "fire",&HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold);50 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 49 51 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 50 52 SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().keybindMode(KeybindMode::OnHold); -
code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
r6417 r7862 29 29 #include "Spectator.h" 30 30 31 #include "util/Convert.h" 31 32 #include "core/CoreIncludes.h" 32 33 #include "core/ConfigValueIncludes.h" 33 34 #include "core/GameMode.h" 35 #include "core/command/CommandExecutor.h" 36 #include "core/command/ConsoleCommand.h" 34 37 35 38 #include "tools/BillboardSet.h" … … 39 42 namespace orxonox 40 43 { 44 extern const std::string __CC_fire_name; 45 41 46 CreateFactory(Spectator); 42 47 … … 148 153 } 149 154 155 /** 156 @brief Changes the keybind mode of the fire command to OnPress. 157 */ 150 158 void Spectator::startLocalHumanControl() 151 159 { 152 160 ControllableEntity::startLocalHumanControl(); 161 162 // change keybind mode of fire command to OnPress to avoid firing after respawn 163 ModifyConsoleCommand(__CC_fire_name).keybindMode(KeybindMode::OnPress); 164 } 165 166 /** 167 @brief Changes the keybind mode of the fire command back to OnHold. 168 */ 169 void Spectator::stopLocalHumanControl() 170 { 171 ControllableEntity::stopLocalHumanControl(); 172 173 // change fire command to a helper function and change keybind mode to OnPress 174 // as soon as the player releases and presses the button again, the helper function will be called which changes the keybind mode back to OnHold 175 ModifyConsoleCommand(__CC_fire_name).pushFunction(&Spectator::resetFireCommand).keybindMode(KeybindMode::OnPress); 176 } 177 178 /** 179 @brief Helper function which changes the fire command back to the original function and keybind mode to OnHold. 180 */ 181 void Spectator::resetFireCommand(unsigned int firemode) 182 { 183 ModifyConsoleCommand(__CC_fire_name).popFunction().keybindMode(KeybindMode::OnHold); // pop this helper function and change keybind mode 184 185 CommandExecutor::execute(__CC_fire_name + " " + multi_cast<std::string>(firemode)); // call the fire command again, this time with the real function 153 186 } 154 187 -
code/trunk/src/orxonox/worldentities/pawns/Spectator.h
r7857 r7862 61 61 virtual void setPlayer(PlayerInfo* player); 62 62 virtual void startLocalHumanControl(); 63 virtual void stopLocalHumanControl(); 63 64 64 65 private: … … 66 67 void changedGreeting(); 67 68 void changedFlareVisibility(); 69 70 static void resetFireCommand(unsigned int firemode); 68 71 69 72 BillboardSet* greetingFlare_;
Note: See TracChangeset
for help on using the changeset viewer.