| 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 "../multiplayer_debugger.h" |
| 34 |
|
| 35 |
#include "scene/debugger/scene_debugger.h" |
| 36 |
#include "scene/gui/box_container.h" |
| 37 |
#include "scene/gui/button.h" |
| 38 |
#include "scene/gui/label.h" |
| 39 |
#include "scene/gui/split_container.h" |
| 40 |
#include "scene/gui/tree.h" |
| 41 |
|
| 42 |
class Timer; |
| 43 |
|
| 44 |
class EditorNetworkProfiler : public VBoxContainer { |
| 45 |
GDCLASS(EditorNetworkProfiler, VBoxContainer) |
| 46 |
|
| 47 |
public: |
| 48 |
struct NodeInfo { |
| 49 |
ObjectID id; |
| 50 |
String type; |
| 51 |
String path; |
| 52 |
|
| 53 |
NodeInfo() {} |
| 54 |
NodeInfo(const ObjectID &p_id) { |
| 55 |
id = p_id; |
| 56 |
path = String::num_int64(p_id); |
| 57 |
} |
| 58 |
}; |
| 59 |
|
| 60 |
private: |
| 61 |
using RPCNodeInfo = MultiplayerDebugger::RPCNodeInfo; |
| 62 |
using SyncInfo = MultiplayerDebugger::SyncInfo; |
| 63 |
|
| 64 |
bool dirty = false; |
| 65 |
Timer *refresh_timer = nullptr; |
| 66 |
Button *activate = nullptr; |
| 67 |
Button *clear_button = nullptr; |
| 68 |
Tree *counters_display = nullptr; |
| 69 |
LineEdit *incoming_bandwidth_text = nullptr; |
| 70 |
LineEdit *outgoing_bandwidth_text = nullptr; |
| 71 |
Tree *replication_display = nullptr; |
| 72 |
|
| 73 |
Label *up_label = nullptr; |
| 74 |
Label *down_label = nullptr; |
| 75 |
|
| 76 |
int incoming_bandwidth = 0; |
| 77 |
int outgoing_bandwidth = 0; |
| 78 |
|
| 79 |
HashMap<ObjectID, RPCNodeInfo> rpc_data; |
| 80 |
HashMap<ObjectID, SyncInfo> sync_data; |
| 81 |
HashMap<ObjectID, NodeInfo> node_data; |
| 82 |
HashSet<ObjectID> missing_node_data; |
| 83 |
|
| 84 |
struct ThemeCache { |
| 85 |
Ref<Texture2D> node_icon; |
| 86 |
Ref<Texture2D> stop_icon; |
| 87 |
Ref<Texture2D> play_icon; |
| 88 |
Ref<Texture2D> clear_icon; |
| 89 |
|
| 90 |
Ref<Texture2D> multiplayer_synchronizer_icon; |
| 91 |
Ref<Texture2D> instance_options_icon; |
| 92 |
|
| 93 |
Ref<Texture2D> incoming_bandwidth_icon; |
| 94 |
Ref<Texture2D> outgoing_bandwidth_icon; |
| 95 |
|
| 96 |
Color incoming_bandwidth_color; |
| 97 |
Color outgoing_bandwidth_color; |
| 98 |
} theme_cache; |
| 99 |
|
| 100 |
void _activate_pressed(); |
| 101 |
void _clear_pressed(); |
| 102 |
void _autostart_toggled(bool p_toggled_on); |
| 103 |
void _refresh(); |
| 104 |
void _update_button_text(); |
| 105 |
void _replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button); |
| 106 |
|
| 107 |
protected: |
| 108 |
virtual void _update_theme_item_cache() override; |
| 109 |
|
| 110 |
void _notification(int p_what); |
| 111 |
static void _bind_methods(); |
| 112 |
|
| 113 |
public: |
| 114 |
void refresh_rpc_data(); |
| 115 |
void refresh_replication_data(); |
| 116 |
|
| 117 |
Array pop_missing_node_data(); |
| 118 |
void add_node_data(const NodeInfo &p_info); |
| 119 |
void add_rpc_frame_data(const RPCNodeInfo &p_frame); |
| 120 |
void add_sync_frame_data(const SyncInfo &p_frame); |
| 121 |
void set_bandwidth(int p_incoming, int p_outgoing); |
| 122 |
bool is_profiling(); |
| 123 |
|
| 124 |
void set_profiling(bool p_pressed); |
| 125 |
void started(); |
| 126 |
void stopped(); |
| 127 |
|
| 128 |
EditorNetworkProfiler(); |
| 129 |
}; |