From 17e1497024143501f03e871c656f6ed460e74ae1 Mon Sep 17 00:00:00 2001 From: Eric Pierce Date: Thu, 13 Jan 2022 19:17:41 -0700 Subject: [PATCH] Add overmap_loc_text and some better comments - Adds a new overmap_loc_text widget variable, showing overmap coords - Add overmap_location_desc to custom sidebar - Documentation --- data/json/ui/overmap.json | 8 ++++++++ data/json/ui/sidebar.json | 1 + doc/SIDEBAR_MOD.md | 1 + src/widget.cpp | 15 +++++++++++++-- src/widget.h | 1 + 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/data/json/ui/overmap.json b/data/json/ui/overmap.json index b530a63679..e2b7bc9bd8 100644 --- a/data/json/ui/overmap.json +++ b/data/json/ui/overmap.json @@ -8,5 +8,13 @@ "width": 0, "height": 7, "flags": [ "W_LABEL_NONE" ] + }, + { + "id": "overmap_location_desc", + "type": "widget", + "label": "Location", + "var": "overmap_loc_text", + "style": "text", + "flags": [ "W_LABEL_NONE" ] } ] diff --git a/data/json/ui/sidebar.json b/data/json/ui/sidebar.json index ac17c31750..5fd59f4135 100644 --- a/data/json/ui/sidebar.json +++ b/data/json/ui/sidebar.json @@ -18,6 +18,7 @@ "weapon_style_layout", "place_date_time_layout", "overmap_full_width", + "overmap_location_desc", "light_moon_wind_temp_layout", "vehicle_azimuth_cruise_fuel_layout", "vital_numbers_layout", diff --git a/doc/SIDEBAR_MOD.md b/doc/SIDEBAR_MOD.md index 8bada56695..f02aea66f9 100644 --- a/doc/SIDEBAR_MOD.md +++ b/doc/SIDEBAR_MOD.md @@ -552,6 +552,7 @@ Some vars refer to text descriptors. These must use style "text". Examples: | `moon_phase_text` | Phase of the moon - "New moon", "Waxing gibbous", "Full moon" etc. | `move_mode_letter` | Movement mode - "W": walking, "R": running, "C": crouching, "P": prone | `move_mode_text` | Movement mode - "walking", "running", "crouching", "prone" +| `overmap_loc_text` | Overmap coordinates, same as shown in the lower corner of overmap screen | `overmap_text` | Colored text rendering of the local overmap; may define "width" and "height" | `pain_text` | "Mild pain", "Distracting pain", "Intense pain", etc. | `place_text` | Location place name diff --git a/src/widget.cpp b/src/widget.cpp index dd82b6326a..c3c9d0332e 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -141,6 +141,8 @@ std::string enum_to_string( widget_var data ) return "move_mode_text"; case widget_var::pain_text: return "pain_text"; + case widget_var::overmap_loc_text: + return "overmap_loc_text"; case widget_var::overmap_text: return "overmap_text"; case widget_var::place_text: @@ -517,6 +519,7 @@ bool widget::uses_text_function() case widget_var::move_mode_letter: case widget_var::move_mode_text: case widget_var::pain_text: + case widget_var::overmap_loc_text: case widget_var::overmap_text: case widget_var::place_text: case widget_var::power_text: @@ -544,10 +547,15 @@ bool widget::uses_text_function() std::string widget::color_text_function_string( const avatar &ava, unsigned int max_width ) { std::string ret; - bool apply_color = true; + // Most text variables have both a string and a color. + // The string and color in `desc` will be converted to colorized text with markup. std::pair desc; - // Give a default color (some widget_vars do not define one) + // Set a default color desc.second = c_light_gray; + // By default, colorize the string in desc.first with the color in desc.second. + bool apply_color = true; + // Some helper display:: functions do their own internal colorization of the string. + // For those, desc.first is the already-colorized string, and apply_color is set to false. switch( _var ) { case widget_var::activity_text: desc = display::activity_text_color( ava ); @@ -592,6 +600,9 @@ std::string widget::color_text_function_string( const avatar &ava, unsigned int case widget_var::pain_text: desc = display::pain_text_color( ava ); break; + case widget_var::overmap_loc_text: + desc.first = display::overmap_position_text( ava.global_omt_location() ); + break; case widget_var::overmap_text: desc.first = display::colorized_overmap_text( ava, _width == 0 ? max_width : _width, _height ); apply_color = false; diff --git a/src/widget.h b/src/widget.h index 6b673e18a1..cdff39b2e8 100644 --- a/src/widget.h +++ b/src/widget.h @@ -59,6 +59,7 @@ enum class widget_var : int { moon_phase_text,// Current phase of the moon move_mode_letter, // Movement mode, color letter (W/R/C/P) move_mode_text, // Movement mode, color text (walking/running/crouching/prone) + overmap_loc_text,// Local overmap position, pseudo latitude/longitude with Z-level overmap_text, // Local overmap and mission marker, multi-line color string pain_text, // Pain description text, color string place_text, // Place name in world where character is -- GitLab