initial commit
This commit is contained in:
@ -0,0 +1,66 @@
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends CheckBox
|
||||
class_name LineEditorBool
|
||||
|
||||
var resource:Resource:
|
||||
get:
|
||||
return resource
|
||||
set(value):
|
||||
resource = value
|
||||
dirty = true
|
||||
|
||||
var prop_name:String:
|
||||
get:
|
||||
return prop_name
|
||||
set(value):
|
||||
prop_name = value
|
||||
dirty = true
|
||||
|
||||
var dirty = true
|
||||
|
||||
func update_from_resource():
|
||||
if resource:
|
||||
var result = resource.get(prop_name)
|
||||
if result != null:
|
||||
button_pressed = result
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if dirty:
|
||||
update_from_resource()
|
||||
dirty = false
|
||||
|
||||
|
||||
func _on_toggled(button_pressed):
|
||||
if resource:
|
||||
print("prop_name %s" % prop_name)
|
||||
print("button_pressed %s" % button_pressed)
|
||||
resource.set(prop_name, button_pressed)
|
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dpncabeqiv1xo"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/controls/resource_inspector/line_editor_bool.gd" id="1_sn3qq"]
|
||||
|
||||
[node name="CheckBox" type="CheckBox"]
|
||||
offset_right = 24.0
|
||||
offset_bottom = 24.0
|
||||
script = ExtResource("1_sn3qq")
|
||||
|
||||
[connection signal="toggled" from="." to="." method="_on_toggled"]
|
@ -0,0 +1,65 @@
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends SpinBox
|
||||
class_name LineEditorFloat
|
||||
|
||||
|
||||
var resource:Resource:
|
||||
get:
|
||||
return resource
|
||||
set(value):
|
||||
resource = value
|
||||
dirty = true
|
||||
|
||||
var prop_name:String:
|
||||
get:
|
||||
return prop_name
|
||||
set(value):
|
||||
prop_name = value
|
||||
dirty = true
|
||||
|
||||
var dirty = true
|
||||
|
||||
func update_from_resource():
|
||||
if resource:
|
||||
var result = resource.get(prop_name)
|
||||
if result != null:
|
||||
value = result
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if dirty:
|
||||
update_from_resource()
|
||||
dirty = false
|
||||
|
||||
|
||||
func _on_value_changed(value):
|
||||
if resource:
|
||||
resource.set(prop_name, value)
|
@ -0,0 +1,11 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dg45e7tw7ttu3"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/controls/resource_inspector/line_editor_float.gd" id="1_o1hmb"]
|
||||
|
||||
[node name="SpinBox" type="SpinBox"]
|
||||
offset_right = 83.0625
|
||||
offset_bottom = 31.0
|
||||
step = 0.001
|
||||
script = ExtResource("1_o1hmb")
|
||||
|
||||
[connection signal="value_changed" from="." to="." method="_on_value_changed"]
|
@ -0,0 +1,71 @@
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends SpinBox
|
||||
class_name LineEditorInt
|
||||
|
||||
var resource:Resource:
|
||||
get:
|
||||
return resource
|
||||
set(value):
|
||||
resource = value
|
||||
dirty = true
|
||||
|
||||
var prop_name:String:
|
||||
get:
|
||||
return prop_name
|
||||
set(value):
|
||||
prop_name = value
|
||||
dirty = true
|
||||
|
||||
var dirty = true
|
||||
|
||||
func update_from_resource():
|
||||
#print("update_from_resource()")
|
||||
if resource:
|
||||
#print("resource %s" % resource)
|
||||
#print("prop_name %s" % prop_name)
|
||||
var result = resource.get(prop_name)
|
||||
#print("result %s" % result)
|
||||
if result != null:
|
||||
value = result
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if dirty:
|
||||
update_from_resource()
|
||||
dirty = false
|
||||
|
||||
|
||||
func _on_value_changed(value):
|
||||
print("_on_value_changed(value)")
|
||||
if resource:
|
||||
print("prop_name %s" % prop_name)
|
||||
print("value %s" % value)
|
||||
resource.set(prop_name, value)
|
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dh6frljlp7oqe"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/controls/resource_inspector/line_editor_int.gd" id="1_ryygx"]
|
||||
|
||||
[node name="SpinBox" type="SpinBox"]
|
||||
offset_right = 83.0625
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_ryygx")
|
||||
|
||||
[connection signal="value_changed" from="." to="." method="_on_value_changed"]
|
@ -0,0 +1,86 @@
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Mark McKay
|
||||
# https://github.com/blackears/cyclopsLevelBuilder
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
@tool
|
||||
extends Control
|
||||
class_name ResourceInspector
|
||||
|
||||
@export var target:Resource:
|
||||
get:
|
||||
return target
|
||||
set(value):
|
||||
target = value
|
||||
build()
|
||||
|
||||
func add_label(name:String):
|
||||
var label:Label = Label.new()
|
||||
label.text = name
|
||||
$GridContainer.add_child(label)
|
||||
|
||||
func build():
|
||||
for child in $GridContainer.get_children():
|
||||
$GridContainer.remove_child(child)
|
||||
|
||||
if !target:
|
||||
return
|
||||
|
||||
for prop_dict in target.get_property_list():
|
||||
var prop_name:String = prop_dict["name"]
|
||||
# prop_dict["class_name"]
|
||||
|
||||
var type:Variant.Type = prop_dict["type"]
|
||||
match type:
|
||||
TYPE_BOOL:
|
||||
add_label(prop_name)
|
||||
|
||||
var editor:LineEditorBool = preload("res://addons/cyclops_level_builder/controls/resource_inspector/line_editor_bool.tscn").instantiate()
|
||||
editor.resource = target
|
||||
editor.prop_name = prop_name
|
||||
$GridContainer.add_child(editor)
|
||||
|
||||
TYPE_INT:
|
||||
add_label(prop_name)
|
||||
|
||||
var editor:LineEditorInt = preload("res://addons/cyclops_level_builder/controls/resource_inspector/line_editor_int.tscn").instantiate()
|
||||
editor.resource = target
|
||||
editor.prop_name = prop_name
|
||||
$GridContainer.add_child(editor)
|
||||
|
||||
TYPE_FLOAT:
|
||||
add_label(prop_name)
|
||||
|
||||
var editor:LineEditorFloat = preload("res://addons/cyclops_level_builder/controls/resource_inspector/line_editor_float.tscn").instantiate()
|
||||
editor.resource = target
|
||||
editor.prop_name = prop_name
|
||||
$GridContainer.add_child(editor)
|
||||
|
||||
pass
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c2484sv0ymy2e"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/cyclops_level_builder/controls/resource_inspector/resource_inspector.gd" id="1_m3yhx"]
|
||||
|
||||
[node name="object_inspector" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_m3yhx")
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
columns = 2
|
Reference in New Issue
Block a user