Skip to content

Commit

Permalink
Fixes to cursor and xrWeatherEditor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Xottab-DUTY committed Feb 11, 2018
1 parent cfafdfd commit 7605f74
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 35 deletions.
27 changes: 16 additions & 11 deletions src/editors/xrWeatherEditor/window_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void window_view::reclip_cursor()
if (EditButton->Checked)
return;

if (!m_loaded)
return;
//if (!m_loaded)
// return;

while (ShowCursor(FALSE) >= 0)
;
Expand All @@ -81,16 +81,19 @@ System::Void window_view::EditButton_Click(System::Object ^ sender, System::Even
ClipCursor(nullptr);
while (ShowCursor(TRUE) <= 0)
;
return;
}

m_engine->pause(false);
m_engine->capture_input(false);
reclip_cursor();
else
{
m_engine->pause(false);
m_engine->capture_input(false);
reclip_cursor();
}
}

System::Void window_view::PauseButton_Click(System::Object ^ sender, System::EventArgs ^ e)
{
if (!PauseButton->Enabled)
return;
PauseButton->Checked = !PauseButton->Checked;
m_engine->pause(PauseButton->Checked);
}
Expand Down Expand Up @@ -131,17 +134,19 @@ System::Void window_view::window_view_Activated(System::Object ^ sender, System:
while (ShowCursor(TRUE) <= 0)
;

if (!m_loaded)
return;
//if (!m_loaded)
// return;

reclip_cursor();
}

