diff options
author | hop311 <hop3114@gmail.com> | 2024-03-20 01:11:22 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-03-20 23:47:37 +0100 |
commit | f8af17618e9f24dd6833ecaab64bf968cca2ec15 (patch) | |
tree | 3b5636e154a067c8383d2d9cac8c9f12839d64a1 /extension/src/openvic-extension/utility | |
parent | 8088824d7b78311c0613b3876ba9555fbbe96c17 (diff) |
Label padding, progressbar range and piechart slice order tweaks
Diffstat (limited to 'extension/src/openvic-extension/utility')
-rw-r--r-- | extension/src/openvic-extension/utility/UITools.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/extension/src/openvic-extension/utility/UITools.cpp b/extension/src/openvic-extension/utility/UITools.cpp index c00b64d..23dcced 100644 --- a/extension/src/openvic-extension/utility/UITools.cpp +++ b/extension/src/openvic-extension/utility/UITools.cpp @@ -177,8 +177,13 @@ static bool generate_icon(generate_gui_args_t&& args) { godot_progress_bar, false, vformat("Failed to create TextureProgressBar for GUI icon %s", icon_name) ); + static constexpr double MIN_VALUE = 0.0, MAX_VALUE = 1.0; + static constexpr uint32_t STEPS = 100; + godot_progress_bar->set_nine_patch_stretch(true); - godot_progress_bar->set_max(1.0); + godot_progress_bar->set_step((MAX_VALUE - MIN_VALUE) / STEPS); + godot_progress_bar->set_min(MIN_VALUE); + godot_progress_bar->set_max(MAX_VALUE); GFX::ProgressBar const* progress_bar = icon.get_sprite()->cast_to<GFX::ProgressBar>(); @@ -435,7 +440,12 @@ static bool generate_text(generate_gui_args_t&& args) { ERR_FAIL_NULL_V_MSG(godot_label, false, vformat("Failed to create Label for GUI text %s", text_name)); godot_label->set_text(std_view_to_godot_string(text.get_text())); - godot_label->set_custom_minimum_size(Utilities::to_godot_fvec2(text.get_max_size())); + + static const Vector2 default_padding { 1.0f, 0.0f }; + const Vector2 border_size = Utilities::to_godot_fvec2(text.get_border_size()) + default_padding; + const Vector2 max_size = Utilities::to_godot_fvec2(text.get_max_size()); + godot_label->set_position(godot_label->get_position() + border_size); + godot_label->set_custom_minimum_size(max_size - 2 * border_size); using enum GUI::AlignedElement::format_t; static const ordered_map<GUI::AlignedElement::format_t, HorizontalAlignment> format_map { |