Add debug menu, add ability to load next floor or spawn item
This commit is contained in:
@@ -24,6 +24,8 @@ public partial class InGameUI : Control, IInGameUI
|
||||
|
||||
[Node] public IUseTeleportPrompt UseTeleportPrompt { get; set; } = default!;
|
||||
|
||||
[Node] public IDebugMenu DebugMenu { get; set; } = default!;
|
||||
|
||||
[Dependency] private IGameRepo _gameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
public IInGameUILogic InGameUILogic { get; set; } = default!;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://b1muxus5qdbeu"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://b1muxus5qdbeu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dlq2mkhl4pe7a" 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"]
|
||||
@@ -6,6 +6,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://dxl8il8f13c2x" path="res://src/ui/player_ui/PlayerInfoUI.tscn" id="4_46s5l"]
|
||||
[ext_resource type="PackedScene" uid="uid://bea2waybmgd6u" path="res://src/ui/teleport_prompt/UseTeleportPrompt.tscn" id="5_h1hgq"]
|
||||
[ext_resource type="Script" uid="uid://dj6oqler47dqf" path="res://src/utils/FpsCounter.cs" id="7_c6o8j"]
|
||||
[ext_resource type="PackedScene" uid="uid://8f3dk16nj0dn" path="res://src/menu/DebugMenu.tscn" id="7_llomk"]
|
||||
|
||||
[node name="InGameUI" type="Control"]
|
||||
process_mode = 3
|
||||
@@ -48,3 +49,8 @@ anchor_bottom = 0.021
|
||||
offset_right = -0.320004
|
||||
offset_bottom = 0.319998
|
||||
script = ExtResource("7_c6o8j")
|
||||
|
||||
[node name="DebugMenu" parent="." instance=ExtResource("7_llomk")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
1
Zennysoft.Game.Ma/src/ui/pause_menu/DebugMenu.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/ui/pause_menu/DebugMenu.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://0jfd7fcxyuq1
|
||||
5
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs
Normal file
5
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IDebugMenu : IControl;
|
||||
1
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/ui/pause_menu/IDebugMenu.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dkibl33wtc58k
|
||||
58
Zennysoft.Game.Ma/src/ui/pause_menu/PauseDebugMenu.cs
Normal file
58
Zennysoft.Game.Ma/src/ui/pause_menu/PauseDebugMenu.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class PauseDebugMenu : Control, IDebugMenu
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] private IMap _map => this.DependOn<IMap>(() => new Map());
|
||||
|
||||
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
|
||||
|
||||
[Node] public Button LoadNextFloorButton { get; set; } = default!;
|
||||
|
||||
[Node] public OptionButton SpawnItemDropDown { get; set; } = default;
|
||||
|
||||
private ImmutableList<InventoryItem> SpawnableItems;
|
||||
|
||||
private ItemDatabase _itemDatabase;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
VisibilityChanged += PauseDebugMenu_VisibilityChanged;
|
||||
LoadNextFloorButton.Pressed += LoadNextFloorButton_Pressed;
|
||||
_itemDatabase = new ItemDatabase();
|
||||
SpawnableItems = _itemDatabase.Items;
|
||||
foreach (var item in SpawnableItems)
|
||||
SpawnItemDropDown.AddItem(item.ItemName, SpawnableItems.IndexOf(item));
|
||||
SpawnItemDropDown.ItemSelected += SpawnItemDropDown_ItemSelected;
|
||||
}
|
||||
|
||||
private void SpawnItemDropDown_ItemSelected(long index)
|
||||
{
|
||||
var itemToSpawn = SpawnableItems.ElementAt((int)index);
|
||||
var duplicated = itemToSpawn.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
duplicated.GlobalPosition = new Vector3(_player.CurrentPosition.X, _player.CurrentPosition.Y + 1, _player.CurrentPosition.Z) + (-_player.CurrentBasis.Z * 2);
|
||||
AddChild(duplicated);
|
||||
}
|
||||
|
||||
private void LoadNextFloorButton_Pressed()
|
||||
{
|
||||
_map.SpawnNextFloor();
|
||||
}
|
||||
|
||||
private void PauseDebugMenu_VisibilityChanged()
|
||||
{
|
||||
if (Visible)
|
||||
LoadNextFloorButton.GrabFocus();
|
||||
else
|
||||
ReleaseFocus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://l1v4ppubryd3
|
||||
@@ -1,8 +1,7 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://blbqgw3wosc1w"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ccrq3"]
|
||||
resource_name = "fade_out"
|
||||
length = 0.5
|
||||
[sub_resource type="Animation" id="Animation_f1eqn"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
@@ -10,10 +9,10 @@ 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),
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bium7"]
|
||||
@@ -32,8 +31,9 @@ tracks/0/keys = {
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_f1eqn"]
|
||||
length = 0.001
|
||||
[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
|
||||
@@ -41,17 +41,17 @@ tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 7.7),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_pmp7u"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_f1eqn"),
|
||||
"fade_in": SubResource("Animation_bium7"),
|
||||
"fade_out": SubResource("Animation_ccrq3")
|
||||
&"RESET": SubResource("Animation_f1eqn"),
|
||||
&"fade_in": SubResource("Animation_bium7"),
|
||||
&"fade_out": SubResource("Animation_ccrq3")
|
||||
}
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
@@ -66,7 +66,7 @@ grow_vertical = 2
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_pmp7u")
|
||||
&"": SubResource("AnimationLibrary_pmp7u")
|
||||
}
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
|
||||
Reference in New Issue
Block a user