Ticket #1882: location-hotkeys.4.patch

File location-hotkeys.4.patch, 9.3 KB (added by alpha123, 11 years ago)

Update manual to list the new hotkeys.

  • source/graphics/GameView.h

     
    8282
    8383    InReaction HandleEvent(const SDL_Event_* ev);
    8484
     85    float GetCameraX();
     86    float GetCameraZ();
    8587    void MoveCameraTarget(const CVector3D& target);
    8688    void ResetCameraTarget(const CVector3D& target);
    8789    void ResetCameraAngleZoom();
  • source/graphics/GameView.cpp

     
    954954    m->ViewCamera.UpdateFrustum();
    955955}
    956956
     957float CGameView::GetCameraX()
     958{
     959    CCamera targetCam = m->ViewCamera;
     960    CVector3D pivot = GetSmoothPivot(targetCam);
     961    return pivot.X;
     962}
     963
     964float CGameView::GetCameraZ()
     965{
     966    CCamera targetCam = m->ViewCamera;
     967    CVector3D pivot = GetSmoothPivot(targetCam);
     968    return pivot.Z;
     969}
     970
    957971void CGameView::MoveCameraTarget(const CVector3D& target)
    958972{
    959973    // Maintain the same orientation and level of zoom, if we can
  • source/gui/scripting/ScriptFunctions.cpp

     
    422428}
    423429
    424430/**
     431 * Get the current X coordinate of the camera.
     432 */
     433float 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 */
     443float CameraGetZ(void* UNUSED(cbdata))
     444{
     445    if (g_Game && g_Game->GetView())
     446        return g_Game->GetView()->GetCameraZ();
     447    return -1;
     448}
     449
     450/**
    425451 * Start / stop camera following mode
    426452 * @param entityid unit id to follow. If zero, stop following mode
    427453 */
     
    660687    scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning");
    661688    scriptInterface.RegisterFunction<CScriptVal, VfsPath, &LoadMapSettings>("LoadMapSettings");
    662689    scriptInterface.RegisterFunction<CScriptVal, &GetMapSettings>("GetMapSettings");
     690    scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX");
     691    scriptInterface.RegisterFunction<float, &CameraGetZ>("CameraGetZ");
    663692    scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow");
    664693    scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS");
    665694    scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, &CameraMoveTo>("CameraMoveTo");
  • binaries/data/config/default.cfg

     
    151151view.height.smoothness = 0.5
    152152view.height.min = 16
    153153
     154; How close do we have to be to the actual location in order to jump back to the previous one?
     155camerajump.threshold = 40
     156
    154157; HOTKEY MAPPINGS:
    155158
    156159; Each one of the specified keys will trigger the action on the left
     
    194197hotkey.camera.rotate.speed.decrease = "Ctrl+Alt+R"          ; Decrease rotation speed
    195198hotkey.camera.zoom.speed.increase = "Ctrl+Shift+Z"          ; Increase zoom speed
    196199hotkey.camera.zoom.speed.decrease = "Ctrl+Alt+Z"            ; Decrease zoom speed
     200hotkey.camera.jump.1 = F5                                   ; Jump to position N
     201hotkey.camera.jump.2 = F6
     202hotkey.camera.jump.3 = F7
     203hotkey.camera.jump.4 = F8
     204;hotkey.camera.jump.5 =
     205;hotkey.camera.jump.6 =
     206;hotkey.camera.jump.7 =
     207;hotkey.camera.jump.8 =
     208;hotkey.camera.jump.9 =
     209;hotkey.camera.jump.10 =
     210hotkey.camera.jump.set.1 = "Ctrl+F5"                        ; Set jump position N
     211hotkey.camera.jump.set.2 = "Ctrl+F6"
     212hotkey.camera.jump.set.3 = "Ctrl+F7"
     213hotkey.camera.jump.set.4 = "Ctrl+F8"
     214;hotkey.camera.jump.set.5 =
     215;hotkey.camera.jump.set.6 =
     216;hotkey.camera.jump.set.7 =
     217;hotkey.camera.jump.set.8 =
     218;hotkey.camera.jump.set.9 =
     219;hotkey.camera.jump.set.10 =
    197220
    198221; > CONSOLE SETTINGS
    199222hotkey.console.toggle = BackQuote, F9       ; Open/close console
  • binaries/data/mods/public/gui/session/session.xml

     
    9696    <object hotkey="camera.follow">
    9797        <action on="Press">setCameraFollow(g_Selection.toList()[0]);</action>
    9898    </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>
    99180   
    100181    <!-- queue first unit in the training queue  -->
    101182    <object hotkey="session.queueunit.1">
  • binaries/data/mods/public/gui/session/input.js

     
    14911491    Engine.PostNetworkCommand({"type": "barter", "sell": command.sell, "buy": command.buy, "amount": command.amount});
    14921492}
    14931493
     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.
     1497var jumpCameraPositions = [], jumpCameraLast;
     1498
     1499function 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
     1516function setJumpCamera(index)
     1517{
     1518    jumpCameraPositions[index] = {x: Engine.CameraGetX(), z: Engine.CameraGetZ()};
     1519}
     1520
    14941521// Batch training:
    14951522// When the user shift-clicks, we set these variables and switch to INPUT_BATCHTRAINING
    14961523// When the user releases shift, or clicks on a different training button, we create the batched units
  • binaries/data/mods/public/gui/manual/intro.txt

     
    6565Ctrl + 1 (and so on up to Ctrl + 0): Create control group 1 (to 0) from the selected units/buildings
    66661 (and so on up to 0): Select the units/buildings in control group 1 (to 0)
    6767Shift + 1 (to 0): Add selected units/buildings to control group 1 (to 0)
     68Ctrl + F5 (and so on up to F8): Mark the current camera position, for jumping back to later.
     69F5, F6, F7, and F8: Move the camera to a marked position. Jump back to the last location if the camera is already over the marked position.
    6870Z, X, C, V, B, N, M: With training buildings selected. Add the 1st, 2nd, ... unit shown to the training queue for all the selected buildings.
    6971
    7072[font="serif-bold-14"]Modify mouse action