Massive refactor (inventory menu still a little broken but its Good Enough)

This commit is contained in:
2024-09-12 02:24:14 -07:00
parent 149c8d9571
commit b4662a0c7b
94 changed files with 1066 additions and 825 deletions

View File

@@ -87,6 +87,7 @@ Panel/styles/panel = SubResource("StyleBoxFlat_uy0d5")
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dboi3"]
[node name="DialogueBalloon" type="CanvasLayer"]
process_mode = 3
layer = 100
script = ExtResource("1_okfmu")
NextAction = "ui_cancel"

View File

@@ -1,6 +1,6 @@
~ floor_exit
Proceed to the next floor?
- Yes
do Exit()
do SpawnNextFloor()
- No
=> END

View File

@@ -3,8 +3,6 @@ using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System;
using System.Linq;
[Meta(typeof(IAutoNode))]
public partial class FloorClearMenu : Control
@@ -27,10 +25,4 @@ public partial class FloorClearMenu : Control
{
EmitSignal(SignalName.TransitionCompleted);
}
private void AnimationPlayer_AnimationFinished(StringName animName)
{
var spawnPoints = GetTree().GetNodesInGroup("Exit").OfType<Marker3D>();
GameRepo.CurrentFloor++;
}
}

View File

@@ -2,19 +2,20 @@ 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 ShowInventoryScreen();
public void HideInventoryScreen();
public void ShowMiniMap();
public void HideMiniMap();
public void ShowInventoryFullMessage(string rejectedItemName);
}
[Meta(typeof(IAutoNode))]
@@ -26,6 +27,13 @@ public partial class InGameUI : Control, IInGameUI
[Node] public IInventoryMenu InventoryMenu { get; set; } = default!;
[Node] public IPlayerInfoUI PlayerInfoUI { get; set; } = default!;
public void ShowInventoryFullMessage(string rejectedItemName)
{
PlayerInfoUI.DisplayInventoryFullMessage(rejectedItemName);
}
public void HideInventoryScreen()
{
InventoryMenu.Hide();
@@ -36,9 +44,9 @@ public partial class InGameUI : Control, IInGameUI
MiniMap.Hide();
}
public async Task ShowInventoryScreen()
public void ShowInventoryScreen()
{
await InventoryMenu.RedrawInventory();
InventoryMenu.RedrawInventory();
InventoryMenu.Show();
}

View File

@@ -1,19 +1,27 @@
[gd_scene load_steps=4 format=3 uid="uid://b1muxus5qdbeu"]
[gd_scene load_steps=5 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"]
[ext_resource type="PackedScene" uid="uid://dxl8il8f13c2x" path="res://src/ui/player_ui/PlayerInfoUI.tscn" id="4_46s5l"]
[node name="InGameUI" type="Control"]
process_mode = 3
custom_minimum_size = Vector2(1920, 1080)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_sc13i")
[node name="PlayerInfoUI" parent="." instance=ExtResource("4_46s5l")]
unique_name_in_owner = true
layout_mode = 1
[node name="MiniMap" parent="." instance=ExtResource("2_6sfje")]
unique_name_in_owner = true
visible = false

View File

@@ -1,21 +1,5 @@
[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
@@ -27,11 +11,27 @@ tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.3),
"transitions": PackedFloat32Array(1, 1),
"transitions": PackedFloat32Array(1, 7.7),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
}
[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, 7.7),
"update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_f1eqn"]
length = 0.001
tracks/0/type = "value"

View File