System::Void window_view::window_view_Deactivate(System::Object ^ sender, System::EventArgs ^ e)
{
if (!Parent)
return;

if (!m_loaded)
return;
//if (!m_loaded)
// return;

ClipCursor(nullptr);
while (ShowCursor(TRUE) <= 0)
Expand Down
7 changes: 3 additions & 4 deletions src/editors/xrWeatherEditor/window_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,15 @@ private: System::Windows::Forms::ImageList ^ imageList1;
this->EditButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"EditButton.Image")));
this->EditButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->EditButton->Name = L"EditButton";
this->EditButton->Size = System::Drawing::Size(31, 22);
this->EditButton->Size = System::Drawing::Size(34, 22);
this->EditButton->Text = L"Edit";
this->EditButton->Click += gcnew System::EventHandler(this, &window_view::EditButton_Click);
this->PauseButton->Checked = true;
this->PauseButton->CheckState = System::Windows::Forms::CheckState::Checked;
this->PauseButton->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
this->PauseButton->Enabled = false;
this->PauseButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"PauseButton.Image")));
this->PauseButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->PauseButton->Name = L"PauseButton";
this->PauseButton->Size = System::Drawing::Size(42, 22);
this->PauseButton->Size = System::Drawing::Size(46, 22);
this->PauseButton->Text = L"Pause";
this->PauseButton->Click += gcnew System::EventHandler(this, &window_view::PauseButton_Click);
this->ViewPanel->Dock = System::Windows::Forms::DockStyle::Fill;
Expand Down
16 changes: 8 additions & 8 deletions src/editors/xrWeatherEditor/window_view.resx
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABS
AgAAAk1TRnQBSQFMAwEBAAEMAQABDAEAARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMA
ARADAAEBAQABIAYAARD/ABcAAr8BBAH/Ar8BBAH/Ar8BBAH/Ar8BBAH/Ar8BBAH/Ar8BBAH/Ar8BBAH/
4AACvwEEAf8CvwEEAf8DBAH/AwQ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IB/+wAAwIB/wPAAf8DAgH/AwIB/wMCAf/wAAMCAf8DAgH/AwIB/8QAAUIBTQE+BwABPgMA
ASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/8BAAL/BgABgAH/BwABPwYAAYABfwYAAcEB/wYAAeAB/wYA
AfABfwYAAfgBPwYAAfwBFwYAAf4BBwYAAf8BAwYAAf8BgQYAAf8HAAH/AcAGAAH/AeAGAAH/AfEGAAs=
</value>
Expand Down
6 changes: 3 additions & 3 deletions src/engine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrRender_R3", "Layers\xrRenderPC_R3\xrRender_R3.vcxproj", "{3F383D3C-FCD8-4170-990B-EB4833F09248}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrEngine", "xrEngine\xrEngine.vcxproj", "{2578C6D8-660D-48AE-9322-7422F8664F06}"
ProjectSection(ProjectDependencies) = postProject
{492D3DFE-9068-4E7E-A008-7C2420A651C0} = {492D3DFE-9068-4E7E-A008-7C2420A651C0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrLC_Light", "utils\xrLC_Light\xrLC_Light.vcxproj", "{EFB76D6F-0092-439C-A783-C0BE10BD17C9}"
ProjectSection(ProjectDependencies) = postProject
Expand Down Expand Up @@ -256,6 +253,9 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPIRV", "..\Externals\SPIRV.vcxproj", "{3AF44175-2EED-3C67-B324-93B1572B7EDD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xr_3da", "xr_3da\xr_3da.vcxproj", "{F4757631-E6E8-469B-AD5A-516BAA01DABD}"
ProjectSection(ProjectDependencies) = postProject
{492D3DFE-9068-4E7E-A008-7C2420A651C0} = {492D3DFE-9068-4E7E-A008-7C2420A651C0}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 2 additions & 0 deletions src/xrEngine/Device_destroy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void CRenderDevice::Reset(bool precache)
{
u32 dwWidth_before = dwWidth;
u32 dwHeight_before = dwHeight;
GetWindowRect(m_hWnd, &m_rcWindowBounds);
GetClientRect(m_hWnd, &m_rcWindowClient);
ShowCursor(true);
u32 tm_start = TimerAsync();
GEnv.Render->Reset(m_hWnd, dwWidth, dwHeight, fWidth_2, fHeight_2);
Expand Down
9 changes: 7 additions & 2 deletions src/xrEngine/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,16 @@ class ENGINE_API IRenderDevice
class ENGINE_API CRenderDeviceData
{
public:
// Rendering resolution
u32 dwWidth;
u32 dwHeight;

// Real application window resolution
RECT m_rcWindowBounds;

// Real game window resolution
RECT m_rcWindowClient;

u32 dwPrecacheFrame;
BOOL b_is_Ready;
BOOL b_is_Active;
Expand Down Expand Up @@ -124,8 +131,6 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase
{
// Main objects used for creating and rendering the 3D scene
u32 m_dwWindowStyle;
RECT m_rcWindowBounds;
RECT m_rcWindowClient;
CTimer TimerMM;
RenderDeviceStatictics stats;

Expand Down
11 changes: 4 additions & 7 deletions src/xrGame/UICursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,13 @@ Fvector2 CUICursor::GetCursorPositionDelta()

void CUICursor::UpdateCursorPosition(int _dx, int _dy)
{
Fvector2 p;
vPrevPos = vPos;
if (m_b_use_win_cursor)
{
Ivector2 pti;
IInputReceiver::IR_GetMousePosReal(pti);
p.x = (float)pti.x;
p.y = (float)pti.y;
vPos.x = p.x * (UI_BASE_WIDTH / (float)Device.dwWidth);
vPos.y = p.y * (UI_BASE_HEIGHT / (float)Device.dwHeight);
vPos.x = (float)pti.x * (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.right);
vPos.y = (float)pti.y * (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.bottom);
}
else
{
Expand All @@ -130,8 +127,8 @@ void CUICursor::SetUICursorPosition(Fvector2 pos)
{
vPos = pos;
POINT p;
p.x = iFloor(vPos.x / (UI_BASE_WIDTH / (float)Device.dwWidth));
p.y = iFloor(vPos.y / (UI_BASE_HEIGHT / (float)Device.dwHeight));
p.x = iFloor(vPos.x / (UI_BASE_WIDTH / (float)Device.m_rcWindowClient.right));
p.y = iFloor(vPos.y / (UI_BASE_HEIGHT / (float)Device.m_rcWindowClient.bottom));
if (m_b_use_win_cursor)
ClientToScreen(Device.m_hWnd, (LPPOINT)&p);
SetCursorPos(p.x, p.y);
Expand Down

0 comments on commit 7605f74

Please sign in to comment.