Path: blob/master/modules/objectdb_profiler/editor/objectdb_profiler_panel.h
11323 views
/**************************************************************************/1/* objectdb_profiler_panel.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 "data_viewers/snapshot_view.h"33#include "snapshot_data.h"3435#include "core/io/dir_access.h"36#include "core/templates/lru.h"3738class TabContainer;39class Tree;4041// UI loaded by the debugger.42class ObjectDBProfilerPanel : public Control {43GDCLASS(ObjectDBProfilerPanel, Control);4445protected:46static constexpr int SNAPSHOT_CACHE_MAX_SIZE = 10;4748enum OdbProfilerMenuOptions {49ODB_MENU_RENAME,50ODB_MENU_SHOW_IN_FOLDER,51ODB_MENU_DELETE,52};5354struct PartialSnapshot {55int total_size;56Vector<uint8_t> data;57};5859int next_request_id = 0;60bool awaiting_debug_break = false;61bool requested_break_for_snapshot = false;6263Tree *snapshot_list = nullptr;64Button *take_snapshot = nullptr;65TabContainer *view_tabs = nullptr;66PopupMenu *rmb_menu = nullptr;67OptionButton *diff_button = nullptr;68HashMap<int, PartialSnapshot> partial_snapshots;6970LocalVector<SnapshotView *> views;71Ref<GameStateSnapshotRef> current_snapshot;72Ref<GameStateSnapshotRef> diff_snapshot;73LRUCache<String, Ref<GameStateSnapshotRef>> snapshot_cache;7475void _request_object_snapshot();76void _begin_object_snapshot();77void _on_debug_breaked(bool p_reallydid, bool p_can_debug, const String &p_reason, bool p_has_stackdump);78void _show_selected_snapshot();79void _on_snapshot_deselected();80Ref<DirAccess> _get_and_create_snapshot_storage_dir();81TreeItem *_add_snapshot_button(const String &p_snapshot_file_name, const String &p_full_file_path);82void _snapshot_rmb(const Vector2 &p_pos, MouseButton p_button);83void _rmb_menu_pressed(int p_tool, bool p_confirm_override);84void _update_view_tabs();85void _update_diff_items();86void _update_enabled_diff_items();87void _edit_snapshot_name();88void _view_tab_changed(int p_tab_idx);89String _to_mb(int p_x);9091public:92ObjectDBProfilerPanel();9394void receive_snapshot(int p_request_id);95void show_snapshot(const String &p_snapshot_file_name, const String &p_snapshot_diff_file_name);96void clear_snapshot(bool p_update_view_tabs = true);97Ref<GameStateSnapshotRef> get_snapshot(const String &p_snapshot_file_name);98void set_enabled(bool p_enabled);99void add_view(SnapshotView *p_to_add);100101bool handle_debug_message(const String &p_message, const Array &p_data, int p_index);102};103104105