From 6e9712f113388af4e3711773555e55c8620102b1 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Fri, 17 Jan 2020 12:37:53 -0500 Subject: [PATCH] Add text outline as an accessibility option --- desktop_version/src/Game.cpp | 25 ++++++++++++++++++------- desktop_version/src/Graphics.cpp | 26 +++++++++++++++----------- desktop_version/src/Graphics.h | 1 + desktop_version/src/Input.cpp | 13 ++++++++++--- desktop_version/src/titlerender.cpp | 18 ++++++++++++++++-- 5 files changed, 60 insertions(+), 23 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index c2881233..ca63357f 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -4438,6 +4438,11 @@ void Game::loadstats( mapclass& map, Graphics& dwgfx ) skipfakeload = atoi(pText); } + if (pKey == "notextoutline") + { + dwgfx.notextoutline = atoi(pText); + } + if (pKey == "flipButton") { SDL_GameControllerButton newButton; @@ -4647,6 +4652,10 @@ void Game::savestats( mapclass& _map, Graphics& _dwgfx ) msg->LinkEndChild(new TiXmlText(tu.String((int) skipfakeload).c_str())); dataNode->LinkEndChild(msg); + msg = new TiXmlElement("notextoutline"); + msg->LinkEndChild(new TiXmlText(tu.String((int) _dwgfx.notextoutline).c_str())); + dataNode->LinkEndChild(msg); + for (size_t i = 0; i < controllerButton_flip.size(); i += 1) { msg = new TiXmlElement("flipButton"); @@ -7025,17 +7034,19 @@ void Game::createmenu( std::string t ) menuoptionsactive[0] = true; menuoptions[1] = "screen effects"; menuoptionsactive[1] = true; - menuoptions[2] = "invincibility"; + menuoptions[2] = "text outline"; menuoptionsactive[2] = true; - menuoptions[3] = "slowdown"; + menuoptions[3] = "invincibility"; menuoptionsactive[3] = true; - menuoptions[4] = "load screen"; + menuoptions[4] = "slowdown"; menuoptionsactive[4] = true; - menuoptions[5] = "return"; + menuoptions[5] = "load screen"; menuoptionsactive[5] = true; - nummenuoptions = 6; - menuxoff = -40; - menuyoff = 16; + menuoptions[6] = "return"; + menuoptionsactive[6] = true; + nummenuoptions = 7; + menuxoff = -60; + menuyoff = 0; } else if(t == "controller") { diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 3b79f5e9..e9d1c84a 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -31,6 +31,7 @@ Graphics::Graphics() showcutscenebars = false; cutscenebarspos = 0; + notextoutline = false; flipmode = false; setflipmode = false; @@ -380,19 +381,22 @@ void Graphics::bprint( int x, int y, std::string t, int r, int g, int b, bool ce { //printmask(x, y, t, cen); - Print(x, y - 1, t, 0, 0, 0, cen); - if (cen) + if (!notextoutline) { - //TODO find different - PrintOff(-1, y, t, 0, 0, 0, cen); - PrintOff(1, y, t, 0, 0, 0, cen); + Print(x, y - 1, t, 0, 0, 0, cen); + if (cen) + { + //TODO find different + PrintOff(-1, y, t, 0, 0, 0, cen); + PrintOff(1, y, t, 0, 0, 0, cen); + } + else + { + Print(x -1, y, t, 0, 0, 0, cen); + Print(x +1, y, t, 0, 0, 0, cen); + } + Print(x, y+1, t, 0, 0, 0, cen); } - else - { - Print(x -1, y, t, 0, 0, 0, cen); - Print(x +1, y, t, 0, 0, 0, cen); - } - Print(x, y+1, t, 0, 0, 0, cen); Print(x, y, t, r, g, b, cen); } diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 95cf1242..09393369 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -216,6 +216,7 @@ public: bool flipmode; bool setflipmode; + bool notextoutline; point tl; //buffer objects. //TODO refactor buffer objects SDL_Surface* backBuffer; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 847c2600..f9ed33de 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -713,6 +713,13 @@ SDL_assert(0 && "Remove open level dir"); } } else if (game.currentmenuoption == 2) + { + //disable text outline + dwgfx.notextoutline = !dwgfx.notextoutline; + game.savestats(map, dwgfx); + music.playef(11, 10); + } + else if (game.currentmenuoption == 3) { //invincibility if (!map.invincibility) @@ -726,20 +733,20 @@ SDL_assert(0 && "Remove open level dir"); } music.playef(11, 10); } - else if (game.currentmenuoption == 3) + else if (game.currentmenuoption == 4) { //change game speed game.createmenu("setslowdown2"); map.nexttowercolour(); music.playef(11, 10); } - else if (game.currentmenuoption == 4) + else if (game.currentmenuoption == 5) { // toggle fake load screen game.skipfakeload = !game.skipfakeload; music.playef(11, 10); } - else if (game.currentmenuoption == 5) + else if (game.currentmenuoption == 6) { //back music.playef(11, 10); diff --git a/desktop_version/src/titlerender.cpp b/desktop_version/src/titlerender.cpp index 209a6001..9079b29e 100644 --- a/desktop_version/src/titlerender.cpp +++ b/desktop_version/src/titlerender.cpp @@ -496,6 +496,20 @@ void titlerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, U } } else if (game.currentmenuoption == 2) + { + dwgfx.bigprint( -1, 40, "Text Outline", tr, tg, tb, true); + dwgfx.Print( -1, 75, "Disables outline on game text", tr, tg, tb, true); + // FIXME: Maybe do an outlined print instead? -flibit + if (!dwgfx.notextoutline) + { + dwgfx.Print( -1, 85, "Text outlines are ON.", tr, tg, tb, true); + } + else + { + dwgfx.Print( -1, 85, "Text outlines are OFF.", tr/2, tg/2, tb/2, true); + } + } + else if (game.currentmenuoption == 3) { dwgfx.bigprint( -1, 40, "Invincibility", tr, tg, tb, true); dwgfx.Print( -1, 75, "Provided to help disabled gamers", tr, tg, tb, true); @@ -509,7 +523,7 @@ void titlerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, U dwgfx.Print( -1, 105, "Invincibility is off.", tr/2, tg/2, tb/2, true); } } - else if (game.currentmenuoption == 3) + else if (game.currentmenuoption == 4) { dwgfx.bigprint( -1, 40, "Game Speed", tr, tg, tb, true); dwgfx.Print( -1, 75, "May be useful for disabled gamers", tr, tg, tb, true); @@ -531,7 +545,7 @@ void titlerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, U dwgfx.Print( -1, 105, "Game speed is at 40%", tr, tg, tb, true); } } - else if (game.currentmenuoption == 4) + else if (game.currentmenuoption == 5) { dwgfx.bigprint(-1, 30, "Fake Load Screen", tr, tg, tb, true); if (game.skipfakeload)