Refactor formatting functions and improve item production logic; update UI components for better layout and usability

This commit is contained in:
Kirill
2026-06-21 17:27:31 +03:00
parent 934d890887
commit 2d2979a1cf
10 changed files with 115 additions and 61 deletions
+5 -4
View File
@@ -34,14 +34,15 @@ func get_description(item_id: String, items: Array = []) -> String:
return description
func format(value: float, digits: int = 0) -> String:
func format_number(value: float, digits: int = 0) -> String:
if value == 0: return ""
if value < 10_000:
return "%.*f" % [digits, value]
var exp = int(floor(log(abs(value)) / log(10.0)))
var mantissa = value / pow(10.0, exp)
var exp_value = int(floor(log(abs(value)) / log(10.0)))
var mantissa = value / pow(10.0, exp_value)
return "%.*f" % [digits, mantissa] + "E%+d" % exp
return "%.*f" % [digits, mantissa] + "E%+d" % exp_value
func _ready() -> void: