Experimental Code Updated For Color

Adds color codes for the ColorRect selection using the recommended depth system.
This commit is contained in:
MacDugRPG 2023-06-11 13:28:29 -04:00
parent 24b1d2c772
commit 2d6ad58c1d
8 changed files with 58 additions and 8 deletions

View File

@ -27,7 +27,7 @@ _global_script_class_icons={
[application] [application]
config/name="Experiment_Location_Folders" config/name="Experiment_Location_Folders"
run/main_scene="res://toolset_test/drag_and_drop_demo_final.tscn" run/main_scene="res://toolset_test_tabbed_merged/tabbed_merged_test_interface.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[gui] [gui]

View File

@ -6,10 +6,10 @@ onready var draggable_assets_scene: PackedScene = preload("res://toolset_test_ta
onready var draggable_assets_container = $Padding/AssetsRows onready var draggable_assets_container = $Padding/AssetsRows
var dragables = [ var dragables = [
{"id": 1, "label": "region"}, {"id": 1, "label": "region", "color": "red"},
{"id": 2, "label": "location"}, {"id": 2, "label": "location", "color": "orange"},
{"id": 3, "label": "space"}, {"id": 3, "label": "space", "color": "yellow"},
{"id": 4, "label": "scene"}, {"id": 4, "label": "scene", "color": "green"},
] ]
@ -22,6 +22,7 @@ func _populate_dragables():
var drag_item = draggable_assets_scene.instance() var drag_item = draggable_assets_scene.instance()
drag_item.id = dragable["id"] drag_item.id = dragable["id"]
drag_item.label = dragable["label"] drag_item.label = dragable["label"]
drag_item.color = _set_color_from_text(dragable["color"])
draggable_assets_container.add_child(drag_item) draggable_assets_container.add_child(drag_item)
func _on_item_dropped_on_target(dropped_item: Draggable_Assets) -> void: func _on_item_dropped_on_target(dropped_item: Draggable_Assets) -> void:
@ -31,3 +32,19 @@ func _on_item_dropped_on_target(dropped_item: Draggable_Assets) -> void:
#draggable_container.remove_child(drag_item) #draggable_container.remove_child(drag_item)
#drag_item.queue_free() #drag_item.queue_free()
break break
#DKM TEMP: for refactoring, this should live elsewhere, but as we get this up.
func _set_color_from_text(colorTerm: String) -> Color:
var end_color = Color8(0,0,0)
match(colorTerm):
"red":
end_color = Color8(255,0,0)
"orange":
end_color = Color8(255,102,0)
"yellow":
end_color = Color8(255,255,0)
"green":
end_color = Color8(0,102,0)
"blue":
end_color = Color8(0,0,255)
return end_color

View File

@ -7,6 +7,12 @@ var draggable_assets: PackedScene = preload("res://toolset_test_tabbed_merged/dr
func can_drop_data(position: Vector2, data) -> bool: func can_drop_data(position: Vector2, data) -> bool:
var can_drop: bool = data is Node and data.is_in_group("DRAGGABLE_ASSETS") var can_drop: bool = data is Node and data.is_in_group("DRAGGABLE_ASSETS")
print("[TargetContainer] can_drop_data has run, returning %s" % can_drop) print("[TargetContainer] can_drop_data has run, returning %s" % can_drop)
#DKM TEMP:
if(!can_drop):
var temp_bool: bool = data is Node
print("Is node? %s" % temp_bool)
temp_bool = data.is_in_group("DRAGGABLE_ASSETS")
print("Is in group DRAGGABLE_ASSETS? %s" % temp_bool)
return can_drop return can_drop
func drop_data(position: Vector2, data) -> void: func drop_data(position: Vector2, data) -> void:
@ -19,7 +25,23 @@ func drop_data(position: Vector2, data) -> void:
draggable_copy.id = data.id draggable_copy.id = data.id
#Instantiate a new version of the specific item in this content capsule #Instantiate a new version of the specific item in this content capsule
draggable_copy.label = data.label draggable_copy.label = data.label
draggable_copy.color = data.color
draggable_copy.dropped_on_target = true # disable further dragging draggable_copy.dropped_on_target = true # disable further dragging
$Padding/Rows.add_child(draggable_copy)
#DKM TEMP: create directory
var directory = Directory.new()
#DKM TEMP: this is ridiculously unchecked -- need to verify this, etc:
var directoryPath = "res://_temp_places/%s_userEnteredName" % data.label
directory.make_dir(directoryPath)
var file = File.new()
var configFilePath = directoryPath + "/config.txt"
file.open(configFilePath, File.WRITE)
file.store_line("Temp Config File")
file.close()
#DKM TEMP: Add to the visual display (for now). Instead of this, we want to
# read the directories that are there for our UI. We can then still use
# something like a ColorRect, but it should come from that.
$Rows.add_child(draggable_copy)
emit_signal("item_dropped_on_target", data) emit_signal("item_dropped_on_target", data)

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://Cabin-VariableFont_wdth,wght.ttf" type="DynamicFontData" id=1] [ext_resource path="res://Cabin-VariableFont_wdth,wght.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://toolset_test/draggable_final.gd" type="Script" id=2] [ext_resource path="res://toolset_test_tabbed_merged/draggable_assets_final.gd" type="Script" id=2]
[sub_resource type="DynamicFont" id=6] [sub_resource type="DynamicFont" id=6]
size = 24 size = 24
@ -11,10 +11,11 @@ font_data = ExtResource( 1 )
margin_right = 150.0 margin_right = 150.0
margin_bottom = 35.0 margin_bottom = 35.0
rect_min_size = Vector2( 150, 35 ) rect_min_size = Vector2( 150, 35 )
color = Color( 0.752941, 0.305882, 0.305882, 1 ) color = Color( 1, 0, 0, 1 )
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
modulate = Color( 0, 0, 0, 1 )
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
custom_fonts/font = SubResource( 6 ) custom_fonts/font = SubResource( 6 )

View File

@ -37,6 +37,9 @@ func _get_preview_control() -> Control:
preview.rect_size = rect_size preview.rect_size = rect_size
var preview_color = color var preview_color = color
preview_color.a = .5 preview_color.a = .5
#DKM TEMP:
var testColor = Color8(125,125,125)
preview_color = testColor
preview.color = preview_color preview.color = preview_color
preview.set_rotation(.1) # in readians preview.set_rotation(.1) # in readians
return preview return preview

View File

@ -143,6 +143,7 @@ margin_right = -4.0
margin_bottom = -4.0 margin_bottom = -4.0
[node name="Structural_Tab" type="Tabs" parent="VLayout/HBoxContainer/TabContainer"] [node name="Structural_Tab" type="Tabs" parent="VLayout/HBoxContainer/TabContainer"]
visible = false
margin_right = 40.0 margin_right = 40.0
margin_bottom = 24.0 margin_bottom = 24.0
@ -159,6 +160,10 @@ margin_right = 643.0
margin_bottom = 525.0 margin_bottom = 525.0
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="Rows" type="VBoxContainer" parent="VLayout/HBoxContainer/TabContainer/Structural_Tab/PanelCanvas_Temp"]
margin_right = 40.0
margin_bottom = 40.0
[node name="DetailsContainer" type="Panel" parent="VLayout/HBoxContainer"] [node name="DetailsContainer" type="Panel" parent="VLayout/HBoxContainer"]
margin_left = 833.0 margin_left = 833.0
margin_right = 1008.0 margin_right = 1008.0