Sync minimap floor data

This commit is contained in:
2025-08-09 19:15:32 -07:00
parent 953cba40c6
commit f8a27d7ba6
7 changed files with 109 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
using Chickensoft.AutoInject; using Chickensoft.AutoInject;
using Chickensoft.Collections;
using Chickensoft.GodotNodeInterfaces; using Chickensoft.GodotNodeInterfaces;
using Chickensoft.SaveFileBuilder; using Chickensoft.SaveFileBuilder;
using Godot; using Godot;
@@ -24,5 +25,5 @@ public interface IMap : INode3D, IProvide<ISaveChunk<MapData>>
void InitializeMapData(); void InitializeMapData();
public int CurrentFloorNumber { get; } public AutoProp<int> CurrentFloorNumber { get; }
} }

View File

@@ -1,5 +1,7 @@
using Chickensoft.AutoInject; using Chickensoft.AutoInject;
using Chickensoft.Collections;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Chickensoft.SaveFileBuilder; using Chickensoft.SaveFileBuilder;
using Godot; using Godot;
using System.Collections.Generic; using System.Collections.Generic;
@@ -35,7 +37,7 @@ public partial class Map : Node3D, IMap
public IDungeonFloor CurrentFloor { get; private set; } public IDungeonFloor CurrentFloor { get; private set; }
public int CurrentFloorNumber { get; private set; } = 0; public AutoProp<int> CurrentFloorNumber { get; private set; } = new AutoProp<int>(0);
public void OnResolved() public void OnResolved()
{ {
@@ -63,7 +65,7 @@ public partial class Map : Node3D, IMap
FloorScenes = []; FloorScenes = [];
foreach (var floor in _floors) foreach (var floor in _floors)
FloorScenes.Add(floor.ResourcePath); FloorScenes.Add(floor.ResourcePath);
CurrentFloorNumber = 0; CurrentFloorNumber.OnNext(0);
} }
public void LoadMap() public void LoadMap()
@@ -88,7 +90,7 @@ public partial class Map : Node3D, IMap
var transform = GetPlayerSpawnPosition(); var transform = GetPlayerSpawnPosition();
Player.TeleportPlayer(transform); Player.TeleportPlayer(transform);
CurrentFloor.FloorIsLoaded = true; CurrentFloor.FloorIsLoaded = true;
CurrentFloorNumber += 1; CurrentFloorNumber.OnNext(CurrentFloorNumber.Value + 1);
} }
public IDungeonRoom GetPlayersCurrentRoom() public IDungeonRoom GetPlayersCurrentRoom()

View File

@@ -0,0 +1,24 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
namespace Zennysoft.Game.Ma;
[Meta(typeof(IAutoNode))]
public partial class Minimap : Control
{
public override void _Notification(int what) => this.Notify(what);
[Dependency] public IMap _map => this.DependOn<IMap>();
[Node] public Label LayerNumberText { get; set; } = default!;
public void OnResolved()
{
_map.CurrentFloorNumber.Sync += CurrentFloorNumber_Sync;
}
private void CurrentFloorNumber_Sync(int obj)
{
LayerNumberText.Text = $"{obj:D2}";
}
}

View File

@@ -0,0 +1 @@
uid://cxi8msbee56t2

View File

