add editor settings override ui component
This commit is contained in:
parent
c9c1cdeaae
commit
2321735df8
@ -0,0 +1,27 @@
|
||||
extends VBoxContainer
|
||||
class_name OverrideEditorSettingsMenu
|
||||
|
||||
const ITEM_SCENE := preload("res://UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenuItem.tscn")
|
||||
|
||||
@onready var override_item_container: VBoxContainer = %OverrideItemContainer
|
||||
@onready var new_override_button: Button = %NewOverrideButton
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
new_override_button.pressed.connect(
|
||||
add_item.bind(ITEM_SCENE.instantiate())
|
||||
)
|
||||
|
||||
|
||||
func add_item(item: OverrideEditorSettingsMenuItem) -> void:
|
||||
override_item_container.add_child(item)
|
||||
|
||||
|
||||
func get_overrides() -> Dictionary:
|
||||
var res := {}
|
||||
|
||||
for item in override_item_container.get_children():
|
||||
item = item as OverrideEditorSettingsMenuItem
|
||||
res.merge(item.get_property())
|
||||
|
||||
return res
|
@ -0,0 +1,25 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://ig4wkr1lxvbv"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd" id="1_ld5wi"]
|
||||
|
||||
[node name="OverrideEditorSettingsMenu" type="VBoxContainer"]
|
||||
offset_right = 671.0
|
||||
offset_bottom = 65.0
|
||||
script = ExtResource("1_ld5wi")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Editor Settings overrides"
|
||||
|
||||
[node name="OverrideItemContainer" type="VBoxContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="NewOverrideButton" type="Button" parent="CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "New override"
|
@ -0,0 +1,65 @@
|
||||
extends HBoxContainer
|
||||
class_name OverrideEditorSettingsMenuItem
|
||||
|
||||
# god help me
|
||||
const TYPE_NAMES := {
|
||||
TYPE_NIL: "Type: Nil",
|
||||
TYPE_BOOL: "Type: Bool",
|
||||
TYPE_INT: "Type: Int",
|
||||
TYPE_FLOAT: "Type: Float",
|
||||
TYPE_STRING: "Type: String",
|
||||
TYPE_VECTOR2: "Type: Vector2",
|
||||
TYPE_VECTOR2I: "Type: Vector2i",
|
||||
TYPE_RECT2: "Type: Rect2",
|
||||
TYPE_RECT2I: "Type: Rect2i",
|
||||
TYPE_VECTOR3: "Type: Vector3",
|
||||
TYPE_VECTOR3I: "Type: Vector3i",
|
||||
TYPE_TRANSFORM2D: "Type: Transform2D",
|
||||
TYPE_VECTOR4: "Type: Vector4",
|
||||
TYPE_VECTOR4I: "Type: Vector4i",
|
||||
TYPE_PLANE: "Type: Plane",
|
||||
TYPE_QUATERNION: "Type: Quaternion",
|
||||
TYPE_AABB: "Type: AABB",
|
||||
TYPE_BASIS: "Type: Basis",
|
||||
TYPE_TRANSFORM3D: "Type: Transform3D",
|
||||
TYPE_PROJECTION: "Type: Projection",
|
||||
TYPE_COLOR: "Type: Color",
|
||||
TYPE_STRING_NAME: "Type: StringName",
|
||||
TYPE_NODE_PATH: "Type: NodePath",
|
||||
TYPE_RID: "Type: RID",
|
||||
TYPE_OBJECT: "Type: Object",
|
||||
TYPE_CALLABLE: "Type: Callable",
|
||||
TYPE_SIGNAL: "Type: Signal",
|
||||
TYPE_DICTIONARY: "Type: Dictionary",
|
||||
TYPE_ARRAY: "Type: Array",
|
||||
TYPE_PACKED_BYTE_ARRAY: "Type: PackedByteArray",
|
||||
TYPE_PACKED_INT32_ARRAY: "Type: PackedInt32Array",
|
||||
TYPE_PACKED_INT64_ARRAY: "Type: PackedInt64Array",
|
||||
TYPE_PACKED_FLOAT32_ARRAY: "Type: PackedFloat32Array",
|
||||
TYPE_PACKED_FLOAT64_ARRAY: "Type: PackedFloat64Array",
|
||||
TYPE_PACKED_STRING_ARRAY: "Type: PackedStringArray",
|
||||
TYPE_PACKED_VECTOR2_ARRAY: "Type: PackedVector2Array",
|
||||
TYPE_PACKED_VECTOR3_ARRAY: "Type: PackedVector3Array",
|
||||
TYPE_PACKED_COLOR_ARRAY: "Type: PackedColorArray",
|
||||
}
|
||||
|
||||
@onready var property_name_line_edit: LineEdit = %PropertyNameLineEdit
|
||||
@onready var property_type_option_button: OptionButton = %PropertyTypeOptionButton
|
||||
@onready var property_value_line_edit: LineEdit = %PropertyValueLineEdit
|
||||
@onready var delete_item_button: Button = %DeleteItemButton
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# for now, type is just a hint for the convert function.
|
||||
# in the future, there will be custom editors for types, like godot's inspector.
|
||||
for type in TYPE_MAX:
|
||||
property_type_option_button.add_item(TYPE_NAMES[type])
|
||||
|
||||
delete_item_button.pressed.connect(queue_free)
|
||||
|
||||
|
||||
func get_property() -> Dictionary:
|
||||
var prop_name = property_name_line_edit.text
|
||||
var value = convert(property_value_line_edit.text, property_type_option_button.get_selected_id())
|
||||
|
||||
return {prop_name: value}
|
@ -0,0 +1,32 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cbp55btxd5pmi"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenuItem.gd" id="1_gtb1r"]
|
||||
|
||||
[node name="OverrideEditorSettingsMenuItem" type="HBoxContainer"]
|
||||
offset_right = 505.0
|
||||
offset_bottom = 32.0
|
||||
script = ExtResource("1_gtb1r")
|
||||
|
||||
[node name="PropertyNameLineEdit" type="LineEdit" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Property name"
|
||||
|
||||
[node name="PropertyTypeOptionButton" type="OptionButton" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.72
|
||||
text_overrun_behavior = 3
|
||||
|
||||
[node name="PropertyValueLineEdit" type="LineEdit" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Property value"
|
||||
|
||||
[node name="DeleteItemButton" type="Button" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "X"
|
Loading…
Reference in New Issue
Block a user