class_view.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**************************************************************************/
  2. /* class_view.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. #pragma once
  31. #include "../snapshot_data.h"
  32. #include "snapshot_view.h"
  33. class Tree;
  34. class TreeItem;
  35. struct ClassData {
  36. ClassData() {}
  37. ClassData(const String &p_name, const String &p_parent) :
  38. class_name(p_name), parent_class_name(p_parent) {}
  39. String class_name;
  40. String parent_class_name;
  41. HashSet<String> child_classes;
  42. LocalVector<SnapshotDataObject *> instances;
  43. TreeItem *tree_node = nullptr;
  44. HashMap<GameStateSnapshot *, int> recursive_instance_count_cache;
  45. int instance_count(GameStateSnapshot *p_snapshot = nullptr);
  46. int get_recursive_instance_count(HashMap<String, ClassData> &p_all_classes, GameStateSnapshot *p_snapshot = nullptr);
  47. };
  48. class SnapshotClassView : public SnapshotView {
  49. GDCLASS(SnapshotClassView, SnapshotView);
  50. protected:
  51. Tree *class_tree = nullptr;
  52. Tree *object_list = nullptr;
  53. Tree *diff_object_list = nullptr;
  54. void _object_selected(Tree *p_tree);
  55. void _class_selected();
  56. void _add_objects_to_class_map(HashMap<String, ClassData> &p_class_map, GameStateSnapshot *p_objects);
  57. void _notification(int p_what);
  58. Tree *_make_object_list_tree(const String &p_column_name);
  59. void _populate_object_list(GameStateSnapshot *p_snapshot, Tree *p_list, const String &p_name_base);
  60. void _update_lists();
  61. public:
  62. SnapshotClassView();
  63. virtual void show_snapshot(GameStateSnapshot *p_data, GameStateSnapshot *p_diff_data) override;
  64. };