Enable native cursor via dvar.
This commit is contained in:
parent
b3e904115d
commit
8b81fe37ae
@ -3,6 +3,8 @@
|
||||
namespace Components
|
||||
{
|
||||
Dvar::Var Window::NoBorder;
|
||||
Dvar::Var Window::NativeCursor;
|
||||
|
||||
HWND Window::MainWindow = 0;
|
||||
BOOL Window::CursorVisible = TRUE;
|
||||
|
||||
@ -20,14 +22,21 @@ namespace Components
|
||||
__asm retn
|
||||
}
|
||||
|
||||
void Window::DrawCursorStub()
|
||||
void Window::DrawCursorStub(void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Game::Material *material)
|
||||
{
|
||||
Window::CursorVisible = TRUE;
|
||||
if (Window::NativeCursor.Get<bool>())
|
||||
{
|
||||
Window::CursorVisible = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Game::UI_DrawHandlePic(scrPlace, x, y, w, h, horzAlign, vertAlign, color, material);
|
||||
}
|
||||
}
|
||||
|
||||
int WINAPI Window::ShowCursorHook(BOOL show)
|
||||
{
|
||||
if (GetForegroundWindow() == Window::MainWindow)
|
||||
if (Window::NativeCursor.Get<bool>() && GetForegroundWindow() == Window::MainWindow)
|
||||
{
|
||||
static int count = 0;
|
||||
(show ? ++count : --count);
|
||||
@ -53,6 +62,8 @@ namespace Components
|
||||
{
|
||||
// Borderless window
|
||||
Window::NoBorder = Dvar::Register<bool>("r_noborder", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Do not use a border in windowed mode");
|
||||
Window::NativeCursor = Dvar::Register<bool>("ui_nativeCursor", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display native cursor");
|
||||
|
||||
Utils::Hook(0x507643, Window::StyleHookStub, HOOK_CALL).Install()->Quick();
|
||||
|
||||
// Main window creation
|
||||
@ -65,7 +76,7 @@ namespace Components
|
||||
// Draw the cursor if necessary
|
||||
Renderer::OnFrame([] ()
|
||||
{
|
||||
if (GetForegroundWindow() == Window::MainWindow)
|
||||
if (Window::NativeCursor.Get<bool>() && GetForegroundWindow() == Window::MainWindow)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
|
@ -7,13 +7,14 @@ namespace Components
|
||||
const char* GetName() { return "Window"; };
|
||||
|
||||
static Dvar::Var NoBorder;
|
||||
static Dvar::Var NativeCursor;
|
||||
static void Window::StyleHookStub();
|
||||
|
||||
private:
|
||||
static BOOL CursorVisible;
|
||||
|
||||
static int WINAPI ShowCursorHook(BOOL show);
|
||||
static void DrawCursorStub();
|
||||
static void DrawCursorStub(void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Game::Material *material);
|
||||
|
||||
static HWND MainWindow;
|
||||
|
||||
|
@ -87,6 +87,7 @@ namespace Game
|
||||
Steam_JoinLobby_t Steam_JoinLobby = (Steam_JoinLobby_t)0x49CF70;
|
||||
|
||||
UI_AddMenuList_t UI_AddMenuList = (UI_AddMenuList_t)0x4533C0;
|
||||
UI_DrawHandlePic_t UI_DrawHandlePic = (UI_DrawHandlePic_t)0x4D0EA0;
|
||||
|
||||
Win_GetLanguage_t Win_GetLanguage = (Win_GetLanguage_t)0x45CBA0;
|
||||
|
||||
|
@ -190,6 +190,9 @@ namespace Game
|
||||
typedef void(__cdecl * UI_AddMenuList_t)(UiContext *dc, MenuList *menuList, int close);
|
||||
extern UI_AddMenuList_t UI_AddMenuList;
|
||||
|
||||
typedef void(__cdecl * UI_DrawHandlePic_t)(/*ScreenPlacement*/void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Material *material);
|
||||
extern UI_DrawHandlePic_t UI_DrawHandlePic;
|
||||
|
||||
typedef const char * (__cdecl * Win_GetLanguage_t)();
|
||||
extern Win_GetLanguage_t Win_GetLanguage;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user