Ticket #3676: t3676.4.patch

File t3676.4.patch, 6.4 KB (added by Sergey Kushnirenko, 8 years ago)
  • binaries/data/mods/public/gui/session/menu.js

     
    214214    Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input
    215215    Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus
    216216    Engine.GetGUIObjectByName("chatDialogPanel").hidden = true;
     217    Engine.CameraSetOption("hotkeysEnabled", "true" );
    217218}
    218219
    219220/**
     
    256257    }
    257258
    258259    chatWindow.hidden = !hidden;
     260    Engine.CameraSetOption("hotkeysEnabled", chatWindow.hidden ? "true" : "false");
    259261}
    260262
    261263function setDiplomacy(data)
  • source/graphics/GameView.cpp

     
    292292    float ViewFOV;
    293293    float ViewNear;
    294294    float ViewFar;
     295    bool hotkeysEnabled = false;
    295296    int JoystickPanX;
    296297    int JoystickPanY;
    297298    int JoystickRotateX;
     
    640641    mouse_last_x = g_mouse_x;
    641642    mouse_last_y = g_mouse_y;
    642643
    643     if (HotkeyIsPressed("camera.rotate.cw"))
    644         m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime);
    645     if (HotkeyIsPressed("camera.rotate.ccw"))
    646         m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime);
    647     if (HotkeyIsPressed("camera.rotate.up"))
    648         m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime);
    649     if (HotkeyIsPressed("camera.rotate.down"))
    650         m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime);
     644    if (m->hotkeysEnabled)
     645    {
     646        if (HotkeyIsPressed("camera.rotate.cw"))
     647            m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime);
     648        if (HotkeyIsPressed("camera.rotate.ccw"))
     649            m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime);
     650        if (HotkeyIsPressed("camera.rotate.up"))
     651            m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime);
     652        if (HotkeyIsPressed("camera.rotate.down"))
     653            m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime);
     654    }
    651655
    652656    float moveRightward = 0.f;
    653657    float moveForward = 0.f;
    654658
    655     if (HotkeyIsPressed("camera.pan"))
     659    if (HotkeyIsPressed("camera.pan") && m->hotkeysEnabled)
    656660    {
    657661        moveRightward += m->ViewDragSpeed * mouse_dx;
    658662        moveForward += m->ViewDragSpeed * -mouse_dy;
     
    671675            moveForward += m->ViewScrollSpeed * deltaRealTime;
    672676    }
    673677
    674     if (HotkeyIsPressed("camera.right"))
    675         moveRightward += m->ViewScrollSpeed * deltaRealTime;
    676     if (HotkeyIsPressed("camera.left"))
    677         moveRightward -= m->ViewScrollSpeed * deltaRealTime;
    678     if (HotkeyIsPressed("camera.up"))
    679         moveForward += m->ViewScrollSpeed * deltaRealTime;
    680     if (HotkeyIsPressed("camera.down"))
    681         moveForward -= m->ViewScrollSpeed * deltaRealTime;
     678    if (m->hotkeysEnabled)
     679    {
     680        if (HotkeyIsPressed("camera.right"))
     681            moveRightward += m->ViewScrollSpeed * deltaRealTime;
     682        if (HotkeyIsPressed("camera.left"))
     683            moveRightward -= m->ViewScrollSpeed * deltaRealTime;
     684        if (HotkeyIsPressed("camera.up"))
     685            moveForward += m->ViewScrollSpeed * deltaRealTime;
     686        if (HotkeyIsPressed("camera.down"))
     687            moveForward -= m->ViewScrollSpeed * deltaRealTime;
     688    }
    682689
    683690    if (g_Joystick.IsEnabled())
    684691    {
     
    754761        }
    755762    }
    756763
    757     if (HotkeyIsPressed("camera.zoom.in"))
    758         m->Zoom.AddSmoothly(-m->ViewZoomSpeed * deltaRealTime);
    759     if (HotkeyIsPressed("camera.zoom.out"))
    760         m->Zoom.AddSmoothly(m->ViewZoomSpeed * deltaRealTime);
     764    if (m->hotkeysEnabled)
     765    {
     766        if (HotkeyIsPressed("camera.zoom.in"))
     767            m->Zoom.AddSmoothly(-m->ViewZoomSpeed * deltaRealTime);
     768        if (HotkeyIsPressed("camera.zoom.out"))
     769            m->Zoom.AddSmoothly(m->ViewZoomSpeed * deltaRealTime);
     770    }
    761771
    762772    if (m->ConstrainCamera)
    763773        m->Zoom.ClampSmoothly(m->ViewZoomMin, m->ViewZoomMax);
     
    893903    m->ViewCamera.UpdateFrustum();
    894904}
    895905
     906std::wstring CGameView::GetCameraOption(const std::wstring& optionName)
     907{
     908    if (L"hotkeysEnabled" == optionName)
     909        return m->hotkeysEnabled ? L"true" : L"false";
     910
     911    return L"";
     912}
     913
     914void CGameView::SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue)
     915{
     916    if (L"hotkeysEnabled" == optionName)
     917        m->hotkeysEnabled = (optionValue == L"true");
     918}
     919
    896920float CGameView::GetCameraX()
    897921{
    898922    CCamera targetCam = m->ViewCamera;
  • source/graphics/GameView.h

     
    9090    float GetCameraRotX();
    9191    float GetCameraRotY();
    9292    float GetCameraZoom();
     93    std::wstring GetCameraOption(const std::wstring& optionName);
     94    void SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue);
    9395    void SetCamera(CVector3D Pos, float RotX, float RotY, float Zoom);
    9496    void MoveCameraTarget(const CVector3D& target);
    9597    void ResetCameraTarget(const CVector3D& target);
  • source/gui/scripting/ScriptFunctions.cpp

     
    532532    return -1;
    533533}
    534534
     535std::wstring CameraGetOption(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& optionName)
     536{
     537    if (g_Game && g_Game->GetView())
     538        return g_Game->GetView()->GetCameraOption(optionName);
     539
     540    return wstring_from_utf8("");
     541}
     542
     543void CameraSetOption(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& optionName, const std::wstring& optionValue)
     544{
     545    if (g_Game && g_Game->GetView())
     546        g_Game->GetView()->SetCameraOption(optionName, optionValue);
     547}
     548
    535549/**
    536550 * Get the current Z coordinate of the camera.
    537551 */
     
    10611075    scriptInterface.RegisterFunction<JS::Value, &GetMapSettings>("GetMapSettings");
    10621076    scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX");
    10631077    scriptInterface.RegisterFunction<float, &CameraGetZ>("CameraGetZ");
     1078    scriptInterface.RegisterFunction<std::wstring, std::wstring, &CameraGetOption>("CameraGetOption");
     1079    scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &CameraSetOption>("CameraSetOption");
    10641080    scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow");
    10651081    scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS");
    10661082    scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, &SetCameraData>("SetCameraData");