aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extension/src/openvic-extension/classes/GFXPieChartTexture.cpp97
-rw-r--r--extension/src/openvic-extension/classes/GFXPieChartTexture.hpp13
-rw-r--r--extension/src/openvic-extension/classes/GUIButton.cpp12
-rw-r--r--extension/src/openvic-extension/classes/GUIButton.hpp7
-rw-r--r--extension/src/openvic-extension/classes/GUIHasTooltip.hpp121
-rw-r--r--extension/src/openvic-extension/classes/GUILabel.cpp57
-rw-r--r--extension/src/openvic-extension/classes/GUILabel.hpp7
-rw-r--r--extension/src/openvic-extension/classes/GUIPieChart.cpp80
-rw-r--r--extension/src/openvic-extension/classes/GUIPieChart.hpp13
-rw-r--r--extension/src/openvic-extension/classes/GUIProgressBar.cpp12
-rw-r--r--extension/src/openvic-extension/classes/GUIProgressBar.hpp7
-rw-r--r--extension/src/openvic-extension/classes/GUIScrollbar.cpp15
-rw-r--r--extension/src/openvic-extension/classes/GUIScrollbar.hpp4
-rw-r--r--extension/src/openvic-extension/classes/GUITextureRect.cpp12
-rw-r--r--extension/src/openvic-extension/classes/GUITextureRect.hpp9
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.cpp33
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.hpp14
-rw-r--r--game/src/Game/GameSession/GameSession.tscn8
-rw-r--r--game/src/Game/GameSession/NationManagementScreen/BudgetMenu.gd21
-rw-r--r--game/src/Game/GameSession/NationManagementScreen/PopulationMenu.gd93
-rw-r--r--game/src/Game/GameSession/Tooltip.gd23
-rw-r--r--game/src/Game/GameSession/Topbar.gd99
22 files changed, 661 insertions, 96 deletions
diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
index 417566d..5d955a3 100644
--- a/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
+++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.cpp
@@ -7,6 +7,7 @@
using namespace godot;
using namespace OpenVic;
+using namespace OpenVic::Utilities::literals;
StringName const& GFXPieChartTexture::_slice_identifier_key() {
static const StringName slice_identifier_key = "identifier";
@@ -21,7 +22,35 @@ StringName const& GFXPieChartTexture::_slice_weight_key() {
return slice_weight_key;
}
-static constexpr float TWO_PI = 2.0f * std::numbers::pi_v<float>;
+GFXPieChartTexture::slice_t const* GFXPieChartTexture::get_slice(Vector2 const& position) const {
+ if (slices.empty() || position.length_squared() > 1.0_real) {
+ return nullptr;
+ }
+
+ static constexpr float TWO_PI = 2.0f * std::numbers::pi_v<float>;
+
+ /* Calculate the anti-clockwise angle between the point and the centre of the image.
+ * The y coordinate is negated as the image coordinate system's y increases downwards. */
+ float theta = atan2(-position.y, position.x);
+ if (theta < 0.0f) {
+ theta += TWO_PI;
+ }
+
+ /* Rescale angle so that total_weight is a full rotation. */
+ theta *= total_weight / TWO_PI;
+
+ /* Find the slice theta lies in. */
+ for (slice_t const& slice : slices) {
+ theta -= slice.weight;
+
+ if (theta <= 0.0f) {
+ return &slice;
+ }
+ }
+
+ /* Default to the first slice in case theta never reaches 0 due to floating point inaccuracy. */
+ return &slices.front();
+}
Error GFXPieChartTexture::_generate_pie_chart_image() {
ERR_FAIL_NULL_V(gfx_pie_chart, FAILED);
@@ -30,60 +59,37 @@ Error GFXPieChartTexture::_generate_pie_chart_image() {
vformat("Invalid GFX::PieChart size for GFXPieChartTexture - %d", gfx_pie_chart->get_size())
);
- const int32_t pie_chart_size = 2 * gfx_pie_chart->get_size();
+ const int32_t pie_chart_radius = gfx_pie_chart->get_size();
+ const int32_t pie_chart_diameter = 2 * pie_chart_radius;
/* Whether we've already set the ImageTexture to an image of the right dimensions,
* and so can update it without creating and setting a new image, or not. */
- const bool can_update = pie_chart_image.is_valid() && pie_chart_image->get_width() == pie_chart_size
- && pie_chart_image->get_height() == pie_chart_size;
+ const bool can_update = pie_chart_image.is_valid() && pie_chart_image->get_width() == pie_chart_diameter
+ && pie_chart_image->get_height() == pie_chart_diameter;
if (!can_update) {
- pie_chart_image = Image::create(pie_chart_size, pie_chart_size, false, Image::FORMAT_RGBA8);
+ pie_chart_image = Image::create(pie_chart_diameter, pie_chart_diameter, false, Image::FORMAT_RGBA8);
ERR_FAIL_NULL_V(pie_chart_image, FAILED);
}
static const Color background_colour { 0.0f, 0.0f, 0.0f, 0.0f };
if (!slices.empty()) {
- const float pie_chart_radius = gfx_pie_chart->get_size();
-
- const Vector2 centre_translation = Vector2 { 0.5f, 0.5f } - static_cast<Vector2>(pie_chart_image->get_size()) * 0.5f;
-
- for (Vector2i point { 0, 0 }; point.y < pie_chart_image->get_height(); ++point.y) {
-
- for (point.x = 0; point.x < pie_chart_image->get_width(); ++point.x) {
-
- const Vector2 offset = centre_translation + point;
-
- if (offset.length() <= pie_chart_radius) {
-
- /* Calculate the anti-clockwise angle between the point and the centre of the image.
- * The y coordinate is negated as the image coordinate system's y increases downwards. */
- float theta = atan2(-offset.y, offset.x);
- if (theta < 0.0f) {
- theta += TWO_PI;
- }
-
- /* Rescale angle so that total_weight is a full rotation. */
- theta *= total_weight / TWO_PI;
+ for (Vector2i point { 0, 0 }; point.y < pie_chart_diameter; ++point.y) {
- /* Default to the first colour in case theta never reaches 0 due to floating point inaccuracy. */
- Color colour = slices.front().first;
+ for (point.x = 0; point.x < pie_chart_diameter; ++point.x) {
- /* Find the slice theta lies in. */
- for (slice_t const& slice : slices) {
- theta -= slice.second;
+ Vector2 offset = point;
+ // Move to the centre of the pixel
+ offset += Vector2 { 0.5_real, 0.5_real };
+ // Normalise to [0, 2]
+ offset /= pie_chart_radius;
+ // Translate to [-1, 1]
+ offset -= Vector2 { 1.0_real, 1.0_real };
- if (theta <= 0.0f) {
- colour = slice.first;
- break;
- }
- }
+ slice_t const* slice = get_slice(offset);
- pie_chart_image->set_pixelv(point, colour);
- } else {
- pie_chart_image->set_pixelv(point, background_colour);
- }
+ pie_chart_image->set_pixelv(point, slice != nullptr ? slice->colour : background_colour);
}
}
} else {
@@ -107,12 +113,15 @@ Error GFXPieChartTexture::set_slices_array(godot_pie_chart_data_t const& new_sli
for (int32_t i = 0; i < new_slices.size(); ++i) {
Dictionary const& slice_dict = new_slices[i];
ERR_CONTINUE_MSG(
- !slice_dict.has(_slice_colour_key()) || !slice_dict.has(_slice_weight_key()),
+ !slice_dict.has(_slice_identifier_key()) || !slice_dict.has(_slice_colour_key())
+ || !slice_dict.has(_slice_weight_key()),
vformat("Invalid slice keys at index %d", i)
);
- const slice_t slice = std::make_pair(slice_dict[_slice_colour_key()], slice_dict[_slice_weight_key()]);
- if (slice.second > 0.0f) {
- total_weight += slice.second;
+ const slice_t slice {
+ slice_dict[_slice_identifier_key()], slice_dict[_slice_colour_key()], slice_dict[_slice_weight_key()]
+ };
+ if (slice.weight > 0.0f) {
+ total_weight += slice.weight;
slices.push_back(slice);
}
}
diff --git a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp
index 9642f4e..3610efb 100644
--- a/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp
+++ b/extension/src/openvic-extension/classes/GFXPieChartTexture.hpp
@@ -10,11 +10,17 @@ namespace OpenVic {
class GFXPieChartTexture : public godot::ImageTexture {
GDCLASS(GFXPieChartTexture, godot::ImageTexture)
- using slice_t = std::pair<godot::Color, float>;
+ public:
+ struct slice_t {
+ godot::String name;
+ godot::Color colour;
+ float weight;
+ };
+ private:
GFX::PieChart const* PROPERTY(gfx_pie_chart);
std::vector<slice_t> slices;
- float total_weight;
+ float PROPERTY(total_weight);
godot::Ref<godot::Image> pie_chart_image;
static godot::StringName const& _slice_identifier_key();
@@ -29,6 +35,9 @@ namespace OpenVic {
public:
GFXPieChartTexture();
+ // Position must be centred and normalised so that coords are in [-1, 1].
+ slice_t const* get_slice(godot::Vector2 const& position) const;
+
using godot_pie_chart_data_t = godot::TypedArray<godot::Dictionary>;
/* Set slices given an Array of Dictionaries, each with the following key-value entries:
diff --git a/extension/src/openvic-extension/classes/GUIButton.cpp b/extension/src/openvic-extension/classes/GUIButton.cpp
index 323b03c..e35d67a 100644
--- a/extension/src/openvic-extension/classes/GUIButton.cpp
+++ b/extension/src/openvic-extension/classes/GUIButton.cpp
@@ -10,7 +10,17 @@
using namespace godot;
using namespace OpenVic;
-void GUIButton::_bind_methods() {}
+GUI_TOOLTIP_IMPLEMENTATIONS(GUIButton)
+
+void GUIButton::_bind_methods() {
+ GUI_TOOLTIP_BIND_METHODS(GUIButton)
+}
+
+void GUIButton::_notification(int what) {
+ _tooltip_notification(what);
+}
+
+GUIButton::GUIButton() : tooltip_active { false } {}
Error GUIButton::set_gfx_button_state_having_texture(Ref<GFXButtonStateHavingTexture> const& texture) {
ERR_FAIL_NULL_V(texture, FAILED);
diff --git a/extension/src/openvic-extension/classes/GUIButton.hpp b/extension/src/openvic-extension/classes/GUIButton.hpp
index 4e53125..3873a4d 100644
--- a/extension/src/openvic-extension/classes/GUIButton.hpp
+++ b/extension/src/openvic-extension/classes/GUIButton.hpp
@@ -5,17 +5,24 @@
#include <openvic-simulation/interface/GFXSprite.hpp>
#include "openvic-extension/classes/GFXButtonStateTexture.hpp"
+#include "openvic-extension/classes/GUIHasTooltip.hpp"
namespace OpenVic {
class GUIButton : public godot::Button {
GDCLASS(GUIButton, godot::Button)
+ GUI_TOOLTIP_DEFINITIONS
+
protected:
static void _bind_methods();
+ void _notification(int what);
+
godot::Error set_gfx_button_state_having_texture(godot::Ref<GFXButtonStateHavingTexture> const& texture);
public:
+ GUIButton();
+
godot::Error set_gfx_font(GFX::Font const* gfx_font);
};
}
diff --git a/extension/src/openvic-extension/classes/GUIHasTooltip.hpp b/extension/src/openvic-extension/classes/GUIHasTooltip.hpp
new file mode 100644
index 0000000..22413ec
--- /dev/null
+++ b/extension/src/openvic-extension/classes/GUIHasTooltip.hpp
@@ -0,0 +1,121 @@
+#pragma once
+
+#include <godot_cpp/classes/control.hpp>
+#include <godot_cpp/variant/string.hpp>
+#include <godot_cpp/variant/utility_functions.hpp>
+#include <godot_cpp/variant/vector2.hpp>
+
+#include <openvic-simulation/utility/Getters.hpp>
+
+#include "openvic-extension/singletons/MenuSingleton.hpp"
+#include "openvic-extension/utility/ClassBindings.hpp"
+#include "openvic-extension/utility/Utilities.hpp"
+
+/* To add tooltip functionality to a class:
+ * - the class must be derived from Control.
+ * - add GUI_TOOLTIP_DEFINITIONS to the class definition, bearing in mind that it leaves visibility as private.
+ * - add GUI_TOOLTIP_IMPLEMENTATIONS(CLASS) to the class' source file.
+ * - add GUI_TOOLTIP_BIND_METHODS(CLASS) to the class' _bind_methods implementation.
+ * - call _tooltip_notification from the class' _notification method.
+ * - initialise tooltip_active to false in the class' constructor. */
+
+#define GUI_TOOLTIP_DEFINITIONS \
+ public: \
+ void set_tooltip_string_and_substitution_dict( \
+ godot::String const& new_tooltip_string, godot::Dictionary const& new_tooltip_substitution_dict \
+ ); \
+ void set_tooltip_string(godot::String const& new_tooltip_string); \
+ void set_tooltip_substitution_dict(godot::Dictionary const& new_tooltip_substitution_dict); \
+ void clear_tooltip(); \
+ private: \
+ godot::String PROPERTY(tooltip_string); \
+ godot::Dictionary PROPERTY(tooltip_substitution_dict); \
+ bool PROPERTY_CUSTOM_PREFIX(tooltip_active, is); \
+ void _tooltip_notification(int what); \
+ void _set_tooltip_active(bool new_tooltip_active); \
+ void _set_tooltip_visibility(bool visible);
+
+#define GUI_TOOLTIP_IMPLEMENTATIONS(CLASS) \
+ void CLASS::set_tooltip_string_and_substitution_dict( \
+ String const& new_tooltip_string, Dictionary const& new_tooltip_substitution_dict \
+ ) { \
+ if (get_mouse_filter() == MOUSE_FILTER_IGNORE) { \
+ UtilityFunctions::push_error("Tooltips won't work for \"", get_name(), "\" as it has MOUSE_FILTER_IGNORE"); \
+ } \
+ if (tooltip_string != new_tooltip_string || tooltip_substitution_dict != new_tooltip_substitution_dict) { \
+ tooltip_string = new_tooltip_string; \
+ tooltip_substitution_dict = new_tooltip_substitution_dict; \
+ if (tooltip_active) { \
+ _set_tooltip_visibility(!tooltip_string.is_empty()); \
+ } \
+ } \
+ } \
+ void CLASS::set_tooltip_string(String const& new_tooltip_string) { \
+ if (get_mouse_filter() == MOUSE_FILTER_IGNORE) { \
+ UtilityFunctions::push_error("Tooltips won't work for \"", get_name(), "\" as it has MOUSE_FILTER_IGNORE"); \
+ } \
+ if (tooltip_string != new_tooltip_string) { \
+ tooltip_string = new_tooltip_string; \
+ if (tooltip_active) { \
+ _set_tooltip_visibility(!tooltip_string.is_empty()); \
+ } \
+ } \
+ } \
+ void CLASS::set_tooltip_substitution_dict(Dictionary const& new_tooltip_substitution_dict) { \
+ if (get_mouse_filter() == MOUSE_FILTER_IGNORE) { \
+ UtilityFunctions::push_error("Tooltips won't work for \"", get_name(), "\" as it has MOUSE_FILTER_IGNORE"); \
+ } \
+ if (tooltip_substitution_dict != new_tooltip_substitution_dict) { \
+ tooltip_substitution_dict = new_tooltip_substitution_dict; \
+ if (tooltip_active) { \
+ _set_tooltip_visibility(!tooltip_string.is_empty()); \
+ } \
+ } \
+ } \
+ void CLASS::clear_tooltip() { \
+ set_tooltip_string_and_substitution_dict({}, {}); \
+ } \
+ void CLASS::_tooltip_notification(int what) { \
+ if (what == NOTIFICATION_MOUSE_ENTER_SELF) { \
+ _set_tooltip_active(true); \
+ } else if (what == NOTIFICATION_MOUSE_EXIT_SELF) { \
+ _set_tooltip_active(false); \
+ } \
+ } \
+ void CLASS::_set_tooltip_active(bool new_tooltip_active) { \
+ if (tooltip_active != new_tooltip_active) { \
+ tooltip_active = new_tooltip_active; \
+ if (!tooltip_string.is_empty()) { \
+ _set_tooltip_visibility(tooltip_active); \
+ } \
+ } \
+ } \
+ void CLASS::_set_tooltip_visibility(bool visible) { \
+ MenuSingleton* menu_singleton = MenuSingleton::get_singleton(); \
+ ERR_FAIL_NULL(menu_singleton); \
+ if (visible) { \
+ menu_singleton->show_control_tooltip(tooltip_string, tooltip_substitution_dict, this); \
+ } else { \
+ menu_singleton->hide_tooltip(); \
+ } \
+ }
+
+#define GUI_TOOLTIP_BIND_METHODS(CLASS) \
+ OV_BIND_METHOD(CLASS::get_tooltip_string); \
+ OV_BIND_METHOD(CLASS::set_tooltip_string, { "new_tooltip_string" }); \
+ OV_BIND_METHOD(CLASS::get_tooltip_substitution_dict); \
+ OV_BIND_METHOD(CLASS::set_tooltip_substitution_dict, { "new_tooltip_substitution_dict" }); \
+ OV_BIND_METHOD( \
+ CLASS::set_tooltip_string_and_substitution_dict, { "new_tooltip_string", "new_tooltip_substitution_dict" } \
+ ); \
+ OV_BIND_METHOD(CLASS::clear_tooltip); \
+ OV_BIND_METHOD(CLASS::is_tooltip_active); \
+ ADD_PROPERTY( \
+ PropertyInfo(Variant::STRING, "tooltip_string", PROPERTY_HINT_MULTILINE_TEXT), \
+ "set_tooltip_string", "get_tooltip_string" \
+ ); \
+ ADD_PROPERTY( \
+ PropertyInfo(Variant::DICTIONARY, "tooltip_substitution_dict"), \
+ "set_tooltip_substitution_dict", "get_tooltip_substitution_dict" \
+ ); \
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tooltip_active"), "", "is_tooltip_active");
diff --git a/extension/src/openvic-extension/classes/GUILabel.cpp b/extension/src/openvic-extension/classes/GUILabel.cpp
index 9fd6b60..732dec2 100644
--- a/extension/src/openvic-extension/classes/GUILabel.cpp
+++ b/extension/src/openvic-extension/classes/GUILabel.cpp
@@ -14,7 +14,30 @@ using namespace OpenVic::Utilities::literals;
static constexpr int32_t DEFAULT_FONT_SIZE = 16;
+GUI_TOOLTIP_IMPLEMENTATIONS(GUILabel)
+
+String const& GUILabel::get_colour_marker() {
+ static const String COLOUR_MARKER = String::chr(0xA7); // §
+ return COLOUR_MARKER;
+}
+
+String const& GUILabel::get_currency_marker() {
+ static const String CURRENCY_MARKER = String::chr(0xA4); // ¤
+ return CURRENCY_MARKER;
+}
+
+String const& GUILabel::get_substitution_marker() {
+ static const String SUBSTITUTION_MARKER = String::chr(0x24); // $
+ return SUBSTITUTION_MARKER;
+}
+
void GUILabel::_bind_methods() {
+ GUI_TOOLTIP_BIND_METHODS(GUILabel)
+
+ OV_BIND_SMETHOD(get_colour_marker);
+ OV_BIND_SMETHOD(get_currency_marker);
+ OV_BIND_SMETHOD(get_substitution_marker);
+
OV_BIND_METHOD(GUILabel::clear);
OV_BIND_METHOD(GUILabel::get_gui_text_name);
@@ -80,6 +103,8 @@ void GUILabel::_bind_methods() {
}
void GUILabel::_notification(int what) {
+ _tooltip_notification(what);
+
switch (what) {
case NOTIFICATION_RESIZED:
case NOTIFICATION_TRANSLATION_CHANGED: {
@@ -146,7 +171,8 @@ void GUILabel::_notification(int what) {
}
GUILabel::GUILabel()
- : gui_text { nullptr },
+ : tooltip_active { false },
+ gui_text { nullptr },
text {},
substitution_dict {},
horizontal_alignment { HORIZONTAL_ALIGNMENT_LEFT },
@@ -454,29 +480,30 @@ void GUILabel::_update_lines() {
}
String GUILabel::generate_substituted_text(String const& base_text) const {
- static const String SUBSTITUTION_MARKER = String::chr(0x24); // $
-
String result;
int64_t start_pos = 0;
int64_t marker_start_pos;
- while ((marker_start_pos = base_text.find(SUBSTITUTION_MARKER, start_pos)) != -1) {
+ while ((marker_start_pos = base_text.find(get_substitution_marker(), start_pos)) != -1) {
result += base_text.substr(start_pos, marker_start_pos - start_pos);
- int64_t marker_end_pos = base_text.find(SUBSTITUTION_MARKER, marker_start_pos + SUBSTITUTION_MARKER.length());
+ int64_t marker_end_pos = base_text.find(
+ get_substitution_marker(), marker_start_pos + get_substitution_marker().length()
+ );
if (marker_end_pos == -1) {
marker_end_pos = base_text.length();
}
String key = base_text.substr(
- marker_start_pos + SUBSTITUTION_MARKER.length(), marker_end_pos - marker_start_pos - SUBSTITUTION_MARKER.length()
+ marker_start_pos + get_substitution_marker().length(),
+ marker_end_pos - marker_start_pos - get_substitution_marker().length()
);
String value = substitution_dict.get(key, String {});
// Use the un-substituted key if no value is found or the value is empty
result += value.is_empty() ? key : is_auto_translating() ? tr(value) : value;
- start_pos = marker_end_pos + SUBSTITUTION_MARKER.length();
+ start_pos = marker_end_pos + get_substitution_marker().length();
}
if (start_pos < base_text.length()) {
@@ -489,25 +516,23 @@ String GUILabel::generate_substituted_text(String const& base_text) const {
std::pair<String, GUILabel::colour_instructions_t> GUILabel::generate_display_text_and_colour_instructions(
String const& substituted_text
) const {
- static const String COLOUR_MARKER = String::chr(0xA7); // §
-
String result;
colour_instructions_t colour_instructions;
int64_t start_pos = 0;
int64_t marker_pos;
- while ((marker_pos = substituted_text.find(COLOUR_MARKER, start_pos)) != -1) {
+ while ((marker_pos = substituted_text.find(get_colour_marker(), start_pos)) != -1) {
result += substituted_text.substr(start_pos, marker_pos - start_pos);
- if (marker_pos + COLOUR_MARKER.length() < substituted_text.length()) {
- const char32_t colour_code = substituted_text[marker_pos + COLOUR_MARKER.length()];
+ if (marker_pos + get_colour_marker().length() < substituted_text.length()) {
+ const char32_t colour_code = substituted_text[marker_pos + get_colour_marker().length()];
// Check that the colour code can be safely cast to a char
if (colour_code >> sizeof(char) * CHAR_BIT == 0) {
colour_instructions.emplace_back(result.length(), static_cast<char>(colour_code));
}
- start_pos = marker_pos + COLOUR_MARKER.length() + 1;
+ start_pos = marker_pos + get_colour_marker().length() + 1;
} else {
return { std::move(result), std::move(colour_instructions) };
}
@@ -588,8 +613,6 @@ void GUILabel::separate_lines(
void GUILabel::separate_currency_segments(
String const& string, Color const& colour, line_t& line
) const {
- static const String CURRENCY_MARKER = String::chr(0xA4); // ¤
-
const auto push_string_segment = [this, &string, &colour, &line](int64_t start, int64_t end) -> void {
String substring = string.substr(start, end - start);
const real_t width = get_string_width(substring);
@@ -602,7 +625,7 @@ void GUILabel::separate_currency_segments(
const real_t currency_width = currency_texture.is_valid() ? currency_texture->get_width() : 0.0_real;
- while ((marker_pos = string.find(CURRENCY_MARKER, start_pos)) != -1) {
+ while ((marker_pos = string.find(get_currency_marker(), start_pos)) != -1) {
if (start_pos < marker_pos) {
push_string_segment(start_pos, marker_pos);
}
@@ -610,7 +633,7 @@ void GUILabel::separate_currency_segments(
line.segments.push_back(currency_segment_t {});
line.width += currency_width;
- start_pos = marker_pos + CURRENCY_MARKER.length();
+ start_pos = marker_pos + get_currency_marker().length();
}
if (start_pos < string.length()) {
diff --git a/extension/src/openvic-extension/classes/GUILabel.hpp b/extension/src/openvic-extension/classes/GUILabel.hpp
index e0982b2..102ad94 100644
--- a/extension/src/openvic-extension/classes/GUILabel.hpp
+++ b/extension/src/openvic-extension/classes/GUILabel.hpp
@@ -8,11 +8,14 @@
#include <openvic-simulation/interface/GUI.hpp>
#include "openvic-extension/classes/GFXSpriteTexture.hpp"
+#include "openvic-extension/classes/GUIHasTooltip.hpp"
namespace OpenVic {
class GUILabel : public godot::Control {
GDCLASS(GUILabel, godot::Control)
+ GUI_TOOLTIP_DEFINITIONS
+
using colour_instructions_t = std::vector<std::pair<int64_t, char>>;
GUI::Text const* PROPERTY(gui_text);
@@ -55,6 +58,10 @@ namespace OpenVic {
void _notification(int what);
public:
+ static godot::String const& get_colour_marker();
+ static godot::String const& get_currency_marker();
+ static godot::String const& get_substitution_marker();
+
GUILabel();
/* Reset gui_text to nullptr and reset current text. */
diff --git a/extension/src/openvic-extension/classes/GUIPieChart.cpp b/extension/src/openvic-extension/classes/GUIPieChart.cpp
index a8ed087..0688dd3 100644
--- a/extension/src/openvic-extension/classes/GUIPieChart.cpp
+++ b/extension/src/openvic-extension/classes/GUIPieChart.cpp
@@ -1,11 +1,51 @@
#include "GUIPieChart.hpp"
+#include <godot_cpp/classes/input_event_mouse_motion.hpp>
+
+#include "openvic-extension/classes/GUILabel.hpp"
+#include "openvic-extension/singletons/MenuSingleton.hpp"
#include "openvic-extension/utility/ClassBindings.hpp"
using namespace godot;
using namespace OpenVic;
using namespace OpenVic::Utilities::literals;
+void GUIPieChart::_update_tooltip() {
+ MenuSingleton* menu_singleton = MenuSingleton::get_singleton();
+ ERR_FAIL_NULL(menu_singleton);
+
+ if (gfx_pie_chart_texture.is_valid()) {
+ GFXPieChartTexture::slice_t const* slice = gfx_pie_chart_texture->get_slice(tooltip_position);
+
+ if (slice != nullptr) {
+ static const String tooltip_identifier_key = "ID";
+ static const String tooltip_percent_key = "PC";
+ // "§Y$ID$§!: $PC$%"
+ static const String tooltip_string =
+ GUILabel::get_colour_marker() + String { "Y" } + GUILabel::get_substitution_marker() + tooltip_identifier_key
+ + GUILabel::get_substitution_marker() + GUILabel::get_colour_marker() + "!: "
+ + GUILabel::get_substitution_marker() + tooltip_percent_key + GUILabel::get_substitution_marker() + "%";
+
+ Dictionary substitution_dict;
+ substitution_dict[tooltip_identifier_key] = slice->name;
+
+ float percent = slice->weight * 100.0f;
+ if (gfx_pie_chart_texture->get_total_weight() > 0.0f) {
+ percent /= gfx_pie_chart_texture->get_total_weight();
+ }
+ substitution_dict[tooltip_percent_key] = Utilities::float_to_string_dp(percent, 2);
+
+ menu_singleton->show_control_tooltip(tooltip_string, substitution_dict, this);
+
+ tooltip_active = true;
+ return;
+ }
+ }
+
+ menu_singleton->hide_tooltip();
+ tooltip_active = false;
+}
+
void GUIPieChart::_bind_methods() {
OV_BIND_METHOD(GUIPieChart::get_gfx_pie_chart_texture);
OV_BIND_METHOD(GUIPieChart::set_gfx_pie_chart_name, { "gfx_pie_chart_name" });
@@ -13,6 +53,28 @@ void GUIPieChart::_bind_methods() {
OV_BIND_METHOD(GUIPieChart::set_slices_array, { "new_slices" });
}
+static const Vector2 disabled_tooltip_position { -1.0_real, -1.0_real };
+
+void GUIPieChart::_notification(int what) {
+ if (what == NOTIFICATION_MOUSE_EXIT_SELF) {
+ tooltip_position = disabled_tooltip_position;
+
+ _update_tooltip();
+ }
+}
+
+void GUIPieChart::_gui_input(Ref<InputEvent> const& event) {
+ Ref<InputEventMouseMotion> mm = event;
+
+ if (mm.is_valid()) {
+ tooltip_position = mm->get_position() * 2.0_real / get_size() - Vector2 { 1.0_real, 1.0_real };
+
+ _update_tooltip();
+ }
+}
+
+GUIPieChart::GUIPieChart() : tooltip_active { false }, tooltip_position { disabled_tooltip_position } {}
+
Error GUIPieChart::set_gfx_pie_chart(GFX::PieChart const* gfx_pie_chart) {
const bool needs_setting = gfx_pie_chart_texture.is_null();
@@ -27,6 +89,10 @@ Error GUIPieChart::set_gfx_pie_chart(GFX::PieChart const* gfx_pie_chart) {
set_texture(gfx_pie_chart_texture);
}
+ if (tooltip_active) {
+ _update_tooltip();
+ }
+
return err;
}
@@ -50,6 +116,10 @@ Error GUIPieChart::set_gfx_pie_chart_name(String const& gfx_pie_chart_name) {
set_texture(gfx_pie_chart_texture);
}
+ if (tooltip_active) {
+ _update_tooltip();
+ }
+
return err;
}
@@ -59,8 +129,14 @@ String GUIPieChart::get_gfx_pie_chart_name() const {
return gfx_pie_chart_texture->get_gfx_pie_chart_name();
}
-Error GUIPieChart::set_slices_array(GFXPieChartTexture::godot_pie_chart_data_t const& new_slices) const {
+Error GUIPieChart::set_slices_array(GFXPieChartTexture::godot_pie_chart_data_t const& new_slices) {
ERR_FAIL_NULL_V(gfx_pie_chart_texture, FAILED);
- return gfx_pie_chart_texture->set_slices_array(new_slices);
+ const Error err = gfx_pie_chart_texture->set_slices_array(new_slices);
+
+ if (tooltip_active) {
+ _update_tooltip();
+ }
+
+ return err;
}
diff --git a/extension/src/openvic-extension/classes/GUIPieChart.hpp b/extension/src/openvic-extension/classes/GUIPieChart.hpp
index 6b4ac87..3356dba 100644
--- a/extension/src/openvic-extension/classes/GUIPieChart.hpp
+++ b/extension/src/openvic-extension/classes/GUIPieChart.hpp
@@ -12,10 +12,21 @@ namespace OpenVic {
godot::Ref<GFXPieChartTexture> gfx_pie_chart_texture;
+ bool tooltip_active;
+ godot::Vector2 tooltip_position;
+
+ void _update_tooltip();
+
protected:
static void _bind_methods();
+ void _notification(int what);
+
public:
+ void _gui_input(godot::Ref<godot::InputEvent> const& event) override;
+
+ GUIPieChart();
+
godot::Error set_gfx_pie_chart(GFX::PieChart const* gfx_pie_chart);
godot::Ref<GFXPieChartTexture> get_gfx_pie_chart_texture() const;
@@ -24,6 +35,6 @@ namespace OpenVic {
godot::String get_gfx_pie_chart_name() const;
- godot::Error set_slices_array(GFXPieChartTexture::godot_pie_chart_data_t const& new_slices) const;
+ godot::Error set_slices_array(GFXPieChartTexture::godot_pie_chart_data_t const& new_slices);
};
}
diff --git a/extension/src/openvic-extension/classes/GUIProgressBar.cpp b/extension/src/openvic-extension/classes/GUIProgressBar.cpp
index 6021746..d13f455 100644
--- a/extension/src/openvic-extension/classes/GUIProgressBar.cpp
+++ b/extension/src/openvic-extension/classes/GUIProgressBar.cpp
@@ -8,7 +8,17 @@
using namespace godot;
using namespace OpenVic;
-void GUIProgressBar::_bind_methods() {}
+GUI_TOOLTIP_IMPLEMENTATIONS(GUIProgressBar)
+
+void GUIProgressBar::_bind_methods() {
+ GUI_TOOLTIP_BIND_METHODS(GUIProgressBar)
+}
+
+void GUIProgressBar::_notification(int what) {
+ _tooltip_notification(what);
+}
+
+GUIProgressBar::GUIProgressBar() : tooltip_active { false } {}
Error GUIProgressBar::set_gfx_progress_bar(GFX::ProgressBar const* progress_bar) {
ERR_FAIL_NULL_V(progress_bar, FAILED);
diff --git a/extension/src/openvic-extension/classes/GUIProgressBar.hpp b/extension/src/openvic-extension/classes/GUIProgressBar.hpp
index 130ac91..11b677a 100644
--- a/extension/src/openvic-extension/classes/GUIProgressBar.hpp
+++ b/extension/src/openvic-extension/classes/GUIProgressBar.hpp
@@ -3,15 +3,22 @@
#include <godot_cpp/classes/texture_progress_bar.hpp>
#include "openvic-simulation/interface/GFXSprite.hpp"
+#include "openvic-extension/classes/GUIHasTooltip.hpp"
namespace OpenVic {
class GUIProgressBar : public godot::TextureProgressBar {
GDCLASS(GUIProgressBar, godot::TextureProgressBar)
+ GUI_TOOLTIP_DEFINITIONS
+
protected:
static void _bind_methods();
+ void _notification(int what);
+
public:
+ GUIProgressBar();
+
godot::Error set_gfx_progress_bar(GFX::ProgressBar const* progress_bar);
};
}
diff --git a/extension/src/openvic-extension/classes/GUIScrollbar.cpp b/extension/src/openvic-extension/classes/GUIScrollbar.cpp
index ddcba7c..6e310d7 100644
--- a/extension/src/openvic-extension/classes/GUIScrollbar.cpp
+++ b/extension/src/openvic-extension/classes/GUIScrollbar.cpp
@@ -18,7 +18,11 @@ StringName const& GUIScrollbar::signal_value_changed() {
return signal_value_changed;
}
+GUI_TOOLTIP_IMPLEMENTATIONS(GUIScrollbar)
+
void GUIScrollbar::_bind_methods() {
+ GUI_TOOLTIP_BIND_METHODS(GUIScrollbar)
+
OV_BIND_METHOD(GUIScrollbar::emit_value_changed);
OV_BIND_METHOD(GUIScrollbar::reset);
OV_BIND_METHOD(GUIScrollbar::clear);
@@ -49,7 +53,7 @@ void GUIScrollbar::_bind_methods() {
ADD_SIGNAL(MethodInfo(signal_value_changed(), PropertyInfo(Variant::INT, "value")));
}
-GUIScrollbar::GUIScrollbar() {
+GUIScrollbar::GUIScrollbar() : tooltip_active { false } {
/* Anything which the constructor might not have default initialised will be set by clear(). */
clear();
}
@@ -587,11 +591,16 @@ void GUIScrollbar::_gui_input(Ref<InputEvent> const& event) {
hover_more = !hover_more;
queue_redraw();
}
+
+ _set_tooltip_active(hover_slider || hover_track || hover_less || hover_more);
+
return;
}
}
void GUIScrollbar::_notification(int what) {
+ // GUIScrollbar doesn't use _tooltip_notification, as we don't want to show tooltips when hovering over transparent parts.
+
switch (what) {
case NOTIFICATION_VISIBILITY_CHANGED:
case NOTIFICATION_MOUSE_EXIT: {
@@ -602,6 +611,10 @@ void GUIScrollbar::_notification(int what) {
queue_redraw();
} break;
+ case NOTIFICATION_MOUSE_EXIT_SELF: {
+ _set_tooltip_active(false);
+ } break;
+
/* Pressing (and holding) less and more buttons. */
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
const double delta = get_physics_process_delta_time();
diff --git a/extension/src/openvic-extension/classes/GUIScrollbar.hpp b/extension/src/openvic-extension/classes/GUIScrollbar.hpp
index 16b2e00..d9b22f1 100644
--- a/extension/src/openvic-extension/classes/GUIScrollbar.hpp
+++ b/extension/src/openvic-extension/classes/GUIScrollbar.hpp
@@ -6,11 +6,14 @@
#include <openvic-simulation/interface/GUI.hpp>
#include "openvic-extension/classes/GFXSpriteTexture.hpp"
+#include "openvic-extension/classes/GUIHasTooltip.hpp"
namespace OpenVic {
class GUIScrollbar : public godot::Control {
GDCLASS(GUIScrollbar, godot::Control)
+ GUI_TOOLTIP_DEFINITIONS
+
GUI::Scrollbar const* PROPERTY(gui_scrollbar);
godot::Ref<GFXSpriteTexture> slider_texture;
@@ -74,6 +77,7 @@ namespace OpenVic {
protected:
static void _bind_methods();
+
void _notification(int what);
public:
diff --git a/extension/src/openvic-extension/classes/GUITextureRect.cpp b/extension/src/openvic-extension/classes/GUITextureRect.cpp
index 13fd3bb..fba9b19 100644
--- a/extension/src/openvic-extension/classes/GUITextureRect.cpp
+++ b/extension/src/openvic-extension/classes/GUITextureRect.cpp
@@ -3,4 +3,14 @@
using namespace godot;
using namespace OpenVic;
-void GUITextureRect::_bind_methods() {}
+GUI_TOOLTIP_IMPLEMENTATIONS(GUITextureRect)
+
+void GUITextureRect::_bind_methods() {
+ GUI_TOOLTIP_BIND_METHODS(GUITextureRect)
+}
+
+void GUITextureRect::_notification(int what) {
+ _tooltip_notification(what);
+}
+
+GUITextureRect::GUITextureRect() : tooltip_active { false } {}
diff --git a/extension/src/openvic-extension/classes/GUITextureRect.hpp b/extension/src/openvic-extension/classes/GUITextureRect.hpp
index afcf4da..6fc8123 100644
--- a/extension/src/openvic-extension/classes/GUITextureRect.hpp
+++ b/extension/src/openvic-extension/classes/GUITextureRect.hpp
@@ -2,11 +2,20 @@
#include <godot_cpp/classes/texture_rect.hpp>
+#include "openvic-extension/classes/GUIHasTooltip.hpp"
+
namespace OpenVic {
class GUITextureRect : public godot::TextureRect {
GDCLASS(GUITextureRect, godot::TextureRect)
+ GUI_TOOLTIP_DEFINITIONS
+
protected:
static void _bind_methods();
+
+ void _notification(int what);
+
+ public:
+ GUITextureRect();
};
}
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.cpp b/extension/src/openvic-extension/singletons/MenuSingleton.cpp
index b95bc15..367462b 100644
--- a/extension/src/openvic-extension/singletons/MenuSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/MenuSingleton.cpp
@@ -30,6 +30,10 @@ StringName const& MenuSingleton::_signal_search_cache_changed() {
static const StringName signal_search_cache_changed = "search_cache_changed";
return signal_search_cache_changed;
}
+StringName const& MenuSingleton::_signal_update_tooltip() {
+ static const StringName signal_update_tooltip = "update_tooltip";
+ return signal_update_tooltip;
+}
String MenuSingleton::get_state_name(State const& state) const {
StateSet const& state_set = state.get_state_set();
@@ -103,6 +107,16 @@ String MenuSingleton::get_country_adjective(CountryInstance const& country) cons
}
void MenuSingleton::_bind_methods() {
+ /* TOOLTIP */
+ OV_BIND_METHOD(MenuSingleton::show_tooltip, { "text", "substitution_dict", "position" });
+ OV_BIND_METHOD(MenuSingleton::show_control_tooltip, { "text", "substitution_dict", "control" });
+ OV_BIND_METHOD(MenuSingleton::hide_tooltip);
+
+ ADD_SIGNAL(MethodInfo(
+ _signal_update_tooltip(), PropertyInfo(Variant::STRING, "text"),
+ PropertyInfo(Variant::DICTIONARY, "substitution_dict"), PropertyInfo(Variant::VECTOR2, "position")
+ ));
+
/* PROVINCE OVERVIEW PANEL */
OV_BIND_METHOD(MenuSingleton::get_province_info_from_index, { "index" });
OV_BIND_METHOD(MenuSingleton::get_province_building_count);
@@ -205,6 +219,25 @@ MenuSingleton::~MenuSingleton() {
singleton = nullptr;
}
+/* TOOLTIP */
+
+void MenuSingleton::show_tooltip(String const& text, Dictionary const& substitution_dict, Vector2 const& position) {
+ emit_signal(_signal_update_tooltip(), text, substitution_dict, position);
+}
+
+void MenuSingleton::show_control_tooltip(String const& text, Dictionary const& substitution_dict, Control const* control) {
+ ERR_FAIL_NULL(control);
+
+ using namespace OpenVic::Utilities::literals;
+ static const Vector2 offset { 0.0_real, 64.0_real };
+
+ show_tooltip(text, substitution_dict, control->get_global_position() + offset);
+}
+
+void MenuSingleton::hide_tooltip() {
+ show_tooltip({}, {}, {});
+}
+
/* PROVINCE OVERVIEW PANEL */
static TypedArray<Dictionary> _make_buildings_dict_array(
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.hpp b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
index 190e3ea..022bce5 100644
--- a/extension/src/openvic-extension/singletons/MenuSingleton.hpp
+++ b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <godot_cpp/classes/control.hpp>
#include <godot_cpp/classes/image.hpp>
#include <openvic-simulation/pop/Pop.hpp>
@@ -95,6 +96,10 @@ namespace OpenVic {
static godot::StringName const& _signal_population_menu_pops_changed();
/* Emitted when the collection of possible search results changes. */
static godot::StringName const& _signal_search_cache_changed();
+ /* Emitted when the current tooltip changes. Arguments: text (godot::String), substitution_dict (godot::Dictionary),
+ * position (godot::Vector2). If text is empty then the tooltip will be hidden, otherwise the text will be shown at
+ * the given position. */
+ static godot::StringName const& _signal_update_tooltip();
godot::String get_state_name(State const& state) const;
godot::String get_country_name(CountryInstance const& country) const;
@@ -110,6 +115,15 @@ namespace OpenVic {
MenuSingleton();
~MenuSingleton();
+ /* TOOLTIP */
+ void show_tooltip(
+ godot::String const& text, godot::Dictionary const& substitution_dict, godot::Vector2 const& position
+ );
+ void show_control_tooltip(
+ godot::String const& text, godot::Dictionary const& substitution_dict, godot::Control const* control
+ );
+ void hide_tooltip();
+
/* PROVINCE OVERVIEW PANEL */
/* Get info to display in Province Overview Panel, packaged in a Dictionary using StringName constants as keys. */
godot::Dictionary get_province_info_from_index(int32_t index) const;
diff --git a/game/src/Game/GameSession/GameSession.tscn b/game/src/Game/GameSession/GameSession.tscn
index 018aad8..5925f3d 100644
--- a/game/src/Game/GameSession/GameSession.tscn
+++ b/game/src/Game/GameSession/GameSession.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=20 format=3 uid="uid://bgnupcshe1m7r"]
+[gd_scene load_steps=21 format=3 uid="uid://bgnupcshe1m7r"]
[ext_resource type="Script" path="res://src/Game/GameSession/GameSession.gd" id="1_eklvp"]
[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/Game/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"]
@@ -19,6 +19,7 @@
[ext_resource type="Script" path="res://src/Game/GameSession/NationManagementScreen/TradeMenu.gd" id="10_mv1r6"]
[ext_resource type="Script" path="res://src/Game/GameSession/NationManagementScreen/DiplomacyMenu.gd" id="11_fu7ys"]
[ext_resource type="Script" path="res://src/Game/GameSession/NationManagementScreen/MilitaryMenu.gd" id="12_6h6nc"]
+[ext_resource type="Script" path="res://src/Game/GameSession/Tooltip.gd" id="20_3306e"]
[node name="GameSession" type="Control" node_paths=PackedStringArray("_model_manager", "_game_session_menu")]
editor_description = "SS-102, UI-546"
@@ -156,6 +157,11 @@ offset_left = -150.0
offset_right = 0.0
grow_horizontal = 0
+[node name="Tooltip" type="GUINode" parent="UICanvasLayer/UI"]
+layout_mode = 1
+anchors_preset = 15
+script = ExtResource("20_3306e")
+
[connection signal="detailed_view_changed" from="MapView" to="ModelManager" method="set_visible"]
[connection signal="map_view_camera_changed" from="MapView" to="UICanvasLayer/UI/MapControlPanel" method="_on_map_view_camera_changed"]
[connection signal="game_session_menu_button_pressed" from="UICanvasLayer/UI/MapControlPanel" to="." method="_on_game_session_menu_button_pressed"]
diff --git a/game/src/Game/GameSession/NationManagementScreen/BudgetMenu.gd b/game/src/Game/GameSession/NationManagementScreen/BudgetMenu.gd
index ea92beb..021c9f2 100644
--- a/game/src/Game/GameSession/NationManagementScreen/BudgetMenu.gd
+++ b/game/src/Game/GameSession/NationManagementScreen/BudgetMenu.gd
@@ -42,6 +42,12 @@ var _debt_chart : GUIPieChart
const _screen : NationManagement.Screen = NationManagement.Screen.BUDGET
+# TODO - testing function, should be replaced with calls to SIM which trigger UI updates through gamestate_updated
+func _on_tax_slider_changed(slider : GUIScrollbar, label : GUILabel, tooltip : String, value : int) -> void:
+ label.text = "%s¤" % GUINode.float_to_string_dp(value, 3 if abs(value) < 1000 else 1)
+ slider.set_tooltip_string("%s: §Y%s%%" % [tr(tooltip), GUINode.float_to_string_dp(value, 1)])
+
+
func _ready() -> void:
GameSingleton.gamestate_updated.connect(_update_info)
@@ -87,15 +93,24 @@ func _ready() -> void:
# income
var _lower_class_slider : GUIScrollbar = get_gui_scrollbar_from_nodepath(^"./country_budget/tax_0_slider")
if _lower_class_slider and _lower_class_label:
- _lower_class_slider.value_changed.connect(func(value : int) -> void: _lower_class_label.text = "%s¤" % GUINode.float_to_string_dp(value, 3 if abs(value) < 1000 else 1))
+ _lower_class_slider.value_changed.connect(
+ func (value : int) -> void:
+ _on_tax_slider_changed(_lower_class_slider, _lower_class_label, "BUDGET_TAX_POOR", value)
+ )
_lower_class_slider.emit_value_changed()
var _middle_class_slider : GUIScrollbar = get_gui_scrollbar_from_nodepath(^"./country_budget/tax_1_slider")
if _middle_class_slider and _middle_class_label:
- _middle_class_slider.value_changed.connect(func(value : int) -> void: _middle_class_label.text = "%s¤" % GUINode.float_to_string_dp(value, 3 if abs(value) < 1000 else 1))
+ _middle_class_slider.value_changed.connect(
+ func (value : int) -> void:
+ _on_tax_slider_changed(_middle_class_slider, _middle_class_label, "BUDGET_TAX_MIDDLE", value)
+ )
_middle_class_slider.emit_value_changed()
var _upper_class_slider : GUIScrollbar = get_gui_scrollbar_from_nodepath(^"./country_budget/tax_2_slider")
if _upper_class_slider and _upper_class_label:
- _upper_class_slider.value_changed.connect(func(value : int) -> void: _upper_class_label.text = "%s¤" % GUINode.float_to_string_dp(value, 3 if abs(value) < 1000 else 1))
+ _upper_class_slider.value_changed.connect(
+ func (value : int) -> void:
+ _on_tax_slider_changed(_upper_class_slider, _upper_class_label, "BUDGET_TAX_RICH", value)
+ )
_upper_class_slider.emit_value_changed()
# costs
diff --git a/game/src/Game/GameSession/NationManagementScreen/PopulationMenu.gd b/game/src/Game/GameSession/NationManagementScreen/PopulationMenu.gd
index d8af97f..eb57387 100644
--- a/game/src/Game/GameSession/NationManagementScreen/PopulationMenu.gd
+++ b/game/src/Game/GameSession/NationManagementScreen/PopulationMenu.gd
@@ -319,15 +319,28 @@ func _setup_pop_list() -> void:
var culture_label : GUILabel = GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_nation"))
_pop_list_culture_labels.push_back(culture_label)
+ if culture_label:
+ culture_label.set_mouse_filter(MOUSE_FILTER_PASS)
- _pop_list_religion_icons.push_back(GUINode.get_gui_icon_from_node(pop_row_panel.get_node(^"./pop_religion")))
+ var religion_icon : GUIIcon = GUINode.get_gui_icon_from_node(pop_row_panel.get_node(^"./pop_religion"))
+ _pop_list_religion_icons.push_back(religion_icon)
+ if religion_icon:
+ religion_icon.set_mouse_filter(MOUSE_FILTER_PASS)
var location_label : GUILabel = GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_location"))
_pop_list_location_labels.push_back(location_label)
+ if location_label:
+ location_label.set_mouse_filter(MOUSE_FILTER_PASS)
- _pop_list_militancy_labels.push_back(GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_mil")))
+ var militancy_label : GUILabel = GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_mil"))
+ _pop_list_militancy_labels.push_back(militancy_label)
+ if militancy_label:
+ militancy_label.set_mouse_filter(MOUSE_FILTER_PASS)
- _pop_list_consciousness_labels.push_back(GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_con")))
+ var consciousness_label : GUILabel = GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_con"))
+ _pop_list_consciousness_labels.push_back(consciousness_label)
+ if consciousness_label:
+ consciousness_label.set_mouse_filter(MOUSE_FILTER_PASS)
_pop_list_ideology_charts.push_back(GUINode.get_gui_pie_chart_from_node(pop_row_panel.get_node(^"./pop_ideology")))
@@ -335,17 +348,20 @@ func _setup_pop_list() -> void:
_pop_list_unemployment_progressbars.push_back(GUINode.get_gui_progress_bar_from_node(pop_row_panel.get_node(^"./pop_unemployment_bar")))
- _pop_list_cash_labels.push_back(GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_cash")))
+ var cash_label : GUILabel = GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_cash"))
+ _pop_list_cash_labels.push_back(cash_label)
+ if cash_label:
+ cash_label.set_mouse_filter(MOUSE_FILTER_PASS)
var pop_list_life_needs_progressbar : GUIProgressBar = GUINode.get_gui_progress_bar_from_node(pop_row_panel.get_node(^"./lifeneed_progress"))
+ _pop_list_life_needs_progressbars.push_back(pop_list_life_needs_progressbar)
if pop_list_life_needs_progressbar:
pop_list_life_needs_progressbar.position += Vector2(1, 0)
- _pop_list_life_needs_progressbars.push_back(pop_list_life_needs_progressbar)
var pop_list_everyday_needs_progressbar : GUIProgressBar = GUINode.get_gui_progress_bar_from_node(pop_row_panel.get_node(^"./eveneed_progress"))
+ _pop_list_everyday_needs_progressbars.push_back(pop_list_everyday_needs_progressbar)
if pop_list_everyday_needs_progressbar:
pop_list_everyday_needs_progressbar.position += Vector2(1, 0)
- _pop_list_everyday_needs_progressbars.push_back(pop_list_everyday_needs_progressbar)
_pop_list_luxury_needs_progressbars.push_back(GUINode.get_gui_progress_bar_from_node(pop_row_panel.get_node(^"./luxneed_progress")))
@@ -357,9 +373,15 @@ func _setup_pop_list() -> void:
_pop_list_national_movement_flags.push_back(GUINode.get_gui_masked_flag_from_node(pop_row_panel.get_node(^"./pop_movement_flag")))
- _pop_list_size_change_icons.push_back(GUINode.get_gui_icon_from_node(pop_row_panel.get_node(^"./growth_indicator")))
+ var size_change_icon : GUIIcon = GUINode.get_gui_icon_from_node(pop_row_panel.get_node(^"./growth_indicator"))
+ _pop_list_size_change_icons.push_back(size_change_icon)
+ if size_change_icon:
+ size_change_icon.set_mouse_filter(MOUSE_FILTER_PASS)
- _pop_list_literacy_labels.push_back(GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_literacy")))
+ var literacy_label : GUILabel = GUINode.get_gui_label_from_node(pop_row_panel.get_node(^"./pop_literacy"))
+ _pop_list_literacy_labels.push_back(literacy_label)
+ if literacy_label:
+ literacy_label.set_mouse_filter(MOUSE_FILTER_PASS)
func _notification(what : int) -> void:
match what:
@@ -514,6 +536,10 @@ func _update_distributions():
var colour_icon : GUIIcon = GUINode.get_gui_icon_from_node(child.get_node(^"./legend_color"))
if colour_icon:
colour_icon.set_modulate(distribution_row[slice_colour_key])
+ colour_icon.set_mouse_filter(MOUSE_FILTER_PASS)
+ colour_icon.set_tooltip_string_and_substitution_dict("§Y$ID$§!: $PC$%", {
+ "ID": distribution_row[slice_identifier_key], "PC": GUINode.float_to_string_dp(distribution_row[slice_weight_key] * 100.0, 2)
+ })
var identifier_label : GUILabel = GUINode.get_gui_label_from_node(child.get_node(^"./legend_title"))
if identifier_label:
@@ -563,30 +589,60 @@ func _update_pop_list() -> void:
_pop_list_size_labels[index].set_text(GUINode.int_to_string_suffixed(pop_row[pop_size_key]))
if _pop_list_type_buttons[index]:
_pop_list_type_buttons[index].set_icon_index(pop_row[pop_type_icon_key])
+ # TODO - replace with actual poptype
+ _pop_list_type_buttons[index].set_tooltip_string("Pop Type #%d" % pop_row[pop_type_icon_key])
if _pop_list_culture_labels[index]:
_pop_list_culture_labels[index].set_text(pop_row[pop_culture_key])
+ _pop_list_culture_labels[index].set_tooltip_string("NO_ASSIM_NOW")
if _pop_list_religion_icons[index]:
_pop_list_religion_icons[index].set_icon_index(pop_row[pop_religion_icon_key])
+ # TODO - replace with actual religion
+ _pop_list_religion_icons[index].set_tooltip_string("Religion #%d" % pop_row[pop_religion_icon_key])
if _pop_list_location_labels[index]:
- _pop_list_location_labels[index].set_text(GUINode.format_province_name(pop_row.get(pop_location_key, "")))
+ var province_name : String = GUINode.format_province_name(pop_row.get(pop_location_key, ""))
+ _pop_list_location_labels[index].set_text(province_name)
+ _pop_list_location_labels[index].set_tooltip_string(province_name)
if _pop_list_militancy_labels[index]:
_pop_list_militancy_labels[index].set_text(GUINode.float_to_string_dp(pop_row[pop_militancy_key], 2))
+ # TODO - test tooltip, add monthly change + source breakdown
+ _pop_list_militancy_labels[index].set_tooltip_string("POP_MIL_TOTAL")
if _pop_list_consciousness_labels[index]:
_pop_list_consciousness_labels[index].set_text(GUINode.float_to_string_dp(pop_row[pop_consciousness_key], 2))
+ # TODO - test tooltip, add monthly change + source breakdown
+ _pop_list_consciousness_labels[index].set_tooltip_string("POP_CON_TOTAL")
if _pop_list_ideology_charts[index]:
_pop_list_ideology_charts[index].set_slices_array(pop_row[pop_ideology_key])
if _pop_list_issues_charts[index]:
_pop_list_issues_charts[index].set_slices_array(pop_row[pop_issues_key])
if _pop_list_unemployment_progressbars[index]:
- _pop_list_unemployment_progressbars[index].set_value_no_signal(pop_row[pop_unemployment_key])
+ var unemployment : float = pop_row[pop_unemployment_key]
+ _pop_list_unemployment_progressbars[index].set_value_no_signal(unemployment)
+ _pop_list_unemployment_progressbars[index].set_tooltip_string("%s: §Y%s%%" % [
+ tr("UNEMPLOYMENT"), GUINode.float_to_string_dp(unemployment * 100.0, 3)
+ ])
if _pop_list_cash_labels[index]:
- _pop_list_cash_labels[index].set_text(GUINode.float_to_string_dp(pop_row[pop_cash_key], 2))
+ _pop_list_cash_labels[index].set_text("%s¤" % GUINode.float_to_string_dp(pop_row[pop_cash_key], 2))
+ _pop_list_cash_labels[index].set_tooltip_string_and_substitution_dict("POP_DAILY_MONEY", {
+ "VAL": GUINode.float_to_string_dp(1.23, 2)
+ })
if _pop_list_life_needs_progressbars[index]:
- _pop_list_life_needs_progressbars[index].set_value_no_signal(pop_row[pop_life_needs_key])
+ var life_needs : float = pop_row[pop_life_needs_key]
+ _pop_list_life_needs_progressbars[index].set_value_no_signal(life_needs)
+ _pop_list_life_needs_progressbars[index].set_tooltip_string_and_substitution_dict("GETTING_NEEDS", {
+ "NEED": "LIFE_NEEDS", "VAL": GUINode.float_to_string_dp(life_needs * 100.0, 1)
+ })
if _pop_list_everyday_needs_progressbars[index]:
- _pop_list_everyday_needs_progressbars[index].set_value_no_signal(pop_row[pop_everyday_needs_key])
+ var everyday_needs : float = pop_row[pop_everyday_needs_key]
+ _pop_list_everyday_needs_progressbars[index].set_value_no_signal(everyday_needs)
+ _pop_list_everyday_needs_progressbars[index].set_tooltip_string_and_substitution_dict("GETTING_NEEDS", {
+ "NEED": "EVERYDAY_NEEDS", "VAL": GUINode.float_to_string_dp(everyday_needs * 100.0, 1)
+ })
if _pop_list_luxury_needs_progressbars[index]:
- _pop_list_luxury_needs_progressbars[index].set_value_no_signal(pop_row[pop_luxury_needs_key])
+ var luxury_needs : float = pop_row[pop_luxury_needs_key]
+ _pop_list_luxury_needs_progressbars[index].set_value_no_signal(luxury_needs)
+ _pop_list_luxury_needs_progressbars[index].set_tooltip_string_and_substitution_dict("GETTING_NEEDS", {
+ "NEED": "LUXURY_NEEDS", "VAL": GUINode.float_to_string_dp(luxury_needs * 100.0, 1)
+ })
if _pop_list_rebel_icons[index]:
var rebel_icon : int = pop_row.get(pop_rebel_icon_key, 0)
if rebel_icon > 0:
@@ -604,9 +660,16 @@ func _update_pop_list() -> void:
_pop_list_national_movement_flags[index].hide()
if _pop_list_size_change_icons[index]:
- _pop_list_size_change_icons[index].set_icon_index(get_growth_icon_index(pop_row[pop_size_change_key]))
+ var pop_change : int = pop_row[pop_size_change_key]
+ _pop_list_size_change_icons[index].set_icon_index(get_growth_icon_index(pop_change))
+ _pop_list_size_change_icons[index].set_tooltip_string("%s §%s%s" % [
+ tr("POPULATION_CHANGED_BY"), "G+" if pop_change > 0 else "Y+" if pop_change == 0 else "R", str(pop_change)
+ ])
if _pop_list_literacy_labels[index]:
_pop_list_literacy_labels[index].set_text("%s%%" % GUINode.float_to_string_dp(pop_row[pop_literacy_key], 2))
+ _pop_list_literacy_labels[index].set_tooltip_string("%s: §G%s%%" % [
+ tr("LIT_CHANGE"), GUINode.float_to_string_dp(pop_row[pop_literacy_key] / 64.0, 2)
+ ])
_pop_list_rows[index].show()
else:
diff --git a/game/src/Game/GameSession/Tooltip.gd b/game/src/Game/GameSession/Tooltip.gd
new file mode 100644
index 0000000..c110e2e
--- /dev/null
+++ b/game/src/Game/GameSession/Tooltip.gd
@@ -0,0 +1,23 @@
+extends GUINode
+
+var _tooltip_label : GUILabel
+
+func _ready() -> void:
+ add_gui_element("core", "ToolTip")
+
+ _tooltip_label = get_gui_label_from_nodepath(^"./ToolTip")
+ if _tooltip_label:
+ _tooltip_label.set_auto_adjust_to_content_size(true)
+
+ MenuSingleton.update_tooltip.connect(update_tooltip)
+
+ hide()
+
+func update_tooltip(text : String, substitution_dict : Dictionary, position : Vector2) -> void:
+ if text:
+ _tooltip_label.set_text(text)
+ _tooltip_label.set_substitution_dict(substitution_dict)
+ _tooltip_label.set_position(position)
+ show()
+ else:
+ hide()
diff --git a/game/src/Game/GameSession/Topbar.gd b/game/src/Game/GameSession/Topbar.gd
index 62fa322..e3e0809 100644
--- a/game/src/Game/GameSession/Topbar.gd
+++ b/game/src/Game/GameSession/Topbar.gd
@@ -16,6 +16,7 @@ var _country_colonial_power_label : GUILabel
# Time controls
var _speed_up_button : GUIIconButton
var _speed_down_button : GUIIconButton
+var _pause_bg_button : GUIButton
var _speed_indicator_button : GUIIconButton
var _date_label : GUILabel
@@ -101,24 +102,42 @@ func _ready() -> void:
_country_flag_overlay_icon = get_gui_icon_from_nodepath(^"./topbar/topbar_flag_overlay")
_country_name_label = get_gui_label_from_nodepath(^"./topbar/CountryName")
_country_rank_label = get_gui_label_from_nodepath(^"./topbar/nation_totalrank")
+ if _country_rank_label:
+ _country_rank_label.set_mouse_filter(MOUSE_FILTER_PASS)
_country_prestige_label = get_gui_label_from_nodepath(^"./topbar/country_prestige")
+ if _country_prestige_label:
+ _country_prestige_label.set_mouse_filter(MOUSE_FILTER_PASS)
_country_prestige_rank_label = get_gui_label_from_nodepath(^"./topbar/selected_prestige_rank")
+ if _country_prestige_rank_label:
+ _country_prestige_rank_label.set_mouse_filter(MOUSE_FILTER_PASS)
_country_industrial_power_label = get_gui_label_from_nodepath(^"./topbar/country_economic")
+ if _country_industrial_power_label:
+ _country_industrial_power_label.set_mouse_filter(MOUSE_FILTER_PASS)
_country_industrial_power_rank_label = get_gui_label_from_nodepath(^"./topbar/selected_industry_rank")
+ if _country_industrial_power_rank_label:
+ _country_industrial_power_rank_label.set_mouse_filter(MOUSE_FILTER_PASS)
_country_military_power_label = get_gui_label_from_nodepath(^"./topbar/country_military")
+ if _country_military_power_label:
+ _country_military_power_label.set_mouse_filter(MOUSE_FILTER_PASS)
_country_military_power_rank_label = get_gui_label_from_nodepath(^"./topbar/selected_military_rank")
+ if _country_military_power_rank_label:
+ _country_military_power_rank_label.set_mouse_filter(MOUSE_FILTER_PASS)
_country_colonial_power_label = get_gui_label_from_nodepath(^"./topbar/country_colonial_power")
+ if _country_colonial_power_label:
+ _country_colonial_power_label.set_mouse_filter(MOUSE_FILTER_PASS)
# Time controls
_speed_up_button = get_gui_icon_button_from_nodepath(^"./topbar/button_speedup")
if _speed_up_button:
_speed_up_button.pressed.connect(_on_increase_speed_button_pressed)
+ _speed_up_button.set_tooltip_string("TOPBAR_INC_SPEED")
_speed_down_button = get_gui_icon_button_from_nodepath(^"./topbar/button_speeddown")
if _speed_down_button:
_speed_down_button.pressed.connect(_on_decrease_speed_button_pressed)
- var pause_bg_button : GUIIconButton = get_gui_icon_button_from_nodepath(^"./topbar/pause_bg")
- if pause_bg_button:
- pause_bg_button.pressed.connect(_on_play_pause_button_pressed)
+ _speed_down_button.set_tooltip_string("TOPBAR_DEC_SPEED")
+ _pause_bg_button = get_gui_icon_button_from_nodepath(^"./topbar/pause_bg")
+ if _pause_bg_button:
+ _pause_bg_button.pressed.connect(_on_play_pause_button_pressed)
_speed_indicator_button = get_gui_icon_button_from_nodepath(^"./topbar/speed_indicator")
if _speed_indicator_button:
_speed_indicator_button.pressed.connect(_on_play_pause_button_pressed)
@@ -141,6 +160,8 @@ func _ready() -> void:
button.pressed.connect(
Events.NationManagementScreens.toggle_nation_management_screen.bind(screen)
)
+ # TODO - test tooltip, replace with actual shortcut strings
+ button.set_tooltip_string(tr("SHORTCUT") + "F3")
_nation_management_buttons[screen] = button
Events.NationManagementScreens.update_active_nation_management_screen.connect(
_on_update_active_nation_management_screen
@@ -158,10 +179,25 @@ func _ready() -> void:
_budget_funds_label = get_gui_label_from_nodepath(^"./topbar/budget_funds")
# Technology
+ var tech_button : GUIIconButton = _nation_management_buttons[NationManagement.Screen.TECHNOLOGY]
_technology_progress_bar = get_gui_progress_bar_from_nodepath(^"./topbar/topbar_tech_progress")
+ if _technology_progress_bar and tech_button:
+ _technology_progress_bar.reparent(tech_button)
_technology_current_research_label = get_gui_label_from_nodepath(^"./topbar/tech_current_research")
+ if _technology_current_research_label:
+ _technology_current_research_label.set_mouse_filter(MOUSE_FILTER_PASS)
+ if tech_button:
+ _technology_current_research_label.reparent(tech_button)
_technology_literacy_label = get_gui_label_from_nodepath(^"./topbar/tech_literacy_value")
+ if _technology_literacy_label:
+ _technology_literacy_label.set_mouse_filter(MOUSE_FILTER_PASS)
+ if tech_button:
+ _technology_literacy_label.reparent(tech_button)
_technology_research_points_label = get_gui_label_from_nodepath(^"./topbar/topbar_researchpoints_value")
+ if _technology_research_points_label:
+ _technology_research_points_label.set_mouse_filter(MOUSE_FILTER_PASS)
+ if tech_button:
+ _technology_research_points_label.reparent(tech_button)
# Politics
_politics_party_icon = get_gui_icon_from_nodepath(^"./topbar/politics_party_icon")
@@ -238,45 +274,66 @@ func _notification(what : int) -> void:
match what:
NOTIFICATION_TRANSLATION_CHANGED:
_update_info()
+ _update_speed_controls()
func _update_info() -> void:
# Placeholder data
const player_country : String = "ENG"
+ const player_rank : int = 0
+
+ const RANK_NAMES : PackedStringArray = [
+ "DIPLOMACY_GREATNATION_STATUS",
+ "DIPLOMACY_COLONIALNATION_STATUS",
+ "DIPLOMACY_CIVILIZEDNATION_STATUS",
+ "DIPLOMACY_UNCIVILIZEDNATION_STATUS"
+ ]
## Country info
if _country_flag_button:
_country_flag_button.set_flag_country_name(player_country)
+ _country_flag_button.set_tooltip_string_and_substitution_dict("PLAYER_COUNTRY_TOPBAR_RANK", {
+ "NAME": player_country, "RANK": RANK_NAMES[player_rank]
+ })
if _country_flag_overlay_icon:
# 1 - Great Power
# 2 - Secondary Power
# 3 - Civilised
# 4 - Uncivilised
- _country_flag_overlay_icon.set_icon_index(1)
+ _country_flag_overlay_icon.set_icon_index(1 + player_rank)
if _country_name_label:
_country_name_label.set_text(player_country)
if _country_rank_label:
_country_rank_label.set_text(str(1))
+ _country_rank_label.set_tooltip_string_and_substitution_dict("PLAYER_COUNTRY_TOPBAR_RANK", {
+ "NAME": player_country, "RANK": RANK_NAMES[player_rank]
+ })
if _country_prestige_label:
_country_prestige_label.set_text(str(11))
+ _country_military_power_label.set_tooltip_string("RANK_PRESTIGE")
if _country_prestige_rank_label:
_country_prestige_rank_label.set_text(str(1))
+ _country_military_power_label.set_tooltip_string("RANK_PRESTIGE")
if _country_industrial_power_label:
_country_industrial_power_label.set_text(str(22))
+ _country_military_power_label.set_tooltip_string("RANK_INDUSTRY")
if _country_industrial_power_rank_label:
_country_industrial_power_rank_label.set_text(str(2))
+ _country_military_power_label.set_tooltip_string("RANK_INDUSTRY")
if _country_military_power_label:
_country_military_power_label.set_text(str(33))
+ _country_military_power_label.set_tooltip_string("RANK_MILITARY")
if _country_military_power_rank_label:
_country_military_power_rank_label.set_text(str(3))
+ _country_military_power_rank_label.set_tooltip_string("RANK_MILITARY")
if _country_colonial_power_label:
var available_colonial_power : int = 123
@@ -284,6 +341,7 @@ func _update_info() -> void:
_country_colonial_power_label.set_text(
"§%s%s§!/%s" % ["W" if available_colonial_power > 0 else "R", available_colonial_power, total_colonial_power]
)
+ _country_colonial_power_label.set_tooltip_string("COLONIAL_POINTS")
## Time control
if _date_label:
@@ -320,12 +378,21 @@ func _update_info() -> void:
if _technology_current_research_label:
# TODO - set current research or "unciv_nation" (in red) if uncivilised
_technology_current_research_label.set_text("TB_TECH_NO_CURRENT")
+ _technology_current_research_label.set_tooltip_string("TECHNOLOGYVIEW_NO_RESEARCH_TOOLTIP")
if _technology_literacy_label:
- _technology_literacy_label.set_text("§Y%s§W%%" % GUINode.float_to_string_dp(80.0, 1))
+ var literacy_float : float = 80.0
+ var literacy_string : String = GUINode.float_to_string_dp(80.0, 1)
+ _technology_literacy_label.set_text("§Y%s§W%%" % literacy_string)
+ _technology_literacy_label.set_tooltip_string_and_substitution_dict("TOPBAR_AVG_LITERACY", { "AVG": literacy_string })
if _technology_research_points_label:
_technology_research_points_label.set_text("§Y%s" % GUINode.float_to_string_dp(10.0, 2))
+ # TODO - test tooltip, replace with actual values from the simulation
+ _technology_research_points_label.set_tooltip_string_and_substitution_dict("TECH_DAILY_RESEARCHPOINTS_TOOLTIP", {
+ "POPTYPE": "Clergymen", "VALUE": GUINode.float_to_string_dp(1.42, 2),
+ "FRACTION": GUINode.float_to_string_dp(0.95, 2), "OPTIMAL": GUINode.float_to_string_dp(2, 2)
+ })
## Politics
if _politics_party_icon:
@@ -418,6 +485,9 @@ func _update_info() -> void:
_military_leadership_points_label.set_text("§Y%d" % 15)
func _update_speed_controls() -> void:
+ var paused : bool = MenuSingleton.is_paused()
+ var speed : int = MenuSingleton.get_speed()
+
# TODO - decide whether to disable these or not
# (they don't appear to get disabled in the base game)
#if _speed_up_button:
@@ -426,10 +496,25 @@ func _update_speed_controls() -> void:
#if _speed_down_button:
# _speed_down_button.disabled = not MenuSingleton.can_decrease_speed()
+ if _pause_bg_button:
+ _pause_bg_button.set_tooltip_string("TOPBAR_DATE_IS_PAUSED" if paused else "TOPBAR_DATE")
+
if _speed_indicator_button:
var index : int = 1
- if not MenuSingleton.is_paused():
- index += MenuSingleton.get_speed() + 1
+ if paused:
+ _speed_indicator_button.set_tooltip_string("TOPBAR_PAUSE_INDICATOR")
+ else:
+ index += speed + 1
+ const SPEED_NAMES : PackedStringArray = [
+ "SLOWEST_SPEED",
+ "SLOW_SPEED",
+ "NORMAL_SPEED",
+ "FAST_SPEED",
+ "FASTEST_SPEED"
+ ]
+ _speed_indicator_button.set_tooltip_string_and_substitution_dict(
+ "TOPBAR_SPEED_INDICATOR", { "SPEED": SPEED_NAMES[speed] if speed < SPEED_NAMES.size() else str(speed) }
+ )
_speed_indicator_button.set_icon_index(index)
# REQUIREMENTS: