Ticket #3676: t3676.3.patch

File t3676.3.patch, 4.9 KB (added by Sergey Kushnirenko, 8 years ago)
Line 
1Index: trunk/binaries/data/mods/public/gui/session/menu.js
2===================================================================
3--- trunk/binaries/data/mods/public/gui/session/menu.js (revision 17774)
4+++ trunk/binaries/data/mods/public/gui/session/menu.js (working copy)
5@@ -197,7 +197,7 @@
6 }
7
8 function openChat()
9-{
10+{
11 if (g_Disconnected)
12 return;
13
14@@ -214,6 +214,7 @@
15 Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input
16 Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus
17 Engine.GetGUIObjectByName("chatDialogPanel").hidden = true;
18+ Engine.CameraSetOption("hotkeyLocked", "false" );
19 }
20
21 /**
22@@ -256,6 +257,7 @@
23 }
24
25 chatWindow.hidden = !hidden;
26+ Engine.CameraSetOption("hotkeyLocked", chatWindow.hidden ? "false" : "true");
27 }
28
29 function setDiplomacy(data)
30Index: trunk/source/graphics/GameView.cpp
31===================================================================
32--- trunk/source/graphics/GameView.cpp (revision 17774)
33+++ trunk/source/graphics/GameView.cpp (working copy)
34@@ -292,6 +292,9 @@
35 float ViewFOV;
36 float ViewNear;
37 float ViewFar;
38+ bool hotkeysEnabled = false;
39 int JoystickPanX;
40 int JoystickPanY;
41 int JoystickRotateX;
42@@ -640,14 +643,17 @@
43 mouse_last_x = g_mouse_x;
44 mouse_last_y = g_mouse_y;
45
46- if (HotkeyIsPressed("camera.rotate.cw"))
47- m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime);
48- if (HotkeyIsPressed("camera.rotate.ccw"))
49- m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime);
50- if (HotkeyIsPressed("camera.rotate.up"))
51- m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime);
52- if (HotkeyIsPressed("camera.rotate.down"))
53- m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime);
54+ if (!m->hotkeysEnabled)
55+ {
56+ if (HotkeyIsPressed("camera.rotate.cw"))
57+ m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime);
58+ if (HotkeyIsPressed("camera.rotate.ccw"))
59+ m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime);
60+ if (HotkeyIsPressed("camera.rotate.up"))
61+ m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime);
62+ if (HotkeyIsPressed("camera.rotate.down"))
63+ m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime);
64+ }
65
66 float moveRightward = 0.f;
67 float moveForward = 0.f;
68@@ -893,6 +899,22 @@
69 m->ViewCamera.UpdateFrustum();
70 }
71
72+std::wstring CGameView::GetCameraOption(const std::wstring& optionName)
73+{
74+ if (L"hotkeyLocked" == optionName)
75+ return m->hotkeysEnabled ? L"true" : L"false";
76+
77+ return L"";
78+}
79+
80+void CGameView::SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue)
81+{
82+ if (L"hotkeyLocked" == optionName)
83+ m->hotkeysEnabled = (optionValue == L"true");
84+}
85+
86 float CGameView::GetCameraX()
87 {
88 CCamera targetCam = m->ViewCamera;
89Index: trunk/source/graphics/GameView.h
90===================================================================
91--- trunk/source/graphics/GameView.h (revision 17774)
92+++ trunk/source/graphics/GameView.h (working copy)
93@@ -90,6 +90,8 @@
94 float GetCameraRotX();
95 float GetCameraRotY();
96 float GetCameraZoom();
97+ std::wstring GetCameraOption(const std::wstring& optionName);
98+ void SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue);
99 void SetCamera(CVector3D Pos, float RotX, float RotY, float Zoom);
100 void MoveCameraTarget(const CVector3D& target);
101 void ResetCameraTarget(const CVector3D& target);
102Index: trunk/source/gui/scripting/ScriptFunctions.cpp
103===================================================================
104--- trunk/source/gui/scripting/ScriptFunctions.cpp (revision 17774)
105+++ trunk/source/gui/scripting/ScriptFunctions.cpp (working copy)
106@@ -532,6 +532,20 @@
107 return -1;
108 }
109
110+std::wstring CameraGetOption(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& optionName)
111+{
112+ if (g_Game && g_Game->GetView())
113+ return g_Game->GetView()->GetCameraOption(optionName);
114+
115+ return wstring_from_utf8("");
116+}
117+
118+void CameraSetOption(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& optionName, const std::wstring& optionValue)
119+{
120+ if (g_Game && g_Game->GetView())
121+ g_Game->GetView()->SetCameraOption(optionName, optionValue);
122+}
123+
124 /**
125 * Get the current Z coordinate of the camera.
126 */
127@@ -1061,6 +1075,8 @@
128 scriptInterface.RegisterFunction<JS::Value, &GetMapSettings>("GetMapSettings");
129 scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX");
130 scriptInterface.RegisterFunction<float, &CameraGetZ>("CameraGetZ");
131+ scriptInterface.RegisterFunction<std::wstring, std::wstring, &CameraGetOption>("CameraGetOption");
132+ scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &CameraSetOption>("CameraSetOption");
133 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow");
134 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS");
135 scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, &SetCameraData>("SetCameraData");