Big refactor in place: Organize nodes in line with dependency injection expectations, use state machine flow more
This commit is contained in:
22
src/ui/death_menu/DeathMenu.cs
Normal file
22
src/ui/death_menu/DeathMenu.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
public interface IDeathMenu : IControl
|
||||
{
|
||||
void FadeIn();
|
||||
void FadeOut();
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class DeathMenu : Control, IDeathMenu
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
public void FadeIn() => AnimationPlayer.Play("fade_in");
|
||||
|
||||
public void FadeOut() => AnimationPlayer.Play("fade_out");
|
||||
}
|
||||
82
src/ui/death_menu/DeathMenu.tscn
Normal file
82
src/ui/death_menu/DeathMenu.tscn
Normal file
@@ -0,0 +1,82 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dbtfgrtgpr4qg"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/death_menu/DeathMenu.cs" id="1_megey"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6ji3u"]
|
||||
resource_name = "fade_out"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_q2nvr"]
|
||||
resource_name = "fade_in"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_qmlrq"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ek7oy"]
|
||||
_data = {
|
||||
&"fade_out": SubResource("Animation_6ji3u"),
|
||||
&"fade_in": SubResource("Animation_q2nvr"),
|
||||
&"RESET": SubResource("Animation_qmlrq")
|
||||
}
|
||||
|
||||
[node name="DeathMenu" type="Control"]
|
||||
process_mode = 3
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_megey")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.137255, 0.121569, 0.12549, 1)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_ek7oy")
|
||||
}
|
||||
36
src/ui/floor_clear/FloorClearMenu.cs
Normal file
36
src/ui/floor_clear/FloorClearMenu.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class FloorClearMenu : Control
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency]
|
||||
public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
public void FadeIn() => AnimationPlayer.Play("fade_in");
|
||||
|
||||
public void FadeOut() => AnimationPlayer.Play("fade_out");
|
||||
|
||||
[Signal]
|
||||
public delegate void TransitionCompletedEventHandler();
|
||||
|
||||
private void AnimationPlayer_AnimationStarted(StringName animName)
|
||||
{
|
||||
EmitSignal(SignalName.TransitionCompleted);
|
||||
}
|
||||
|
||||
private void AnimationPlayer_AnimationFinished(StringName animName)
|
||||
{
|
||||
var spawnPoints = GetTree().GetNodesInGroup("Exit").OfType<Marker3D>();
|
||||
GameRepo.CurrentFloor++;
|
||||
}
|
||||
}
|
||||
97
src/ui/floor_clear/FloorClearMenu.tscn
Normal file
97
src/ui/floor_clear/FloorClearMenu.tscn
Normal file
@@ -0,0 +1,97 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://pu6gp8de3ck4"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/floor_clear/FloorClearMenu.cs" id="1_q65kq"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_nc1gg"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("FloorClearMenu/LoadScreen:color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("FloorClearMenu:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_p616x"]
|
||||
resource_name = "fade_in"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("FloorClearMenu:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_dhyvw"]
|
||||
resource_name = "fade_out"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("FloorClearMenu:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_opfbx"]
|
||||
_data = {
|
||||
&"fade_out": SubResource("Animation_dhyvw"),
|
||||
&"fade_in": SubResource("Animation_p616x"),
|
||||
&"RESET": SubResource("Animation_nc1gg")
|
||||
}
|
||||
|
||||
[node name="FloorClearMenu" type="Control"]
|
||||
process_mode = 3
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_q65kq")
|
||||
|
||||
[node name="LoadScreen" type="ColorRect" parent="."]
|
||||
process_mode = 3
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.137255, 0.121569, 0.12549, 1)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
root_node = NodePath("../..")
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_opfbx")
|
||||
}
|
||||
49
src/ui/in_game_ui/InGameUI.cs
Normal file
49
src/ui/in_game_ui/InGameUI.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameJamDungeon;
|
||||
|
||||
public interface IInGameUI : IControl
|
||||
{
|
||||
public Task ShowInventoryScreen();
|
||||
|
||||
public void HideInventoryScreen();
|
||||
|
||||
public void ShowMiniMap();
|
||||
|
||||
public void HideMiniMap();
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class InGameUI : Control, IInGameUI
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public Control MiniMap { get; set; } = default!;
|
||||
|
||||
[Node] public IInventoryMenu InventoryMenu { get; set; } = default!;
|
||||
|
||||
public void HideInventoryScreen()
|
||||
{
|
||||
InventoryMenu.Hide();
|
||||
}
|
||||
|
||||
public void HideMiniMap()
|
||||
{
|
||||
MiniMap.Hide();
|
||||
}
|
||||
|
||||
public async Task ShowInventoryScreen()
|
||||
{
|
||||
await InventoryMenu.RedrawInventory();
|
||||
InventoryMenu.Show();
|
||||
}
|
||||
|
||||
public void ShowMiniMap()
|
||||
{
|
||||
MiniMap.Hide();
|
||||
}
|
||||
}
|
||||
26
src/ui/in_game_ui/InGameUI.tscn
Normal file
26
src/ui/in_game_ui/InGameUI.tscn
Normal file
@@ -0,0 +1,26 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://b1muxus5qdbeu"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/in_game_ui/InGameUI.cs" id="1_sc13i"]
|
||||
[ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="2_6sfje"]
|
||||
[ext_resource type="PackedScene" uid="uid://dlj8qdg1c5048" path="res://src/inventory_menu/InventoryMenu.tscn" id="3_4vcdl"]
|
||||
|
||||
[node name="InGameUI" type="Control"]
|
||||
process_mode = 3
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_sc13i")
|
||||
|
||||
[node name="MiniMap" parent="." instance=ExtResource("2_6sfje")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="InventoryMenu" parent="." instance=ExtResource("3_4vcdl")]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
23
src/ui/pause_menu/PauseMenu.cs
Normal file
23
src/ui/pause_menu/PauseMenu.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public interface IPauseMenu : IControl
|
||||
{
|
||||
void FadeIn();
|
||||
void FadeOut();
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class PauseMenu : Control, IPauseMenu
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
public void FadeIn() => AnimationPlayer.Play("fade_in");
|
||||
|
||||
public void FadeOut() => AnimationPlayer.Play("fade_out");
|
||||
}
|
||||
79
src/ui/pause_menu/PauseMenu.tscn
Normal file
79
src/ui/pause_menu/PauseMenu.tscn
Normal file
@@ -0,0 +1,79 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://blbqgw3wosc1w"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bium7"]
|
||||
resource_name = "fade_in"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ccrq3"]
|
||||
resource_name = "fade_out"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_f1eqn"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_pmp7u"]
|
||||
_data = {
|
||||
&"fade_out": SubResource("Animation_ccrq3"),
|
||||
&"fade_in": SubResource("Animation_bium7"),
|
||||
&"RESET": SubResource("Animation_f1eqn")
|
||||
}
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
process_mode = 3
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_pmp7u")
|
||||
}
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 1)
|
||||
Reference in New Issue
Block a user