From a402c990bf7fd01ec810092fd3f6d5fc83b520c8 Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 22 Jun 2020 15:23:15 -0700 Subject: [PATCH] Add Graphics::map_option() Similar to Graphics::map_tab(), this ensures that I don't have to copy-paste printing the map options for every single game.menupage case I want, and in this case that's a good thing because there'll be 4 game.menupage cases I'll be using. --- desktop_version/src/Graphics.cpp | 28 ++++++++++++++++++++++++++++ desktop_version/src/Graphics.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 76a32a63..f5f3aece 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -314,6 +314,34 @@ void Graphics::map_tab(int opt, const std::string& text, bool selected /*= false } } +void Graphics::map_option(int opt, int num_opts, const std::string& text, bool selected /*= false*/) +{ + int x = 80 + opt*32; + int y = 136; // start from middle of menu + + int yoff = -(num_opts * 12) / 2; // could be simplified to -num_opts * 6, this conveys my intent better though + yoff += opt * 12; + + if (flipmode) + { + y -= yoff; // going down, which in Flip Mode means going up + y -= 40; + } + else + { + y += yoff; // going up + } + + if (selected) + { + Print(x - 16, y, "[ " + text + " ]", 196, 196, 255 - help.glow); + } + else + { + Print(x, y, text, 96, 96, 96); + } +} + void Graphics::Print( int _x, int _y, std::string _s, int r, int g, int b, bool cen /*= false*/ ) { return PrintAlpha(_x,_y,_s,r,g,b,255,cen); } diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 05218340..dfa01ab8 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -113,6 +113,8 @@ public: void map_tab(int opt, const std::string& text, bool selected = false); + void map_option(int opt, int num_opts, const std::string& text, bool selected = false); + void Print(int _x, int _y, std::string _s, int r, int g, int b, bool cen = false); void PrintAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);