@@ -0,0 +1,75 @@
using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using Godot;
namespace GameJamDungeon;
public interface IPlayerInfoUI : IControl
{
public void DisplayInventoryFullMessage(string rejectedItemName);
}
[Meta(typeof(IAutoNode))]
public partial class PlayerInfoUI : Control, IPlayerInfoUI
{
public override void _Notification(int what) => this.Notify(what);
private LabelSettings _labelSettings { get; set; }
#region Nodes
[Node] public VBoxContainer PlayerInfo { get; set; } = default!;
[Node] public Label LevelNumber { get; set; } = default!;
[Node] public Label HPNumber { get; set; } = default!;
[Node] public Label VTNumber { get; set; } = default!;
#endregion
[Dependency]
public IGameRepo GameRepo => this.DependOn<IGameRepo>();
public void OnResolved()
{
_labelSettings = GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextRegular.tres");
GameRepo.PlayerData.CurrentHP.Sync += CurrentHP_Sync;
GameRepo.PlayerData.MaximumHP.Sync += MaximumHP_Sync;
GameRepo.PlayerData.CurrentVT.Sync += CurrentVT_Sync;
GameRepo.PlayerData.MaximumVT.Sync += MaximumVT_Sync;
GameRepo.PlayerData.CurrentLevel.Sync += CurrentLevel_Sync;
}
private void CurrentLevel_Sync(int obj)
{
LevelNumber.Text = $"{obj}";
}
private void MaximumVT_Sync(int obj)
{
VTNumber.Text = $"{GameRepo.PlayerData.CurrentVT.Value}/{obj}";
}
private void CurrentVT_Sync(int obj)
{
VTNumber.Text = $"{obj}/{GameRepo.PlayerData.MaximumVT.Value}";
}
private void MaximumHP_Sync(int obj)
{
HPNumber.Text = $"{GameRepo.PlayerData.CurrentHP.Value}/{obj}";
}
private void CurrentHP_Sync(int obj)
{
HPNumber.Text = $"{obj}/{GameRepo.PlayerData.MaximumHP.Value}";
}
public void DisplayInventoryFullMessage(string rejectedItemName)
{
var newLabel = new Label() { Text = $"Could not pick up {rejectedItemName}.", LabelSettings = _labelSettings };
PlayerInfo.AddChild(newLabel);
}
}

View File

@@ -0,0 +1,98 @@
[gd_scene load_steps=5 format=3 uid="uid://dxl8il8f13c2x"]
[ext_resource type="Texture2D" uid="uid://hg2kraa5nrnl" path="res://src/ui/textures/blank level symbol.png" id="1_78qrq"]
[ext_resource type="Script" path="res://src/ui/player_ui/PlayerInfoUI.cs" id="1_d8yyu"]
[ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="2_aa7fx"]
[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="3_xdjh1"]
[node name="PlayerInfoUI" 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_d8yyu")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 9
anchor_bottom = 1.0
offset_right = 426.0
grow_vertical = 2
theme_override_constants/margin_left = 32
[node name="PlayerInfo" type="VBoxContainer" parent="MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PlayerInfo"]
layout_mode = 2
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/PlayerInfo/HBoxContainer"]
layout_mode = 2
[node name="TextureRect" type="TextureRect" parent="MarginContainer/PlayerInfo/HBoxContainer/CenterContainer"]
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
size_flags_vertical = 3
texture = ExtResource("1_78qrq")
expand_mode = 1
stretch_mode = 4
[node name="LevelNumber" type="Label" parent="MarginContainer/PlayerInfo/HBoxContainer/CenterContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(80, 80)
layout_mode = 2
text = "99"
label_settings = ExtResource("2_aa7fx")
horizontal_alignment = 1
vertical_alignment = 1
[node name="VBox" type="VBoxContainer" parent="MarginContainer/PlayerInfo/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/separation = 15
[node name="HBox" type="HBoxContainer" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox"]
layout_mode = 2
size_flags_horizontal = 3
[node name="HP" type="Label" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox/HBox"]
layout_mode = 2
text = "HP: "
label_settings = ExtResource("2_aa7fx")
[node name="ReferenceRect" type="ReferenceRect" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox/HBox"]
custom_minimum_size = Vector2(30, 0)
layout_mode = 2
border_width = 0.0
[node name="HPNumber" type="Label" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox/HBox"]
unique_name_in_owner = true
layout_mode = 2
text = "222/222"
label_settings = ExtResource("3_xdjh1")
[node name="HBox2" type="HBoxContainer" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox"]
layout_mode = 2
[node name="VT" type="Label" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox/HBox2"]
layout_mode = 2
text = "VT:"
label_settings = ExtResource("2_aa7fx")
[node name="ReferenceRect" type="ReferenceRect" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox/HBox2"]
custom_minimum_size = Vector2(30, 0)
layout_mode = 2
border_width = 0.0
[node name="VTNumber" type="Label" parent="MarginContainer/PlayerInfo/HBoxContainer/VBox/HBox2"]
unique_name_in_owner = true
layout_mode = 2
text = "444/444"
label_settings = ExtResource("3_xdjh1")
[node name="TextureButton" type="TextureButton" parent="MarginContainer"]
layout_mode = 2