From eb8c141ad9fcd00255462035390ea58a696ef49e Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 6 Jun 2017 22:13:08 +0200 Subject: [PATCH] [Window] Apply waiting cursor while loading fastfiles --- src/Components/Modules/Window.cpp | 23 +++++++++++++++++++++-- src/Components/Modules/Window.hpp | 4 ++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Window.cpp b/src/Components/Modules/Window.cpp index 57d6ac3b..adde2efc 100644 --- a/src/Components/Modules/Window.cpp +++ b/src/Components/Modules/Window.cpp @@ -124,6 +124,23 @@ namespace Components return Window::MainWindow; } + void Window::ApplyCursor() + { + bool isLoading = !FastFiles::Ready(); + SetCursor(LoadCursor(nullptr, isLoading ? IDC_WAIT : IDC_ARROW)); + } + + BOOL WINAPI Window::MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) + { + if(Msg == WM_SETCURSOR) + { + Window::ApplyCursor(); + return TRUE; + } + + return Utils::Hook::Call(0x4731F0)(hWnd, Msg, wParam, lParam); + } + Window::Window() { // Borderless window @@ -145,11 +162,10 @@ namespace Components if (Window::NativeCursor.get() && IsWindow(Window::MainWindow) && GetForegroundWindow() == Window::MainWindow && Window::IsCursorWithin(Window::MainWindow)) { int value = 0; + Window::ApplyCursor(); if (Window::CursorVisible) { - SetCursor(LoadCursor(nullptr, IDC_ARROW)); - while ((value = ShowCursor(TRUE)) < 0) {}; while (value > 0) { value = ShowCursor(FALSE); } // Set display counter to 0 } @@ -165,5 +181,8 @@ namespace Components // Don't let the game interact with the native cursor Utils::Hook::Set(0x6D7348, Window::ShowCursorHook); + + // Use custom message handler + Utils::Hook::Set(0x64D298, Window::MessageHandler); } } diff --git a/src/Components/Modules/Window.hpp b/src/Components/Modules/Window.hpp index cd39da7a..37a97547 100644 --- a/src/Components/Modules/Window.hpp +++ b/src/Components/Modules/Window.hpp @@ -25,8 +25,12 @@ namespace Components static HWND MainWindow; + static void ApplyCursor(); + static int IsNoBorder(); + static BOOL WINAPI MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); + static int WINAPI ShowCursorHook(BOOL show); static void DrawCursorStub(void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Game::Material *material);