From 6c66f7248db86cddd01cd901e797acb53c53856b Mon Sep 17 00:00:00 2001 From: lsaa <39929221+lsaa@users.noreply.github.com> Date: Thu, 5 Aug 2021 18:31:20 -0300 Subject: [PATCH] Add in-game timer option (#790) --- desktop_version/CONTRIBUTORS.txt | 1 + desktop_version/src/Game.cpp | 14 ++++++++++++++ desktop_version/src/Game.h | 2 ++ desktop_version/src/Input.cpp | 6 ++++++ desktop_version/src/Render.cpp | 17 +++++++++++++++++ 5 files changed, 40 insertions(+) diff --git a/desktop_version/CONTRIBUTORS.txt b/desktop_version/CONTRIBUTORS.txt index ef98c555..c7d47057 100644 --- a/desktop_version/CONTRIBUTORS.txt +++ b/desktop_version/CONTRIBUTORS.txt @@ -12,6 +12,7 @@ Contributors * Dav999 (Dav999-v) * Allison Fleischer (AllisonFleischer) * Malte Grimm (@trelbutate) +* KyoZM (@lsaa) * Daniel Lee (@ddm999) * Fredrik Ljungdahl (@FredrIQ) * Nichole Mattera (@NicholeMattera) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 004c68c5..45eec122 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -380,6 +380,7 @@ void Game::init(void) fadetolabdelay = 0; over30mode = true; + showingametimer = false; ingame_titlemode = false; #if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) @@ -4212,6 +4213,11 @@ void Game::deserializesettings(tinyxml2::XMLElement* dataNode, ScreenSettings* s GlitchrunnerMode_set(GlitchrunnerMode_string_to_enum(pText)); } + if (SDL_strcmp(pKey, "showingametimer") == 0) + { + showingametimer = help.Int(pText); + } + if (SDL_strcmp(pKey, "vsync") == 0) { screen_settings->useVsync = help.Int(pText); @@ -4477,6 +4483,8 @@ void Game::serializesettings(tinyxml2::XMLElement* dataNode, const ScreenSetting GlitchrunnerMode_enum_to_string(GlitchrunnerMode_get()) ); + xml::update_tag(dataNode, "showingametimer", (int) showingametimer); + xml::update_tag(dataNode, "vsync", (int) screen_settings->useVsync); xml::update_tag(dataNode, "musicvolume", music.user_music_volume); @@ -6091,6 +6099,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) option("input delay"); option("interact button"); option("fake load screen"); + option("toggle in game timer"); option("return"); menuyoff = 0; maxspacing = 15; @@ -6896,3 +6905,8 @@ bool Game::nocompetitive(void) { return slowdown < 30 || map.invincibility; } + +bool Game::isingamecompletescreen() +{ + return (state >= 3501 && state <= 3518) || (state >= 3520 && state <= 3522); +} diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index e7940cf3..4d22e2f5 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -229,6 +229,7 @@ public: bool hascontrol, jumpheld; int jumppressed; int gravitycontrol; + bool isingamecompletescreen(); bool muted; int mutebutton; @@ -460,6 +461,7 @@ public: bool nocompetitive(void); bool over30mode; + bool showingametimer; bool ingame_titlemode; #if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index f2971479..94fcbbad 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -684,6 +684,12 @@ static void menuactionpress(void) game.savestatsandsettings_menu(); music.playef(11); break; + case 4: + // toggle in game timer + game.showingametimer = !game.showingametimer; + game.savestatsandsettings_menu(); + music.playef(11); + break; default: //back music.playef(11); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 32ae7e46..101ffcc0 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -648,6 +648,17 @@ static void menurender(void) else graphics.Print(-1, 65, "Fake loading screen is ON", tr, tg, tb, true); break; + case 4: + graphics.bigprint(-1, 30, "In Game Timer", tr, tg, tb, true); + if (game.showingametimer) + { + graphics.Print(-1, 65, "In Game Timer is ON", tr, tg, tb, true); + } + else + { + graphics.Print(-1, 65, "In Game Timer is OFF", tr / 2, tg / 2, tb / 2, true); + } + break; } break; case Menu::setglitchrunner: @@ -1675,6 +1686,12 @@ void gamerender(void) } } + if (graphics.fademode==0 && !game.intimetrial && !game.isingamecompletescreen() && game.swngame != 1 && game.showingametimer) + { + graphics.bprint(6, 6, "TIME:", 255,255,255); + graphics.bprint(46, 6, game.timestring(), 196, 196, 196); + } + if(map.extrarow==0 || (map.custommode && map.roomname!="")) { graphics.footerrect.y = 230;