Debugger: Add status icons and better name shortening
This commit is contained in:
parent
0e2f4930e8
commit
077c9553b5
|
@ -65,18 +65,22 @@ void BehaviorTreeView::update_tree(const BehaviorTreeData &p_data) {
|
|||
TreeItem *item = tree->create_item(parent);
|
||||
// Do this first because it resets properties of the cell...
|
||||
item->set_cell_mode(0, TreeItem::CELL_MODE_CUSTOM);
|
||||
item->set_cell_mode(1, TreeItem::CELL_MODE_ICON);
|
||||
|
||||
item->set_metadata(0, task_data.id);
|
||||
item->set_text(0, task_data.name);
|
||||
item->set_icon(0, LimboUtility::get_singleton()->get_task_icon(task_data.type_name));
|
||||
item->set_text(1, rtos(Math::snapped(task_data.elapsed_time, 0.01)));
|
||||
item->set_text(2, rtos(Math::snapped(task_data.elapsed_time, 0.01)));
|
||||
|
||||
if (task_data.status == BTTask::SUCCESS) {
|
||||
item->set_custom_draw(0, this, SNAME("_draw_success_status"));
|
||||
item->set_icon(1, icon_success);
|
||||
} else if (task_data.status == BTTask::FAILURE) {
|
||||
item->set_custom_draw(0, this, SNAME("_draw_failure_status"));
|
||||
item->set_icon(1, icon_failure);
|
||||
} else if (task_data.status == BTTask::RUNNING) {
|
||||
item->set_custom_draw(0, this, SNAME("_draw_running_status"));
|
||||
item->set_icon(1, icon_running);
|
||||
}
|
||||
|
||||
if (task_data.id == selected_id) {
|
||||
|
@ -99,6 +103,14 @@ void BehaviorTreeView::clear() {
|
|||
collapsed_ids.clear();
|
||||
}
|
||||
|
||||
void BehaviorTreeView::_notification(int p_notification) {
|
||||
if (p_notification == NOTIFICATION_THEME_CHANGED) {
|
||||
icon_running = get_theme_icon(SNAME("BTClock"), SNAME("EditorIcons"));
|
||||
icon_success = get_theme_icon(SNAME("BTAlwaysSucceed"), SNAME("EditorIcons"));
|
||||
icon_failure = get_theme_icon(SNAME("BTAlwaysFail"), SNAME("EditorIcons"));
|
||||
}
|
||||
}
|
||||
|
||||
void BehaviorTreeView::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_draw_running_status"), &BehaviorTreeView::_draw_running_status);
|
||||
ClassDB::bind_method(D_METHOD("_draw_success_status"), &BehaviorTreeView::_draw_success_status);
|
||||
|
@ -109,10 +121,12 @@ void BehaviorTreeView::_bind_methods() {
|
|||
BehaviorTreeView::BehaviorTreeView() {
|
||||
tree = memnew(Tree);
|
||||
add_child(tree);
|
||||
tree->set_columns(2);
|
||||
tree->set_columns(3);
|
||||
tree->set_column_expand(0, true);
|
||||
tree->set_column_expand(1, false);
|
||||
tree->set_column_custom_minimum_width(1, 40.0 * EDSCALE);
|
||||
tree->set_column_expand(2, false);
|
||||
tree->set_column_custom_minimum_width(1, 18.0 * EDSCALE);
|
||||
tree->set_column_custom_minimum_width(2, 40.0 * EDSCALE);
|
||||
tree->set_anchor(SIDE_RIGHT, ANCHOR_END);
|
||||
tree->set_anchor(SIDE_BOTTOM, ANCHOR_END);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "scene/gui/control.h"
|
||||
#include "scene/gui/tree.h"
|
||||
#include "scene/resources/style_box.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
class BehaviorTreeView : public Control {
|
||||
GDCLASS(BehaviorTreeView, Control);
|
||||
|
@ -20,6 +21,10 @@ private:
|
|||
StyleBoxFlat sbf_failure;
|
||||
Vector<int> collapsed_ids;
|
||||
|
||||
Ref<Texture2D> icon_running;
|
||||
Ref<Texture2D> icon_success;
|
||||
Ref<Texture2D> icon_failure;
|
||||
|
||||
void _draw_success_status(Object *p_obj, Rect2 p_rect);
|
||||
void _draw_running_status(Object *p_obj, Rect2 p_rect);
|
||||
void _draw_failure_status(Object *p_obj, Rect2 p_rect);
|
||||
|
@ -28,6 +33,8 @@ private:
|
|||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
void _notification(int p_notification);
|
||||
|
||||
public:
|
||||
void update_tree(const BehaviorTreeData &p_data);
|
||||
void clear();
|
||||
|
|
|
@ -36,7 +36,7 @@ void LimboDebuggerTab::stop_session() {
|
|||
session->send_message("limboai:stop_session", Array());
|
||||
}
|
||||
|
||||
void LimboDebuggerTab::update_bt_list(const Array &p_items) {
|
||||
void LimboDebuggerTab::update_bt_list(const Array &p_node_paths) {
|
||||
// Remember selected item.
|
||||
String selected_bt = "";
|
||||
if (bt_list->is_anything_selected()) {
|
||||
|
@ -45,9 +45,11 @@ void LimboDebuggerTab::update_bt_list(const Array &p_items) {
|
|||
|
||||
bt_list->clear();
|
||||
int select_idx = -1;
|
||||
for (int i = 0; i < p_items.size(); i++) {
|
||||
bt_list->add_item(p_items[i]);
|
||||
if (p_items[i] == selected_bt) {
|
||||
for (int i = 0; i < p_node_paths.size(); i++) {
|
||||
bt_list->add_item(p_node_paths[i]);
|
||||
// Make item text shortened from the left, e.g ".../Agent/BTPlayer".
|
||||
bt_list->set_item_text_direction(i, TEXT_DIRECTION_RTL);
|
||||
if (p_node_paths[i] == selected_bt) {
|
||||
select_idx = i;
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ LimboDebuggerTab::LimboDebuggerTab(Ref<EditorDebuggerSession> p_session) {
|
|||
|
||||
bt_list = memnew(ItemList);
|
||||
hsc->add_child(bt_list);
|
||||
bt_list->set_custom_minimum_size(Size2(280.0 * EDSCALE, 0.0));
|
||||
bt_list->set_custom_minimum_size(Size2(240.0 * EDSCALE, 0.0));
|
||||
bt_list->connect(SNAME("item_selected"), callable_mp(this, &LimboDebuggerTab::_bt_selected));
|
||||
|
||||
view_box = memnew(VBoxContainer);
|
||||
|
|
|
@ -34,7 +34,7 @@ private:
|
|||
public:
|
||||
void start_session();
|
||||
void stop_session();
|
||||
void update_bt_list(const Array &p_items);
|
||||
void update_bt_list(const Array &p_node_paths);
|
||||
BehaviorTreeView *get_behavior_tree_view() const { return bt_view; }
|
||||
|
||||
LimboDebuggerTab(Ref<EditorDebuggerSession> p_session);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg enable-background="new 0 0 16 16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0"><path d="m15 8.01c0-1.69-.6-3.23-1.59-4.44l.01-.01c-.38-.46-.82-.87-1.31-1.22l-.01.01c-.66-.48-1.4-.84-2.21-1.07v-.01c-.6-.17-1.23-.27-1.89-.27s-1.29.1-1.89.27v.01c-2.58.72-4.55 2.87-5.01 5.54v.02c-.07.38-.1.77-.1 1.17 0 3.86 3.13 6.99 7 6.99s7-3.13 7-6.99zm-7 5.48c-3.02 0-5.48-2.46-5.48-5.48 0-2.76 2.06-5.03 4.73-5.4v5.4h1.51v-5.41c2.66.37 4.73 2.64 4.73 5.4-.01 3.03-2.47 5.49-5.49 5.49z"/><path d="m7.99 15c1.69 0 3.23-.6 4.44-1.59l.01.01c.46-.38.87-.82 1.22-1.31l-.01-.01c.48-.66.84-1.4 1.07-2.21h.01c.17-.6.27-1.23.27-1.89s-.1-1.29-.27-1.89h-.01c-.72-2.57-2.87-4.55-5.55-5-.01 0-.01 0-.02 0-.37-.08-.76-.11-1.16-.11-3.86 0-6.99 3.13-6.99 7s3.13 7 6.99 7zm-5.48-7c0-3.02 2.46-5.48 5.48-5.48 2.76 0 5.03 2.06 5.4 4.73h-5.4v1.51h5.4c-.37 2.66-2.64 4.73-5.4 4.73-3.02-.01-5.48-2.47-5.48-5.49z"/><circle cx="8" cy="8" r="1.5"/></g></svg>
|
After Width: | Height: | Size: 951 B |
Loading…
Reference in New Issue