Path: blob/master/modules/multiplayer/editor/editor_network_profiler.h
11353 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;7172HashMap<ObjectID, RPCNodeInfo> rpc_data;73HashMap<ObjectID, SyncInfo> sync_data;74HashMap<ObjectID, NodeInfo> node_data;75HashSet<ObjectID> missing_node_data;7677struct ThemeCache {78Ref<Texture2D> node_icon;79Ref<Texture2D> stop_icon;80Ref<Texture2D> play_icon;81Ref<Texture2D> clear_icon;8283Ref<Texture2D> multiplayer_synchronizer_icon;84Ref<Texture2D> instance_options_icon;8586Ref<Texture2D> incoming_bandwidth_icon;87Ref<Texture2D> outgoing_bandwidth_icon;8889Color incoming_bandwidth_color;90Color outgoing_bandwidth_color;91} theme_cache;9293void _activate_pressed();94void _clear_pressed();95void _autostart_toggled(bool p_toggled_on);96void _refresh();97void _update_button_text();98void _replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button);99100protected:101virtual void _update_theme_item_cache() override;102103void _notification(int p_what);104static void _bind_methods();105106public:107void refresh_rpc_data();108void refresh_replication_data();109110Array pop_missing_node_data();111void add_node_data(const NodeInfo &p_info);112void add_rpc_frame_data(const RPCNodeInfo &p_frame);113void add_sync_frame_data(const SyncInfo &p_frame);114void set_bandwidth(int p_incoming, int p_outgoing);115bool is_profiling();116117void set_profiling(bool p_pressed);118void started();119void stopped();120121EditorNetworkProfiler();122};123124125