Debian Codegraph @

modules/multiplayer/editor/editor_network_profiler.h

raw symbols SCIP
1 /**************************************************************************/
2 /* editor_network_profiler.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
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 };