diff options
author | hop311 <hop3114@gmail.com> | 2024-08-15 01:13:54 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-08-15 01:13:54 +0200 |
commit | 7c85ab11e840c281a2499dcc6dd3219c33e7d37f (patch) | |
tree | 84460d9e4c3af8656604add874fc9a379a0adc4a /extension/src/openvic-extension/utility/Utilities.cpp | |
parent | 82b16bcca7c74607a8885b882ec36f5202e7ef70 (diff) |
Add GUITextLabel (colour code + currency icon support)
Diffstat (limited to 'extension/src/openvic-extension/utility/Utilities.cpp')
-rw-r--r-- | extension/src/openvic-extension/utility/Utilities.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/utility/Utilities.cpp b/extension/src/openvic-extension/utility/Utilities.cpp index 4a774a7..1fcdea8 100644 --- a/extension/src/openvic-extension/utility/Utilities.cpp +++ b/extension/src/openvic-extension/utility/Utilities.cpp @@ -63,6 +63,11 @@ String Utilities::float_to_string_dp(float val, int32_t decimal_places) { return String::num(val, decimal_places).pad_decimals(decimal_places); } +String Utilities::float_to_string_dp_dynamic(float val) { + const float abs_val = std::abs(val); + return float_to_string_dp(val, abs_val < 2.0f ? 3 : abs_val < 10.0f ? 2 : 1); +} + /* Date formatted like this: "January 1, 1836" (with the month localised, if possible). */ String Utilities::date_to_formatted_string(Date date) { const String month_name = Utilities::std_to_godot_string(date.get_month_name()); |