Ticket #3676: t3676.4.patch
File t3676.4.patch, 6.4 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/session/menu.js
214 214 Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input 215 215 Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus 216 216 Engine.GetGUIObjectByName("chatDialogPanel").hidden = true; 217 Engine.CameraSetOption("hotkeysEnabled", "true" ); 217 218 } 218 219 219 220 /** … … 256 257 } 257 258 258 259 chatWindow.hidden = !hidden; 260 Engine.CameraSetOption("hotkeysEnabled", chatWindow.hidden ? "true" : "false"); 259 261 } 260 262 261 263 function setDiplomacy(data) -
source/graphics/GameView.cpp
292 292 float ViewFOV; 293 293 float ViewNear; 294 294 float ViewFar; 295 bool hotkeysEnabled = false; 295 296 int JoystickPanX; 296 297 int JoystickPanY; 297 298 int JoystickRotateX; … … 640 641 mouse_last_x = g_mouse_x; 641 642 mouse_last_y = g_mouse_y; 642 643 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 } 651 655 652 656 float moveRightward = 0.f; 653 657 float moveForward = 0.f; 654 658 655 if (HotkeyIsPressed("camera.pan") )659 if (HotkeyIsPressed("camera.pan") && m->hotkeysEnabled) 656 660 { 657 661 moveRightward += m->ViewDragSpeed * mouse_dx; 658 662 moveForward += m->ViewDragSpeed * -mouse_dy; … … 671 675 moveForward += m->ViewScrollSpeed * deltaRealTime; 672 676 } 673 677 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 } 682 689 683 690 if (g_Joystick.IsEnabled()) 684 691 { … … 754 761 } 755 762 } 756 763 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 } 761 771 762 772 if (m->ConstrainCamera) 763 773 m->Zoom.ClampSmoothly(m->ViewZoomMin, m->ViewZoomMax); … … 893 903 m->ViewCamera.UpdateFrustum(); 894 904 } 895 905 906 std::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 914 void CGameView::SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue) 915 { 916 if (L"hotkeysEnabled" == optionName) 917 m->hotkeysEnabled = (optionValue == L"true"); 918 } 919 896 920 float CGameView::GetCameraX() 897 921 { 898 922 CCamera targetCam = m->ViewCamera; -
source/graphics/GameView.h
90 90 float GetCameraRotX(); 91 91 float GetCameraRotY(); 92 92 float GetCameraZoom(); 93 std::wstring GetCameraOption(const std::wstring& optionName); 94 void SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue); 93 95 void SetCamera(CVector3D Pos, float RotX, float RotY, float Zoom); 94 96 void MoveCameraTarget(const CVector3D& target); 95 97 void ResetCameraTarget(const CVector3D& target); -
source/gui/scripting/ScriptFunctions.cpp
532 532 return -1; 533 533 } 534 534 535 std::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 543 void 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 535 549 /** 536 550 * Get the current Z coordinate of the camera. 537 551 */ … … 1061 1075 scriptInterface.RegisterFunction<JS::Value, &GetMapSettings>("GetMapSettings"); 1062 1076 scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX"); 1063 1077 scriptInterface.RegisterFunction<float, &CameraGetZ>("CameraGetZ"); 1078 scriptInterface.RegisterFunction<std::wstring, std::wstring, &CameraGetOption>("CameraGetOption"); 1079 scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &CameraSetOption>("CameraSetOption"); 1064 1080 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow"); 1065 1081 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS"); 1066 1082 scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, &SetCameraData>("SetCameraData");