From e41c161202fe4e0a25fb5cdbbf674d68fc390215 Mon Sep 17 00:00:00 2001 From: Sri Sham Haran Date: Sat, 4 Feb 2023 11:21:25 +0800 Subject: [PATCH] Adjusted lighting a bit cuz it looked janky at one portion Hide and clip mouse cursor for builds without editor (only when window is active) --- Assets/Editor/Layouts/UserLayout.ini | 167 ------------------ Assets/Scenes/MainGame.shade | 2 +- .../src/Application/SBApplication.cpp | 4 +- .../src/Graphics/Windowing/SHWindow.cpp | 34 +++- .../src/Graphics/Windowing/SHWindow.h | 5 +- 5 files changed, 38 insertions(+), 174 deletions(-) delete mode 100644 Assets/Editor/Layouts/UserLayout.ini diff --git a/Assets/Editor/Layouts/UserLayout.ini b/Assets/Editor/Layouts/UserLayout.ini deleted file mode 100644 index 781f61c0..00000000 --- a/Assets/Editor/Layouts/UserLayout.ini +++ /dev/null @@ -1,167 +0,0 @@ -[Window][MainStatusBar] -Pos=0,989 -Size=2560,20 -Collapsed=0 - -[Window][SHEditorMenuBar] -Pos=0,48 -Size=2560,941 -Collapsed=0 - -[Window][Hierarchy Panel] -Pos=0,187 -Size=300,802 -Collapsed=0 -DockId=0x00000004,0 - -[Window][Debug##Default] -Pos=60,60 -Size=400,400 -Collapsed=0 - -[Window][Inspector] -Pos=2074,48 -Size=486,941 -Collapsed=0 -DockId=0x00000006,0 - -[Window][Profiler] -Pos=0,48 -Size=300,137 -Collapsed=0 -DockId=0x00000003,0 - -[Window][Viewport] -Pos=227,48 -Size=1457,1012 -Collapsed=0 -DockId=0x0000000B,0 - -[Window][面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面o] -Pos=60,60 -Size=32,64 -Collapsed=0 - -[Window][面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面面] -Pos=60,60 -Size=999,581 -Collapsed=0 - -[Window][o] -Pos=60,60 -Size=32,64 -Collapsed=0 - -[Window][面面] -Pos=60,60 -Size=553,422 -Collapsed=0 - -[Window][] -Pos=60,60 -Size=770,394 -Collapsed=0 - -[Window][ Viewport] -Pos=227,48 -Size=1457,1012 -Collapsed=0 -DockId=0x0000000B,0 - -[Window][ Viewport] -Pos=227,48 -Size=1457,1012 -Collapsed=0 -DockId=0x0000000B,0 - -[Window][ Viewport] -Pos=302,48 -Size=1770,705 -Collapsed=0 -DockId=0x0000000B,0 - -[Window][V] -Pos=310,722 -Size=1501,338 -Collapsed=0 -DockId=0x00000008,0 - -[Window][p] -Pos=310,750 -Size=1501,310 -Collapsed=0 -DockId=0x0000000A,0 - -[Window][ Asset Browser] -Pos=302,755 -Size=1770,234 -Collapsed=0 -DockId=0x0000000C,0 - -[Window][Material Inspector] -Pos=2074,48 -Size=486,941 -Collapsed=0 -DockId=0x00000006,1 - -[Window][Save scene as...] -Pos=1197,693 -Size=165,120 -Collapsed=0 - -[Window][Create New Asset] -Pos=896,472 -Size=464,144 -Collapsed=0 - -[Window][Collider Tag Panel] -Pos=302,48 -Size=1770,705 -Collapsed=0 -DockId=0x0000000B,1 - -[Window][Input Bindings Panel] -Pos=2074,48 -Size=486,941 -Collapsed=0 -DockId=0x00000006,2 - -[Window][Save Scene As] -Pos=877,444 -Size=165,120 -Collapsed=0 - -[Table][0x9D40AE32,17] -Column 0 Weight=1.0696 -Column 1 Weight=0.9194 -Column 2 Weight=0.9945 -Column 3 Weight=1.0320 -Column 4 Weight=0.9570 -Column 5 Weight=0.9945 -Column 6 Weight=0.9945 -Column 7 Weight=0.9945 -Column 8 Weight=0.9945 -Column 9 Weight=1.0320 -Column 10 Weight=0.9570 -Column 11 Weight=1.0133 -Column 12 Weight=0.9945 -Column 13 Weight=0.8444 -Column 14 Weight=0.9945 -Column 15 Weight=0.8632 -Column 16 Weight=1.3510 - -[Docking][Data] -DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=2560,941 Split=X - DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1432,1036 Split=X - DockNode ID=0x00000001 Parent=0x00000005 SizeRef=300,1036 Split=Y Selected=0x1E6EB881 - DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,147 Selected=0x1E6EB881 - DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,863 Selected=0xE096E5AE - DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1130,1036 Split=Y Selected=0xB41284E7 - DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7 - DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7 - DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0xB41284E7 - DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,234 Selected=0xB128252A - DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6 - DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532 - DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=486,1036 Selected=0xE7039252 - diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 77d80689..73ea9a83 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -8476,7 +8476,7 @@ Light Component: Position: {x: 2, y: 1.5, z: -5.5999999} Type: Directional - Direction: {x: 1, y: 0, z: 0} + Direction: {x: -0.245000005, y: 0, z: 0} Color: {x: 0, y: 0, z: 0, w: 1} Layer: 4294967295 Strength: 1 diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index ffc4bacc..a89fb050 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -171,6 +171,7 @@ namespace Sandbox SHSceneManager::InitSceneManager(editorConfig.workingSceneID); #else SHSceneManager::InitSceneManager(appConfig.startingSceneID); + window.SetMouseVisible(false); #endif SHFrameRateController::UpdateFRC(); @@ -199,7 +200,8 @@ namespace Sandbox #ifdef SHEDITOR if(editor->editorState == SHEditor::State::PLAY) - +#else + window.ClipMouseCursor(); #endif SHSceneManager::SceneUpdate(0.016f); #ifdef SHEDITOR diff --git a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp index 401a920c..13d9c143 100644 --- a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp +++ b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp @@ -185,12 +185,40 @@ namespace SHADE void SHWindow::SetMouseVisible(bool show) { - ShowCursor(show ? TRUE : FALSE); + if (GetActiveWindow() == wndHWND) + ShowCursor(show); } - void SHWindow::SetMousePosition(unsigned x, unsigned y) + void SHWindow::SetMousePosition(int x, int y) { - SetCursorPos(x, y); + if(GetActiveWindow() == wndHWND) + { + //if(x == -1) + // x = GetSystemMetrics(SM_CXSCREEN) * 0.5; + //if (y == -1) + // y = GetSystemMetrics(SM_CYSCREEN) * 0.5; + //SetCursorPos(x, y); + } + } + + void SHWindow::ClipMouseCursor(int left, int top, int right, int bottom) + { + if (GetActiveWindow() == wndHWND) + { + RECT rect{}; + if (left == 0 || right == 0) + { + GetClientRect(wndHWND, &rect); + } + else + { + rect.left = left; + rect.right = right; + rect.top = top; + rect.bottom = bottom; + } + ClipCursor(&rect); + } } //unsigned SHWindow::GetBGColor() diff --git a/SHADE_Engine/src/Graphics/Windowing/SHWindow.h b/SHADE_Engine/src/Graphics/Windowing/SHWindow.h index ac4f3a71..530f1778 100644 --- a/SHADE_Engine/src/Graphics/Windowing/SHWindow.h +++ b/SHADE_Engine/src/Graphics/Windowing/SHWindow.h @@ -106,7 +106,9 @@ namespace SHADE void SetMouseVisible(bool show); - void SetMousePosition(unsigned x, unsigned y); + void SetMousePosition(int x = -1, int y = -1); + + void ClipMouseCursor(int left = 0, int top = 0, int right = 0, int bottom = 0); //unsigned GetBGColor(); @@ -144,7 +146,6 @@ namespace SHADE void SetHWND(HWND hwnd); - HWND wndHWND = nullptr; HINSTANCE hInstance = nullptr; -- 2.40.1