Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/multiplayer/editor/editor_network_profiler.h
11353 views
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
HashMap<ObjectID, RPCNodeInfo> rpc_data;
74
HashMap<ObjectID, SyncInfo> sync_data;
75
HashMap<ObjectID, NodeInfo> node_data;
76
HashSet<ObjectID> missing_node_data;
77
78
struct ThemeCache {
79
Ref<Texture2D> node_icon;
80
Ref<Texture2D> stop_icon;
81
Ref<Texture2D> play_icon;
82
Ref<Texture2D> clear_icon;
83
84
Ref<Texture2D> multiplayer_synchronizer_icon;
85
Ref<Texture2D> instance_options_icon;
86
87
Ref<Texture2D> incoming_bandwidth_icon;
88
Ref<Texture2D> outgoing_bandwidth_icon;
89
90
Color incoming_bandwidth_color;
91
Color outgoing_bandwidth_color;
92
} theme_cache;
93
94
void _activate_pressed();
95
void _clear_pressed();
96
void _autostart_toggled(bool p_toggled_on);
97
void _refresh();
98
void _update_button_text();
99
void _replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button);
100
101
protected:
102
virtual void _update_theme_item_cache() override;
103
104
void _notification(int p_what);
105
static void _bind_methods();
106
107
public:
108
void refresh_rpc_data();
109
void refresh_replication_data();
110
111
Array pop_missing_node_data();
112
void add_node_data(const NodeInfo &p_info);
113
void add_rpc_frame_data(const RPCNodeInfo &p_frame);
114
void add_sync_frame_data(const SyncInfo &p_frame);
115
void set_bandwidth(int p_incoming, int p_outgoing);
116
bool is_profiling();
117
118
void set_profiling(bool p_pressed);
119
void started();
120
void stopped();
121
122
EditorNetworkProfiler();
123
};
124
125