Skip to content

Commit 7605f74

Browse files
committed
Fixes to cursor and xrWeatherEditor
When running xrWeatherEditor, in-game cursor position matches desktop cursor position (real game resolution used instead of rendering resolution) Fixes to Edit and Pause buttons behaviour in xrWeatherEditor
1 parent cfafdfd commit 7605f74

File tree

7 files changed

+43
-35
lines changed

7 files changed

+43
-35
lines changed

src/editors/xrWeatherEditor/window_view.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ void window_view::reclip_cursor()
5353
if (EditButton->Checked)
5454
return;
5555

56-
if (!m_loaded)
57-
return;
56+
//if (!m_loaded)
57+
// return;
5858

5959
while (ShowCursor(FALSE) >= 0)
6060
;
@@ -81,16 +81,19 @@ System::Void window_view::EditButton_Click(System::Object ^ sender, System::Even
8181
ClipCursor(nullptr);
8282
while (ShowCursor(TRUE) <= 0)
8383
;
84-
return;
8584
}
86-
87-
m_engine->pause(false);
88-
m_engine->capture_input(false);
89-
reclip_cursor();
85+
else
86+
{
87+
m_engine->pause(false);
88+
m_engine->capture_input(false);
89+
reclip_cursor();
90+
}
9091
}
9192

9293
System::Void window_view::PauseButton_Click(System::Object ^ sender, System::EventArgs ^ e)
9394
{
95+
if (!PauseButton->Enabled)
96+
return;
9497
PauseButton->Checked = !PauseButton->Checked;
9598
m_engine->pause(PauseButton->Checked);
9699
}
@@ -131,17 +134,19 @@ System::Void window_view::window_view_Activated(System::Object ^ sender, System:
131134
while (ShowCursor(TRUE) <= 0)
132135
;
133136

134-
if (!m_loaded)
135-
return;
137+
//if (!m_loaded)
138+
// return;
139+
140+
reclip_cursor();
136141
}
137142

138143
System::Void window_view::window_view_Deactivate(System::Object ^ sender, System::EventArgs ^ e)
139144
{
140145
if (!Parent)
141146
return;
142147

143-
if (!m_loaded)
144-
return;
148+
//if (!m_loaded)
149+
// return;
145150

146151
ClipCursor(nullptr);
147152
while (ShowCursor(TRUE) <= 0)

src/editors/xrWeatherEditor/window_view.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,15 @@ private: System::Windows::Forms::ImageList ^ imageList1;
8787
this->EditButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"EditButton.Image")));
8888
this->EditButton->ImageTransparentColor = System::Drawing::Color::Magenta;
8989
this->EditButton->Name = L"EditButton";
90-
this->EditButton->Size = System::Drawing::Size(31, 22);
90+
this->EditButton->Size = System::Drawing::Size(34, 22);
9191
this->EditButton->Text = L"Edit";
9292
this->EditButton->Click += gcnew System::EventHandler(this, &window_view::EditButton_Click);
93-
this->PauseButton->Checked = true;
94-
this->PauseButton->CheckState = System::Windows::Forms::CheckState::Checked;
9593
this->PauseButton->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
94+
this->PauseButton->Enabled = false;
9695
this->PauseButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"PauseButton.Image")));
9796
this->PauseButton->ImageTransparentColor = System::Drawing::Color::Magenta;
9897
this->PauseButton->Name = L"PauseButton";
99-
this->PauseButton->Size = System::Drawing::Size(42, 22);
98+
this->PauseButton->Size = System::Drawing::Size(46, 22);
10099
this->PauseButton->Text = L"Pause";
101100
this->PauseButton->Click += gcnew System::EventHandler(this, &window_view::PauseButton_Click);
102101
this->ViewPanel->Dock = System::Windows::Forms::DockStyle::Fill;

src/editors/xrWeatherEditor/window_view.resx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@
159159
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
160160
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
161161
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABS
162-
AgAAAk1TRnQBSQFM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A4EB/wMCAf/wAAMCCf8DgQH/AwIB/wQA
167+
AwIB/+gAAwIJ/wOBAf8DAgH/AwIB/+wAAwIF/wMCAf8DAgH/AwIB/wMCAf/sAAMCAf8DAgH/AwIB/wMC
168+
Af8DAgH/AwIB/+QAAwIB/wMCAf8DAgH/AwIB/wMCAf8DAgH/AwIB/wMCAf/oAAMCAf8DAgH/AwIB/wMC
169+
Af8DAgH/AwIB/+wAAwIB/wPAAf8DAgH/AwIB/wMCAf/wAAMCAf8DAgH/AwIB/8QAAUIBTQE+BwABPgMA
170170
ASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/8BAAL/BgABgAH/BwABPwYAAYABfwYAAcEB/wYAAeAB/wYA
171171
AfABfwYAAfgBPwYAAfwBFwYAAf4BBwYAAf8BAwYAAf8BgQYAAf8HAAH/AcAGAAH/AeAGAAH/AfEGAAs=
172172
</value>

