From 85b16b969acc173c02f8e49ae984022cb853dc28 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 16 Apr 2020 23:05:49 -0700 Subject: [PATCH] Add a "previous page" option to the levels list This makes it more convenient if you have a large levels directory, as some people in the VVVVVV custom levels community do. On the first page, this option will change to be "last page" instead. Since the addition of another menu option pushes up the list of levels too close to the selected level data itself, I've had to move the list of levels down by 4 pixels (but "next page"/"previous page"/"return to menu" are still in their same position). This feature was already added to VCE but hasn't been upstreamed until now. --- desktop_version/src/Game.cpp | 8 ++++++++ desktop_version/src/Graphics.cpp | 12 ++++++------ desktop_version/src/Input.cpp | 13 ++++++++++++- desktop_version/src/Render.cpp | 4 ++-- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 02d8f996..a7a10dd0 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6690,6 +6690,14 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) { option("first page"); } + if (levelpage == 0) + { + option("last page"); + } + else + { + option("previous page"); + } option("return to menu"); menuxoff = -90; diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index cf0274a1..be6684d5 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1129,7 +1129,7 @@ void Graphics::drawlevelmenu( int cr, int cg, int cb, int division /*= 30*/ ) { if ((int) i == game.currentmenuoption) { - if(game.menuoptions.size()-i<=2){ + if(game.menuoptions.size()-i<=3){ //Draw it highlighted if (game.menuoptions[i].active) { @@ -1152,20 +1152,20 @@ void Graphics::drawlevelmenu( int cr, int cg, int cb, int division /*= 30*/ ) std::string tempstring = game.menuoptions[i].text; std::transform(tempstring.begin(), tempstring.end(),tempstring.begin(), ::toupper); tempstring = std::string("[ ") + tempstring + std::string(" ]"); - Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb); + Print(110 + (i * division) - 16 +game.menuxoff, 144 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb); } else { std::string tempstring = game.menuoptions[i].text; tempstring = "[ " + tempstring + " ]"; //Draw it in gray - Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128); + Print(110 + (i * division) - 16 +game.menuxoff, 144 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128); } } } else { - if(game.menuoptions.size()-i<=2){ + if(game.menuoptions.size()-i<=3){ //Draw it normally if (game.menuoptions[i].active) { @@ -1180,12 +1180,12 @@ void Graphics::drawlevelmenu( int cr, int cg, int cb, int division /*= 30*/ ) //Draw it normally if (game.menuoptions[i].active) { - Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i].text, cr, cg, cb); + Print(110 + (i * division) +game.menuxoff, 144 + (i * 12)+game.menuyoff, game.menuoptions[i].text, cr, cg, cb); } else { //Draw it in gray - Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i].text, 128, 128, 128); + Print(110 + (i * division) +game.menuxoff, 144 + (i * 12)+game.menuyoff, game.menuoptions[i].text, 128, 128, 128); } } } diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 3853ab5a..2fb71da1 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -199,6 +199,17 @@ void menuactionpress() game.returnmenu(); map.nexttowercolour(); }else if(game.currentmenuoption==(int)game.menuoptions.size()-2){ + //previous page + music.playef(11); + if(game.levelpage==0){ + game.levelpage=(ed.ListOfMetaData.size()-1)/8; + }else{ + game.levelpage--; + } + game.createmenu(Menu::levellist, true); + game.currentmenuoption=game.menuoptions.size()-2; + map.nexttowercolour(); + }else if(game.currentmenuoption==(int)game.menuoptions.size()-3){ //next page music.playef(11); if((size_t) ((game.levelpage*8)+8) >= ed.ListOfMetaData.size()){ @@ -207,7 +218,7 @@ void menuactionpress() game.levelpage++; } game.createmenu(Menu::levellist, true); - game.currentmenuoption=game.menuoptions.size()-2; + game.currentmenuoption=game.menuoptions.size()-3; map.nexttowercolour(); }else{ //Ok, launch the level! diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index b7c11431..2ebe2a1a 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -46,8 +46,8 @@ void menurender() } int tmp=game.currentmenuoption+(game.levelpage*8); if(tmp>=0 && tmp < (int) ed.ListOfMetaData.size()){ // FIXME: size_t/int! -flibit - //Don't show next page or return to menu options here! - if(game.menuoptions.size() - game.currentmenuoption<=2){ + //Don't show next/previous page or return to menu options here! + if(game.menuoptions.size() - game.currentmenuoption<=3){ }else{ graphics.bigprint( -1, 15, ed.ListOfMetaData[tmp].title, tr, tg, tb, true);