Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/multiplayer/editor/editor_network_profiler.h
10278 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 EditorNetworkProfiler : public VBoxContainer {
43
GDCLASS(EditorNetworkProfiler, VBoxContainer)
44
45
public:
46
struct NodeInfo {
47
ObjectID id;
48
String type;
49
String path;
50
51
NodeInfo() {}
52
NodeInfo(const ObjectID &p_id) {
53
id = p_id;
54
path = String::num_int64(p_id);
55
}
56
};
57
58
private:
59
using RPCNodeInfo = MultiplayerDebugger::RPCNodeInfo;
60
using SyncInfo = MultiplayerDebugger::SyncInfo;
61
62
bool dirty = false;
63
Timer *refresh_timer = nullptr;
64
Button *activate = nullptr;
65
Button *clear_button = nullptr;
66
Tree *counters_display = nullptr;
67
LineEdit *incoming_bandwidth_text = nullptr;
68
LineEdit *outgoing_bandwidth_text = nullptr;
69
Tree *replication_display = nullptr;
70
71
HashMap<ObjectID, RPCNodeInfo> rpc_data;
72
HashMap<ObjectID, SyncInfo> sync_data;
73
HashMap<ObjectID, NodeInfo> node_data;
74
HashSet<ObjectID> missing_node_data;
75
76
struct ThemeCache {
77
Ref<Texture2D> node_icon;
78
Ref<Texture2D> stop_icon;
79
Ref<Texture2D> play_icon;
80
Ref<Texture2D> clear_icon;
81
82
Ref<Texture2D> multiplayer_synchronizer_icon;
83
Ref<Texture2D> instance_options_icon;
84
85
Ref<Texture2D> incoming_bandwidth_icon;
86
Ref<Texture2D> outgoing_bandwidth_icon;
87
88
Color incoming_bandwidth_color;
89
Color outgoing_bandwidth_color;
90
} theme_cache;
91
92
void _activate_pressed();
93
void _clear_pressed();
94
void _autostart_toggled(bool p_toggled_on);
95
void _refresh();
96
void _update_button_text();
97
void _replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button);
98
99
protected:
100
virtual void _update_theme_item_cache() override;
101
102
void _notification(int p_what);
103
static void _bind_methods();
104
105
public:
106
void refresh_rpc_data();
107
void refresh_replication_data();
108
109
Array pop_missing_node_data();
110
void add_node_data(const NodeInfo &p_info);
111
void add_rpc_frame_data(const RPCNodeInfo &p_frame);
112
void add_sync_frame_data(const SyncInfo &p_frame);
113
void set_bandwidth(int p_incoming, int p_outgoing);
114
bool is_profiling();
115
116
void set_profiling(bool p_pressed);
117
void started();
118
void stopped();
119
120
EditorNetworkProfiler();
121
};
122
123