Changed shader to use uniforms, created inspector
This commit is contained in:
1 parent
0f05a2bdef
commit
b3f7a0ae31
18 files changed
+404
-17
No files matched your search
@@ -0,0 +1,28 @@
|
||||
class_name ColorParam extends ParamField
|
||||
|
||||
@onready var label: Label = $Label
|
||||
@onready var popup_panel: PopupPanel = $PopupPanel
|
||||
@onready var color_rect: ColorRect = $Button/ColorRect
|
||||
@onready var color_picker: ColorPicker = $PopupPanel/ColorPicker
|
||||
|
||||
|
||||
func setup(
|
||||
dict: Dictionary,
|
||||
key: String) -> void:
|
||||
name = key
|
||||
_d = dict
|
||||
_k = key
|
||||
label.text = key.capitalize()
|
||||
|
||||
color_rect.color = _d[_k]
|
||||
color_picker.color = _d[_k]
|
||||
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
popup_panel.position = get_viewport().get_mouse_position()
|
||||
popup_panel.show()
|
||||
|
||||
|
||||
func _on_color_picker_color_changed(color: Color) -> void:
|
||||
color_rect.color = color
|
||||
_d[_k] = color
|
||||
@@ -0,0 +1 @@
|
||||
uid://bwensumb106vg
|
||||
@@ -0,0 +1,48 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://vynteayrjwyo"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://t07qph6qe3g7" path="res://inspector_theme.tres" id="1_xmr10"]
|
||||
[ext_resource type="Script" uid="uid://bwensumb106vg" path="res://components/color_param.gd" id="2_xmr10"]
|
||||
|
||||
[node name="ColorParam" type="HBoxContainer"]
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
grow_horizontal = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme = ExtResource("1_xmr10")
|
||||
script = ExtResource("2_xmr10")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Label"
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Button"]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 3.0
|
||||
offset_top = 3.0
|
||||
offset_right = -3.0
|
||||
offset_bottom = -3.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="PopupPanel" type="PopupPanel" parent="."]
|
||||
title = "Pick a Color"
|
||||
size = Vector2i(318, 580)
|
||||
|
||||
[node name="ColorPicker" type="ColorPicker" parent="PopupPanel"]
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 314.0
|
||||
offset_bottom = 576.0
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
[connection signal="color_changed" from="PopupPanel/ColorPicker" to="." method="_on_color_picker_color_changed"]
|
||||
@@ -0,0 +1,33 @@
|
||||
class_name FloatParam extends ParamField
|
||||
|
||||
|
||||
@onready var label: Label = $Labels/Label
|
||||
@onready var value_label: Label = $Labels/ValueLabel
|
||||
@onready var h_slider: HSlider = $HSlider
|
||||
|
||||
var decimal_places: int
|
||||
|
||||
func setup(
|
||||
dict: Dictionary,
|
||||
key: String,
|
||||
decimal_places: int = 2,
|
||||
min: float = 0.0,
|
||||
max: float = 1) -> void:
|
||||
name = key
|
||||
_d = dict
|
||||
_k = key
|
||||
label.text = key.capitalize()
|
||||
decimal_places = decimal_places
|
||||
|
||||
h_slider.min_value = min
|
||||
h_slider.max_value = max
|
||||
h_slider.step = 1.0 / pow(10, decimal_places)
|
||||
h_slider.value = dict[key]
|
||||
value_label.text = str(h_slider.value)
|
||||
|
||||
h_slider.value_changed.connect(_on_h_slider_value_changed)
|
||||
|
||||
|
||||
func _on_h_slider_value_changed(value: float) -> void:
|
||||
value_label.text = str(value)
|
||||
_d[_k] = value
|
||||
@@ -0,0 +1 @@
|
||||
uid://cm12tjnh26d8q
|
||||
@@ -0,0 +1,31 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dpvn15tum5qq5"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://t07qph6qe3g7" path="res://inspector_theme.tres" id="1_8buni"]
|
||||
[ext_resource type="Script" uid="uid://cm12tjnh26d8q" path="res://components/float_param.gd" id="2_mbky6"]
|
||||
|
||||
[node name="FloatControl" type="HBoxContainer"]
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
grow_horizontal = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme = ExtResource("1_8buni")
|
||||
script = ExtResource("2_mbky6")
|
||||
|
||||
[node name="Labels" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="Labels"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Label"
|
||||
|
||||
[node name="ValueLabel" type="Label" parent="Labels"]
|
||||
layout_mode = 2
|
||||
text = "100"
|
||||
|
||||
[node name="HSlider" type="HSlider" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
@@ -0,0 +1,4 @@
|
||||
class_name ParamField extends HBoxContainer
|
||||
|
||||
var _d: Dictionary
|
||||
var _k: String
|
||||
@@ -0,0 +1 @@
|
||||
uid://dpbttno55qmoe
|
||||
@@ -0,0 +1,28 @@
|
||||
class_name Vec2Param extends ParamField
|
||||
|
||||
@onready var label: Label = $Label
|
||||
|
||||
@onready var spin_box_x: SpinBox = $HBoxContainer/SpinBox_X
|
||||
@onready var spin_box_y: SpinBox = $HBoxContainer/SpinBox_Y
|
||||
|
||||
var decimal_places: int
|
||||
|
||||
func setup(
|
||||
dict: Dictionary,
|
||||
key: String) -> void:
|
||||
name = key
|
||||
_d = dict
|
||||
_k = key
|
||||
label.text = key.capitalize()
|
||||
decimal_places = decimal_places
|
||||
|
||||
var value: Vector2 = dict[key]
|
||||
spin_box_x.set_value_no_signal(value.x)
|
||||
spin_box_y.set_value_no_signal(value.y)
|
||||
|
||||
|
||||
func _on_spin_box_x_value_changed(value: float) -> void:
|
||||
_d[_k].x = value
|
||||
|
||||
func _on_spin_box_y_value_changed(value: float) -> void:
|
||||
_d[_k].y = value
|
||||
@@ -0,0 +1 @@
|
||||
uid://ddh6dx1piks05
|
||||
@@ -0,0 +1,62 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://h7mgbxxwg86d"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://t07qph6qe3g7" path="res://inspector_theme.tres" id="1_utjn2"]
|
||||
[ext_resource type="Script" uid="uid://ddh6dx1piks05" path="res://components/vec2_param.gd" id="2_j6hhs"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_v5o8a"]
|
||||
font_size = 18
|
||||
font_color = Color(1, 0.0392157, 0.0392157, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_cuurt"]
|
||||
font_size = 18
|
||||
font_color = Color(0.0392157, 1, 0.0392157, 1)
|
||||
|
||||
[node name="Vec2Control" type="HBoxContainer"]
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
grow_horizontal = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme = ExtResource("1_utjn2")
|
||||
script = ExtResource("2_j6hhs")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Label"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "x"
|
||||
label_settings = SubResource("LabelSettings_v5o8a")
|
||||
|
||||
[node name="SpinBox_X" type="SpinBox" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = -10.0
|
||||
max_value = 10.0
|
||||
step = 0.01
|
||||
custom_arrow_step = 0.01
|
||||
select_all_on_focus = true
|
||||
|
||||
[node name="Label2" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "y"
|
||||
label_settings = SubResource("LabelSettings_cuurt")
|
||||
|
||||
[node name="SpinBox_Y" type="SpinBox" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = -10.0
|
||||
max_value = 10.0
|
||||
step = 0.01
|
||||
custom_arrow_step = 0.01
|
||||
select_all_on_focus = true
|
||||
|
||||
[connection signal="value_changed" from="HBoxContainer/SpinBox_X" to="." method="_on_spin_box_x_value_changed"]
|
||||
[connection signal="value_changed" from="HBoxContainer/SpinBox_Y" to="." method="_on_spin_box_y_value_changed"]
|
||||
Reference in new issue
Block a user