mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
add ability to remove variables in variable viewer
This commit is contained in:
parent
bcdba9818c
commit
b2439d9209
6 changed files with 84 additions and 2 deletions
|
@ -209,6 +209,10 @@ func update_variable(old_name: String, new_name: String, new_value: Variant) ->
|
|||
variable_stack[new_name] = new_value
|
||||
|
||||
|
||||
func remove_variable(name: String) -> void:
|
||||
variable_stack.erase(name)
|
||||
|
||||
|
||||
## Group the [param nodes_to_group] into a new deck and return it.
|
||||
## Returns [code]null[/code] on failure.[br]
|
||||
## Adds a group node to this deck, and adds group input and output nodes in the group.
|
||||
|
|
|
@ -120,6 +120,11 @@ func _ready() -> void:
|
|||
get_active_deck().update_variable(old_name, new_name, new_value)
|
||||
)
|
||||
|
||||
bottom_dock.variable_viewer.top_field_removed.connect(
|
||||
func(field_name: String) -> void:
|
||||
get_active_deck().remove_variable(field_name)
|
||||
)
|
||||
|
||||
|
||||
func _on_tab_container_tab_about_to_change(previous_tab: int) -> void:
|
||||
var deck := get_deck_at_tab(previous_tab)
|
||||
|
|
1
graph_node_renderer/textures/remove-icon.svg
Normal file
1
graph_node_renderer/textures/remove-icon.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m5 1v1h-4v2h14v-2h-4v-1zm-3 4v8a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-8zm1 2h2v6h-2zm4 0h2v6h-2zm4 0h2v6h-2z" fill="#e0e0e0"/></svg>
|
After Width: | Height: | Size: 218 B |
37
graph_node_renderer/textures/remove-icon.svg.import
Normal file
37
graph_node_renderer/textures/remove-icon.svg.import
Normal file
|
@ -0,0 +1,37 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cdhco73u4faf8"
|
||||
path="res://.godot/imported/remove-icon.svg-39dfaea1590f79f30a4d86a2f83a7c3d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graph_node_renderer/textures/remove-icon.svg"
|
||||
dest_files=["res://.godot/imported/remove-icon.svg-39dfaea1590f79f30a4d86a2f83a7c3d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
|
@ -3,13 +3,16 @@
|
|||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
extends VBoxContainer
|
||||
class_name VariableViewer
|
||||
|
||||
const REMOVE_ICON = preload("res://graph_node_renderer/textures/remove-icon.svg")
|
||||
|
||||
@onready var variable_tree: Tree = %VariableTree
|
||||
@onready var types_popup: PopupMenu = %TypesPopup
|
||||
var root: TreeItem
|
||||
|
||||
var _old_name: String
|
||||
|
||||
signal top_field_edited(old_name: String, new_name: String, new_value: Variant)
|
||||
signal top_field_removed(field_name: String)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -74,7 +77,7 @@ func _ready() -> void:
|
|||
|
||||
# array
|
||||
if item.get_meta(&"indexed", false):
|
||||
var index := int(new_name)
|
||||
var index := item.get_index()
|
||||
(container as Array)[index] = new_value
|
||||
# dictionary
|
||||
else:
|
||||
|
@ -127,5 +130,34 @@ func add_item(item_name: String, item_value: Variant, parent: TreeItem = root, c
|
|||
for i in (item_value as Array).size():
|
||||
add_item(str(i), item_value[i], item, item_value, true)
|
||||
item.collapsed = true
|
||||
item.add_button(2, REMOVE_ICON)
|
||||
|
||||
return item
|
||||
|
||||
|
||||
func _on_variable_tree_button_clicked(item: TreeItem, column: int, id: int, mouse_button_index: int) -> void:
|
||||
if mouse_button_index != MOUSE_BUTTON_LEFT:
|
||||
return
|
||||
|
||||
if item.get_meta(&"container", -1) is int:
|
||||
var key := item.get_text(0)
|
||||
top_field_removed.emit(key)
|
||||
item.free()
|
||||
else:
|
||||
var container = item.get_meta(&"container")
|
||||
|
||||
# array
|
||||
if item.get_meta(&"indexed", false):
|
||||
var index := item.get_index()
|
||||
var parent := item.get_parent()
|
||||
(container as Array).remove_at(index)
|
||||
item.free()
|
||||
|
||||
# go through the array and reset the index strings
|
||||
for i in (container as Array).size():
|
||||
parent.get_child(i).set_text(0, str(i))
|
||||
|
||||
# dictionary
|
||||
else:
|
||||
(container as Dictionary).erase(item.get_text(0))
|
||||
item.free()
|
||||
|
|
|
@ -21,8 +21,11 @@ layout_mode = 2
|
|||
size_flags_vertical = 3
|
||||
columns = 3
|
||||
column_titles_visible = true
|
||||
allow_rmb_select = true
|
||||
allow_search = false
|
||||
hide_root = true
|
||||
|
||||
[node name="TypesPopup" type="PopupMenu" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[connection signal="button_clicked" from="VariableTree" to="." method="_on_variable_tree_button_clicked"]
|
||||
|
|
Loading…
Reference in a new issue