1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-24 13:38:29 +02:00

Add graphics option to toggle mouse cursor

Adds an option to show or hide the system mouse cursor over the game window.
This commit is contained in:
Allison Fleischer 2020-01-28 23:17:13 -08:00 committed by Ethan Lee
parent 5afba66d2e
commit 03a4c3362a
5 changed files with 47 additions and 2 deletions

View File

@ -4448,6 +4448,11 @@ void Game::loadstats( mapclass& map, Graphics& dwgfx )
dwgfx.translucentroomname = atoi(pText);
}
if (pKey == "showmousecursor")
{
dwgfx.showmousecursor = atoi(pText);
}
if (pKey == "flipButton")
{
SDL_GameControllerButton newButton;
@ -4496,6 +4501,14 @@ void Game::loadstats( mapclass& map, Graphics& dwgfx )
}
dwgfx.screenbuffer->ResizeScreen(width, height);
if (dwgfx.showmousecursor == true)
{
SDL_ShowCursor(SDL_ENABLE);
}
else {
SDL_ShowCursor(SDL_DISABLE);
}
if (controllerButton_flip.size() < 1)
{
controllerButton_flip.push_back(SDL_CONTROLLER_BUTTON_A);
@ -4665,6 +4678,10 @@ void Game::savestats( mapclass& _map, Graphics& _dwgfx )
msg->LinkEndChild(new TiXmlText(tu.String((int) _dwgfx.translucentroomname).c_str()));
dataNode->LinkEndChild(msg);
msg = new TiXmlElement("showmousecursor");
msg->LinkEndChild(new TiXmlText(tu.String((int)_dwgfx.showmousecursor).c_str()));
dataNode->LinkEndChild(msg);
for (size_t i = 0; i < controllerButton_flip.size(); i += 1)
{
msg = new TiXmlElement("flipButton");
@ -6888,9 +6905,11 @@ void Game::createmenu( std::string t )
menuoptionsactive[2] = true;
menuoptions[3] = "toggle analogue";
menuoptionsactive[3] = true;
menuoptions[4] = "return";
menuoptions[4] = "toggle mouse";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuoptions[5] = "return";
menuoptionsactive[5] = true;
nummenuoptions = 6;
menuxoff = -50;
menuyoff = 8;
/* Old stuff, not used anymore

View File

@ -124,6 +124,7 @@ Graphics::Graphics()
warprect = SDL_Rect();
translucentroomname = false;
showmousecursor = true;
}
Graphics::~Graphics()

View File

@ -278,6 +278,8 @@ public:
int warpskip, warpfcol, warpbcol;
bool translucentroomname;
bool showmousecursor;
};
#endif /* GRAPHICS_H */

View File

@ -460,6 +460,17 @@ SDL_assert(0 && "Remove open level dir");
game.savestats(map, dwgfx);
game.createmenu("graphicoptions");
game.currentmenuoption = 3;
}else if (game.currentmenuoption == 4) {
//toggle mouse cursor
music.playef(11, 10);
if (dwgfx.showmousecursor == true) {
SDL_ShowCursor(SDL_DISABLE);
dwgfx.showmousecursor = false;
}
else {
SDL_ShowCursor(SDL_ENABLE);
dwgfx.showmousecursor = true;
}
}
else
{

View File

@ -230,6 +230,18 @@ void titlerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, U
dwgfx.Print( -1, 75, "television set. Do not attempt to", tr, tg, tb, true);
dwgfx.Print( -1, 85, "adjust the picture.", tr, tg, tb, true);
}
else if (game.currentmenuoption == 4)
{
dwgfx.bigprint(-1, 30, "Toggle Mouse Cursor", tr, tg, tb, true);
dwgfx.Print(-1, 65, "Show/hide the system mouse cursor.", tr, tg, tb, true);
if (dwgfx.showmousecursor) {
dwgfx.Print(-1, 85, "Current mode: SHOW", tr, tg, tb, true);
}
else {
dwgfx.Print(-1, 85, "Current mode: HIDE", tr, tg, tb, true);
}
}
}
else if (game.currentmenuname == "credits")
{