| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "data_viewers/snapshot_view.h" |
| 34 |
#include "snapshot_data.h" |
| 35 |
|
| 36 |
#include "core/io/dir_access.h" |
| 37 |
#include "core/templates/lru.h" |
| 38 |
|
| 39 |
class TabContainer; |
| 40 |
class Tree; |
| 41 |
|
| 42 |
|
| 43 |
class ObjectDBProfilerPanel : public Control { |
| 44 |
GDCLASS(ObjectDBProfilerPanel, Control); |
| 45 |
|
| 46 |
protected: |
| 47 |
static constexpr int SNAPSHOT_CACHE_MAX_SIZE = 10; |
| 48 |
|
| 49 |
enum OdbProfilerMenuOptions { |
| 50 |
ODB_MENU_RENAME, |
| 51 |
ODB_MENU_SHOW_IN_FOLDER, |
| 52 |
ODB_MENU_DELETE, |
| 53 |
}; |
| 54 |
|
| 55 |
struct PartialSnapshot { |
| 56 |
int total_size; |
| 57 |
Vector<uint8_t> data; |
| 58 |
}; |
| 59 |
|
| 60 |
int next_request_id = 0; |
| 61 |
bool awaiting_debug_break = false; |
| 62 |
bool requested_break_for_snapshot = false; |
| 63 |
|
| 64 |
Tree *snapshot_list = nullptr; |
| 65 |
Button *take_snapshot = nullptr; |
| 66 |
TabContainer *view_tabs = nullptr; |
| 67 |
PopupMenu *rmb_menu = nullptr; |
| 68 |
OptionButton *diff_button = nullptr; |
| 69 |
HashMap<int, PartialSnapshot> partial_snapshots; |
| 70 |
|
| 71 |
LocalVector<SnapshotView *> views; |
| 72 |
Ref<GameStateSnapshot> current_snapshot; |
| 73 |
Ref<GameStateSnapshot> diff_snapshot; |
| 74 |
LRUCache<String, Ref<GameStateSnapshot>> snapshot_cache; |
| 75 |
|
| 76 |
void _request_object_snapshot(); |
| 77 |
void _begin_object_snapshot(); |
| 78 |
void _on_debug_breaked(bool p_reallydid, bool p_can_debug, const String &p_reason, bool p_has_stackdump); |
| 79 |
void _show_selected_snapshot(); |
| 80 |
void _on_snapshot_deselected(); |
| 81 |
Ref<DirAccess> _get_and_create_snapshot_storage_dir(); |
| 82 |
TreeItem *_add_snapshot_button(const String &p_snapshot_file_name, const String &p_full_file_path); |
| 83 |
void _snapshot_rmb(const Vector2 &p_pos, MouseButton p_button); |
| 84 |
void _rmb_menu_pressed(int p_tool, bool p_confirm_override); |
| 85 |
void _update_view_tabs(); |
| 86 |
void _update_diff_items(); |
| 87 |
void _update_enabled_diff_items(); |
| 88 |
void _edit_snapshot_name(); |
| 89 |
void _view_tab_changed(int p_tab_idx); |
| 90 |
String _to_mb(int p_x); |
| 91 |
|
| 92 |
public: |
| 93 |
ObjectDBProfilerPanel(); |
| 94 |
|
| 95 |
void receive_snapshot(int p_request_id); |
| 96 |
void show_snapshot(const String &p_snapshot_file_name, const String &p_snapshot_diff_file_name); |
| 97 |
void clear_snapshot(bool p_update_view_tabs = true); |
| 98 |
Ref<GameStateSnapshot> get_snapshot(const String &p_snapshot_file_name); |
| 99 |
void set_enabled(bool p_enabled); |
| 100 |
void add_view(SnapshotView *p_to_add); |
| 101 |
|
| 102 |
bool handle_debug_message(const String &p_message, const Array &p_data, int p_index); |
| 103 |
}; |