Compare commits

...

5 Commits

Author SHA1 Message Date
Serhii Snitsaruk 5a10492fb7
Merge 4787413cb6 into 4d0d2c0507 2024-07-05 18:49:21 +00:00
Serhii Snitsaruk 4787413cb6
Add header to the sidebar 2024-07-05 20:49:16 +02:00
Serhii Snitsaruk 2813728785
Fix connected signal error when loading BT for the second time 2024-07-05 20:32:53 +02:00
Serhii Snitsaruk 4d0d2c0507
Merge pull request #155 from dpalais/auto_translate_deprecated
Replace deprecated set_auto_translate call with set_auto_translate_mode
2024-07-02 20:25:11 +02:00
Dave Palais 4cba3b39db Replace deprecated set_auto_translate call with set_auto_translate_mode 2024-07-02 12:50:56 -05:00
1 changed files with 43 additions and 19 deletions

View File

@ -221,6 +221,8 @@ 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) {
@ -235,14 +237,9 @@ 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()) {
if (task_tree->get_bt().is_valid() && !task_tree->get_bt()->is_connected(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty))) {
task_tree->get_bt()->connect(LW_NAME(changed), callable_mp(this, &LimboAIEditor::_mark_as_dirty).bind(true));
}
@ -959,6 +956,10 @@ 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) {
@ -1302,9 +1303,11 @@ void LimboAIEditor::_notification(int p_what) {
cf->set_value("bt_editor", "bteditor_hsplit", split_offset);
cf->save(conf_path);
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->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));
}
}
} break;
case NOTIFICATION_READY: {
@ -1495,14 +1498,14 @@ LimboAIEditor::LimboAIEditor() {
misc_btn->set_flat(true);
toolbar->add_child(misc_btn);
HBoxContainer *toolbar_end_hbox = memnew(HBoxContainer);
toolbar_end_hbox->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END);
toolbar->add_child(toolbar_end_hbox);
HBoxContainer *version_hbox = memnew(HBoxContainer);
version_hbox->set_h_size_flags(SIZE_EXPAND | SIZE_SHRINK_END);
toolbar->add_child(version_hbox);
TextureRect *logo = memnew(TextureRect);
logo->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
logo->set_texture(LimboUtility::get_singleton()->get_task_icon("LimboAI"));
toolbar_end_hbox->add_child(logo);
version_hbox->add_child(logo);
version_btn = memnew(LinkButton);
version_btn->set_text(TTR("v") + String(GET_LIMBOAI_FULL_VERSION()));
@ -1510,11 +1513,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);
toolbar_end_hbox->add_child(version_btn);
version_hbox->add_child(version_btn);
Control *version_spacer = memnew(Control);
version_spacer->set_custom_minimum_size(Size2(2, 0) * EDSCALE);
toolbar_end_hbox->add_child(version_spacer);
version_hbox->add_child(version_spacer);
tab_bar_panel = memnew(PanelContainer);
vbox->add_child(tab_bar_panel);
@ -1525,7 +1528,7 @@ LimboAIEditor::LimboAIEditor() {
tab_bar->set_select_with_rmb(true);
tab_bar->set_drag_to_rearrange_enabled(true);
tab_bar->set_max_tab_width(int(EDITOR_GET("interface/scene_tabs/maximum_width")) * EDSCALE);
tab_bar->set_auto_translate(false);
tab_bar->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
tab_bar->set_tab_close_display_policy(TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
tab_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
tab_bar->set_focus_mode(FocusMode::FOCUS_NONE);
@ -1565,19 +1568,40 @@ LimboAIEditor::LimboAIEditor() {
task_palette = memnew(TaskPalette());
task_palette->hide();
hsc->add_child(task_palette);
editor_layout = (EditorLayout)(int)EDITOR_GET("limbo_ai/editor/layout");
if (editor_layout == EditorLayout::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);
hsc->set_split_offset(300);
} else {
hsc->set_split_offset(-300);
}
hsc->set_split_offset((editor_layout == EditorLayout::CLASSIC ? -320 : 320) * EDSCALE);
change_type_popup = memnew(PopupPanel);
add_child(change_type_popup);
{