Path: blob/master/modules/multiplayer/editor/editor_network_profiler.h
10278 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 EditorNetworkProfiler : public VBoxContainer {42GDCLASS(EditorNetworkProfiler, VBoxContainer)4344public:45struct NodeInfo {46ObjectID id;47String type;48String path;4950NodeInfo() {}51NodeInfo(const ObjectID &p_id) {52id = p_id;53path = String::num_int64(p_id);54}55};5657private:58using RPCNodeInfo = MultiplayerDebugger::RPCNodeInfo;59using SyncInfo = MultiplayerDebugger::SyncInfo;6061bool dirty = false;62Timer *refresh_timer = nullptr;63Button *activate = nullptr;64Button *clear_button = nullptr;65Tree *counters_display = nullptr;66LineEdit *incoming_bandwidth_text = nullptr;67LineEdit *outgoing_bandwidth_text = nullptr;68Tree *replication_display = nullptr;6970HashMap<ObjectID, RPCNodeInfo> rpc_data;71HashMap<ObjectID, SyncInfo> sync_data;72HashMap<ObjectID, NodeInfo> node_data;73HashSet<ObjectID> missing_node_data;7475struct ThemeCache {76Ref<Texture2D> node_icon;77Ref<Texture2D> stop_icon;78Ref<Texture2D> play_icon;79Ref<Texture2D> clear_icon;8081Ref<Texture2D> multiplayer_synchronizer_icon;82Ref<Texture2D> instance_options_icon;8384Ref<Texture2D> incoming_bandwidth_icon;85Ref<Texture2D> outgoing_bandwidth_icon;8687Color incoming_bandwidth_color;88Color outgoing_bandwidth_color;89} theme_cache;9091void _activate_pressed();92void _clear_pressed();93void _autostart_toggled(bool p_toggled_on);94void _refresh();95void _update_button_text();96void _replication_button_clicked(TreeItem *p_item, int p_column, int p_idx, MouseButton p_button);9798protected:99virtual void _update_theme_item_cache() override;100101void _notification(int p_what);102static void _bind_methods();103104public:105void refresh_rpc_data();106void refresh_replication_data();107108Array pop_missing_node_data();109void add_node_data(const NodeInfo &p_info);110void add_rpc_frame_data(const RPCNodeInfo &p_frame);111void add_sync_frame_data(const SyncInfo &p_frame);112void set_bandwidth(int p_incoming, int p_outgoing);113bool is_profiling();114115void set_profiling(bool p_pressed);116void started();117void stopped();118119EditorNetworkProfiler();120};121122123