matadors moving, thrusty bull, slop

This commit is contained in:
2026-05-20 21:07:09 +03:00
parent a8b9f166a6
commit af0790a1ce
16 changed files with 138 additions and 159 deletions
+24 -58
View File
@@ -9,7 +9,6 @@ var _prev_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_CAPTURED
func _ready() -> void:
_build_ui()
DP.any_changed.connect(_on_dp_changed)
func _build_ui() -> void:
@@ -64,6 +63,11 @@ func _build_ui() -> void:
save_btn.pressed.connect(_on_save)
toolbar.add_child(save_btn)
var rand_all_btn := Button.new()
rand_all_btn.text = "Randomize All"
rand_all_btn.pressed.connect(_on_randomize_all)
toolbar.add_child(rand_all_btn)
var reset_btn := Button.new()
reset_btn.text = "Reset All"
reset_btn.pressed.connect(DP.reset_all)
@@ -113,8 +117,6 @@ func _build_params(content: VBoxContainer) -> void:
var meta: Dictionary = DP.get_all()[key]
if meta["type"] == TYPE_FLOAT:
_add_float_row(content, key, meta)
elif meta["type"] == TYPE_BOOL:
_add_bool_row(content, key, meta)
func _add_float_row(parent: VBoxContainer, key: String, meta: Dictionary) -> void:
@@ -145,6 +147,16 @@ func _add_float_row(parent: VBoxContainer, key: String, meta: Dictionary) -> voi
spin.custom_minimum_size.x = 85
row.add_child(spin)
var rand_btn := Button.new()
rand_btn.text = "🎲"
rand_btn.tooltip_text = "Randomize"
rand_btn.pressed.connect(func() -> void:
var v := randf_range(meta["min"], meta["max"])
v = snappedf(v, meta["step"])
slider.value = v
)
row.add_child(rand_btn)
# Slider → SpinBox + DP (use no_signal to avoid echo)
slider.value_changed.connect(func(v: float) -> void:
spin.set_value_no_signal(v)
@@ -165,46 +177,6 @@ func _add_float_row(parent: VBoxContainer, key: String, meta: Dictionary) -> voi
)
func _add_bool_row(parent: VBoxContainer, key: String, meta: Dictionary) -> void:
var row := HBoxContainer.new()
row.size_flags_horizontal = Control.SIZE_FILL
parent.add_child(row)
var lbl := Label.new()
lbl.text = key.replace("_", " ")
lbl.custom_minimum_size.x = 140
lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
row.add_child(lbl)
var btn := Button.new()
btn.toggle_mode = true
btn.button_pressed = meta["value"]
btn.text = "HIDDEN" if not meta["value"] else "SHOWN"
_update_btn_style(btn, meta["value"])
row.add_child(btn)
btn.toggled.connect(func(v: bool) -> void:
btn.text = "HIDDEN" if not v else "SHOWN"
_update_btn_style(btn, v)
DP.set_value(key, v)
)
DP.any_changed.connect(func(changed_key: String, _val: Variant) -> void:
if changed_key != key and changed_key != "__all__":
return
var v_b: bool = DP.b(key)
btn.set_pressed_no_signal(v_b)
btn.text = "HIDDEN" if not v_b else "SHOWN"
_update_btn_style(btn, v_b)
)
func _update_btn_style(btn: Button, active: bool) -> void:
if active:
btn.add_theme_color_override("font_color", Color(0.4, 1.0, 0.5))
else:
btn.add_theme_color_override("font_color", Color(1.0, 0.4, 0.4))
func _on_save() -> void:
DP.save()
@@ -214,21 +186,6 @@ func _on_save() -> void:
)
func _on_dp_changed(key: String, _value: Variant) -> void:
if key == "show_collisions" or key == "__all__":
var active: bool = DP.b("show_collisions")
get_tree().debug_collisions_hint = active
# Force refresh of all collision shapes
_refresh_collisions(get_tree().root, active)
func _refresh_collisions(node: Node, active: bool) -> void:
if node is CollisionShape3D or node is CollisionPolygon3D:
node.visible = !node.visible # Trigger a notification
node.visible = !node.visible
for child in node.get_children():
_refresh_collisions(child, active)
func _input(event: InputEvent) -> void:
@@ -248,3 +205,12 @@ func _unhandled_input(event: InputEvent) -> void:
else:
Input.mouse_mode = _prev_mouse_mode
get_viewport().set_input_as_handled()
func _on_randomize_all() -> void:
for key: String in DP.get_all():
var meta: Dictionary = DP.get_all()[key]
if meta["type"] == TYPE_FLOAT:
var v := snappedf(randf_range(meta["min"], meta["max"]), meta["step"])
DP.set_value(key, v)