From b17c134c9aa7499e078639dc48954cc653e83244 Mon Sep 17 00:00:00 2001 From: Zenny Date: Fri, 13 Feb 2026 16:12:34 -0800 Subject: [PATCH] Add debug info folder that got filtered by git --- Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs | 40 +++++++++ .../src/debug_info/DebugInfo.cs.uid | 1 + .../src/debug_info/DebugInfo.tscn | 82 +++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs create mode 100644 Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs.uid create mode 100644 Zennysoft.Game.Ma/src/debug_info/DebugInfo.tscn diff --git a/Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs b/Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs new file mode 100644 index 000000000..c1c13b485 --- /dev/null +++ b/Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs @@ -0,0 +1,40 @@ +using Chickensoft.AutoInject; +using Chickensoft.Introspection; +using Godot; +using System.Linq; +using Zennysoft.Game.Ma; +using Zennysoft.Ma.Adapter; +using Zennysoft.Ma.Adapter.Entity; + +[Meta(typeof(IAutoNode)), Id("debug")] +public partial class DebugInfo : Control +{ + public override void _Notification(int what) => this.Notify(what); + + [Dependency] private IGame _game => this.DependOn(); + [Dependency] private IGameRepo _gameRepo => this.DependOn(); + [Dependency] private IMap _map => this.DependOn(); + [Dependency] private IPlayer _player => this.DependOn(); + + [Node] public Label MapName { get; set; } + [Node] public Label EnemyCount { get; set; } + [Node] public Label DeathCount { get; set; } + + public void OnResolved() + { + _map.FloorLoaded += _map_FloorLoaded; + _gameRepo.EnemyDied += _gameRepo_EnemyDied; + _player.PlayerDied += _player_PlayerDied; + DeathCount.Text = _game.QuestData.DeathCount.ToString(); + } + + private void _gameRepo_EnemyDied(IEnemy obj) => EnemyCount.Text = (EnemyCount.Text.ToInt() - 1).ToString(); + + private void _map_FloorLoaded() + { + MapName.Text = _map.CurrentFloor.SceneFilePath.GetFile().TrimSuffix(".tscn"); + EnemyCount.Text = _map.CurrentFloor.GetChild(0).GetChildren().OfType().Select(x => x.GetChildren().OfType()).Count().ToString(); + } + + private void _player_PlayerDied() => DeathCount.Text = _game.QuestData.DeathCount.ToString(); +} diff --git a/Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs.uid b/Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs.uid new file mode 100644 index 000000000..e5a1adcda --- /dev/null +++ b/Zennysoft.Game.Ma/src/debug_info/DebugInfo.cs.uid @@ -0,0 +1 @@ +uid://c4g3frcpt0h36 diff --git a/Zennysoft.Game.Ma/src/debug_info/DebugInfo.tscn b/Zennysoft.Game.Ma/src/debug_info/DebugInfo.tscn new file mode 100644 index 000000000..68c9238e1 --- /dev/null +++ b/Zennysoft.Game.Ma/src/debug_info/DebugInfo.tscn @@ -0,0 +1,82 @@ +[gd_scene load_steps=4 format=3 uid="uid://t22s2y1t8ktc"] + +[ext_resource type="Script" uid="uid://c4g3frcpt0h36" path="res://src/debug_info/DebugInfo.cs" id="1_6tk84"] +[ext_resource type="LabelSettings" uid="uid://b6f8ggy3ulonb" path="res://src/ui/label_settings/GeorgiaItalic.tres" id="1_i766g"] +[ext_resource type="Script" uid="uid://3fpuxsgdl8xe" path="res://src/utils/FpsCounter.cs" id="3_rco7p"] + +[node name="DebugInfo" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_6tk84") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 20 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 20 +theme_override_constants/margin_bottom = 20 + +[node name="VFlowContainer" type="VFlowContainer" parent="MarginContainer"] +layout_mode = 2 +alignment = 2 + +[node name="FPS" type="HBoxContainer" parent="MarginContainer/VFlowContainer"] +layout_mode = 2 + +[node name="FPSLabel" type="Label" parent="MarginContainer/VFlowContainer/FPS"] +layout_mode = 2 +text = "FPS:" +label_settings = ExtResource("1_i766g") + +[node name="FPSCounter" type="Label" parent="MarginContainer/VFlowContainer/FPS"] +layout_mode = 2 +label_settings = ExtResource("1_i766g") +script = ExtResource("3_rco7p") + +[node name="MapInfo" type="HBoxContainer" parent="MarginContainer/VFlowContainer"] +layout_mode = 2 + +[node name="Map Name Label" type="Label" parent="MarginContainer/VFlowContainer/MapInfo"] +layout_mode = 2 +text = "Map Name:" +label_settings = ExtResource("1_i766g") + +[node name="MapName" type="Label" parent="MarginContainer/VFlowContainer/MapInfo"] +unique_name_in_owner = true +layout_mode = 2 +label_settings = ExtResource("1_i766g") + +[node name="EnemyInfo" type="HBoxContainer" parent="MarginContainer/VFlowContainer"] +layout_mode = 2 + +[node name="Enemy Count Label" type="Label" parent="MarginContainer/VFlowContainer/EnemyInfo"] +layout_mode = 2 +text = "Number of enemies:" +label_settings = ExtResource("1_i766g") + +[node name="EnemyCount" type="Label" parent="MarginContainer/VFlowContainer/EnemyInfo"] +unique_name_in_owner = true +layout_mode = 2 +label_settings = ExtResource("1_i766g") + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VFlowContainer"] +layout_mode = 2 + +[node name="DeathCountLabel" type="Label" parent="MarginContainer/VFlowContainer/HBoxContainer"] +layout_mode = 2 +text = "Player Death Count:" +label_settings = ExtResource("1_i766g") + +[node name="DeathCount" type="Label" parent="MarginContainer/VFlowContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +label_settings = ExtResource("1_i766g")