diff --git a/addons/ai_editor/AIEditorScene.gd b/addons/ai_editor/AIEditorScene.gd deleted file mode 100644 index f4bec53..0000000 --- a/addons/ai_editor/AIEditorScene.gd +++ /dev/null @@ -1,12 +0,0 @@ -tool -extends Control - -#var _ai_action : AIAction - -func _ready(): - pass - -#func set_target(ai_action : AIAction) -> void: -# _ai_action = ai_action - -# $AIGraphEdit.set_target(ai_action) diff --git a/addons/ai_editor/AIEditorScene.tscn b/addons/ai_editor/AIEditorScene.tscn deleted file mode 100644 index 76c7930..0000000 --- a/addons/ai_editor/AIEditorScene.tscn +++ /dev/null @@ -1,68 +0,0 @@ -[gd_scene load_steps=4 format=2] - -[ext_resource path="res://addons/ai_editor/AIEditorScene.gd" type="Script" id=1] -[ext_resource path="res://addons/ai_editor/AIGraphEdit.gd" type="Script" id=2] -[ext_resource path="res://addons/ai_editor/CreateActionPopup.gd" type="Script" id=3] - -[node name="AIEditorScene" type="Control"] -anchor_right = 1.0 -anchor_bottom = 1.0 -rect_min_size = Vector2( 0, 200 ) -mouse_filter = 2 -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="AIGraphEdit" type="GraphEdit" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -right_disconnects = true -script = ExtResource( 2 ) -__meta__ = { -"_edit_lock_": true, -"_edit_use_anchors_": false -} -create_action_popup = NodePath("../CreateActionPopup") - -[node name="CreateActionPopup" type="ConfirmationDialog" parent="."] -margin_left = 38.0 -margin_top = 113.0 -margin_right = 262.0 -margin_bottom = 357.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -window_title = "Add New ..." -resizable = true -script = ExtResource( 3 ) -__meta__ = { -"_edit_use_anchors_": false -} -tree_path = NodePath("VBoxContainer/Tree") -search_le_path = NodePath("VBoxContainer/LineEdit") - -[node name="VBoxContainer" type="VBoxContainer" parent="CreateActionPopup"] -margin_left = 8.0 -margin_top = 8.0 -margin_right = 216.0 -margin_bottom = 208.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="LineEdit" type="LineEdit" parent="CreateActionPopup/VBoxContainer"] -visible = false -margin_right = 208.0 -margin_bottom = 24.0 -size_flags_horizontal = 3 -placeholder_text = "Search" - -[node name="Tree" type="Tree" parent="CreateActionPopup/VBoxContainer"] -margin_right = 208.0 -margin_bottom = 200.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -hide_folding = true -hide_root = true diff --git a/addons/ai_editor/AIGraphEdit.gd b/addons/ai_editor/AIGraphEdit.gd deleted file mode 100644 index 8e9786c..0000000 --- a/addons/ai_editor/AIGraphEdit.gd +++ /dev/null @@ -1,172 +0,0 @@ -tool -extends GraphEdit - -export(NodePath) var create_action_popup : NodePath - -var _create_action_popup : PopupMenu -var _actions : Array - -func _ready() -> void: - _create_action_popup = get_node(create_action_popup) - _create_action_popup.connect("action_selected", self, "create_action") - - connect("popup_request", self, "popup_request") - connect("connection_request", self, "connection_request") - connect("disconnection_request", self, "disconnection_request") - - -func popup_request(position: Vector2) -> void: - _create_action_popup.rect_position = position - _create_action_popup.popup() - -func create_action(action) -> void: - var cls : Script - - var pclass = action - while cls == null and pclass != "": - var file_name : String = "res://addons/ai_editor/editors/" + pclass + "Editor.gd" - - var d : Directory = Directory.new() - - if d.file_exists(file_name): - cls = load(file_name) - else: - pclass = get_parent_class(pclass) - - if cls == null: - print("AiGraphEdit cls==null! (create_action)") - - var n : GraphNode = cls.new() as GraphNode - add_child(n) - n.owner = self - n.rect_position = _create_action_popup.rect_position - - if ClassDB.class_exists(action): - n.set_action(ClassDB.instance(action)) - else: - var gsc : Array = ProjectSettings.get("_global_script_classes") - - for i in range(gsc.size()): - var d : Dictionary = gsc[i] as Dictionary - - if action == d["class"]: - var scls : Script = load(d["path"]) - n.set_action(scls.new()) - -func connection_request(from: String, from_slot: int, to: String, to_slot: int) -> void: - var node = get_node(from) - var to_node = get_node(to) - if node.connected_to(from_slot, to_node): - connect_node(from, from_slot, to, to_slot) - save() - -func disconnection_request(from: String, from_slot: int, to: String, to_slot: int) -> void: - var node = get_node(from) - if node.disconnected_from(from_slot): - disconnect_node(from, from_slot, to, to_slot) - save() - -func save(): - for action in _actions: - ResourceSaver.save(action.resource_path, action) - -func close_request(graph_node : Node) -> void: - remove_node(graph_node) - -# { from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }. - -func remove_node(graph_node : Node) -> void: - var connections : Array = get_connection_list() - - for conn in connections: - if conn["from"] == graph_node.name: - remove_node(get_node(conn["to"])) - disconnect_node(conn["from"], conn["from_port"], conn["to"], conn["to_port"]) - - graph_node.queue_free() - -func add_action(ai_action : AIAction, position: Vector2) -> void: - _actions.append(ai_action) - - var n : GraphNode = get_graph_node_for(ai_action) - - n.rect_position = position -# n.rect_position = _create_action_popup.rect_position - n.set_action(ai_action) - -func get_parent_class(cls_name: String) -> String: - if ClassDB.class_exists(cls_name): - return ClassDB.get_parent_class(cls_name) - - var gsc : Array = ProjectSettings.get("_global_script_classes") - - for i in range(gsc.size()): - var d : Dictionary = gsc[i] as Dictionary - - if cls_name == d["class"]: - return d["base"] - - return "" - -func get_graph_node_for(action : AIAction) -> GraphNode: - var cls : Script - - var pclass : String = action.get_class() - -# if action.get_script() != null: -# var gsc : Array = ProjectSettings.get("_global_script_classes") -# -# for i in range(gsc.size()): -# var d : Dictionary = gsc[i] as Dictionary -# -# print(d) -# if cls_name == d["path"]: -# d["base"] - - while cls == null and pclass != "": - var file_name : String = "res://addons/ai_editor/editors/" + pclass + "Editor.gd" - - var d : Directory = Directory.new() - - if d.file_exists(file_name): - cls = load(file_name) - else: - pclass = get_parent_class(pclass) - - if cls == null: - print("AiGraphEdit cls==null! (get_graph_node_for)") - return null - - var n : GraphNode = cls.new() as GraphNode - add_child(n) - n.owner = self - - return n - -func can_drop_data(position, data): - if data is AIAction: - return true - - if data is Dictionary: - if data.has("type") and data["type"] == "files" and data.has("files"): - for file in data["files"]: - if ResourceLoader.exists(file): - var res : Resource = ResourceLoader.load(file) - - if res is AIAction: - return true - - return false - -func drop_data(position, data): - if data is AIAction: - return true - - if data is Dictionary: - if data.has("type") and data["type"] == "files" and data.has("files"): - for file in data["files"]: - if ResourceLoader.exists(file): - var res : Resource = ResourceLoader.load(file) - - if res is AIAction: - add_action(res, position) diff --git a/addons/ai_editor/CreateActionPopup.gd b/addons/ai_editor/CreateActionPopup.gd deleted file mode 100644 index 617c69c..0000000 --- a/addons/ai_editor/CreateActionPopup.gd +++ /dev/null @@ -1,59 +0,0 @@ -tool -extends AcceptDialog - -signal action_selected - -export(NodePath) var tree_path : NodePath -export(NodePath) var search_le_path : NodePath - -var _search_le : LineEdit -var _tree : Tree - -var _group : ButtonGroup - -func _ready(): - _search_le = get_node(search_le_path) as LineEdit - _tree = get_node(tree_path) as Tree - _tree.connect("item_activated", self, "item_activated") - - connect("about_to_show", self, "about_to_show") - -func about_to_show(): - _tree.clear() - - var arr : PoolStringArray = PoolStringArray() - arr.append("AIAction") - arr.append_array(ClassDB.get_inheriters_from_class("AIAction")) - - var gsc : Array = ProjectSettings.get("_global_script_classes") - - var l : int = arr.size() - 1 - - while (arr.size() != l): - l = arr.size() - - for i in range(gsc.size()): - var d : Dictionary = gsc[i] as Dictionary - - var found = false - for j in range(arr.size()): - if arr[j] == d["class"]: - found = true - break - - if found: - continue - - for j in range(arr.size()): - if arr[j] == d["base"]: - arr.append(d["class"]) - - _tree.create_item() - for a in arr: - var ti : TreeItem = _tree.create_item() - ti.set_text(0, a) - - -func item_activated() -> void: - emit_signal("action_selected", _tree.get_selected().get_text(0)) - hide() diff --git a/addons/ai_editor/editors/AIActionContainerEditor.gd b/addons/ai_editor/editors/AIActionContainerEditor.gd deleted file mode 100644 index 1bba4bc..0000000 --- a/addons/ai_editor/editors/AIActionContainerEditor.gd +++ /dev/null @@ -1,79 +0,0 @@ -extends "AIActionEditor.gd" - -var _add_button : Button -var _remove_button : Button -var _hbox : HBoxContainer -var _labels : Array - -func _ready(): - title = "AIActionContainer" - -func setup() -> void: - .setup() - - _hbox = HBoxContainer.new() - _hbox.size_flags_vertical = SIZE_EXPAND_FILL - add_child(_hbox) - _hbox.owner = self - - _add_button = Button.new() - _add_button.rect_min_size = Vector2(0, 30) - _add_button.size_flags_horizontal = SIZE_EXPAND_FILL - _add_button.text = "Add" - _add_button.connect("pressed", self, "add_pressed") - _hbox.add_child(_add_button) - _add_button.owner = _hbox - - _remove_button = Button.new() - _remove_button.rect_min_size = Vector2(0, 30) - _remove_button.size_flags_horizontal = SIZE_EXPAND_FILL - _remove_button.text = "Remove" - _remove_button.connect("pressed", self, "remove_pressed") - _hbox.add_child(_remove_button) - _remove_button.owner = _hbox - - -func add_pressed() -> void: - _action.set_num_ai_actions(_action.get_num_ai_actions() + 1) - - var button : Label = Label.new() - button.rect_min_size = Vector2(0, 30) - button.text = "Entry " + str(_labels.size()) - - if _labels.size() > 0: - add_child_below_node(_labels.back(), button) - else: - add_child(button) - - set_slot(get_child_count() - 1, false, 0, Color(1, 0, 0), true, 0, Color(1, 0, 0)) - - button.owner = self - - _labels.append(button) - -func remove_pressed() -> void: - pass - -func connected_to(from_slot, to_node) -> bool: - if from_slot > _labels.size(): - return false - - if (_action.get_ai_action(from_slot) != null): - return false - - var action : AIAction = to_node._action - - for i in range(_action.get_num_ai_actions()): - if (_action.get_ai_action(i) == action): - return false - - _action.set_ai_action(from_slot, action) - return true - -func disconnected_from(from_slot) -> bool: - if from_slot > _labels.size(): - return false - - _action.set_ai_action(from_slot, null) - - return true diff --git a/addons/ai_editor/editors/AIActionEditor.gd b/addons/ai_editor/editors/AIActionEditor.gd deleted file mode 100644 index ab8f896..0000000 --- a/addons/ai_editor/editors/AIActionEditor.gd +++ /dev/null @@ -1,52 +0,0 @@ -extends GraphNode - -var _action : AIAction - -func _ready(): - title = "AIAction" - show_close = true - resizable = true - rect_min_size = Vector2(200, 40) - - connect("close_request", self, "close_request") - connect("resize_request", self, "resize_request") - - setup() - -func set_action(action) -> void: - _action = action - - if _action: - title = _action.get_class() - - if _action.has_method("get_title"): - title = _action.get_title() - - setup() - -func setup() -> void: - for ch in get_children(): - ch.queue_free() - remove_child(ch) - - var le : LineEdit = LineEdit.new() - le.rect_min_size = Vector2(0, 30) - le.placeholder_text = "Description" - add_child(le) - le.owner = self - - set_slot(0, true, 0, Color(1, 0, 0), false, 0, Color(1, 0, 0)) - - -func close_request() -> void: - get_node("..").close_request(self) -# queue_free() - -func resize_request(new_min_size: Vector2) -> void: - rect_min_size = new_min_size - -func connected_to(from_slot, to_node) -> bool: - return false - -func disconnected_from(from_slot) -> bool: - return false diff --git a/addons/ai_editor/plugin.cfg b/addons/ai_editor/plugin.cfg deleted file mode 100644 index 1968e6e..0000000 --- a/addons/ai_editor/plugin.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[plugin] - -name="AI Editor" -description="" -author="Relintai" -version="" -script="plugin.gd" diff --git a/addons/ai_editor/plugin.gd b/addons/ai_editor/plugin.gd deleted file mode 100644 index ab879c1..0000000 --- a/addons/ai_editor/plugin.gd +++ /dev/null @@ -1,31 +0,0 @@ -tool -extends EditorPlugin - -var ai_editor_scene_data : PackedScene = preload("res://addons/ai_editor/AIEditorScene.tscn") as PackedScene - -var main_scene : Control -var bottom_panel_button : ToolButton - -var edited_ai_action : AIAction - -func _enter_tree(): - main_scene = ai_editor_scene_data.instance() as Control - bottom_panel_button = add_control_to_bottom_panel(main_scene, "AI Editor") - -func _exit_tree(): - remove_control_from_bottom_panel(main_scene) - main_scene.queue_free() -# bottom_panel_button.queue_free() -# bottom_panel_button.hide() - -# -#func edit(object : Object) -> void: -# edited_ai_action = object as AIAction -# main_scene.set_target(edited_ai_action) -# -# bottom_panel_button.show() -# -# -#func handles(object : Object) -> bool: -# return object is AIAction -