src/engine.sln

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ EndProject
109109
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrRender_R3", "Layers\xrRenderPC_R3\xrRender_R3.vcxproj", "{3F383D3C-FCD8-4170-990B-EB4833F09248}"
110110
EndProject
111111
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrEngine", "xrEngine\xrEngine.vcxproj", "{2578C6D8-660D-48AE-9322-7422F8664F06}"
112-
ProjectSection(ProjectDependencies) = postProject
113-
{492D3DFE-9068-4E7E-A008-7C2420A651C0} = {492D3DFE-9068-4E7E-A008-7C2420A651C0}
114-
EndProjectSection
115112
EndProject
116113
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrLC_Light", "utils\xrLC_Light\xrLC_Light.vcxproj", "{EFB76D6F-0092-439C-A783-C0BE10BD17C9}"
117114
ProjectSection(ProjectDependencies) = postProject
@@ -256,6 +253,9 @@ EndProject
256253
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPIRV", "..\Externals\SPIRV.vcxproj", "{3AF44175-2EED-3C67-B324-93B1572B7EDD}"
257254
EndProject
258255
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xr_3da", "xr_3da\xr_3da.vcxproj", "{F4757631-E6E8-469B-AD5A-516BAA01DABD}"
256+
ProjectSection(ProjectDependencies) = postProject
257+
{492D3DFE-9068-4E7E-A008-7C2420A651C0} = {492D3DFE-9068-4E7E-A008-7C2420A651C0}
258+
EndProjectSection
259259
EndProject
260260
Global
261261
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/xrEngine/Device_destroy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void CRenderDevice::Reset(bool precache)
3838
{
3939
u32 dwWidth_before = dwWidth;
4040
u32 dwHeight_before = dwHeight;
41+
GetWindowRect(m_hWnd, &m_rcWindowBounds);
42+
GetClientRect(m_hWnd, &m_rcWindowClient);
4143
ShowCursor(true);
4244
u32 tm_start = TimerAsync();
4345
GEnv.Render->Reset(m_hWnd, dwWidth, dwHeight, fWidth_2, fHeight_2);

src/xrEngine/device.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,16 @@ class ENGINE_API IRenderDevice
5858
class ENGINE_API CRenderDeviceData
5959
{
6060
public:
61+
// Rendering resolution
6162
u32 dwWidth;
6263
u32 dwHeight;
6364

65+
// Real application window resolution
66+
RECT m_rcWindowBounds;
67+
68+
// Real game window resolution
69+
RECT m_rcWindowClient;
70+
6471
u32 dwPrecacheFrame;
6572
BOOL b_is_Ready;
6673
BOOL b_is_Active;
@@ -124,8 +131,6 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase
124131
{
125132
// Main objects used for creating and rendering the 3D scene
126133
u32 m_dwWindowStyle;
127-
RECT m_rcWindowBounds;
128-
RECT m_rcWindowClient;
129134
CTimer TimerMM;
130135
RenderDeviceStatictics stats;
131136

src/xrGame/UICursor.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,13 @@ Fvector2 CUICursor::GetCursorPositionDelta()
105105

106106
void CUICursor::UpdateCursorPosition(int _dx, int _dy)
107107
{
108-
Fvector2 p;
109108
vPrevPos = vPos;
110109
if (m_b_use_win_cursor)
111110
{
112111
Ivector2 pti;
113112
IInputReceiver::IR_GetMousePosReal(pti);
114-
p.x = (float)pti.x;
115-
p.y = (float)pti.y;
116-
vPos.x = p.x * (UI_BASE_WIDTH / (float)Device.dwWidth);
117-
vPos.y = p.y * (UI_BASE_HEIGHT / (float)Device.dwHeight);
113+
vPos.x = (float)pti.x * (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.right);
114+
vPos.y = (float)pti.y * (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.bottom);
118115
}
119116
else
120117
{
@@ -130,8 +127,8 @@ void CUICursor::SetUICursorPosition(Fvector2 pos)
130127
{
131128
vPos = pos;
132129
POINT p;
133-
p.x = iFloor(vPos.x / (UI_BASE_WIDTH / (float)Device.dwWidth));
134-
p.y = iFloor(vPos.y / (UI_BASE_HEIGHT / (float)Device.dwHeight));
130+
p.x = iFloor(vPos.x / (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.right));
131+
p.y = iFloor(vPos.y / (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.bottom));
135132
if (m_b_use_win_cursor)
136133
ClientToScreen(Device.m_hWnd, (LPPOINT)&p);
137134
SetCursorPos(p.x, p.y);

0 commit comments

Comments
 (0)