From aa3c1c80531fdb2de123ca22b046e57935d6828e Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 20 Jun 2020 18:33:55 -0700 Subject: [PATCH] Add Graphics::map_tab() This function is useful to de-duplicate all the map page names at the bottom, which are MAP, CREW/SHIP/GRAV, STATS, and SAVE. If selected, it will surround the text in square brackets and automatically handle the positioning. Shamelessly copy-pasted from Dav999's localization branch. --- desktop_version/src/Graphics.cpp | 13 +++++++++++++ desktop_version/src/Graphics.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 548fd95f..76a32a63 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -301,6 +301,19 @@ void Graphics::MakeSpriteArray() } +void Graphics::map_tab(int opt, const std::string& text, bool selected /*= false*/) +{ + int x = opt*80 + 40 - len(text)/2; + if (selected) + { + Print(x-8, 220, "[" + text + "]", 196, 196, 255 - help.glow); + } + else + { + Print(x, 220, text, 64, 64, 64); + } +} + 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 906bffb3..05218340 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -111,6 +111,8 @@ public: void printcrewnamedark(int x, int y, int t); + void map_tab(int opt, 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);