@@ -1,8 +1,20 @@
[gd_scene load_steps=2 format=3 uid="uid://bwbofurcvf3yh"] [gd_scene load_steps=7 format=3 uid="uid://bwbofurcvf3yh"]
[ext_resource type="FontFile" uid="uid://cm8j5vcdop5x0" path="res://src/ui/fonts/Mrs-Eaves-OT-Roman_31443.ttf" id="1_tt5q2"]
[ext_resource type="Script" uid="uid://cxi8msbee56t2" path="res://src/minimap/Minimap.cs" id="1_yn75n"]
[ext_resource type="FontFile" uid="uid://dp1k143v7cppw" path="res://src/ui/fonts/Lust_Sans_Regular.otf" id="2_yn75n"]
[sub_resource type="Environment" id="Environment_3fkgx"] [sub_resource type="Environment" id="Environment_3fkgx"]
background_color = Color(1, 1, 1, 1) background_color = Color(1, 1, 1, 1)
[sub_resource type="Theme" id="Theme_75ec6"]
default_font = ExtResource("1_tt5q2")
default_font_size = 50
[sub_resource type="Theme" id="Theme_qgswn"]
default_font = ExtResource("1_tt5q2")
default_font_size = 50
[node name="Minimap" type="Control"] [node name="Minimap" type="Control"]
process_mode = 3 process_mode = 3
light_mask = 2 light_mask = 2
@@ -15,6 +27,7 @@ anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_yn75n")
[node name="CenterContainer" type="CenterContainer" parent="."] [node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1 layout_mode = 1
@@ -25,13 +38,13 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="SubViewportContainer" type="SubViewportContainer" parent="CenterContainer"] [node name="SubViewportContainer" type="SubViewportContainer" parent="CenterContainer"]
custom_minimum_size = Vector2(300, 300) custom_minimum_size = Vector2(350, 300)
layout_mode = 2 layout_mode = 2
[node name="SubViewport" type="SubViewport" parent="CenterContainer/SubViewportContainer"] [node name="SubViewport" type="SubViewport" parent="CenterContainer/SubViewportContainer"]
transparent_bg = true transparent_bg = true
handle_input_locally = false handle_input_locally = false
size = Vector2i(500, 500) size = Vector2i(350, 300)
render_target_update_mode = 4 render_target_update_mode = 4
[node name="Minimap Camera" type="Camera3D" parent="CenterContainer/SubViewportContainer/SubViewport"] [node name="Minimap Camera" type="Camera3D" parent="CenterContainer/SubViewportContainer/SubViewport"]
@@ -41,3 +54,53 @@ environment = SubResource("Environment_3fkgx")
fov = 45.0 fov = 45.0
size = 100.0 size = 100.0
near = 0.001 near = 0.001
[node name="MarginContainer" type="MarginContainer" parent="CenterContainer/SubViewportContainer/SubViewport"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 200
theme_override_constants/margin_top = 200
[node name="Control" type="Control" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer"]
layout_mode = 2
[node name="LayerText" type="Label" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer/Control"]
custom_minimum_size = Vector2(80, 15)
layout_mode = 2
offset_left = -10.0
offset_top = 29.0
offset_right = 140.0
offset_bottom = 70.0
size_flags_vertical = 6
theme = SubResource("Theme_75ec6")
theme_override_colors/font_color = Color(0.792157, 0.698039, 0.643137, 1)
theme_override_colors/font_shadow_color = Color(0.792157, 0.698039, 0.643137, 0.0392157)
theme_override_constants/shadow_offset_x = 1
theme_override_constants/shadow_offset_y = -2
theme_override_constants/shadow_outline_size = 15
theme_override_font_sizes/font_size = 40
text = "Layer"
vertical_alignment = 2
[node name="LayerNumberText" type="Label" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer/Control"]
unique_name_in_owner = true
custom_minimum_size = Vector2(80, 15)
layout_mode = 2
offset_left = 69.0
offset_top = 13.0
offset_right = 149.0
offset_bottom = 65.0
theme = SubResource("Theme_qgswn")
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_shadow_color = Color(1, 1, 1, 0.027451)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 2
theme_override_constants/shadow_offset_y = -2
theme_override_constants/outline_size = 2
theme_override_fonts/font = ExtResource("2_yn75n")
theme_override_font_sizes/font_size = 40
text = "01"
horizontal_alignment = 1

View File

@@ -16,8 +16,6 @@ public partial class InGameUI : Control, IInGameUI
{ {
public override void _Notification(int what) => this.Notify(what); public override void _Notification(int what) => this.Notify(what);
[Node] public Control MiniMap { get; set; } = default!;
[Node] public IInventoryMenu InventoryMenu { get; set; } = default!; [Node] public IInventoryMenu InventoryMenu { get; set; } = default!;
[Node] public IPlayerInfoUI PlayerInfoUI { get; set; } = default!; [Node] public IPlayerInfoUI PlayerInfoUI { get; set; } = default!;

View File

@@ -104,8 +104,18 @@ unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
[node name="MiniMap" parent="HBoxContainer/Panel/MarginContainer/VBoxContainer" instance=ExtResource("2_6sfje")] [node name="MinimapZone" type="CenterContainer" parent="HBoxContainer/Panel/MarginContainer/VBoxContainer"]
custom_minimum_size = Vector2(350, 300)
layout_mode = 2
[node name="ColorRect" type="ColorRect" parent="HBoxContainer/Panel/MarginContainer/VBoxContainer/MinimapZone"]
custom_minimum_size = Vector2(350, 300)
layout_mode = 2
color = Color(0.027451, 0.0901961, 0.0745098, 1)
[node name="MiniMap" parent="HBoxContainer/Panel/MarginContainer/VBoxContainer/MinimapZone" instance=ExtResource("2_6sfje")]
unique_name_in_owner = true unique_name_in_owner = true
custom_minimum_size = Vector2(350, 300)
layout_mode = 2 layout_mode = 2
[node name="Sigil Marker" type="ReferenceRect" parent="HBoxContainer/Panel/MarginContainer/VBoxContainer"] [node name="Sigil Marker" type="ReferenceRect" parent="HBoxContainer/Panel/MarginContainer/VBoxContainer"]