Refactor formatting functions and improve item production logic; update UI components for better layout and usability
This commit is contained in:
+15
-2
@@ -12,6 +12,7 @@ signal action_pressed(page_id, amount: float)
|
||||
]
|
||||
|
||||
var page_id: int = -1
|
||||
var current_item_id = ""
|
||||
|
||||
var action_values: Dictionary = {
|
||||
0: 0,
|
||||
@@ -22,11 +23,23 @@ var action_values: Dictionary = {
|
||||
}
|
||||
|
||||
|
||||
func set_actions(item_id: String, value: float) -> void:
|
||||
current_item_id = item_id
|
||||
_set_action_values(_get_distribution(value))
|
||||
|
||||
func set_action_values(values: Array) -> void:
|
||||
func _get_distribution(value: float) -> Array:
|
||||
var distribution: Array = [value, 0, 0, 0, 0]
|
||||
|
||||
var exp_value = int(floor(log(abs(value)) / log(10.0)))
|
||||
var floor_value = max(exp_value - 4, -1)
|
||||
for ev in range(exp_value, floor_value, -1):
|
||||
distribution.push_front(pow(10.0, ev))
|
||||
return distribution
|
||||
|
||||
func _set_action_values(values: Array) -> void:
|
||||
for ind in range(0, 5):
|
||||
action_values[ind] = values[ind]
|
||||
action_labels[ind].text = str(values[ind]) if values[ind] > 0 else ""
|
||||
action_labels[ind].text = Global.format_number(values[ind]) if values[ind] > 0 else ""
|
||||
|
||||
|
||||
func _on_action_button_pressed(button_id: int) -> void:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://gsclv7fr1rbr" path="res://ui/actions/action_button.png" id="2_cjivn"]
|
||||
|
||||
[node name="Actions" type="HBoxContainer" unique_id=503388208]
|
||||
custom_minimum_size = Vector2(0, 184)
|
||||
custom_minimum_size = Vector2(0, 216)
|
||||
script = ExtResource("1_cjivn")
|
||||
|
||||
[node name="ActionControl0" type="Control" parent="." unique_id=1275614326]
|
||||
@@ -22,6 +22,7 @@ theme_override_font_sizes/font_size = 32
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="ActionControl0" unique_id=1122042557]
|
||||
custom_minimum_size = Vector2(216, 184)
|
||||
layout_mode = 0
|
||||
offset_top = 32.0
|
||||
offset_right = 216.0
|
||||
@@ -42,6 +43,7 @@ theme_override_font_sizes/font_size = 32
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="ActionControl1" unique_id=1538851090]
|
||||
custom_minimum_size = Vector2(216, 184)
|
||||
layout_mode = 0
|
||||
offset_top = 32.0
|
||||
offset_right = 216.0
|
||||
@@ -62,6 +64,7 @@ theme_override_font_sizes/font_size = 32
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="ActionControl2" unique_id=1137903803]
|
||||
custom_minimum_size = Vector2(216, 184)
|
||||
layout_mode = 0
|
||||
offset_top = 32.0
|
||||
offset_right = 216.0
|
||||
@@ -82,6 +85,7 @@ theme_override_font_sizes/font_size = 32
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="ActionControl3" unique_id=1783481629]
|
||||
custom_minimum_size = Vector2(216, 184)
|
||||
layout_mode = 0
|
||||
offset_top = 32.0
|
||||
offset_right = 216.0
|
||||
@@ -102,6 +106,7 @@ theme_override_font_sizes/font_size = 32
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="ActionControl4" unique_id=1477690280]
|
||||
custom_minimum_size = Vector2(216, 184)
|
||||
layout_mode = 0
|
||||
offset_top = 32.0
|
||||
offset_right = 216.0
|
||||
|
||||
Reference in New Issue
Block a user