diff options
author | hop311 <hop3114@gmail.com> | 2024-08-29 00:16:24 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-08-29 23:04:30 +0200 |
commit | bdc2ba527bc02e7cdf977f6040f2ca85aa4f9a94 (patch) | |
tree | 4627ad955ac60f5c66b94dfc3106bd8442b58302 /extension/src/openvic-extension/singletons/MenuSingleton.cpp | |
parent | 88acb31bd43f0e163522837bb1d0dd7da2977c4a (diff) |
Add tooltips for buttons, labels, icons, pie charts, sliders, and progress barstooltip
Diffstat (limited to 'extension/src/openvic-extension/singletons/MenuSingleton.cpp')
-rw-r--r-- | extension/src/openvic-extension/singletons/MenuSingleton.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
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( |