2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* limbo_debugger_plugin.h
|
|
|
|
* =============================================================================
|
2024-03-21 20:38:57 +00:00
|
|
|
* Copyright 2021-2024 Serhii Snitsaruk
|
2023-07-21 09:50:06 +00:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
2023-04-13 07:29:45 +00:00
|
|
|
|
2024-01-11 10:22:02 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
|
2023-04-13 07:29:45 +00:00
|
|
|
#ifndef LIMBO_DEBUGGER_PLUGIN_H
|
|
|
|
#define LIMBO_DEBUGGER_PLUGIN_H
|
|
|
|
|
2024-01-09 20:47:22 +00:00
|
|
|
#include "../../editor/debugger/behavior_tree_data.h"
|
|
|
|
#include "../../editor/debugger/behavior_tree_view.h"
|
2024-01-11 14:38:29 +00:00
|
|
|
#include "../../util/compat_window_wrapper.h"
|
2023-07-20 16:35:36 +00:00
|
|
|
|
2024-01-09 20:47:22 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
2023-04-13 07:29:45 +00:00
|
|
|
#include "core/object/class_db.h"
|
|
|
|
#include "core/object/object.h"
|
|
|
|
#include "core/typedefs.h"
|
2024-02-17 13:56:19 +00:00
|
|
|
#include "editor/gui/editor_spin_slider.h"
|
2023-04-13 07:29:45 +00:00
|
|
|
#include "editor/plugins/editor_debugger_plugin.h"
|
2023-08-02 10:13:00 +00:00
|
|
|
#include "editor/window_wrapper.h"
|
2023-04-13 07:29:45 +00:00
|
|
|
#include "scene/gui/box_container.h"
|
|
|
|
#include "scene/gui/item_list.h"
|
|
|
|
#include "scene/gui/panel_container.h"
|
|
|
|
#include "scene/gui/split_container.h"
|
|
|
|
#include "scene/gui/texture_rect.h"
|
2024-01-13 16:10:42 +00:00
|
|
|
#endif // LIMBOAI_MODULE
|
2024-01-09 20:47:22 +00:00
|
|
|
|
|
|
|
#ifdef LIMBOAI_GDEXTENSION
|
|
|
|
#include <godot_cpp/classes/button.hpp>
|
|
|
|
#include <godot_cpp/classes/editor_debugger_plugin.hpp>
|
|
|
|
#include <godot_cpp/classes/editor_debugger_session.hpp>
|
2024-02-17 13:56:19 +00:00
|
|
|
#include <godot_cpp/classes/editor_spin_slider.hpp>
|
2024-01-09 20:47:22 +00:00
|
|
|
#include <godot_cpp/classes/h_box_container.hpp>
|
|
|
|
#include <godot_cpp/classes/h_split_container.hpp>
|
|
|
|
#include <godot_cpp/classes/item_list.hpp>
|
|
|
|
#include <godot_cpp/classes/label.hpp>
|
|
|
|
#include <godot_cpp/classes/line_edit.hpp>
|
|
|
|
#include <godot_cpp/classes/panel_container.hpp>
|
|
|
|
#include <godot_cpp/classes/texture_rect.hpp>
|
|
|
|
#include <godot_cpp/classes/v_box_container.hpp>
|
2024-01-13 16:10:42 +00:00
|
|
|
#endif // LIMBOAI_GDEXTENSION
|
2023-04-13 07:29:45 +00:00
|
|
|
|
|
|
|
class LimboDebuggerTab : public PanelContainer {
|
|
|
|
GDCLASS(LimboDebuggerTab, PanelContainer);
|
|
|
|
|
|
|
|
private:
|
2024-08-03 09:07:06 +00:00
|
|
|
struct BTInstanceInfo {
|
|
|
|
uint64_t instance_id;
|
|
|
|
String owner_node_path;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<BTInstanceInfo> active_bt_instances;
|
2023-04-13 07:29:45 +00:00
|
|
|
Ref<EditorDebuggerSession> session;
|
2023-08-02 10:13:00 +00:00
|
|
|
VBoxContainer *root_vb = nullptr;
|
|
|
|
HBoxContainer *toolbar = nullptr;
|
|
|
|
HSplitContainer *hsc = nullptr;
|
|
|
|
Label *info_message = nullptr;
|
2024-08-03 09:07:06 +00:00
|
|
|
ItemList *bt_instance_list = nullptr;
|
2023-08-02 10:13:00 +00:00
|
|
|
BehaviorTreeView *bt_view = nullptr;
|
|
|
|
VBoxContainer *view_box = nullptr;
|
|
|
|
HBoxContainer *alert_box = nullptr;
|
|
|
|
TextureRect *alert_icon = nullptr;
|
|
|
|
Label *alert_message = nullptr;
|
|
|
|
LineEdit *filter_players = nullptr;
|
2023-12-12 22:37:28 +00:00
|
|
|
Button *resource_header = nullptr;
|
2023-08-02 10:13:00 +00:00
|
|
|
Button *make_floating = nullptr;
|
2024-02-17 13:56:19 +00:00
|
|
|
EditorSpinSlider *update_interval = nullptr;
|
2024-01-09 20:47:22 +00:00
|
|
|
CompatWindowWrapper *window_wrapper = nullptr;
|
2023-04-13 07:29:45 +00:00
|
|
|
|
2024-01-09 20:47:22 +00:00
|
|
|
void _reset_controls();
|
2023-04-15 07:01:37 +00:00
|
|
|
void _show_alert(const String &p_message);
|
2024-08-03 09:07:06 +00:00
|
|
|
void _update_bt_instance_list(const Vector<BTInstanceInfo> &p_instances, const String &p_filter);
|
|
|
|
void _bt_instance_selected(int p_idx);
|
2023-04-15 07:01:37 +00:00
|
|
|
void _filter_changed(String p_text);
|
2023-08-02 10:13:00 +00:00
|
|
|
void _window_visibility_changed(bool p_visible);
|
2023-12-12 22:37:28 +00:00
|
|
|
void _resource_header_pressed();
|
2023-04-13 07:29:45 +00:00
|
|
|
|
2023-08-29 10:54:38 +00:00
|
|
|
protected:
|
2024-01-09 20:47:22 +00:00
|
|
|
static void _bind_methods();
|
2023-08-29 10:54:38 +00:00
|
|
|
void _notification(int p_what);
|
|
|
|
|
2023-04-13 07:29:45 +00:00
|
|
|
public:
|
|
|
|
void start_session();
|
|
|
|
void stop_session();
|
2024-08-03 09:07:06 +00:00
|
|
|
void update_active_bt_instances(const Array &p_data);
|
2023-04-14 08:28:33 +00:00
|
|
|
BehaviorTreeView *get_behavior_tree_view() const { return bt_view; }
|
2024-08-03 09:07:06 +00:00
|
|
|
uint64_t get_selected_bt_instance_id();
|
2024-02-03 15:31:21 +00:00
|
|
|
void update_behavior_tree(const Ref<BehaviorTreeData> &p_data);
|
2023-04-13 07:29:45 +00:00
|
|
|
|
2024-01-09 20:47:22 +00:00
|
|
|
void setup(Ref<EditorDebuggerSession> p_session, CompatWindowWrapper *p_wrapper);
|
|
|
|
LimboDebuggerTab();
|
2023-04-13 07:29:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class LimboDebuggerPlugin : public EditorDebuggerPlugin {
|
|
|
|
GDCLASS(LimboDebuggerPlugin, EditorDebuggerPlugin);
|
|
|
|
|
|
|
|
private:
|
2023-08-20 09:34:13 +00:00
|
|
|
static LimboDebuggerPlugin *singleton;
|
|
|
|
|
2024-04-21 11:04:16 +00:00
|
|
|
HashMap<int, CompatWindowWrapper *> session_windows;
|
2023-08-02 10:13:00 +00:00
|
|
|
|
|
|
|
void _window_visibility_changed(bool p_visible);
|
2023-04-13 07:29:45 +00:00
|
|
|
|
2024-01-09 20:47:22 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2023-04-13 07:29:45 +00:00
|
|
|
public:
|
2023-08-20 09:34:13 +00:00
|
|
|
static _FORCE_INLINE_ LimboDebuggerPlugin *get_singleton() { return singleton; }
|
|
|
|
|
2024-01-09 20:47:22 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
2024-04-21 11:04:16 +00:00
|
|
|
void setup_session(int p_session_id) override;
|
2023-04-13 07:29:45 +00:00
|
|
|
bool has_capture(const String &p_capture) const override;
|
2024-04-21 11:04:16 +00:00
|
|
|
bool capture(const String &p_message, const Array &p_data, int p_session_id) override;
|
2024-01-13 16:10:42 +00:00
|
|
|
#elif LIMBOAI_GDEXTENSION
|
2024-01-09 20:47:22 +00:00
|
|
|
void _setup_session(int32_t p_idx) override;
|
|
|
|
bool _has_capture(const String &p_capture) const override;
|
2024-04-21 11:04:16 +00:00
|
|
|
bool _capture(const String &p_message, const Array &p_data, int32_t p_session_id) override;
|
2024-01-13 16:10:42 +00:00
|
|
|
#endif
|
2023-04-13 07:29:45 +00:00
|
|
|
|
2024-04-21 11:04:16 +00:00
|
|
|
CompatWindowWrapper *get_first_session_window() const;
|
|
|
|
int get_first_session_tab_index() const;
|
2023-08-20 09:34:13 +00:00
|
|
|
|
2023-04-13 07:29:45 +00:00
|
|
|
LimboDebuggerPlugin();
|
2023-08-20 09:34:13 +00:00
|
|
|
~LimboDebuggerPlugin();
|
2023-04-13 07:29:45 +00:00
|
|
|
};
|
|
|
|
|
2024-01-13 16:10:42 +00:00
|
|
|
#endif // LIMBO_DEBUGGER_PLUGIN_H
|
2024-01-11 10:22:02 +00:00
|
|
|
|
|
|
|
#endif // ! TOOLS_ENABLED
|