Skip to content

Commit

Permalink
First approximation to hiding windows cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
FiskSM committed Dec 14, 2018
1 parent ea91ce9 commit f95188d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
-- Everything relating to the gameplay screen is gradually moved to WifeJudgmentSpotting.lua
local inReplay = GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerController() == "PlayerController_Replay"
local inCustomize = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).CustomizeGameplay

if not inReplay and not inCustomize then
HOOKS:ShowCursor(false)
end

local t = Def.ActorFrame {}
t[#t + 1] = LoadActor("WifeJudgmentSpotting")
t[#t + 1] = LoadActor("titlesplash")
Expand Down
2 changes: 1 addition & 1 deletion src/LuaManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "Command.h"
#include "LuaManager.h"
#include "LuaReference.h"
Expand Down
2 changes: 2 additions & 0 deletions src/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ScreenManager.h"
#include "RageInput.h"
#include "ThemeManager.h"
#include "arch/ArchHooks/ArchHooks.h"

#define NEXT_SCREEN THEME->GetMetric(m_sName, "NextScreen")
#define PREV_SCREEN THEME->GetMetric(m_sName, "PrevScreen")
Expand Down Expand Up @@ -43,6 +44,7 @@ Screen::Init()
HANDLE_BACK_BUTTON.Load(m_sName, "HandleBackButton");
REPEAT_RATE.Load(m_sName, "RepeatRate");
REPEAT_DELAY.Load(m_sName, "RepeatDelay");
HOOKS->sShowCursor(true);

m_Codes.Load(m_sName);

Expand Down
6 changes: 6 additions & 0 deletions src/arch/ArchHooks/ArchHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,18 @@ class LunaArchHooks : public Luna<ArchHooks>
DEFINE_METHOD(AppHasFocus, AppHasFocus());
DEFINE_METHOD(GetArchName, GetArchName());
DEFINE_METHOD(GetClipboard, GetClipboard());
static int ShowCursor(T* p, lua_State* L)
{
p->sShowCursor(BArg(1));
return 0;
}

LunaArchHooks()
{
ADD_METHOD(AppHasFocus);
ADD_METHOD(GetArchName);
ADD_METHOD(GetClipboard);
ADD_METHOD(ShowCursor);
}
};
LUA_REGISTER_CLASS(ArchHooks);
Expand Down
2 changes: 1 addition & 1 deletion src/arch/ArchHooks/ArchHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ArchHooks
/* This is called as soon as the loading window is shown, and we can
* safely log. */
virtual void DumpDebugInfo() {}

virtual void sShowCursor(bool set) {}
/**
* @brief Re-exec the game.
*
Expand Down
9 changes: 9 additions & 0 deletions src/arch/ArchHooks/ArchHooks_Win32.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ARCH_HOOKS_WIN32_H
#define ARCH_HOOKS_WIN32_H

#include <windows.h>
#include "ArchHooks.h"
class RageMutex;

Expand All @@ -26,6 +27,14 @@ class ArchHooks_Win32 : public ArchHooks
/** @brief Fetch the window width. */
int GetWindowWidth();

void sShowCursor(bool set) override
{
if (set)
while (ShowCursor(true) < 0);
else
while (ShowCursor(false) >= 0);
}

/** @brief Fetch the window height. */
int GetWindowHeight();
};
Expand Down

0 comments on commit f95188d

Please sign in to comment.