Compare commits

..

No commits in common. "f1af947060748e1bf78613b46ba2ab9889bcae73" and "4d0d2c05075e95fe468496fec44ad60881f24ea2" have entirely different histories.

7 changed files with 29 additions and 142 deletions

View File

@ -78,16 +78,12 @@ String BBVariable::get_hint_string() const {
return data->hint_string;
}
BBVariable BBVariable::duplicate(bool p_deep) const {
BBVariable BBVariable::duplicate() const {
BBVariable var;
var.data->hint = data->hint;
var.data->hint_string = data->hint_string;
var.data->type = data->type;
if (p_deep) {
var.data->value = data->value.duplicate(p_deep);
} else {
var.data->value = data->value;
}
var.data->value = data->value;
var.data->binding_path = data->binding_path;
var.data->bound_object = data->bound_object;
var.data->bound_property = data->bound_property;

View File

@ -54,7 +54,7 @@ public:
void set_hint_string(const String &p_hint_string);
String get_hint_string() const;
BBVariable duplicate(bool p_deep = false) const;
BBVariable duplicate() const;
_FORCE_INLINE_ bool is_value_changed() const { return data->value_changed; }
_FORCE_INLINE_ void reset_value_changed() { data->value_changed = false; }

View File

@ -391,7 +391,7 @@ void BlackboardPlan::sync_with_base_plan() {
inline void bb_add_var_dup_with_prefetch(const Ref<Blackboard> &p_blackboard, const StringName &p_name, const BBVariable &p_var, bool p_prefetch, Node *p_node) {
if (unlikely(p_prefetch && p_var.get_type() == Variant::NODE_PATH)) {
Node *n = p_node->get_node_or_null(p_var.get_value());
BBVariable var = p_var.duplicate(true);
BBVariable var = p_var.duplicate();
if (n != nullptr) {
var.set_value(n);
} else {
@ -404,7 +404,7 @@ inline void bb_add_var_dup_with_prefetch(const Ref<Blackboard> &p_blackboard, co
}
p_blackboard->assign_var(p_name, var);
} else {
p_blackboard->assign_var(p_name, p_var.duplicate(true));
p_blackboard->assign_var(p_name, p_var.duplicate());
}
}

View File

@ -12,7 +12,7 @@ config_version=5
config/name="LimboAI Demo"
run/main_scene="res://demo/scenes/showcase.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://demo/assets/icon.svg"
[display]

View File

@ -41,7 +41,7 @@ void ActionBanner::close() {
void ActionBanner::add_action(const String &p_name, const Callable &p_action, bool p_auto_close) {
Button *action_btn = memnew(Button);
action_btn->set_text(p_name);
action_btn->connect(LW_NAME(pressed), callable_mp(this, &ActionBanner::_execute_action).bind(p_action, p_auto_close), CONNECT_DEFERRED);
action_btn->connect(LW_NAME(pressed), callable_mp(this, &ActionBanner::_execute_action).bind(p_action, p_auto_close));
hbox->add_child(action_btn);
}

View File

@ -34,7 +34,6 @@
#include "editor/debugger/script_editor_debugger.h"
#include "editor/editor_file_system.h"
#include "editor/editor_help.h"
#include "editor/editor_interface.h"
#include "editor/editor_paths.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
@ -222,8 +221,6 @@ void LimboAIEditor::_load_bt(String p_path) {
void LimboAIEditor::_disable_editing() {
task_tree->unload();
task_palette->hide();
task_tree->hide();
usage_hint->show();
}
void LimboAIEditor::edit_bt(Ref<BehaviorTree> p_behavior_tree, bool p_force_refresh) {
@ -238,9 +235,14 @@ void LimboAIEditor::edit_bt(Ref<BehaviorTree> p_behavior_tree, bool p_force_refr
p_behavior_tree->notify_property_list_changed();
#endif // LIMBOAI_MODULE
if (task_tree->get_bt().is_valid() &&
task_tree->get_bt()->is_connected(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty).bind(true))) {
task_tree->get_bt()->disconnect(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty).bind(true));
}
task_tree->load_bt(p_behavior_tree);
if (task_tree->get_bt().is_valid() && !task_tree->get_bt()->is_connected(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty))) {
if (task_tree->get_bt().is_valid()) {
task_tree->get_bt()->connect(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty).bind(true));
}
@ -317,12 +319,6 @@ void LimboAIEditor::_remove_task_from_favorite(const String &p_task) {
ProjectSettings::get_singleton()->save();
}
void LimboAIEditor::_save_and_restart() {
ProjectSettings::get_singleton()->save();
EditorInterface::get_singleton()->save_all_scenes();
EditorInterface::get_singleton()->restart_editor(true);
}
void LimboAIEditor::_extract_subtree(const String &p_path) {
Ref<BTTask> selected = task_tree->get_selected();
ERR_FAIL_COND(selected.is_null());
@ -706,16 +702,6 @@ void LimboAIEditor::_misc_option_selected(int p_id) {
case MISC_PROJECT_SETTINGS: {
_edit_project_settings();
} break;
case MISC_LAYOUT_CLASSIC: {
EDITOR_SETTINGS()->set_setting("limbo_ai/editor/layout", LAYOUT_CLASSIC);
EDITOR_SETTINGS()->mark_setting_changed("limbo_ai/editor/layout");
_update_banners();
} break;
case MISC_LAYOUT_WIDESCREEN_OPTIMIZED: {
EDITOR_SETTINGS()->set_setting("limbo_ai/editor/layout", LAYOUT_WIDESCREEN_OPTIMIZED);
EDITOR_SETTINGS()->mark_setting_changed("limbo_ai/editor/layout");
_update_banners();
} break;
case MISC_CREATE_SCRIPT_TEMPLATE: {
String template_path = _get_script_template_path();
String template_dir = template_path.get_base_dir();
@ -973,10 +959,6 @@ void LimboAIEditor::_tab_clicked(int p_tab) {
void LimboAIEditor::_tab_closed(int p_tab) {
ERR_FAIL_INDEX(p_tab, history.size());
Ref<BehaviorTree> history_bt = history[p_tab];
if (history_bt.is_valid() && history_bt->is_connected(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty))) {
history_bt->disconnect(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty));
}
history.remove_at(p_tab);
idx_history = MIN(idx_history, history.size() - 1);
if (idx_history < 0) {
@ -1234,20 +1216,6 @@ void LimboAIEditor::_update_misc_menu() {
#endif // LIMBOAI_MODULE
misc_menu->add_item(TTR("Project Settings..."), MISC_PROJECT_SETTINGS);
PopupMenu *layout_menu = Object::cast_to<PopupMenu>(misc_menu->get_node_or_null(NodePath("LayoutMenu")));
if (layout_menu == nullptr) {
layout_menu = memnew(PopupMenu);
layout_menu->set_name("LayoutMenu");
layout_menu->connect(LW_NAME(id_pressed), callable_mp(this, &LimboAIEditor::_misc_option_selected));
misc_menu->add_child(layout_menu);
}
layout_menu->add_radio_check_item(TTR("Classic"), MISC_LAYOUT_CLASSIC);
layout_menu->add_radio_check_item(TTR("Widescreen Optimized"), MISC_LAYOUT_WIDESCREEN_OPTIMIZED);
misc_menu->add_submenu_item(TTR("Layout"), "LayoutMenu");
EditorLayout saved_layout = (EditorLayout)(int)EDITOR_GET("limbo_ai/editor/layout");
layout_menu->set_item_checked(0, saved_layout == LAYOUT_CLASSIC);
layout_menu->set_item_checked(1, saved_layout == LAYOUT_WIDESCREEN_OPTIMIZED);
misc_menu->add_separator();
misc_menu->add_item(
FILE_EXISTS(_get_script_template_path()) ? TTR("Edit Script Template") : TTR("Create Script Template"),
@ -1288,15 +1256,6 @@ void LimboAIEditor::_update_banners() {
banners->call_deferred(LW_NAME(add_child), banner);
}
}
EditorLayout saved_layout = (EditorLayout)(int)EDITOR_GET("limbo_ai/editor/layout");
if (saved_layout != editor_layout) {
ActionBanner *banner = memnew(ActionBanner);
banner->set_text(TTR("Restart required to apply changes to editor layout"));
banner->add_action(TTR("Save & Restart"), callable_mp(this, &LimboAIEditor::_save_and_restart), true);
banner->set_meta(LW_NAME(managed), Variant(true));
banners->call_deferred(LW_NAME(add_child), banner);
}
}
void LimboAIEditor::_do_update_theme_item_cache() {
@ -1335,19 +1294,12 @@ void LimboAIEditor::_notification(int p_what) {
cf.instantiate();
String conf_path = PROJECT_CONFIG_FILE();
cf->load(conf_path);
int split_offset = hsc->get_split_offset();
if (editor_layout != (int)EDITOR_GET("limbo_ai/editor/layout")) {
// Editor layout settings changed - flip split offset.
split_offset *= -1;
}
cf->set_value("bt_editor", "bteditor_hsplit", split_offset);
cf->set_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset());
cf->save(conf_path);
task_tree->unload();
for (int i = 0; i < history.size(); i++) {
if (history[i]->is_connected(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty))) {
history[i]->disconnect(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty));
}
if (task_tree->get_bt().is_valid() &&
task_tree->get_bt()->is_connected(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty).bind(true))) {
task_tree->get_bt()->disconnect(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty).bind(true));
}
} break;
case NOTIFICATION_READY: {
@ -1402,12 +1354,7 @@ void LimboAIEditor::_notification(int p_what) {
BUTTON_SET_ICON(misc_btn, get_theme_icon(LW_NAME(Tools), LW_NAME(EditorIcons)));
_update_favorite_tasks();
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (is_visible_in_tree()) {
_update_banners();
}
} break;
}
}
}
@ -1430,20 +1377,6 @@ LimboAIEditor::LimboAIEditor() {
plugin = nullptr;
idx_history = 0;
#ifdef LIMBOAI_MODULE
EDITOR_DEF("limbo_ai/editor/layout", 0);
EDITOR_SETTINGS()->add_property_hint(PropertyInfo(Variant::INT, "limbo_ai/editor/layout", PROPERTY_HINT_ENUM, "Classic:0,Widescreen Optimized:1"));
EDITOR_SETTINGS()->set_restart_if_changed("limbo_ai/editor/layout", true);
#elif LIMBOAI_GDEXTENSION
EDITOR_SETTINGS()->set_initial_value("limbo_ai/editor/layout", 0, false);
Dictionary pinfo;
pinfo["name"] = "limbo_ai/editor/layout";
pinfo["type"] = Variant::INT;
pinfo["hint"] = PROPERTY_HINT_ENUM;
pinfo["hint_string"] = "Classic:0,Widescreen Optimized:1";
EDITOR_SETTINGS()->add_property_info(pinfo);
#endif
LW_SHORTCUT("limbo_ai/rename_task", TTR("Rename"), LW_KEY(F2));
// Todo: Add override support for shortcuts.
// LW_SHORTCUT_OVERRIDE("limbo_ai/rename_task", "macos", Key::ENTER);
@ -1543,14 +1476,14 @@ LimboAIEditor::LimboAIEditor() {
misc_btn->set_flat(true);
toolbar->add_child(misc_btn);
HBoxContainer *version_hbox = memnew(HBoxContainer);
version_hbox->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END);
toolbar->add_child(version_hbox);
HBoxContainer *toolbar_end_hbox = memnew(HBoxContainer);
toolbar_end_hbox->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END);
toolbar->add_child(toolbar_end_hbox);
TextureRect *logo = memnew(TextureRect);
logo->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
logo->set_texture(LimboUtility::get_singleton()->get_task_icon("LimboAI"));
version_hbox->add_child(logo);
toolbar_end_hbox->add_child(logo);
version_btn = memnew(LinkButton);
version_btn->set_text(TTR("v") + String(GET_LIMBOAI_FULL_VERSION()));
@ -1558,11 +1491,11 @@ LimboAIEditor::LimboAIEditor() {
version_btn->set_self_modulate(Color(1, 1, 1, 0.65));
version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
version_btn->set_v_size_flags(SIZE_SHRINK_CENTER);
version_hbox->add_child(version_btn);
toolbar_end_hbox->add_child(version_btn);
Control *version_spacer = memnew(Control);
version_spacer->set_custom_minimum_size(Size2(2, 0) * EDSCALE);
version_hbox->add_child(version_spacer);
toolbar_end_hbox->add_child(version_spacer);
tab_bar_panel = memnew(PanelContainer);
vbox->add_child(tab_bar_panel);
@ -1611,46 +1544,10 @@ LimboAIEditor::LimboAIEditor() {
usage_hint->add_child(usage_label);
task_palette = memnew(TaskPalette());
hsc->set_split_offset(-300);
task_palette->hide();
hsc->add_child(task_palette);
banners = memnew(VBoxContainer);
vbox->add_child(banners);
editor_layout = (EditorLayout)(int)EDITOR_GET("limbo_ai/editor/layout");
if (editor_layout == LAYOUT_WIDESCREEN_OPTIMIZED) {
// * Alternative layout optimized for wide screen.
VBoxContainer *sidebar_vbox = memnew(VBoxContainer);
hsc->add_child(sidebar_vbox);
sidebar_vbox->set_v_size_flags(SIZE_EXPAND_FILL);
HBoxContainer *header_bar = memnew(HBoxContainer);
sidebar_vbox->add_child(header_bar);
Control *header_spacer = memnew(Control);
header_bar->add_child(header_spacer);
header_spacer->set_custom_minimum_size(Size2(6, 0) * EDSCALE);
TextureRect *header_logo = Object::cast_to<TextureRect>(logo->duplicate());
header_bar->add_child(header_logo);
Label *header_title = memnew(Label);
header_bar->add_child(header_title);
header_title->set_text(TTR("Behavior Tree Editor"));
header_title->set_v_size_flags(SIZE_SHRINK_CENTER);
header_title->set_theme_type_variation("HeaderMedium");
task_palette->reparent(sidebar_vbox);
task_palette->set_v_size_flags(SIZE_EXPAND_FILL);
VBoxContainer *editor_vbox = memnew(VBoxContainer);
hsc->add_child(editor_vbox);
toolbar->reparent(editor_vbox);
tab_bar_panel->reparent(editor_vbox);
task_tree->reparent(editor_vbox);
usage_hint->reparent(editor_vbox);
banners->reparent(editor_vbox);
}
hsc->set_split_offset((editor_layout == LAYOUT_CLASSIC ? -320 : 320) * EDSCALE);
change_type_popup = memnew(PopupPanel);
add_child(change_type_popup);
{
@ -1669,6 +1566,9 @@ LimboAIEditor::LimboAIEditor() {
change_type_palette->set_v_size_flags(SIZE_EXPAND_FILL);
}
banners = memnew(VBoxContainer);
vbox->add_child(banners);
menu = memnew(PopupMenu);
add_child(menu);

View File

@ -26,8 +26,8 @@
#include "core/object/object.h"
#include "core/templates/hash_set.h"
#include "editor/editor_node.h"
#include "editor/gui/editor_spin_slider.h"
#include "editor/plugins/editor_plugin.h"
#include "editor/gui/editor_spin_slider.h"
#include "scene/gui/box_container.h"
#include "scene/gui/control.h"
#include "scene/gui/dialogs.h"
@ -98,8 +98,6 @@ private:
MISC_DOC_INTRODUCTION,
MISC_DOC_CUSTOM_TASKS,
MISC_OPEN_DEBUGGER,
MISC_LAYOUT_CLASSIC,
MISC_LAYOUT_WIDESCREEN_OPTIMIZED,
MISC_PROJECT_SETTINGS,
MISC_CREATE_SCRIPT_TEMPLATE,
};
@ -113,11 +111,6 @@ private:
TAB_CLOSE_ALL,
};
enum EditorLayout {
LAYOUT_CLASSIC,
LAYOUT_WIDESCREEN_OPTIMIZED,
};
struct ThemeCache {
Ref<Texture2D> duplicate_task_icon;
Ref<Texture2D> edit_script_icon;
@ -139,7 +132,6 @@ private:
} theme_cache;
EditorPlugin *plugin;
EditorLayout editor_layout;
Vector<Ref<BehaviorTree>> history;
int idx_history;
bool updating_tabs = false;
@ -203,7 +195,6 @@ private:
void _mark_as_dirty(bool p_dirty);
void _create_user_task_dir();
void _remove_task_from_favorite(const String &p_task);
void _save_and_restart();
void _extract_subtree(const String &p_path);
void _replace_task(const Ref<BTTask> &p_task, const Ref<BTTask> &p_by_task);