From c3dfd4a4b1817d2546c300c8bf5021d223685236 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 25 Sep 2021 17:16:52 -0700 Subject: [PATCH] De-duplicate map menu stats screen rendering code Between accounting for Flip Mode and custom levels, this code was copy-pasted three times, leading to _four_ instances of one code! Anyways, I've cleaned it up. The position of the text in Flip Mode is going to differ by 4 pixels from how it was previously, but that really shouldn't matter. --- desktop_version/src/Render.cpp | 63 +++++++++------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 96ca1ba0..ad748770 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2468,59 +2468,30 @@ void maprender(void) } break; case 2: -#if !defined(NO_CUSTOM_LEVELS) - if(map.custommode) + { + int total; +#ifndef NO_CUSTOM_LEVELS + if (map.custommode) { - if (graphics.flipmode) - { - graphics.Print(0, 164, "[Trinkets found]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 152, help.number_words(game.trinkets()) + " out of " + help.number_words(cl.numtrinkets()), 96,96,96, true); - - graphics.Print(0, 114, "[Number of Deaths]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 102,help.String(game.deathcounts), 96,96,96, true); - - graphics.Print(0, 64, "[Time Taken]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 52, game.timestring(), 96, 96, 96, true); - } - else - { - graphics.Print(0, 52, "[Trinkets found]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 64, help.number_words(game.trinkets()) + " out of "+help.number_words(cl.numtrinkets()), 96,96,96, true); - - graphics.Print(0, 102, "[Number of Deaths]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 114,help.String(game.deathcounts), 96,96,96, true); - - graphics.Print(0, 152, "[Time Taken]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 164, game.timestring(), 96, 96, 96, true); - } + total = cl.numtrinkets(); } else #endif { - if (graphics.flipmode) - { - graphics.Print(0, 164, "[Trinkets found]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 152, help.number_words(game.trinkets()) + " out of Twenty", 96,96,96, true); - - graphics.Print(0, 114, "[Number of Deaths]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 102,help.String(game.deathcounts), 96,96,96, true); - - graphics.Print(0, 64, "[Time Taken]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 52, game.timestring(), 96, 96, 96, true); - } - else - { - graphics.Print(0, 52, "[Trinkets found]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 64, help.number_words(game.trinkets()) + " out of Twenty", 96,96,96, true); - - graphics.Print(0, 102, "[Number of Deaths]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 114,help.String(game.deathcounts), 96,96,96, true); - - graphics.Print(0, 152, "[Time Taken]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 164, game.timestring(), 96, 96, 96, true); - } + total = 20; } + + /* Stats. */ + graphics.Print(0, FLIP(52), "[Trinkets found]", 196, 196, 255 - help.glow, true); + graphics.Print(0, FLIP(64), help.number_words(game.trinkets()) + " out of " + help.number_words(total), 96, 96, 96, true); + + graphics.Print(0, FLIP(102), "[Number of Deaths]", 196, 196, 255 - help.glow, true); + graphics.Print(0, FLIP(114), help.String(game.deathcounts), 96, 96, 96, true); + + graphics.Print(0, FLIP(152), "[Time Taken]", 196, 196, 255 - help.glow, true); + graphics.Print(0, FLIP(164), game.timestring(), 96, 96, 96, true); break; + } case 3: if (game.inintermission) {