diff --git a/.github/workflows/gdextension.yml b/.github/workflows/gdextension.yml index bb82542..91b7ed9 100644 --- a/.github/workflows/gdextension.yml +++ b/.github/workflows/gdextension.yml @@ -162,15 +162,13 @@ jobs: - name: Setup project structure for GDExtension shell: bash run: | - python ./limboai/gdextension/update_icons.py - mkdir -p demo/addons/limboai/bin - mv limboai/icons demo/addons/limboai/ - cp limboai/gdextension/SConstruct SConstruct - cp limboai/gdextension/limboai.gdextension demo/addons/limboai/bin + bash ./limboai/gdextension/setup_gdextension.sh --copy-all echo "---" ls -l + echo "---" ls -l -R ./demo/ + - name: Compilation shell: bash env: @@ -184,7 +182,10 @@ jobs: run: | mkdir out mv demo/addons/ out/ + cp limboai/{README,LICENSE,LOGO_LICENSE}.md out/addons/limboai/ + cp -R limboai/demo/demo out/demo rm -f out/addons/limboai/bin/*.{exp,lib,pdb} + echo "---" ls -R out/ - name: Strip lib diff --git a/demo/default_env.tres b/demo/default_env.tres deleted file mode 100644 index 1a5570b..0000000 --- a/demo/default_env.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="Environment" load_steps=2 format=2] - -[sub_resource type="Sky" id=1] - -[resource] -background_mode = 2 -background_sky = SubResource( 1 ) diff --git a/demo/ai/tasks/arrive_pos.gd b/demo/demo/ai/tasks/arrive_pos.gd similarity index 90% rename from demo/ai/tasks/arrive_pos.gd rename to demo/demo/ai/tasks/arrive_pos.gd index e0e361d..4d228f1 100644 --- a/demo/ai/tasks/arrive_pos.gd +++ b/demo/demo/ai/tasks/arrive_pos.gd @@ -18,12 +18,14 @@ extends BTAction @export var tolerance := 50.0 +@warning_ignore("native_method_override") # needed for GDExtension version. func _generate_name() -> String: return "Arrive pos: %s speed: %s" % [ LimboUtility.decorate_var(target_position_var), LimboUtility.decorate_var(speed_var), ] +@warning_ignore("native_method_override") func _tick(p_delta: float) -> Status: var target_pos: Vector2 = blackboard.get_var(target_position_var, Vector2.ZERO) if target_pos.distance_to(agent.global_position) < tolerance: diff --git a/demo/ai/trees/variables.tres b/demo/demo/ai/trees/variables.tres similarity index 100% rename from demo/ai/trees/variables.tres rename to demo/demo/ai/trees/variables.tres diff --git a/demo/ai/trees/waypoints.tres b/demo/demo/ai/trees/waypoints.tres similarity index 93% rename from demo/ai/trees/waypoints.tres rename to demo/demo/ai/trees/waypoints.tres index ecabd99..f94049a 100644 --- a/demo/ai/trees/waypoints.tres +++ b/demo/demo/ai/trees/waypoints.tres @@ -1,6 +1,6 @@ [gd_resource type="BehaviorTree" load_steps=10 format=3 uid="uid://cjkqi41oagagd"] -[ext_resource type="Script" path="res://ai/tasks/arrive_pos.gd" id="1_rhs33"] +[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="1_rhs33"] [sub_resource type="BTAction" id="BTAction_3xal7"] script = ExtResource("1_rhs33") diff --git a/demo/examples/variables/variables.tscn b/demo/demo/examples/variables/variables.tscn similarity index 70% rename from demo/examples/variables/variables.tscn rename to demo/demo/examples/variables/variables.tscn index 0f955f7..0a59bb0 100644 --- a/demo/examples/variables/variables.tscn +++ b/demo/demo/examples/variables/variables.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=2 format=3 uid="uid://d4bjeyescflm8"] -[ext_resource type="BehaviorTree" uid="uid://cvm3gqes75f53" path="res://ai/trees/variables.tres" id="1_tq7fc"] +[ext_resource type="BehaviorTree" uid="uid://cvm3gqes75f53" path="res://demo/ai/trees/variables.tres" id="1_cm2sf"] [node name="Variables Example" type="Node2D"] [node name="BTPlayer" type="BTPlayer" parent="."] -behavior_tree = ExtResource("1_tq7fc") +behavior_tree = ExtResource("1_cm2sf") diff --git a/demo/examples/waypoints/example_waypoints.gd b/demo/demo/examples/waypoints/example_waypoints.gd similarity index 100% rename from demo/examples/waypoints/example_waypoints.gd rename to demo/demo/examples/waypoints/example_waypoints.gd diff --git a/demo/examples/waypoints/example_waypoints.tscn b/demo/demo/examples/waypoints/example_waypoints.tscn similarity index 75% rename from demo/examples/waypoints/example_waypoints.tscn rename to demo/demo/examples/waypoints/example_waypoints.tscn index 2bb4425..e338ca1 100644 --- a/demo/examples/waypoints/example_waypoints.tscn +++ b/demo/demo/examples/waypoints/example_waypoints.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://p5i7fdku3hqs"] -[ext_resource type="Script" path="res://examples/waypoints/example_waypoints.gd" id="1_d4sso"] -[ext_resource type="Script" path="res://examples/waypoints/waypoint_marker.gd" id="2_l26sl"] -[ext_resource type="PackedScene" uid="uid://c26b8c8dndtop" path="res://examples/waypoints/patrolling_agent.tscn" id="3_t4qgi"] +[ext_resource type="Script" path="res://demo/examples/waypoints/example_waypoints.gd" id="1_d4sso"] +[ext_resource type="Script" path="res://demo/examples/waypoints/waypoint_marker.gd" id="2_l26sl"] +[ext_resource type="PackedScene" uid="uid://c26b8c8dndtop" path="res://demo/examples/waypoints/patrolling_agent.tscn" id="3_t4qgi"] [node name="ExampleWaypoints" type="Node2D"] script = ExtResource("1_d4sso") diff --git a/demo/examples/waypoints/patrolling_agent.gd b/demo/demo/examples/waypoints/patrolling_agent.gd similarity index 100% rename from demo/examples/waypoints/patrolling_agent.gd rename to demo/demo/examples/waypoints/patrolling_agent.gd diff --git a/demo/examples/waypoints/patrolling_agent.tscn b/demo/demo/examples/waypoints/patrolling_agent.tscn similarity index 87% rename from demo/examples/waypoints/patrolling_agent.tscn rename to demo/demo/examples/waypoints/patrolling_agent.tscn index 41d7661..e058444 100644 --- a/demo/examples/waypoints/patrolling_agent.tscn +++ b/demo/demo/examples/waypoints/patrolling_agent.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=3 uid="uid://c26b8c8dndtop"] -[ext_resource type="Script" path="res://examples/waypoints/patrolling_agent.gd" id="1_5wwhb"] -[ext_resource type="BehaviorTree" uid="uid://cjkqi41oagagd" path="res://ai/trees/waypoints.tres" id="2_66y4v"] -[ext_resource type="Texture2D" uid="uid://d0mht3ntak7e5" path="res://icon.png" id="3_j5bxx"] +[ext_resource type="Script" path="res://demo/examples/waypoints/patrolling_agent.gd" id="1_5wwhb"] +[ext_resource type="BehaviorTree" uid="uid://cjkqi41oagagd" path="res://demo/ai/trees/waypoints.tres" id="2_66y4v"] +[ext_resource type="Texture2D" uid="uid://d0mht3ntak7e5" path="res://demo/godot.png" id="3_64ge2"] [sub_resource type="Animation" id="Animation_5id00"] length = 0.001 @@ -51,7 +51,7 @@ _blackboard_data = { } [node name="Sprite2D" type="Sprite2D" parent="."] -texture = ExtResource("3_j5bxx") +texture = ExtResource("3_64ge2") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] libraries = { diff --git a/demo/examples/waypoints/waypoint_marker.gd b/demo/demo/examples/waypoints/waypoint_marker.gd similarity index 100% rename from demo/examples/waypoints/waypoint_marker.gd rename to demo/demo/examples/waypoints/waypoint_marker.gd diff --git a/demo/icon.png b/demo/demo/godot.png similarity index 100% rename from demo/icon.png rename to demo/demo/godot.png diff --git a/demo/icon.png.import b/demo/demo/godot.png.import similarity index 73% rename from demo/icon.png.import rename to demo/demo/godot.png.import index 977b708..924caba 100644 --- a/demo/icon.png.import +++ b/demo/demo/godot.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://d0mht3ntak7e5" -path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" +path="res://.godot/imported/godot.png-a8a26b1338954efbba9baa82b9ad4a96.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://icon.png" -dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] +source_file="res://demo/godot.png" +dest_files=["res://.godot/imported/godot.png-a8a26b1338954efbba9baa82b9ad4a96.ctex"] [params] diff --git a/demo/tests/agent_properties/agent_properties.gd b/demo/demo/tests/agent_properties/agent_properties.gd similarity index 100% rename from demo/tests/agent_properties/agent_properties.gd rename to demo/demo/tests/agent_properties/agent_properties.gd diff --git a/demo/tests/agent_properties/agent_properties.tscn b/demo/demo/tests/agent_properties/agent_properties.tscn similarity index 62% rename from demo/tests/agent_properties/agent_properties.tscn rename to demo/demo/tests/agent_properties/agent_properties.tscn index 9309aeb..59e664a 100644 --- a/demo/tests/agent_properties/agent_properties.tscn +++ b/demo/demo/tests/agent_properties/agent_properties.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://c3d3ed6545cly"] -[ext_resource type="Script" path="res://tests/agent_properties/agent_properties.gd" id="1_jh88u"] -[ext_resource type="BehaviorTree" uid="uid://ddhxf0haxgw" path="res://tests/agent_properties/bt_agent_properties.tres" id="2_txe8k"] +[ext_resource type="Script" path="res://demo/tests/agent_properties/agent_properties.gd" id="1_jh88u"] +[ext_resource type="BehaviorTree" uid="uid://ddhxf0haxgw" path="res://demo/tests/agent_properties/bt_agent_properties.tres" id="2_txe8k"] [node name="AgentProperties" type="Node2D"] script = ExtResource("1_jh88u") diff --git a/demo/tests/agent_properties/bt_agent_properties.tres b/demo/demo/tests/agent_properties/bt_agent_properties.tres similarity index 100% rename from demo/tests/agent_properties/bt_agent_properties.tres rename to demo/demo/tests/agent_properties/bt_agent_properties.tres diff --git a/demo/tests/blackboard_parameters/test_bb_params.gd b/demo/demo/tests/blackboard_parameters/test_bb_params.gd similarity index 100% rename from demo/tests/blackboard_parameters/test_bb_params.gd rename to demo/demo/tests/blackboard_parameters/test_bb_params.gd diff --git a/demo/tests/probability_selector/bt_test_probability_selector.tres b/demo/demo/tests/probability_selector/bt_test_probability_selector.tres similarity index 100% rename from demo/tests/probability_selector/bt_test_probability_selector.tres rename to demo/demo/tests/probability_selector/bt_test_probability_selector.tres diff --git a/demo/tests/probability_selector/test_probability_selector.tscn b/demo/demo/tests/probability_selector/test_probability_selector.tscn similarity index 75% rename from demo/tests/probability_selector/test_probability_selector.tscn rename to demo/demo/tests/probability_selector/test_probability_selector.tscn index dbdca9a..0746b2e 100644 --- a/demo/tests/probability_selector/test_probability_selector.tscn +++ b/demo/demo/tests/probability_selector/test_probability_selector.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dgeb7tg8xb3j4"] -[ext_resource type="BehaviorTree" uid="uid://cen725hsk8lyl" path="res://tests/probability_selector/bt_test_probability_selector.tres" id="1_lr7l2"] +[ext_resource type="BehaviorTree" uid="uid://cen725hsk8lyl" path="res://demo/tests/probability_selector/bt_test_probability_selector.tres" id="1_lr7l2"] [node name="test_probability_selector" type="Node2D"] diff --git a/demo/project.godot b/demo/project.godot index d2dd19f..b3fd502 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -12,9 +12,9 @@ config_version=5 config/name="LimboAI Test" config/tags=PackedStringArray("demo") -run/main_scene="res://examples/waypoints/example_waypoints.tscn" +run/main_scene="res://demo/examples/waypoints/example_waypoints.tscn" config/features=PackedStringArray("4.2") -config/icon="res://icon.png" +config/icon="res://demo/godot.png" [debug] @@ -24,6 +24,11 @@ gdscript/warnings/native_method_override=1 common/drop_mouse_on_gui_input_disabled=true +[limbo_ai] + +behavior_tree/behavior_tree_default_dir="res://demo/ai/trees" +behavior_tree/user_task_dir_1="res://demo/ai/tasks" + [physics] common/enable_pause_aware_picking=true diff --git a/editor/action_banner.cpp b/editor/action_banner.cpp index bdc8a77..7eb493b 100644 --- a/editor/action_banner.cpp +++ b/editor/action_banner.cpp @@ -17,11 +17,13 @@ #include "../util/limbo_string_names.h" #ifdef LIMBOAI_MODULE +#include "editor/editor_scale.h" #include "scene/gui/button.h" #endif // LIMBOAI_MODULE #ifdef LIMBOAI_GDEXTENSION #include +#include #endif // LIMBOAI_GDEXTENSION void ActionBanner::set_text(const String &p_text) { @@ -43,6 +45,12 @@ void ActionBanner::add_action(const String &p_name, const Callable &p_action, bo hbox->add_child(action_btn); } +void ActionBanner::add_spacer() { + Control *spacer = memnew(Control); + spacer->set_custom_minimum_size(Vector2(8.0 * EDSCALE, 0.0)); + hbox->add_child(spacer); +} + void ActionBanner::_execute_action(const Callable &p_action, bool p_auto_close) { #ifdef LIMBOAI_MODULE Callable::CallError ce; diff --git a/editor/action_banner.h b/editor/action_banner.h index 4b91ea3..cc15ab8 100644 --- a/editor/action_banner.h +++ b/editor/action_banner.h @@ -50,6 +50,7 @@ public: String get_text() const; void add_action(const String &p_name, const Callable &p_action, bool p_auto_close = false); + void add_spacer(); void close(); diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index 56b568b..a185e0d 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -272,8 +272,10 @@ void LimboAIEditor::_edit_project_settings() { ProjectSettingsEditor::get_singleton()->connect(LW_NAME(visibility_changed), callable_mp(this, &LimboAIEditor::_update_banners), CONNECT_ONE_SHOT); #elif LIMBOAI_GDEXTENSION // TODO: Find a way to show project setting in GDExtension. - // TODO: Maybe show a popup dialog instead. - ERR_PRINT("Can't do in GDExtension. To edit project settings, navigate to \"Project->Project Settings\", enable \"Advanced settings\", and scroll down to the \"LimboAI\" section."); + String text = "Can't open settings in GDExtension, sorry :(\n" + "To edit project settings, navigate to \"Project->Project Settings\",\n" + "enable \"Advanced settings\", and scroll down to the \"LimboAI\" section."; + _popup_info_dialog(text); #endif } @@ -592,12 +594,15 @@ void LimboAIEditor::_probability_popup_closed() { void LimboAIEditor::_misc_option_selected(int p_id) { switch (p_id) { - case MISC_INTRODUCTION: { - LimboUtility::get_singleton()->open_doc_introduction(); - } break; case MISC_ONLINE_DOCUMENTATION: { LimboUtility::get_singleton()->open_doc_online(); } break; + case MISC_DOC_INTRODUCTION: { + LimboUtility::get_singleton()->open_doc_introduction(); + } break; + case MISC_DOC_CUSTOM_TASKS: { + LimboUtility::get_singleton()->open_doc_custom_tasks(); + } break; case MISC_OPEN_DEBUGGER: { ERR_FAIL_COND(LimboDebuggerPlugin::get_singleton() == nullptr); if (LimboDebuggerPlugin::get_singleton()->get_session_tab()->get_window_enabled()) { @@ -882,6 +887,11 @@ void LimboAIEditor::_resave_modified(String _str) { disk_changed_files.clear(); } +void LimboAIEditor::_popup_info_dialog(const String &p_text) { + info_dialog->set_text(p_text); + info_dialog->popup_centered(); +} + void LimboAIEditor::_rename_task_confirmed() { ERR_FAIL_COND(!task_tree->get_selected().is_valid()); rename_dialog->hide(); @@ -944,8 +954,9 @@ void LimboAIEditor::_update_misc_menu() { misc_menu->clear(); - misc_menu->add_icon_item(theme_cache.introduction_icon, TTR("Introduction"), MISC_INTRODUCTION); misc_menu->add_icon_item(theme_cache.doc_icon, TTR("Online Documentation"), MISC_ONLINE_DOCUMENTATION); + misc_menu->add_icon_item(theme_cache.introduction_icon, TTR("Introduction"), MISC_DOC_INTRODUCTION); + misc_menu->add_icon_item(theme_cache.introduction_icon, TTR("Creating custom tasks in GDScript"), MISC_DOC_CUSTOM_TASKS); misc_menu->add_separator(); #ifdef LIMBOAI_MODULE @@ -974,6 +985,8 @@ void LimboAIEditor::_update_banners() { banner->set_text(vformat(TTR("Task folder not found: %s"), task_dir)); banner->add_action(TTR("Create"), callable_mp(this, &LimboAIEditor::_create_user_task_dir), true); banner->add_action(TTR("Edit Path..."), callable_mp(this, &LimboAIEditor::_edit_project_settings)); + banner->add_spacer(); + banner->add_action(TTR("Help..."), callable_mp(LimboUtility::get_singleton(), &LimboUtility::open_doc_custom_tasks)); banner->set_meta(LW_NAME(managed), Variant(true)); banners->call_deferred(LW_NAME(add_child), banner); } @@ -992,6 +1005,17 @@ void LimboAIEditor::_update_banners() { banners->call_deferred(LW_NAME(add_child), banner); } } + +#ifdef LIMBOAI_GDEXTENSION + if (!limitations_banner_shown && GLOBAL_GET("debug/gdscript/warnings/native_method_override") == Variant(2)) { + ActionBanner *banner = memnew(ActionBanner); + banner->set_text(vformat(TTR("In Project Settings, \"debug/gdscript/warnings/native_method_override\" is set to \"Error\""))); + banner->add_action(TTR("Instructions..."), callable_mp(LimboUtility::get_singleton(), &LimboUtility::open_doc_gdextension_limitations)); + banner->add_action(TTR("Dismiss"), callable_mp(banner, &ActionBanner::close)); + banners->call_deferred(LW_NAME(add_child), banner); + limitations_banner_shown = true; + } +#endif // LIMBOAI_GDEXTENSION } void LimboAIEditor::_do_update_theme_item_cache() { @@ -1101,6 +1125,7 @@ void LimboAIEditor::_bind_methods() { } LimboAIEditor::LimboAIEditor() { + plugin = nullptr; idx_history = 0; LW_SHORTCUT("limbo_ai/rename_task", TTR("Rename"), LW_KEY(F2)); @@ -1341,6 +1366,9 @@ LimboAIEditor::LimboAIEditor() { disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); } + info_dialog = memnew(AcceptDialog); + add_child(info_dialog); + BASE_CONTROL()->add_child(disk_changed); GLOBAL_DEF(PropertyInfo(Variant::STRING, "limbo_ai/behavior_tree/behavior_tree_default_dir", PROPERTY_HINT_DIR), "res://ai/trees"); diff --git a/editor/limbo_ai_editor_plugin.h b/editor/limbo_ai_editor_plugin.h index 1fe3f7d..01a6ed1 100644 --- a/editor/limbo_ai_editor_plugin.h +++ b/editor/limbo_ai_editor_plugin.h @@ -28,6 +28,7 @@ #include "editor/gui/editor_spin_slider.h" #include "scene/gui/box_container.h" #include "scene/gui/control.h" +#include "scene/gui/dialogs.h" #include "scene/gui/file_dialog.h" #include "scene/gui/flow_container.h" #include "scene/gui/line_edit.h" @@ -44,6 +45,7 @@ #endif // LIMBOAI_MODULE #ifdef LIMBOAI_GDEXTENSION +#include "godot_cpp/classes/accept_dialog.hpp" #include #include #include @@ -83,8 +85,9 @@ private: }; enum MiscMenu { - MISC_INTRODUCTION, MISC_ONLINE_DOCUMENTATION, + MISC_DOC_INTRODUCTION, + MISC_DOC_CUSTOM_TASKS, MISC_OPEN_DEBUGGER, MISC_PROJECT_SETTINGS, MISC_CREATE_SCRIPT_TEMPLATE, @@ -107,6 +110,10 @@ private: Ref behavior_tree_icon; } theme_cache; +#ifdef LIMBOAI_GDEXTENSION + bool limitations_banner_shown = false; +#endif // LIMBOAI_GDEXTENSION + EditorPlugin *plugin; Vector> history; int idx_history; @@ -149,6 +156,8 @@ private: Tree *disk_changed_list; HashSet disk_changed_files; + AcceptDialog *info_dialog; + void _add_task(const Ref &p_task); Ref _create_task_by_class_or_path(const String &p_class_or_path) const; void _add_task_by_class_or_path(const String &p_class_or_path); @@ -171,6 +180,7 @@ private: void _reload_modified(); void _resave_modified(String _str = ""); void _popup_file_dialog(FileDialog *p_dialog) { p_dialog->popup_centered_clamped(Size2i(700, 500), 0.8f); } + void _popup_info_dialog(const String &p_text); void _rename_task_confirmed(); void _on_tree_rmb(const Vector2 &p_menu_pos); diff --git a/gdextension/limboai.gdextension b/gdextension/limboai.gdextension index 8f12f49..c71edd6 100644 --- a/gdextension/limboai.gdextension +++ b/gdextension/limboai.gdextension @@ -24,7 +24,6 @@ android.release.arm64 = "res://addons/limboai/bin/liblimboai.android.template_re [icons] -BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg" BTAction = "res://addons/limboai/icons/BTAction.svg" BTAlwaysFail = "res://addons/limboai/icons/BTAlwaysFail.svg" BTAlwaysSucceed = "res://addons/limboai/icons/BTAlwaysSucceed.svg" @@ -68,12 +67,13 @@ BTSubtree = "res://addons/limboai/icons/BTSubtree.svg" BTTimeLimit = "res://addons/limboai/icons/BTTimeLimit.svg" BTWait = "res://addons/limboai/icons/BTWait.svg" BTWaitTicks = "res://addons/limboai/icons/BTWaitTicks.svg" +BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg" LimboAI = "res://addons/limboai/icons/LimboAI.svg" LimboDeselectAll = "res://addons/limboai/icons/LimboDeselectAll.svg" LimboExtraBlackboard = "res://addons/limboai/icons/LimboExtraBlackboard.svg" LimboExtraClock = "res://addons/limboai/icons/LimboExtraClock.svg" -LimboExtractSubtree = "res://addons/limboai/icons/LimboExtractSubtree.svg" LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg" +LimboExtractSubtree = "res://addons/limboai/icons/LimboExtractSubtree.svg" LimboHSM = "res://addons/limboai/icons/LimboHSM.svg" LimboPercent = "res://addons/limboai/icons/LimboPercent.svg" LimboSelectAll = "res://addons/limboai/icons/LimboSelectAll.svg" diff --git a/gdextension/setup_gdextension.sh b/gdextension/setup_gdextension.sh index 74f8327..36df50a 100755 --- a/gdextension/setup_gdextension.sh +++ b/gdextension/setup_gdextension.sh @@ -28,7 +28,7 @@ HIGHLIGHT_COLOR='\033[1;36m' # Light Cyan NC='\033[0m' # No Color ERROR_COLOR="\033[0;31m" # Red -usage() { echo "Usage: $0 [--copy-demo]"; } +usage() { echo "Usage: $0 [--copy-demo] [--copy-all] [--trash-old]"; } msg () { echo -e "$@"; } highlight() { echo -e "${HIGHLIGHT_COLOR}$@${NC}"; } @@ -47,6 +47,8 @@ trap exit SIGINT set -e copy_demo=0 +copy_all=0 +trash_old=0 # Parsing arguments for i in "$@" @@ -56,14 +58,43 @@ do copy_demo=1 shift ;; + --copy-all) + copy_demo=1 + copy_all=1 + shift + ;; + --trash-old) + trash_old=1 + shift + ;; *) usage + exit 1 ;; esac done highlight Setup started. +${PYTHON} limboai/gdextension/update_icons.py --silent +highlight -- Icon declarations updated. + +transfer="ln -s" +transfer_word="Linked" +if [ ${copy_all} == 1 ]; then + transfer="cp -R" + transfer_word="Copied" +fi + +if [ ${trash_old} == 1 ]; then + if ! command -v trash &> /dev/null; then + error trash command not available. Aborting. + exit 1 + fi + trash SConstruct limboai/demo/addons demo || /bin/true + highlight -- Trashed old setup. +fi + if [ ! -d "${PWD}/godot-cpp/" ]; then highlight -- Cloning godot-cpp... git clone -b ${GODOT_CPP_VERSION} https://github.com/godotengine/godot-cpp @@ -73,15 +104,15 @@ else fi if [ ! -f "${PWD}/SConstruct" ]; then - ln -s limboai/gdextension/SConstruct SConstruct - highlight -- Linked SConstruct. + ${transfer} limboai/gdextension/SConstruct SConstruct + highlight -- ${transfer_word} SConstruct. else highlight -- Skipping \"SConstruct\". File already exists! fi if [ ! -e "${PWD}/demo" ]; then if [ ${copy_demo} == 1 ]; then - cp -r limboai/demo demo + cp -R limboai/demo demo highlight -- Copied demo. else ln -s limboai/demo demo @@ -91,48 +122,31 @@ else highlight -- Skipping \"demo\". File already exists! fi -# if [ -d "${PWD}/demo/" ]; then -# highlight -- Demo project exists. Archiving... -# backup_version=1 -# backup_dir="${PWD}/demo.old${backup_version}" -# while [ -d "${backup_dir}" ]; do -# ((backup_version++)) -# backup_dir="${PWD}/demo.old${backup_version}" -# done -# mv demo/ ${backup_dir} -# highlight -- Demo project archived as \"$(basename ${backup_dir})\". -# fi - -# if [ ! -d "${PWD}/demo/" ]; then -# cp -r limboai/demo demo -# highlight -- Copied demo project. -# else -# error Error: \"demo\" directory exists! -# exit 2 -# fi - -if [ ! -e "${PWD}/limboai/demo/addons/limboai/bin/limboai.gdextension" ]; then - ls -l - mkdir -p ./limboai/demo/addons/limboai/bin/ - cd ./limboai/demo/addons/limboai/bin/ - ln -s ../../../../gdextension/limboai.gdextension limboai.gdextension || ln -s ../../../../limboai/gdextension/limboai.gdextension limboai.gdextension - ls -l +if [ ! -e "${PWD}/demo/addons/limboai/bin/limboai.gdextension" ]; then + mkdir -p ./demo/addons/limboai/bin/ + cd ./demo/addons/limboai/bin/ + if [ -f "../../../../gdextension/limboai.gdextension" ]; then + ${transfer} ../../../../gdextension/limboai.gdextension limboai.gdextension + else + ${transfer} ../../../../limboai/gdextension/limboai.gdextension limboai.gdextension + fi cd - - highlight -- Linked limboai.gdextension. + highlight -- ${transfer_word} limboai.gdextension. else highlight -- Skipping limboai.gdextension. File already exists! fi -if [ ! -e "${PWD}/limboai/demo/addons/limboai/icons/" ]; then - cd ./limboai/demo/addons/limboai/ - ln -s ../../../icons icons || ln -s ../../../limboai/icons icons +if [ ! -e "${PWD}/demo/addons/limboai/icons/" ]; then + cd ./demo/addons/limboai/ + if [ -d "../../../icons" ]; then + ${transfer} ../../../icons icons + else + ${transfer} ../../../limboai/icons icons + fi cd - - highlight -- Linked icons. + highlight -- ${transfer_word} icons. else - highlight -- Skipping linking icons. File already exists! + highlight -- Skipping icons. File already exists! fi -${PYTHON} limboai/gdextension/update_icons.py --silent -highlight -- Icon declarations updated. - highlight Setup complete. diff --git a/gdextension/update_icons.py b/gdextension/update_icons.py index 8d65696..7280e90 100755 --- a/gdextension/update_icons.py +++ b/gdextension/update_icons.py @@ -58,9 +58,14 @@ def main(): content += "[icons]\n\n" + icon_files = [] icons_dir = os.path.join(config_dir, "../icons/") for icon_file in glob.glob(icons_dir + "/*.svg"): icon_file = os.path.basename(icon_file) + icon_files.append(icon_file) + + icon_files.sort() + for icon_file in icon_files: content += os.path.splitext(icon_file)[0] + " = \"res://addons/limboai/icons/" + icon_file + "\"\n" f = open(config_path, "w") diff --git a/util/limbo_utility.cpp b/util/limbo_utility.cpp index 835579f..087dcd0 100644 --- a/util/limbo_utility.cpp +++ b/util/limbo_utility.cpp @@ -334,7 +334,7 @@ Ref LimboUtility::get_shortcut(const String &p_path) const { } void LimboUtility::open_doc_introduction() { - OS::get_singleton()->shell_open(vformat("https://limboai.readthedocs.io/en/%s/classes/class_behaviortree.html", + OS::get_singleton()->shell_open(vformat("https://limboai.readthedocs.io/en/%s/getting-started/introduction.html", LIMBO_DOC_VERSION)); } @@ -343,6 +343,16 @@ void LimboUtility::open_doc_online() { LIMBO_DOC_VERSION)); } +void LimboUtility::open_doc_gdextension_limitations() { + OS::get_singleton()->shell_open(vformat("https://limboai.readthedocs.io/en/%s/getting-started/gdextension.html#limitations-of-the-gdextension-version", + LIMBO_DOC_VERSION)); +} + +void LimboUtility::open_doc_custom_tasks() { + OS::get_singleton()->shell_open(vformat("https://limboai.readthedocs.io/en/%s/getting-started/custom-tasks.html", + LIMBO_DOC_VERSION)); +} + void LimboUtility::open_doc_class(const String &p_class_name) { if (p_class_name.begins_with("res://")) { SHOW_DOC(vformat("class_name:\"%s\"", p_class_name)); diff --git a/util/limbo_utility.h b/util/limbo_utility.h index 10c10e1..bcb5a1d 100644 --- a/util/limbo_utility.h +++ b/util/limbo_utility.h @@ -95,6 +95,8 @@ public: void open_doc_introduction(); void open_doc_online(); + void open_doc_gdextension_limitations(); + void open_doc_custom_tasks(); void open_doc_class(const String &p_class_name); #endif // TOOLS_ENABLED