Ticket #1882: location-hotkeys.3.patch
File location-hotkeys.3.patch, 9.3 KB (added by , 11 years ago) |
---|
-
source/graphics/GameView.h
82 82 83 83 InReaction HandleEvent(const SDL_Event_* ev); 84 84 85 float GetCameraX(); 86 float GetCameraZ(); 85 87 void MoveCameraTarget(const CVector3D& target); 86 88 void ResetCameraTarget(const CVector3D& target); 87 89 void ResetCameraAngleZoom(); -
source/graphics/GameView.cpp
954 954 m->ViewCamera.UpdateFrustum(); 955 955 } 956 956 957 float CGameView::GetCameraX() 958 { 959 CCamera targetCam = m->ViewCamera; 960 CVector3D pivot = GetSmoothPivot(targetCam); 961 return pivot.X; 962 } 963 964 float CGameView::GetCameraZ() 965 { 966 CCamera targetCam = m->ViewCamera; 967 CVector3D pivot = GetSmoothPivot(targetCam); 968 return pivot.Z; 969 } 970 957 971 void CGameView::MoveCameraTarget(const CVector3D& target) 958 972 { 959 973 // Maintain the same orientation and level of zoom, if we can -
source/gui/scripting/ScriptFunctions.cpp
422 428 } 423 429 424 430 /** 431 * Get the current X coordinate of the camera. 432 */ 433 float CameraGetX(void* UNUSED(cbdata)) 434 { 435 if (g_Game && g_Game->GetView()) 436 return g_Game->GetView()->GetCameraX(); 437 return -1; 438 } 439 440 /** 441 * Get the current Z coordinate of the camera. 442 */ 443 float CameraGetZ(void* UNUSED(cbdata)) 444 { 445 if (g_Game && g_Game->GetView()) 446 return g_Game->GetView()->GetCameraZ(); 447 return -1; 448 } 449 450 /** 425 451 * Start / stop camera following mode 426 452 * @param entityid unit id to follow. If zero, stop following mode 427 453 */ … … 660 687 scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning"); 661 688 scriptInterface.RegisterFunction<CScriptVal, VfsPath, &LoadMapSettings>("LoadMapSettings"); 662 689 scriptInterface.RegisterFunction<CScriptVal, &GetMapSettings>("GetMapSettings"); 690 scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX"); 691 scriptInterface.RegisterFunction<float, &CameraGetZ>("CameraGetZ"); 663 692 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow"); 664 693 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS"); 665 694 scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, &CameraMoveTo>("CameraMoveTo"); -
binaries/data/config/default.cfg
151 151 view.height.smoothness = 0.5 152 152 view.height.min = 16 153 153 154 ; How close do we have to be to the actual location in order to jump back to the previous one? 155 camerajump.threshold = 40 156 154 157 ; HOTKEY MAPPINGS: 155 158 156 159 ; Each one of the specified keys will trigger the action on the left … … 194 197 hotkey.camera.rotate.speed.decrease = "Ctrl+Alt+R" ; Decrease rotation speed 195 198 hotkey.camera.zoom.speed.increase = "Ctrl+Shift+Z" ; Increase zoom speed 196 199 hotkey.camera.zoom.speed.decrease = "Ctrl+Alt+Z" ; Decrease zoom speed 200 hotkey.camera.jump.1 = U ; Jump to position 1 201 hotkey.camera.jump.2 = I ; Jump to position 2 202 hotkey.camera.jump.3 = O ; Jump to position 3 203 hotkey.camera.jump.4 = P ; Jump to position 4 204 ;hotkey.camera.jump.5 = ; Jump to position 5 205 ;hotkey.camera.jump.6 = ; Jump to position 6 206 ;hotkey.camera.jump.7 = ; Jump to position 7 207 ;hotkey.camera.jump.8 = ; Jump to position 8 208 ;hotkey.camera.jump.9 = ; Jump to position 9 209 ;hotkey.camera.jump.10 = ; Jump to position 10 210 hotkey.camera.jump.set.1 = "Ctrl+U" ; Set jump position 1 211 hotkey.camera.jump.set.2 = "Ctrl+I" ; Set jump position 2 212 hotkey.camera.jump.set.3 = "Ctrl+O" ; Set jump position 3 213 hotkey.camera.jump.set.4 = "Ctrl+P" ; Set jump position 4 214 ;hotkey.camera.jump.set.5 = ; Set jump position 5 215 ;hotkey.camera.jump.set.6 = ; Set jump position 6 216 ;hotkey.camera.jump.set.7 = ; Set jump position 7 217 ;hotkey.camera.jump.set.8 = ; Set jump position 8 218 ;hotkey.camera.jump.set.9 = ; Set jump position 9 219 ;hotkey.camera.jump.set.10 = ; Set jump position 10 197 220 198 221 ; > CONSOLE SETTINGS 199 222 hotkey.console.toggle = BackQuote, F9 ; Open/close console -
binaries/data/mods/public/gui/session/session.xml
96 96 <object hotkey="camera.follow"> 97 97 <action on="Press">setCameraFollow(g_Selection.toList()[0]);</action> 98 98 </object> 99 100 <!-- Camera jumping - press a hotkey to mark a position and another hotkey to jump back there --> 101 <object hotkey="camera.jump.1"> 102 <action on="Press">jumpCamera(1);</action> 103 </object> 104 105 <object hotkey="camera.jump.2"> 106 <action on="Press">jumpCamera(2);</action> 107 </object> 108 109 <object hotkey="camera.jump.3"> 110 <action on="Press">jumpCamera(3);</action> 111 </object> 112 113 <object hotkey="camera.jump.4"> 114 <action on="Press">jumpCamera(4);</action> 115 </object> 116 117 <object hotkey="camera.jump.5"> 118 <action on="Press">jumpCamera(5);</action> 119 </object> 120 121 <object hotkey="camera.jump.6"> 122 <action on="Press">jumpCamera(6);</action> 123 </object> 124 125 <object hotkey="camera.jump.7"> 126 <action on="Press">jumpCamera(7);</action> 127 </object> 128 129 <object hotkey="camera.jump.8"> 130 <action on="Press">jumpCamera(8);</action> 131 </object> 132 133 <object hotkey="camera.jump.9"> 134 <action on="Press">jumpCamera(9);</action> 135 </object> 136 137 <object hotkey="camera.jump.10"> 138 <action on="Press">jumpCamera(10);</action> 139 </object> 140 141 <object hotkey="camera.jump.set.1"> 142 <action on="Press">setJumpCamera(1);</action> 143 </object> 144 145 <object hotkey="camera.jump.set.2"> 146 <action on="Press">setJumpCamera(2);</action> 147 </object> 148 149 <object hotkey="camera.jump.set.3"> 150 <action on="Press">setJumpCamera(3);</action> 151 </object> 152 153 <object hotkey="camera.jump.set.4"> 154 <action on="Press">setJumpCamera(4);</action> 155 </object> 156 157 <object hotkey="camera.jump.set.5"> 158 <action on="Press">setJumpCamera(5);</action> 159 </object> 160 161 <object hotkey="camera.jump.set.6"> 162 <action on="Press">setJumpCamera(6);</action> 163 </object> 164 165 <object hotkey="camera.jump.set.7"> 166 <action on="Press">setJumpCamera(7);</action> 167 </object> 168 169 <object hotkey="camera.jump.set.8"> 170 <action on="Press">setJumpCamera(8);</action> 171 </object> 172 173 <object hotkey="camera.jump.set.9"> 174 <action on="Press">setJumpCamera(9);</action> 175 </object> 176 177 <object hotkey="camera.jump.set.10"> 178 <action on="Press">setJumpCamera(10);</action> 179 </object> 99 180 100 181 <!-- queue first unit in the training queue --> 101 182 <object hotkey="session.queueunit.1"> -
binaries/data/mods/public/gui/session/input.js
1491 1491 Engine.PostNetworkCommand({"type": "barter", "sell": command.sell, "buy": command.buy, "amount": command.amount}); 1492 1492 } 1493 1493 1494 // Camera jumping: when the user presses a hotkey the current camera location is marked. 1495 // When they press another hotkey the camera jumps back to that position. If the camera is already roughly at that location, 1496 // jump back to where it was previously. 1497 var jumpCameraPositions = [], jumpCameraLast; 1498 1499 function jumpCamera(index) 1500 { 1501 var position = jumpCameraPositions[index], distanceThreshold = g_ConfigDB.system["camerajump.threshold"]; 1502 if (position) 1503 { 1504 if (jumpCameraLast && 1505 Math.abs(Engine.CameraGetX() - position.x) < distanceThreshold && 1506 Math.abs(Engine.CameraGetZ() - position.z) < distanceThreshold) 1507 Engine.CameraMoveTo(jumpCameraLast.x, jumpCameraLast.z); 1508 else 1509 { 1510 jumpCameraLast = {x: Engine.CameraGetX(), z: Engine.CameraGetZ()}; 1511 Engine.CameraMoveTo(position.x, position.z); 1512 } 1513 } 1514 } 1515 1516 function setJumpCamera(index) 1517 { 1518 jumpCameraPositions[index] = {x: Engine.CameraGetX(), z: Engine.CameraGetZ()}; 1519 } 1520 1494 1521 // Batch training: 1495 1522 // When the user shift-clicks, we set these variables and switch to INPUT_BATCHTRAINING 1496 1523 // When the user releases shift, or clicks on a different training button, we create the batched units