Ticket #3676: t3676.patch

File t3676.patch, 6.2 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/Camera.cpp
31===================================================================
32--- trunk/source/graphics/Camera.cpp (revision 17774)
33+++ trunk/source/graphics/Camera.cpp (working copy)
34@@ -131,6 +131,16 @@
35 m_ViewFrustum.m_aPlanes[i].Normalize();
36 }
37
38+std::wstring CCamera::GetOption(const std::wstring& optionName)
39+{
40+ return L"";
41+}
42+
43+void CCamera::SetOption(const std::wstring& optionName, const std::wstring& optionValue)
44+{
45+
46+}
47+
48 void CCamera::ClipFrustum(const CPlane& clipPlane)
49 {
50 CPlane normClipPlane = clipPlane;
51Index: trunk/source/graphics/Camera.h
52===================================================================
53--- trunk/source/graphics/Camera.h (revision 17774)
54+++ trunk/source/graphics/Camera.h (working copy)
55@@ -61,6 +61,9 @@
56 void ClipFrustum(const CPlane& clipPlane);
57 const CFrustum& GetFrustum() const { return m_ViewFrustum; }
58
59+ std::wstring GetOption(const std::wstring& optionName);
60+ void SetOption(const std::wstring& optionName, const std::wstring& optionValue);
61+
62 void SetViewPort(const SViewPort& viewport);
63 const SViewPort& GetViewPort() const { return m_ViewPort; }
64
65Index: trunk/source/graphics/GameView.cpp
66===================================================================
67--- trunk/source/graphics/GameView.cpp (revision 17774)
68+++ trunk/source/graphics/GameView.cpp (working copy)
69@@ -292,6 +292,9 @@
70 float ViewFOV;
71 float ViewNear;
72 float ViewFar;
73+ struct {
74+ bool isHotkeyLock = false;
75+ } view;
76 int JoystickPanX;
77 int JoystickPanY;
78 int JoystickRotateX;
79@@ -640,14 +643,17 @@
80 mouse_last_x = g_mouse_x;
81 mouse_last_y = g_mouse_y;
82
83- if (HotkeyIsPressed("camera.rotate.cw"))
84- m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime);
85- if (HotkeyIsPressed("camera.rotate.ccw"))
86- m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime);
87- if (HotkeyIsPressed("camera.rotate.up"))
88- m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime);
89- if (HotkeyIsPressed("camera.rotate.down"))
90- m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime);
91+ if (!m->view.isHotkeyLock)
92+ {
93+ if (HotkeyIsPressed("camera.rotate.cw"))
94+ m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime);
95+ if (HotkeyIsPressed("camera.rotate.ccw"))
96+ m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime);
97+ if (HotkeyIsPressed("camera.rotate.up"))
98+ m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime);
99+ if (HotkeyIsPressed("camera.rotate.down"))
100+ m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime);
101+ }
102
103 float moveRightward = 0.f;
104 float moveForward = 0.f;
105@@ -893,6 +899,22 @@
106 m->ViewCamera.UpdateFrustum();
107 }
108
109+std::wstring CGameView::GetCameraOption(const std::wstring& optionName)
110+{
111+ if (L"hotkeyLocked" == optionName)
112+ return m->view.isHotkeyLock ? L"true" : L"false";
113+
114+ return m->ViewCamera.GetOption(optionName);
115+}
116+
117+void CGameView::SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue)
118+{
119+ if (L"hotkeyLocked" == optionName)
120+ m->view.isHotkeyLock = (optionValue == L"true");
121+ else
122+ m->ViewCamera.SetOption(optionName,optionValue);
123+}
124+
125 float CGameView::GetCameraX()
126 {
127 CCamera targetCam = m->ViewCamera;
128Index: trunk/source/graphics/GameView.h
129===================================================================
130--- trunk/source/graphics/GameView.h (revision 17774)
131+++ trunk/source/graphics/GameView.h (working copy)
132@@ -90,6 +90,8 @@
133 float GetCameraRotX();
134 float GetCameraRotY();
135 float GetCameraZoom();
136+ std::wstring GetCameraOption(const std::wstring& optionName);
137+ void SetCameraOption(const std::wstring& optionName, const std::wstring& optionValue);
138 void SetCamera(CVector3D Pos, float RotX, float RotY, float Zoom);
139 void MoveCameraTarget(const CVector3D& target);
140 void ResetCameraTarget(const CVector3D& target);
141Index: trunk/source/gui/scripting/ScriptFunctions.cpp
142===================================================================
143--- trunk/source/gui/scripting/ScriptFunctions.cpp (revision 17774)
144+++ trunk/source/gui/scripting/ScriptFunctions.cpp (working copy)
145@@ -532,6 +532,20 @@
146 return -1;
147 }
148
149+std::wstring CameraGetOption(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& optionName)
150+{
151+ if (g_Game && g_Game->GetView())
152+ return g_Game->GetView()->GetCameraOption(optionName);
153+
154+ return wstring_from_utf8("");
155+}
156+
157+void CameraSetOption(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& optionName, const std::wstring& optionValue)
158+{
159+ if (g_Game && g_Game->GetView())
160+ g_Game->GetView()->SetCameraOption(optionName, optionValue);
161+}
162+
163 /**
164 * Get the current Z coordinate of the camera.
165 */
166@@ -1061,6 +1075,8 @@
167 scriptInterface.RegisterFunction<JS::Value, &GetMapSettings>("GetMapSettings");
168 scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX");
169 scriptInterface.RegisterFunction<float, &CameraGetZ>("CameraGetZ");
170+ scriptInterface.RegisterFunction<std::wstring, std::wstring, &CameraGetOption>("CameraGetOption");
171+ scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &CameraSetOption>("CameraSetOption");
172 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow");
173 scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS");
174 scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, &SetCameraData>("SetCameraData");