Path: blob/master/modules/multiplayer/editor/editor_network_profiler.h
21038 views
/**************************************************************************/1/* editor_network_profiler.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "../multiplayer_debugger.h"3334#include "scene/debugger/scene_debugger.h"35#include "scene/gui/box_container.h"36#include "scene/gui/button.h"37#include "scene/gui/label.h"38#include "scene/gui/split_container.h"39#include "scene/gui/tree.h"4041class Timer;4243class EditorNetworkProfiler : public VBoxContainer {44GDCLASS(EditorNetworkProfiler, VBoxContainer)4546public:47struct NodeInfo {48ObjectID id;49String type;50String path;5152NodeInfo() {}53NodeInfo(const ObjectID &p_id) {54id = p_id;55path = String::num_int64(p_id);56}57};5859private:60using RPCNodeInfo = MultiplayerDebugger::RPCNodeInfo;61using SyncInfo = MultiplayerDebugger::SyncInfo;6263bool dirty = false;64Timer *refresh_timer = nullptr;65Button *activate = nullptr;66Button *clear_button = nullptr;67Tree *counters_display = nullptr;68LineEdit *incoming_bandwidth_text = nullptr;69LineEdit *outgoing_bandwidth_text = nullptr;70Tree *replication_display = nullptr;7172Label *up_label = nullptr;73Label *down_label = nullptr;7475int incoming_bandwidth = 0;76int outgoing_bandwidth = 0;7778HashMap<ObjectID, RPCNodeInfo> rpc_data;79HashMap<ObjectID, SyncInfo> sync_data;80HashMap<ObjectID, NodeInfo> node_data;81HashSet<ObjectID> missing_node_data;8283struct ThemeCache {84Ref<Texture2D> node_icon;85Ref<Texture2D> stop_icon;86Ref<Texture2D> play_icon;87Ref<Texture2D> clear_icon;8889Ref<Texture2D> multiplayer_synchronizer_icon;90Ref<Texture2D> instance_options_icon;9192Ref<Texture2D> incoming_bandwidth_icon;93Ref<Texture2D> outgoing_bandwidth_icon;9495Color incoming_bandwidth_color;96Color outgoing_bandwidth_color;97} theme_cache;9899void _activate_pressed();100void _clear_pressed();101void _autostart_toggled(bool p_toggled_on);102void _refresh();103void _update_button_text();104void _replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button);105106protected:107virtual void _update_theme_item_cache() override;108109void _notification(int p_what);110static void _bind_methods();111112public:113void refresh_rpc_data();114void refresh_replication_data();115116Array pop_missing_node_data();117void add_node_data(const NodeInfo &p_info);118void add_rpc_frame_data(const RPCNodeInfo &p_frame);119void add_sync_frame_data(const SyncInfo &p_frame);120void set_bandwidth(int p_incoming, int p_outgoing);121bool is_profiling();122123void set_profiling(bool p_pressed);124void started();125void stopped();126127EditorNetworkProfiler();128};129130131