From 4dd89e2035d8358dee3a896a4aeaed6d207de950 Mon Sep 17 00:00:00 2001 From: Zenny Date: Sun, 1 Sep 2024 13:22:40 -0700 Subject: [PATCH] Barebones inventory menu addition --- src/game/Game.cs | 4 +++ src/game/Game.tscn | 7 +++- src/game/IGameRepo.cs | 10 ------ src/inventory_menu/InventoryMenu.tscn | 45 ++++++++++++++++++++++++++ src/inventory_menu/cursor.png | Bin 0 -> 474 bytes src/inventory_menu/cursor.png.import | 34 +++++++++++++++++++ 6 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 src/inventory_menu/InventoryMenu.tscn create mode 100644 src/inventory_menu/cursor.png create mode 100644 src/inventory_menu/cursor.png.import diff --git a/src/game/Game.cs b/src/game/Game.cs index a23417b6..afcadc0b 100644 --- a/src/game/Game.cs +++ b/src/game/Game.cs @@ -24,6 +24,8 @@ public partial class Game : Node3D, IGame [Dependency] public IAppRepo AppRepo => this.DependOn(); + [Node] public IInventoryMenu InventoryMenu { get; set; } = default!; + [Node] public Control MiniMap { get; set; } = default!; public void Setup() @@ -40,6 +42,8 @@ public partial class Game : Node3D, IGame GameBinding .Handle((in GameLogic.Output.StartGame _) => { GameRepo.Resume(); }) .Handle((in GameLogic.Output.SetPauseMode output) => { CallDeferred(nameof(SetPauseMode), output.IsPaused); }) + .Handle((in GameLogic.Output.SetInventoryMode _) => { InventoryMenu.PopulateItems(_.Inventory); InventoryMenu.Show(); }) + .Handle((in GameLogic.Output.HideInventory _) => { InventoryMenu.Hide(); InventoryMenu.ClearItems(); }) .Handle((in GameLogic.Output.ShowMiniMap _) => { MiniMap.Show(); }) .Handle((in GameLogic.Output.HideMiniMap _) => { MiniMap.Hide(); }) .Handle((in GameLogic.Output.GameOver _) => { AppRepo.OnGameOver(); }); diff --git a/src/game/Game.tscn b/src/game/Game.tscn index 24d0fdf7..f1d9946b 100644 --- a/src/game/Game.tscn +++ b/src/game/Game.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=10 format=3 uid="uid://33ek675mfb5n"] +[gd_scene load_steps=11 format=3 uid="uid://33ek675mfb5n"] [ext_resource type="Script" path="res://src/game/Game.cs" id="1_ytcii"] [ext_resource type="PackedScene" uid="uid://wg25dg65ksgg" path="res://src/map/dungeon/DungeonGenerator.tscn" id="2_cgboj"] [ext_resource type="PackedScene" uid="uid://cfecvvav8kkp6" path="res://src/player/Player.tscn" id="3_kk6ly"] [ext_resource type="PackedScene" uid="uid://dhpwwqow1ahrc" path="res://src/map/dungeon/rooms/Room1.tscn" id="4_56rmd"] [ext_resource type="PackedScene" uid="uid://bbwgmqy3evhh2" path="res://src/map/dungeon/rooms/Room2.tscn" id="4_clpvl"] +[ext_resource type="PackedScene" uid="uid://dlj8qdg1c5048" path="res://src/inventory_menu/InventoryMenu.tscn" id="4_wk8gw"] [ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="6_owlf4"] [sub_resource type="Environment" id="Environment_fke5g"] @@ -40,6 +41,10 @@ shape = SubResource("BoxShape3D_s2hwi") unique_name_in_owner = true visible = false +[node name="InventoryMenu" parent="." instance=ExtResource("4_wk8gw")] +unique_name_in_owner = true +visible = false + [node name="OmniLight3D" type="OmniLight3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 24.5244, 0) layers = 3 diff --git a/src/game/IGameRepo.cs b/src/game/IGameRepo.cs index 6785c40f..390f3f84 100644 --- a/src/game/IGameRepo.cs +++ b/src/game/IGameRepo.cs @@ -23,10 +23,6 @@ public interface IGameRepo : IDisposable void SetPlayerGlobalPosition(Vector3 playerGlobalPosition); - void SetNavigationRegion(NavigationRegion3D region); - - IAutoProp NavigationRegion3D { get; } - public Weapon EquippedWeapon { get; } } @@ -50,9 +46,6 @@ public class GameRepo : IGameRepo private Weapon _equippedWeapon; public Weapon EquippedWeapon => _equippedWeapon; - private AutoProp _navigationRegion3D; - public IAutoProp NavigationRegion3D => _navigationRegion3D; - private bool _disposedValue; public GameRepo() @@ -62,7 +55,6 @@ public class GameRepo : IGameRepo _isPaused = new AutoProp(false); _playerGlobalPosition = new AutoProp(Vector3.Zero); _equippedWeapon = new Weapon() { InventoryInfo = WeaponInfo.Default }; - _navigationRegion3D = new AutoProp(new NavigationRegion3D()); } public void Pause() @@ -79,8 +71,6 @@ public class GameRepo : IGameRepo public void SetPlayerGlobalPosition(Vector3 playerGlobalPosition) => _playerGlobalPosition.OnNext(playerGlobalPosition); - public void SetNavigationRegion(NavigationRegion3D region) => _navigationRegion3D.OnNext(region); - public void OnGameEnded() { Pause(); diff --git a/src/inventory_menu/InventoryMenu.tscn b/src/inventory_menu/InventoryMenu.tscn new file mode 100644 index 00000000..093cf69f --- /dev/null +++ b/src/inventory_menu/InventoryMenu.tscn @@ -0,0 +1,45 @@ +[gd_scene load_steps=3 format=3 uid="uid://dlj8qdg1c5048"] + +[ext_resource type="Texture2D" uid="uid://dr8mjn3wahdvp" path="res://src/inventory_menu/cursor.png" id="1_efrp8"] +[ext_resource type="Script" path="res://src/inventory_menu/InventoryMenu.cs" id="1_l64wl"] + +[node name="InventoryMenu" type="Control"] +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_l64wl") + +[node name="CenterContainer" type="CenterContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="ItemList" type="VBoxContainer" parent="CenterContainer"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Cursor" type="TextureRect" parent="."] +unique_name_in_owner = true +layout_mode = 0 +offset_left = -88.0 +offset_top = -47.0 +offset_right = -48.0 +offset_bottom = -7.0 +texture = ExtResource("1_efrp8") + +[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) diff --git a/src/inventory_menu/cursor.png b/src/inventory_menu/cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..53534b8a1e54bcea5ea2744133925087aeaf0eb0 GIT binary patch literal 474 zcmV<00VV#4P)Gf{ZbX8TEZ%{03G`D_b%qBGh$_ zvMd1rUDx69c#SWrO=mXx z!!RI(kex^RZ>>dHmQYH`@TAEaW8xN2U~Ib95;kOra}L&8iPu^~YrP2+m~$>`5wGz& z1JaLUs;XK|FqPahV@zzC2G&}sf(>~fxSDjY@B1Qs2)5cdyVOfTJUnUDzkRA^uvDkh zNjALq0KU&6v0ws9Ib)!x>n+JwDZf8NGaUz#oggh_Ue QTmS$707*qoM6N<$f^GxHnE(I) literal 0 HcmV?d00001 diff --git a/src/inventory_menu/cursor.png.import b/src/inventory_menu/cursor.png.import new file mode 100644 index 00000000..6c12185f --- /dev/null +++ b/src/inventory_menu/cursor.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dr8mjn3wahdvp" +path="res://.godot/imported/cursor.png-0fec02edb5cdc5cc9912cb19d5a7e260.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/inventory_menu/cursor.png" +dest_files=["res://.godot/imported/cursor.png-0fec02edb5cdc5cc9912cb19d5a7e260.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1