mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Merge pull request #730 from InfoTeddy/general-improvements
Axe mouse cursor config option in favor of automatically toggling mouse
This commit is contained in:
commit
07c425b2f8
6 changed files with 79 additions and 46 deletions
|
@ -4215,11 +4215,6 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s
|
|||
graphics.translucentroomname = help.Int(pText);
|
||||
}
|
||||
|
||||
if (SDL_strcmp(pKey, "showmousecursor") == 0)
|
||||
{
|
||||
graphics.showmousecursor = help.Int(pText);
|
||||
}
|
||||
|
||||
if (SDL_strcmp(pKey, "musicvolume") == 0)
|
||||
{
|
||||
music.user_music_volume = help.Int(pText);
|
||||
|
@ -4273,15 +4268,6 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s
|
|||
|
||||
}
|
||||
|
||||
if (graphics.showmousecursor)
|
||||
{
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
}
|
||||
|
||||
if (controllerButton_flip.size() < 1)
|
||||
{
|
||||
controllerButton_flip.push_back(SDL_CONTROLLER_BUTTON_A);
|
||||
|
@ -4451,8 +4437,6 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSetting
|
|||
|
||||
xml::update_tag(dataNode, "translucentroomname", (int) graphics.translucentroomname);
|
||||
|
||||
xml::update_tag(dataNode, "showmousecursor", (int) graphics.showmousecursor);
|
||||
|
||||
xml::update_tag(dataNode, "over30mode", (int) over30mode);
|
||||
|
||||
xml::update_tag(dataNode, "inputdelay", (int) inputdelay);
|
||||
|
@ -6062,7 +6046,6 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
|
|||
maxspacing = 15;
|
||||
break;
|
||||
case Menu::advancedoptions:
|
||||
option("toggle mouse");
|
||||
option("unfocus pause");
|
||||
option("room name background");
|
||||
option("return");
|
||||
|
|
|
@ -125,7 +125,6 @@ void Graphics::init(void)
|
|||
warprect = SDL_Rect();
|
||||
|
||||
translucentroomname = false;
|
||||
showmousecursor = true;
|
||||
|
||||
alpha = 1.0f;
|
||||
|
||||
|
|
|
@ -323,8 +323,6 @@ public:
|
|||
|
||||
bool translucentroomname;
|
||||
|
||||
bool showmousecursor;
|
||||
|
||||
std::map<int, int> font_positions;
|
||||
|
||||
SDL_Surface* ghostbuffer;
|
||||
|
|
|
@ -601,25 +601,12 @@ static void menuactionpress(void)
|
|||
switch (game.currentmenuoption)
|
||||
{
|
||||
case 0:
|
||||
//toggle mouse cursor
|
||||
music.playef(11);
|
||||
if (graphics.showmousecursor == true) {
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
graphics.showmousecursor = false;
|
||||
}
|
||||
else {
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
graphics.showmousecursor = true;
|
||||
}
|
||||
game.savestatsandsettings_menu();
|
||||
break;
|
||||
case 1:
|
||||
// toggle unfocus pause
|
||||
game.disablepause = !game.disablepause;
|
||||
game.savestatsandsettings_menu();
|
||||
music.playef(11);
|
||||
break;
|
||||
case 2:
|
||||
case 1:
|
||||
// toggle translucent roomname BG
|
||||
graphics.translucentroomname = !graphics.translucentroomname;
|
||||
game.savestatsandsettings_menu();
|
||||
|
|
|
@ -81,8 +81,60 @@ void KeyPoll::toggleFullscreen(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int changemousestate(
|
||||
int timeout,
|
||||
const bool show,
|
||||
const bool hide
|
||||
) {
|
||||
int prev;
|
||||
int new_;
|
||||
|
||||
if (timeout > 0)
|
||||
{
|
||||
return --timeout;
|
||||
}
|
||||
|
||||
/* If we want to both show and hide at the same time, prioritize showing */
|
||||
if (show)
|
||||
{
|
||||
new_ = SDL_ENABLE;
|
||||
}
|
||||
else if (hide)
|
||||
{
|
||||
new_ = SDL_DISABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return timeout;
|
||||
}
|
||||
|
||||
prev = SDL_ShowCursor(SDL_QUERY);
|
||||
|
||||
if (prev == new_)
|
||||
{
|
||||
return timeout;
|
||||
}
|
||||
|
||||
SDL_ShowCursor(new_);
|
||||
|
||||
switch (new_)
|
||||
{
|
||||
case SDL_DISABLE:
|
||||
timeout = 0;
|
||||
break;
|
||||
case SDL_ENABLE:
|
||||
timeout = 30;
|
||||
break;
|
||||
}
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
void KeyPoll::Poll(void)
|
||||
{
|
||||
static int mousetoggletimeout = 0;
|
||||
bool showmouse = false;
|
||||
bool hidemouse = false;
|
||||
bool altpressed = false;
|
||||
bool fullscreenkeybind = false;
|
||||
SDL_Event evt;
|
||||
|
@ -324,7 +376,32 @@ void KeyPoll::Poll(void)
|
|||
VVV_exit(0);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (evt.type)
|
||||
{
|
||||
case SDL_KEYDOWN:
|
||||
if (evt.key.repeat == 0)
|
||||
{
|
||||
hidemouse = true;
|
||||
}
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
hidemouse = true;
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
showmouse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mousetoggletimeout = changemousestate(
|
||||
mousetoggletimeout,
|
||||
showmouse,
|
||||
hidemouse
|
||||
);
|
||||
|
||||
if (fullscreenkeybind)
|
||||
{
|
||||
|
|
|
@ -595,17 +595,6 @@ static void menurender(void)
|
|||
switch (game.currentmenuoption)
|
||||
{
|
||||
case 0:
|
||||
graphics.bigprint(-1, 30, "Toggle Mouse Cursor", tr, tg, tb, true);
|
||||
graphics.Print(-1, 65, "Show/hide the system mouse cursor.", tr, tg, tb, true);
|
||||
|
||||
if (graphics.showmousecursor) {
|
||||
graphics.Print(-1, 95, "Current mode: SHOW", tr, tg, tb, true);
|
||||
}
|
||||
else {
|
||||
graphics.Print(-1, 95, "Current mode: HIDE", tr/2, tg/2, tb/2, true);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
graphics.bigprint( -1, 30, "Unfocus Pause", tr, tg, tb, true);
|
||||
graphics.Print( -1, 65, "Toggle if the game will pause", tr, tg, tb, true);
|
||||
graphics.Print( -1, 75, "when the window is unfocused.", tr, tg, tb, true);
|
||||
|
@ -618,7 +607,7 @@ static void menurender(void)
|
|||
graphics.Print(-1, 95, "Unfocus pause is ON", tr, tg, tb, true);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 1:
|
||||
graphics.bigprint(-1, 30, "Room Name BG", tr, tg, tb, true);
|
||||
graphics.Print( -1, 65, "Lets you see through what is behind", tr, tg, tb, true);
|
||||
graphics.Print( -1, 75, "the name at the bottom of the screen.", tr, tg, tb, true);
|
||||
|
|
Loading…
Reference in a new issue