diff --git a/Zennysoft.Game.Ma.Implementation/Components/IExperiencePointsComponent.cs b/Zennysoft.Game.Ma.Implementation/Components/IExperiencePointsComponent.cs index 09d9a2153..16ccdf399 100644 --- a/Zennysoft.Game.Ma.Implementation/Components/IExperiencePointsComponent.cs +++ b/Zennysoft.Game.Ma.Implementation/Components/IExperiencePointsComponent.cs @@ -16,6 +16,8 @@ public interface IExperiencePointsComponent : IEntityComponent public void Gain(int baseExpGain); + public void GainUnmodified(int flateRateExpGain); + public void LevelUp(); public event Action PlayerLevelUp; diff --git a/Zennysoft.Game.Ma/src/Components/ExperiencePointsComponent.cs b/Zennysoft.Game.Ma/src/Components/ExperiencePointsComponent.cs index 1fee4d89b..17952b3a5 100644 --- a/Zennysoft.Game.Ma/src/Components/ExperiencePointsComponent.cs +++ b/Zennysoft.Game.Ma/src/Components/ExperiencePointsComponent.cs @@ -51,6 +51,16 @@ public class ExperiencePointsComponent : IExperiencePointsComponent var cappedAmount = Math.Min(baseExpGain + _currentExp.Value, _expToNextLevel.Value); _currentExp.OnNext(cappedAmount); } + + public void GainUnmodified(int flatRateExp) + { + var newCurrentExpTotal = flatRateExp + _currentExp.Value; + while (flatRateExp + _currentExp.Value >= _expToNextLevel.Value) + LevelUp(); + var cappedAmount = Math.Min(flatRateExp + _currentExp.Value, _expToNextLevel.Value); + _currentExp.OnNext(cappedAmount); + } + public void ModifyExpGainRate(double newRate) => _expGainRate.OnNext(newRate); public void LevelUp() diff --git a/Zennysoft.Game.Ma/src/app/App.cs b/Zennysoft.Game.Ma/src/app/App.cs index 75afe463e..b9910e44f 100644 --- a/Zennysoft.Game.Ma/src/app/App.cs +++ b/Zennysoft.Game.Ma/src/app/App.cs @@ -146,7 +146,7 @@ public partial class App : Node, IApp }) .Handle((in AppLogic.Output.SetupGameScene _) => { - LoadingScreen.Show(); + LoadingScreen.ShowLoadingScreen(); LoadGame(GAME_SCENE_PATH); }) .Handle((in AppLogic.Output.ShowMainMenu _) => @@ -155,7 +155,7 @@ public partial class App : Node, IApp }) .Handle((in AppLogic.Output.CloseGame _) => { - LoadingScreen.Hide(); + LoadingScreen.HideLoadingScreen(); _game.GameExitRequested -= GameExitRequested; MainMenu.StartGameButton.GrabFocus(); _game.CallDeferred(MethodName.QueueFree, []); @@ -166,13 +166,13 @@ public partial class App : Node, IApp }) .Handle((in AppLogic.Output.EnemyViewerOpened _) => { - LoadingScreen.Show(); + LoadingScreen.ShowLoadingScreen(); MainMenu.Hide(); LoadEnemyViewer(ENEMY_VIEWER_PATH); }) .Handle((in AppLogic.Output.EnemyViewerExited _) => { - LoadingScreen.Hide(); + LoadingScreen.HideLoadingScreen(); if (_enemyViewer != null && _enemyViewer is DataViewer enemyViewer) enemyViewer.CallDeferred(MethodName.QueueFree); MainMenu.Show(); @@ -203,24 +203,22 @@ public partial class App : Node, IApp _game = scene as IGame; _game.GameLoaded += OnGameLoaded; _game.GameExitRequested += GameExitRequested; - await ToSignal(GetTree().CreateTimer(0.8f), "timeout"); CallDeferred(MethodName.AddChild, scene); } - private void OnGameLoaded() => LoadingScreen.Hide(); + private void OnGameLoaded() => LoadingScreen.HideLoadingScreen(); private async void LoadEnemyViewer(string sceneName) { var scene = await LoadSceneInternal(sceneName); _enemyViewer = scene as IDataViewer; - await ToSignal(GetTree().CreateTimer(0.8f), "timeout"); CallDeferred(MethodName.AddChild, scene); - LoadingScreen.Hide(); + LoadingScreen.HideLoadingScreen(); } private async Task LoadSceneInternal(string sceneName) { - LoadingScreen.Show(); + LoadingScreen.ShowLoadingScreen(); LoadingScreen.ProgressBar.Value = 0; var sceneLoader = new SceneLoader(); CallDeferred(MethodName.AddChild, sceneLoader); diff --git a/Zennysoft.Game.Ma/src/app/App.tscn b/Zennysoft.Game.Ma/src/app/App.tscn index d051ef24d..1a5f43e92 100644 --- a/Zennysoft.Game.Ma/src/app/App.tscn +++ b/Zennysoft.Game.Ma/src/app/App.tscn @@ -10,9 +10,16 @@ process_mode = 3 script = ExtResource("1_rt73h") +[node name="ColorRect" type="ColorRect" parent="."] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 1) + [node name="MainMenu" parent="." instance=ExtResource("2_1uiag")] unique_name_in_owner = true -visible = false [node name="OptionsMenu" parent="." instance=ExtResource("2_v0mgf")] unique_name_in_owner = true @@ -24,5 +31,6 @@ visible = false [node name="LoadingScreen" parent="." instance=ExtResource("3_3st5l")] unique_name_in_owner = true +visible = false top_level = true z_index = 999 diff --git a/Zennysoft.Game.Ma/src/audio/SFXDatabase.tscn b/Zennysoft.Game.Ma/src/audio/SFXDatabase.tscn index ca600f796..019d4bf14 100644 --- a/Zennysoft.Game.Ma/src/audio/SFXDatabase.tscn +++ b/Zennysoft.Game.Ma/src/audio/SFXDatabase.tscn @@ -39,6 +39,7 @@ bus = &"SFX" [node name="MoveSound" type="AudioStreamPlayer" parent="UI"] unique_name_in_owner = true stream = ExtResource("6_r16t0") +max_polyphony = 5 bus = &"SFX" [node name="SelectSound" type="AudioStreamPlayer" parent="UI"] diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn index 2992adf39..f74fd409a 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn @@ -109,7 +109,6 @@ _acquireTargetTime = 2.0 unique_name_in_owner = true avoidance_enabled = true radius = 1.0 -debug_enabled = true [node name="SFX" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.0617, 0) diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 39dc55a28..71962a804 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -157,9 +157,7 @@ public partial class Game : Node3D, IGame GameState.Set(_player); GameState.Set(_map); GameState.Set(InGameUI); - GameRepo.Resume(); - InGameUI.Show(); HandleGameLogic(); GameState.Start(); this.Provide(); @@ -188,6 +186,8 @@ public partial class Game : Node3D, IGame GameRepo.IsPaused.Sync += IsPaused_Sync; InGameUI.PlayerInfoUI.Activate(); + InGameUI.Show(); + GameRepo.Resume(); } private void GameRepo_EnemyDied(IEnemy obj) @@ -209,7 +209,6 @@ public partial class Game : Node3D, IGame _effectService = new EffectService(this, _player, _map); _player.Activate(); await _map.LoadFloor(); - GameLoaded?.Invoke(); } public async Task Save() => await SaveFile.Save(); @@ -233,9 +232,6 @@ public partial class Game : Node3D, IGame EnactEffectItemEffects(effectItem); break; } - - await ToSignal(GetTree().CreateTimer(0.3f), "timeout"); - RemoveItemOrSubtractFromItemCount(item); } @@ -398,7 +394,10 @@ public partial class Game : Node3D, IGame InGameUI.InventoryMenu.SetProcessInput(false); } - private async void LoadLevel() => await _map.LoadFloor(); + private async void LoadLevel() + { + await _map.LoadFloor(); + } private void FloorClearMenu_GoToNextFloor() => GameState.Input(new GameState.Input.LoadNextFloor()); @@ -419,7 +418,6 @@ public partial class Game : Node3D, IGame private void UseTeleportPrompt_TeleportToNextFloor() { - //_player.LookUp(); GameState.Input(new GameState.Input.UseTeleport()); } @@ -588,6 +586,8 @@ public partial class Game : Node3D, IGame private void OnFloorLoadFinished() { LoadNextLevel.Hide(); + GameLoaded?.Invoke(); + _map.FadeIn(); } private void OnQuit() => GameExitRequested?.Invoke(); diff --git a/Zennysoft.Game.Ma/src/game/Game.tscn b/Zennysoft.Game.Ma/src/game/Game.tscn index cee46c7fb..dd945fa7d 100644 --- a/Zennysoft.Game.Ma/src/game/Game.tscn +++ b/Zennysoft.Game.Ma/src/game/Game.tscn @@ -11,11 +11,11 @@ process_mode = 3 script = ExtResource("1_ytcii") [node name="SubViewportContainer" type="SubViewportContainer" parent="."] -custom_minimum_size = Vector2(1440, 1080) +custom_minimum_size = Vector2(1456, 1080) anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -480.0 +offset_right = -464.0 grow_horizontal = 2 grow_vertical = 2 stretch = true @@ -23,7 +23,7 @@ stretch = true [node name="SubViewport" type="SubViewport" parent="SubViewportContainer"] handle_input_locally = false audio_listener_enable_3d = true -size = Vector2i(1440, 1080) +size = Vector2i(1456, 1080) render_target_update_mode = 4 [node name="PauseContainer" type="Node3D" parent="SubViewportContainer/SubViewport"] diff --git a/Zennysoft.Game.Ma/src/items/EffectService.cs b/Zennysoft.Game.Ma/src/items/EffectService.cs index 97f790cec..7b5aa19b4 100644 --- a/Zennysoft.Game.Ma/src/items/EffectService.cs +++ b/Zennysoft.Game.Ma/src/items/EffectService.cs @@ -172,7 +172,11 @@ public class EffectService SfxDatabase.Instance.Play(SoundEffect.IncreaseStat); } - public void RaiseLevel() => _player.LevelUp(); + public void RaiseLevel() + { + var expToNextLevel = _player.ExperiencePointsComponent.ExpToNextLevel.Value - _player.ExperiencePointsComponent.CurrentExp.Value; + _player.ExperiencePointsComponent.GainUnmodified(expToNextLevel); + } public void TeleportToRandomRoom(IEnemy enemy) { diff --git a/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import b/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import index 947fcd210..0c842ad38 100644 --- a/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import +++ b/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import @@ -3,7 +3,7 @@ importer="texture" type="CompressedTexture2D" uid="uid://c63uufq63qpuy" -path.bptc="res://.godot/imported/RONDO.PNG-77b50e9afaf9eb46f5672e079a5f50bf.bptc.ctex" +path.bptc="res://.godot/imported/Rondo.png-57553b850a093da6dba43a1e1947fcce.bptc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], "vram_texture": true @@ -11,8 +11,8 @@ metadata={ [deps] -source_file="res://src/items/weapons/textures/RONDO.PNG" -dest_files=["res://.godot/imported/RONDO.PNG-77b50e9afaf9eb46f5672e079a5f50bf.bptc.ctex"] +source_file="res://src/items/weapons/textures/Rondo.png" +dest_files=["res://.godot/imported/Rondo.png-57553b850a093da6dba43a1e1947fcce.bptc.ctex"] [params] diff --git a/Zennysoft.Game.Ma/src/map/IMap.cs b/Zennysoft.Game.Ma/src/map/IMap.cs index 5fa9272a9..48dd01271 100644 --- a/Zennysoft.Game.Ma/src/map/IMap.cs +++ b/Zennysoft.Game.Ma/src/map/IMap.cs @@ -20,6 +20,10 @@ public interface IMap : INode3D void InitializeMapData(); + public void FadeIn(); + + public void FadeOut(); + public AutoProp CurrentFloorNumber { get; } public event Action<(Vector3 Rotation, Vector3 Position)> SpawnPointCreated; diff --git a/Zennysoft.Game.Ma/src/map/Map.cs b/Zennysoft.Game.Ma/src/map/Map.cs index 945fab4bf..5b6e92fd4 100644 --- a/Zennysoft.Game.Ma/src/map/Map.cs +++ b/Zennysoft.Game.Ma/src/map/Map.cs @@ -59,9 +59,11 @@ public partial class Map : Node3D, IMap var floor = MapOrder.GetChildren().OfType().ElementAt(CurrentFloorNumber.Value); if (CurrentFloor is DungeonFloor dungeonFloor && floor is DungeonFloorNode dungeonFloorNode) dungeonFloor.SpawnEnemies(dungeonFloorNode); - AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, ("fade_in")); } + public void FadeIn() => AnimationPlayer.Play("fade_in"); + public void FadeOut() => AnimationPlayer.Play("fade_out"); + public void InitializeMapData() { CurrentFloorNumber.OnNext(-1); @@ -89,7 +91,7 @@ public partial class Map : Node3D, IMap public async Task LoadFloor(string sceneName) { - AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out"); + CallDeferred(MethodName.FadeOut); _sceneName = sceneName; var dimmableAudio = GetTree().GetNodesInGroup("DimmableAudio").OfType(); foreach (var node in dimmableAudio) diff --git a/Zennysoft.Game.Ma/src/map/Map.tscn b/Zennysoft.Game.Ma/src/map/Map.tscn index d2b1bfdbd..4aa509385 100644 --- a/Zennysoft.Game.Ma/src/map/Map.tscn +++ b/Zennysoft.Game.Ma/src/map/Map.tscn @@ -19,7 +19,22 @@ tracks/0/keys = { "values": [Color(0, 0, 0, 1)] } -[sub_resource type="Animation" id="Animation_g6eui"] +[sub_resource type="Animation" id="Animation_v14r0"] +resource_name = "fade_out" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] +} + +[sub_resource type="Animation" id="Animation_0qcd2"] resource_name = "fade_in" tracks/0/type = "value" tracks/0/imported = false @@ -34,39 +49,16 @@ tracks/0/keys = { "values": [Color(0, 0, 0, 1), Color(0, 0, 0, 0)] } -[sub_resource type="Animation" id="Animation_v14r0"] -resource_name = "fade_out" -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("ColorRect:color") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(-0.0666667, 0), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Color(0, 0, 0, 1), Color(0, 0, 0, 1)] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_00xd7"] _data = { &"RESET": SubResource("Animation_00xd7"), -&"fade_in": SubResource("Animation_g6eui"), +&"fade_in": SubResource("Animation_0qcd2"), &"fade_out": SubResource("Animation_v14r0") } [node name="Map" type="Node3D"] script = ExtResource("1_bw70o") -[node name="ColorRect" type="ColorRect" parent="."] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -color = Color(0, 0, 0, 1) - [node name="AnimationPlayer" type="AnimationPlayer" parent="."] unique_name_in_owner = true libraries = { @@ -219,3 +211,11 @@ FloorName = 4 [node name="Final Floor" type="Node" parent="MapOrder"] script = ExtResource("3_v14r0") FloorName = 6 + +[node name="ColorRect" type="ColorRect" parent="."] +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/Zennysoft.Game.Ma/src/menu/LoadingScreen.cs b/Zennysoft.Game.Ma/src/menu/LoadingScreen.cs index ca1547d03..fbadef58d 100644 --- a/Zennysoft.Game.Ma/src/menu/LoadingScreen.cs +++ b/Zennysoft.Game.Ma/src/menu/LoadingScreen.cs @@ -7,6 +7,28 @@ public partial class LoadingScreen : Control { public override void _Notification(int what) => this.Notify(what); - [Node] - public ProgressBar ProgressBar { get; set; } = default!; + [Node] public ProgressBar ProgressBar { get; set; } = default!; + + [Node] public AnimationPlayer AnimationPlayer { get; set; } = default!; + + public void OnResolved() + { + AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished; + } + + private void AnimationPlayer_AnimationFinished(StringName animName) + { + if (animName == "fade_out") + Hide(); + } + + public void ShowLoadingScreen() + { + Show(); + } + + public void HideLoadingScreen() + { + AnimationPlayer.Play("fade_out"); + } } diff --git a/Zennysoft.Game.Ma/src/menu/LoadingScreen.tscn b/Zennysoft.Game.Ma/src/menu/LoadingScreen.tscn index 2b17c42e2..b60baf621 100644 --- a/Zennysoft.Game.Ma/src/menu/LoadingScreen.tscn +++ b/Zennysoft.Game.Ma/src/menu/LoadingScreen.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://cpjlj7kxdhv16"] +[gd_scene load_steps=9 format=3 uid="uid://cpjlj7kxdhv16"] [ext_resource type="Script" uid="uid://b07ueredevhr3" path="res://src/menu/LoadingScreen.cs" id="1_5uxhf"] [ext_resource type="Texture2D" uid="uid://d2krh4u2v06k5" path="res://src/ui/rendered_assets/SCREEN_RENDERS_Loading_720_16_9.png" id="2_xfkmi"] @@ -8,8 +8,61 @@ [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xfkmi"] bg_color = Color(0.804743, 0.804743, 0.804743, 1) +[sub_resource type="Animation" id="Animation_xfkmi"] +resource_name = "fade_in" +length = 0.500003 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:color") +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(0, 0, 0, 1), Color(0, 0, 0, 0)] +} + +[sub_resource type="Animation" id="Animation_6i7rn"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(0, 0, 0, 0)] +} + +[sub_resource type="Animation" id="Animation_jrbvh"] +resource_name = "fade_out" +length = 1.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("ColorRect:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_jrbvh"] +_data = { +&"RESET": SubResource("Animation_6i7rn"), +&"fade_in": SubResource("Animation_xfkmi"), +&"fade_out": SubResource("Animation_jrbvh") +} + [node name="LoadingScreen" type="Control"] -visible = false layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -48,3 +101,18 @@ offset_bottom = 981.0 theme_override_styles/background = SubResource("StyleBoxTexture_xfkmi") theme_override_styles/fill = SubResource("StyleBoxFlat_xfkmi") show_percentage = false + +[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, 0) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +unique_name_in_owner = true +libraries = { +&"": SubResource("AnimationLibrary_jrbvh") +} diff --git a/Zennysoft.Game.Ma/src/menu/MainMenu.tscn b/Zennysoft.Game.Ma/src/menu/MainMenu.tscn index aba6810fe..1af5c8460 100644 --- a/Zennysoft.Game.Ma/src/menu/MainMenu.tscn +++ b/Zennysoft.Game.Ma/src/menu/MainMenu.tscn @@ -1,7 +1,10 @@ -[gd_scene load_steps=3 format=3 uid="uid://rfvnddfqufho"] +[gd_scene load_steps=6 format=3 uid="uid://rfvnddfqufho"] [ext_resource type="Script" uid="uid://14b7o2c6cgry" path="res://src/menu/MainMenu.cs" id="1_y6722"] +[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="2_2ijnm"] [ext_resource type="Shortcut" uid="uid://dumkrjur22k2a" path="res://src/ui/ButtonShortcut.tres" id="2_7fwjx"] +[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="2_dftre"] +[ext_resource type="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="3_dftre"] [node name="MainMenu" type="Control"] layout_mode = 3 @@ -19,45 +22,78 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -color = Color(0.137255, 0.121569, 0.12549, 1) +color = Color(0.0962047, 0.0962048, 0.0962047, 1) [node name="MarginContainer" type="MarginContainer" parent="."] layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 anchor_bottom = 1.0 +offset_left = -59.0 +offset_top = -171.0 +offset_right = 59.0 grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/margin_left = 100 -theme_override_constants/margin_top = 100 -theme_override_constants/margin_right = 100 -theme_override_constants/margin_bottom = 100 +grow_vertical = 0 +theme_override_constants/margin_bottom = 200 -[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +[node name="CenterContainer" type="CenterContainer" parent="MarginContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/CenterContainer"] layout_mode = 2 size_flags_horizontal = 0 size_flags_vertical = 0 -[node name="StartGameButton" type="Button" parent="MarginContainer/VBoxContainer"] +[node name="StartGameButton" type="Button" parent="MarginContainer/CenterContainer/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 focus_neighbor_bottom = NodePath("../EnemyViewerButton") focus_next = NodePath("../EnemyViewerButton") theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1) +theme_override_fonts/font = ExtResource("2_dftre") +theme_override_font_sizes/font_size = 25 +theme_override_styles/focus = ExtResource("2_2ijnm") +theme_override_styles/disabled_mirrored = ExtResource("3_dftre") +theme_override_styles/disabled = ExtResource("3_dftre") +theme_override_styles/hover_pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/hover_pressed = ExtResource("3_dftre") +theme_override_styles/hover_mirrored = ExtResource("3_dftre") +theme_override_styles/hover = ExtResource("3_dftre") +theme_override_styles/pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/pressed = ExtResource("3_dftre") +theme_override_styles/normal_mirrored = ExtResource("3_dftre") +theme_override_styles/normal = ExtResource("3_dftre") shortcut = ExtResource("2_7fwjx") text = "Start Game" +alignment = 0 -[node name="EnemyViewerButton" type="Button" parent="MarginContainer/VBoxContainer"] +[node name="EnemyViewerButton" type="Button" parent="MarginContainer/CenterContainer/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 focus_neighbor_bottom = NodePath("../GalleryButton") focus_next = NodePath("../GalleryButton") focus_previous = NodePath("../StartGameButton") theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1) +theme_override_fonts/font = ExtResource("2_dftre") +theme_override_font_sizes/font_size = 25 +theme_override_styles/focus = ExtResource("2_2ijnm") +theme_override_styles/disabled_mirrored = ExtResource("3_dftre") +theme_override_styles/disabled = ExtResource("3_dftre") +theme_override_styles/hover_pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/hover_pressed = ExtResource("3_dftre") +theme_override_styles/hover_mirrored = ExtResource("3_dftre") +theme_override_styles/hover = ExtResource("3_dftre") +theme_override_styles/pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/pressed = ExtResource("3_dftre") +theme_override_styles/normal_mirrored = ExtResource("3_dftre") +theme_override_styles/normal = ExtResource("3_dftre") shortcut = ExtResource("2_7fwjx") text = "Enemy Viewer" +alignment = 0 -[node name="GalleryButton" type="Button" parent="MarginContainer/VBoxContainer"] +[node name="GalleryButton" type="Button" parent="MarginContainer/CenterContainer/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 focus_neighbor_top = NodePath("../EnemyViewerButton") @@ -65,10 +101,24 @@ focus_neighbor_bottom = NodePath("../OptionsButton") focus_next = NodePath("../OptionsButton") focus_previous = NodePath("../EnemyViewerButton") theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1) +theme_override_fonts/font = ExtResource("2_dftre") +theme_override_font_sizes/font_size = 25 +theme_override_styles/focus = ExtResource("2_2ijnm") +theme_override_styles/disabled_mirrored = ExtResource("3_dftre") +theme_override_styles/disabled = ExtResource("3_dftre") +theme_override_styles/hover_pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/hover_pressed = ExtResource("3_dftre") +theme_override_styles/hover_mirrored = ExtResource("3_dftre") +theme_override_styles/hover = ExtResource("3_dftre") +theme_override_styles/pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/pressed = ExtResource("3_dftre") +theme_override_styles/normal_mirrored = ExtResource("3_dftre") +theme_override_styles/normal = ExtResource("3_dftre") shortcut = ExtResource("2_7fwjx") text = "Gallery" +alignment = 0 -[node name="OptionsButton" type="Button" parent="MarginContainer/VBoxContainer"] +[node name="OptionsButton" type="Button" parent="MarginContainer/CenterContainer/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 focus_neighbor_top = NodePath("../GalleryButton") @@ -76,10 +126,24 @@ focus_neighbor_bottom = NodePath("../QuitButton") focus_next = NodePath("../QuitButton") focus_previous = NodePath("../GalleryButton") theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1) +theme_override_fonts/font = ExtResource("2_dftre") +theme_override_font_sizes/font_size = 25 +theme_override_styles/focus = ExtResource("2_2ijnm") +theme_override_styles/disabled_mirrored = ExtResource("3_dftre") +theme_override_styles/disabled = ExtResource("3_dftre") +theme_override_styles/hover_pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/hover_pressed = ExtResource("3_dftre") +theme_override_styles/hover_mirrored = ExtResource("3_dftre") +theme_override_styles/hover = ExtResource("3_dftre") +theme_override_styles/pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/pressed = ExtResource("3_dftre") +theme_override_styles/normal_mirrored = ExtResource("3_dftre") +theme_override_styles/normal = ExtResource("3_dftre") shortcut = ExtResource("2_7fwjx") text = "Options" +alignment = 0 -[node name="QuitButton" type="Button" parent="MarginContainer/VBoxContainer"] +[node name="QuitButton" type="Button" parent="MarginContainer/CenterContainer/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 focus_neighbor_top = NodePath("../OptionsButton") @@ -87,6 +151,20 @@ focus_neighbor_bottom = NodePath(".") focus_next = NodePath(".") focus_previous = NodePath("../OptionsButton") theme_override_colors/font_focus_color = Color(0.976471, 0.827451, 0, 1) +theme_override_fonts/font = ExtResource("2_dftre") +theme_override_font_sizes/font_size = 25 +theme_override_styles/focus = ExtResource("2_2ijnm") +theme_override_styles/disabled_mirrored = ExtResource("3_dftre") +theme_override_styles/disabled = ExtResource("3_dftre") +theme_override_styles/hover_pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/hover_pressed = ExtResource("3_dftre") +theme_override_styles/hover_mirrored = ExtResource("3_dftre") +theme_override_styles/hover = ExtResource("3_dftre") +theme_override_styles/pressed_mirrored = ExtResource("3_dftre") +theme_override_styles/pressed = ExtResource("3_dftre") +theme_override_styles/normal_mirrored = ExtResource("3_dftre") +theme_override_styles/normal = ExtResource("3_dftre") shortcut = ExtResource("2_7fwjx") text = "Quit " +alignment = 0 diff --git a/Zennysoft.Game.Ma/src/menu/splash/Splash.tscn b/Zennysoft.Game.Ma/src/menu/splash/Splash.tscn index bded16df1..89e70ded5 100644 --- a/Zennysoft.Game.Ma/src/menu/splash/Splash.tscn +++ b/Zennysoft.Game.Ma/src/menu/splash/Splash.tscn @@ -61,4 +61,3 @@ unique_name_in_owner = true libraries = { &"": SubResource("AnimationLibrary_jiqgw") } -autoplay = "intro" diff --git a/Zennysoft.Game.Ma/src/minimap/Minimap.tscn b/Zennysoft.Game.Ma/src/minimap/Minimap.tscn index 86fffa658..651ca43af 100644 --- a/Zennysoft.Game.Ma/src/minimap/Minimap.tscn +++ b/Zennysoft.Game.Ma/src/minimap/Minimap.tscn @@ -55,6 +55,7 @@ grow_vertical = 2 script = ExtResource("1_yn75n") [node name="CenterContainer" type="CenterContainer" parent="."] +custom_minimum_size = Vector2(400, 400) layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -63,13 +64,13 @@ grow_horizontal = 2 grow_vertical = 2 [node name="SubViewportContainer" type="SubViewportContainer" parent="CenterContainer"] -custom_minimum_size = Vector2(350, 300) +custom_minimum_size = Vector2(400, 400) layout_mode = 2 [node name="SubViewport" type="SubViewport" parent="CenterContainer/SubViewportContainer"] transparent_bg = true handle_input_locally = false -size = Vector2i(350, 300) +size = Vector2i(350, 350) render_target_update_mode = 4 [node name="MinimapCamera" type="Camera3D" parent="CenterContainer/SubViewportContainer/SubViewport"] @@ -84,24 +85,26 @@ size = 100.0 near = 0.001 [node name="MarginContainer" type="MarginContainer" parent="CenterContainer/SubViewportContainer/SubViewport"] -anchors_preset = 15 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 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 +offset_left = -190.0 +offset_top = -48.0 +grow_horizontal = 0 +grow_vertical = 0 +theme_override_constants/margin_left = 20 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 20 +theme_override_constants/margin_bottom = 20 -[node name="Control" type="Control" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer"] layout_mode = 2 -[node name="LayerText" type="Label" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer/Control"] +[node name="LayerText" type="Label" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer/HBoxContainer"] custom_minimum_size = Vector2(80, 15) layout_mode = 2 -offset_left = -14.0 -offset_top = 26.0 -offset_right = 136.0 -offset_bottom = 68.0 size_flags_vertical = 6 theme = SubResource("Theme_75ec6") theme_override_colors/font_color = Color(0.792157, 0.698039, 0.643137, 1) @@ -114,14 +117,10 @@ text = "LAYER" label_settings = SubResource("LabelSettings_yn75n") vertical_alignment = 2 -[node name="LayerNumberText" type="Label" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer/Control"] +[node name="LayerNumberText" type="Label" parent="CenterContainer/SubViewportContainer/SubViewport/MarginContainer/HBoxContainer"] unique_name_in_owner = true custom_minimum_size = Vector2(80, 15) layout_mode = 2 -offset_left = 79.0 -offset_top = 22.0 -offset_right = 159.0 -offset_bottom = 74.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) diff --git a/Zennysoft.Game.Ma/src/player/Player.tscn b/Zennysoft.Game.Ma/src/player/Player.tscn index 6e875f8c7..b588b22f5 100644 --- a/Zennysoft.Game.Ma/src/player/Player.tscn +++ b/Zennysoft.Game.Ma/src/player/Player.tscn @@ -10340,8 +10340,6 @@ animations = [{ collision_layer = 802 collision_mask = 775 script = ExtResource("1_xcol5") -HealthTimerIsActive = true -AutoRevive = true [node name="MainCollision" type="CollisionShape3D" parent="."] unique_name_in_owner = true diff --git a/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.tscn b/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.tscn index ff4b41472..636f42365 100644 --- a/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.tscn +++ b/Zennysoft.Game.Ma/src/ui/in_game_ui/InGameUI.tscn @@ -2,17 +2,16 @@ [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"] -[ext_resource type="PackedScene" uid="uid://t22s2y1t8ktc" path="res://src/debug/DebugInfo.tscn" id="2_f0tui"] +[ext_resource type="PackedScene" uid="uid://t22s2y1t8ktc" path="res://src/debug_info/DebugInfo.tscn" id="2_f0tui"] [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="PackedScene" uid="uid://x0f1ol50nnp3" path="res://src/ui/in_game_ui/InventoryMessageUI.tscn" id="6_y26qy"] [ext_resource type="PackedScene" uid="uid://8f3dk16nj0dn" path="res://src/menu/DebugMenu.tscn" id="7_llomk"] [ext_resource type="Texture2D" uid="uid://bj4p4qxb1mj3q" path="res://src/ui/player_ui/Assets/panel rough draft.png" id="7_ur8ag"] -[ext_resource type="PackedScene" uid="uid://c3e6hbctay1us" path="res://src/ui/inventory_menu/InventoryMenu.tscn" id="9_ur8ag"] +[ext_resource type="PackedScene" uid="uid://cbxw70qa7gifp" path="res://src/ui/inventory_menu/InventoryMenu.tscn" id="9_ur8ag"] [ext_resource type="PackedScene" uid="uid://dwa7o6hkkwjg1" path="res://src/ui/inventory_menu/ItemRescueMenu.tscn" id="10_higkc"] -[sub_resource type="StyleBoxLine" id="StyleBoxLine_ur8ag"] -color = Color(0.792157, 0.698039, 0.643137, 1) +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_higkc"] [node name="InGameUI" type="Control"] process_mode = 3 @@ -76,17 +75,36 @@ visible = false custom_minimum_size = Vector2(1440, 1080) layout_mode = 2 -[node name="Panel" type="ColorRect" parent="HBoxContainer"] -custom_minimum_size = Vector2(480, 0) -layout_mode = 2 +[node name="InventoryMenu" parent="." instance=ExtResource("9_ur8ag")] +unique_name_in_owner = true +layout_mode = 1 -[node name="MinimapZone" type="Panel" parent="HBoxContainer/Panel"] -layout_mode = 2 -offset_top = 14.0 -offset_right = 480.0 -offset_bottom = 14.0 +[node name="ItemRescueMenu" parent="." instance=ExtResource("10_higkc")] +unique_name_in_owner = true +visible = false +layout_mode = 1 -[node name="MiniMap" parent="HBoxContainer/Panel/MinimapZone" instance=ExtResource("2_6sfje")] +[node name="Sidebar Container" type="PanelContainer" parent="."] +custom_minimum_size = Vector2(459, 0) +layout_mode = 1 +anchors_preset = 11 +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 0 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxEmpty_higkc") + +[node name="MinimapContainer" type="MarginContainer" parent="Sidebar Container"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 0 + +[node name="MinimapZone" type="Panel" parent="Sidebar Container/MinimapContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="MiniMap" parent="Sidebar Container/MinimapContainer/MinimapZone" instance=ExtResource("2_6sfje")] unique_name_in_owner = true custom_minimum_size = Vector2(50, 50) layout_mode = 2 @@ -100,55 +118,26 @@ offset_top = 354.0 offset_right = 423.0 offset_bottom = 620.0 -[node name="HSeparator2" type="HSeparator" parent="HBoxContainer/Panel/MinimapZone"] +[node name="Sidebar Texture" type="TextureRect" parent="Sidebar Container"] layout_mode = 2 -offset_left = 78.0 -offset_top = 716.0 -offset_right = 370.0 -offset_bottom = 722.0 -theme_override_styles/separator = SubResource("StyleBoxLine_ur8ag") - -[node name="TextureRect" type="TextureRect" parent="HBoxContainer/Panel"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_bottom = 1072.0 -grow_horizontal = 2 -grow_vertical = 2 texture = ExtResource("7_ur8ag") -stretch_mode = 4 -[node name="PlayerInfoUI" parent="HBoxContainer/Panel" instance=ExtResource("4_46s5l")] +[node name="PlayerInfoContainer" type="MarginContainer" parent="Sidebar Container"] +layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 200 + +[node name="PlayerInfoUI" parent="Sidebar Container/PlayerInfoContainer" instance=ExtResource("4_46s5l")] unique_name_in_owner = true layout_mode = 2 -anchors_preset = 0 -offset_left = 29.0 -offset_top = 197.0 -offset_right = 29.0 -offset_bottom = -746.0 - -[node name="HSeparator" type="HSeparator" parent="HBoxContainer/Panel"] -layout_mode = 2 -offset_left = 99.0 -offset_top = 326.0 -offset_right = 391.0 -offset_bottom = 332.0 -theme_override_styles/separator = SubResource("StyleBoxLine_ur8ag") - -[node name="Sigil Marker" type="ReferenceRect" parent="HBoxContainer/Panel"] -layout_mode = 2 -offset_left = 75.0 -offset_top = 813.0 -offset_right = 267.0 -offset_bottom = 1004.0 size_flags_vertical = 3 -[node name="InventoryMenu" parent="." instance=ExtResource("9_ur8ag")] -unique_name_in_owner = true -layout_mode = 1 +[node name="SigilContainer" type="MarginContainer" parent="Sidebar Container"] +layout_mode = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 800 +theme_override_constants/margin_right = 175 +theme_override_constants/margin_bottom = 50 -[node name="ItemRescueMenu" parent="." instance=ExtResource("10_higkc")] -unique_name_in_owner = true -visible = false -layout_mode = 1 +[node name="ReferenceRect" type="ReferenceRect" parent="Sidebar Container/SigilContainer"] +layout_mode = 2 diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs index ac1c70ca2..6e85cdc21 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs @@ -26,6 +26,8 @@ public partial class ActionPanel : Panel public event Action ReturnToGameAction; + public event Action AugmentMenuRequested; + public void OnResolved() { InteractButton.Pressed += InteractButton_Pressed; @@ -44,12 +46,29 @@ public partial class ActionPanel : Panel { InteractButton.GrabFocus(); } + + public void HideActionPanel() + { + InteractButton.Disabled = false; + ThrowButton.Disabled = false; + DropButton.Disabled = false; + ThrowButton.FocusMode = FocusModeEnum.All; + DropButton.FocusMode = FocusModeEnum.All; + ActionPanelClosing?.Invoke(); + } + + public override void _Input(InputEvent @event) + { + if (Visible && Input.IsActionJustPressed(GameInputs.Interact)) + { + GetViewport().SetInputAsHandled(); + HideActionPanel(); + } + } + private void InteractButton_Pressed() { - if (_currentlySelected is IEquipableItem equipable) - PerformAction(equipable); - _currentlySelected = null; - ActionPanelClosing?.Invoke(); + PerformAction((dynamic)_currentlySelected); } private void ThrowButton_Pressed() @@ -57,6 +76,7 @@ public partial class ActionPanel : Panel _game.ThrowItem(_currentlySelected); _currentlySelected = null; ActionPanelClosing?.Invoke(); + ReturnToGameAction?.Invoke(); } private void DropButton_Pressed() @@ -64,6 +84,7 @@ public partial class ActionPanel : Panel _game.DropItem(_currentlySelected); _currentlySelected = null; ActionPanelClosing?.Invoke(); + ReturnToGameAction?.Invoke(); } private void SetOptions(IBaseInventoryItem item) @@ -71,12 +92,24 @@ public partial class ActionPanel : Panel SetOptionsInternal((dynamic)item); } + private void ResetActionPanel() + { + InteractButton.Disabled = false; + ThrowButton.Disabled = false; + DropButton.Disabled = false; + ThrowButton.FocusMode = FocusModeEnum.All; + DropButton.FocusMode = FocusModeEnum.All; + } + private void SetOptionsInternal(IEquipableItem equipable) { - InteractButton.Text = _player.EquipmentComponent.IsItemEquipped(equipable) ? "Unequip" : "Equip"; + var isItemEquipped = _player.EquipmentComponent.IsItemEquipped(equipable); + InteractButton.Text = isItemEquipped ? "Unequip" : "Equip"; InteractButton.Disabled = equipable.Glued; - ThrowButton.Disabled = equipable.Glued; - DropButton.Disabled = equipable.Glued; + ThrowButton.Disabled = equipable.Glued || isItemEquipped; + DropButton.Disabled = equipable.Glued || isItemEquipped; + ThrowButton.FocusMode = ThrowButton.Disabled ? FocusModeEnum.None : FocusModeEnum.All; + DropButton.FocusMode = DropButton.Disabled ? FocusModeEnum.None : FocusModeEnum.All; } private void SetOptionsInternal(IAugmentItem equipable) @@ -101,10 +134,32 @@ public partial class ActionPanel : Panel _player.EquipmentComponent.Equip(equipable); SfxDatabase.Instance.Play(SoundEffect.Equip); } + + _currentlySelected = null; + ActionPanelClosing?.Invoke(); + } + + private void PerformAction(Plastique plastique) + { + SfxDatabase.Instance.Play(SoundEffect.SelectUI); + _game.SetItem(plastique); + _currentlySelected = null; + ActionPanelClosing?.Invoke(); + ReturnToGameAction?.Invoke(); + } + + private void PerformAction(Jewel jewel) + { + SfxDatabase.Instance.Play(SoundEffect.SelectUI); + ActionPanelClosing?.Invoke(); + AugmentMenuRequested?.Invoke(); } private void PerformAction(IBaseInventoryItem item) { + SfxDatabase.Instance.Play(SoundEffect.SelectUI); _game.UseItem(item); + _currentlySelected = null; + ActionPanelClosing?.Invoke(); } } diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.tscn b/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.tscn index c83f2f8cc..37678bf80 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.tscn +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.tscn @@ -10,6 +10,7 @@ bg_color = Color(0, 0, 0, 0.745098) [node name="ActionPanel" type="Panel"] custom_minimum_size = Vector2(200, 200) focus_mode = 2 +mouse_filter = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_g7ag1") script = ExtResource("1_r13ox") diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs new file mode 100644 index 000000000..aa24098e0 --- /dev/null +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs @@ -0,0 +1,106 @@ +using Chickensoft.AutoInject; +using Chickensoft.Introspection; +using Godot; +using System; +using System.Collections.Generic; +using System.Linq; +using Zennysoft.Game.Ma; +using Zennysoft.Ma.Adapter; + +[Meta(typeof(IAutoNode))] +public partial class AugmentableItemsMenu : Control +{ + public override void _Notification(int what) => this.Notify(what); + + [Dependency] private IPlayer _player => this.DependOn(); + + [Node] public VBoxContainer Inventory { get; set; } + + [Node] public Button CancelAugmentButton { get; set; } + + [Node] public Button ConfirmAugmentButton { get; set; } + + [Node] public Control ConfirmAugmentContainer { get; set; } + + private List ItemSlots; + + private IItemSlot _currentlySelected; + + private IAugmentItem _augmentingItem; + + public event Action AugmentMenuClosing; + + public void OnResolved() + { + ItemSlots = [.. Inventory.GetChildren().OfType()]; + ItemSlots.ForEach(x => x.ItemPressed += ItemPressed); + ItemSlots.ForEach(x => x.ItemSelected += ItemSelected); + CancelAugmentButton.Pressed += CancelAugmentButton_Pressed; + ConfirmAugmentButton.Pressed += ConfirmAugmentButton_Pressed; + } + + private void ConfirmAugmentButton_Pressed() + { + _player.ApplyNewAugment(_augmentingItem, _currentlySelected.Item.Value as IAugmentableItem); + ConfirmAugmentContainer.Hide(); + AugmentMenuClosing?.Invoke(); + SfxDatabase.Instance.Play(SoundEffect.SelectUI); + } + + private void CancelAugmentButton_Pressed() + { + CloseAugmentMenu(); + } + + private void CloseAugmentMenu() + { + SfxDatabase.Instance.Play(SoundEffect.CancelUI); + ConfirmAugmentContainer.Hide(); + AugmentMenuClosing?.Invoke(); + } + + public void OpenAugmentMenu(IAugmentItem augmentingItem) + { + _augmentingItem = augmentingItem; + + var inventory = _player.Inventory.Items; + ItemSlots.ForEach(x => x.SetEmpty()); + var slotIndex = 0; + + foreach (var item in inventory) + { + if (item is IAugmentableItem augmentable && augmentable.Augment == null) + ItemSlots[slotIndex++].SetItemToSlot(item); + } + + Show(); + ItemSlots.First().FocusItem(); + } + + public override void _Input(InputEvent @event) + { + if (Visible && Input.IsActionJustPressed(GameInputs.Interact)) + { + GetViewport().SetInputAsHandled(); + if (ConfirmAugmentContainer.Visible) + { + if (ConfirmAugmentButton.HasFocus()) + SfxDatabase.Instance.Play(SoundEffect.CancelUI); + CancelAugmentButton.GrabFocus(); + } + else + CloseAugmentMenu(); + } + } + + private void ItemSelected(IItemSlot selectedItem) + { + _currentlySelected = selectedItem; + } + + private void ItemPressed(IItemSlot slot) + { + ConfirmAugmentContainer.Show(); + ConfirmAugmentButton.GrabFocus(); + } +} diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs.uid b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs.uid new file mode 100644 index 000000000..6523887bb --- /dev/null +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs.uid @@ -0,0 +1 @@ +uid://brtic4hw6thox diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.tscn b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.tscn new file mode 100644 index 000000000..33b7a52c5 --- /dev/null +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.tscn @@ -0,0 +1,245 @@ +[gd_scene load_steps=11 format=3 uid="uid://tpqh7q0xh63c"] + +[ext_resource type="PackedScene" uid="uid://c005nd0m2eim" path="res://src/ui/inventory_menu/ItemSlot.tscn" id="1_a5r0f"] +[ext_resource type="Script" uid="uid://brtic4hw6thox" path="res://src/ui/inventory_menu/AugmentableItemsMenu.cs" id="1_ukqf2"] +[ext_resource type="FontFile" uid="uid://beh6d5lo5ihq0" path="res://src/ui/fonts/georgiai.ttf" id="2_ukqf2"] +[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="3_qtvkp"] +[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="4_p84pf"] +[ext_resource type="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="5_rxojm"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_l0byb"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7co7g"] +bg_color = Color(0, 0, 0, 0.745098) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_unikd"] +bg_color = Color(0, 0, 0, 1) + +[sub_resource type="LabelSettings" id="LabelSettings_unikd"] +line_spacing = 1.0 +font = ExtResource("2_ukqf2") +font_size = 40 +outline_size = 3 +outline_color = Color(0, 0, 0, 1) + +[node name="AugmentMenu" type="Panel"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBoxEmpty_l0byb") +script = ExtResource("1_ukqf2") + +[node name="CenterContainer2" type="CenterContainer" parent="."] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -400.0 +offset_right = 400.0 +offset_bottom = 1025.0 +grow_horizontal = 2 + +[node name="AugmentableItemsList" type="PanelContainer" parent="CenterContainer2"] +unique_name_in_owner = true +custom_minimum_size = Vector2(800, 1025) +layout_mode = 2 + +[node name="Panel" type="Panel" parent="CenterContainer2/AugmentableItemsList"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_7co7g") + +[node name="MarginContainer" type="MarginContainer" parent="CenterContainer2/AugmentableItemsList/Panel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 5 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 5 +theme_override_constants/margin_bottom = 5 + +[node name="ReferenceRect" type="ReferenceRect" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer"] +layout_mode = 2 +border_color = Color(1, 1, 1, 1) +editor_only = false + +[node name="MarginContainer2" type="MarginContainer" parent="CenterContainer2/AugmentableItemsList/Panel"] +layout_mode = 2 +offset_right = 800.0 +offset_bottom = 1050.0 +theme_override_constants/margin_left = 25 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 25 +theme_override_constants/margin_bottom = 15 + +[node name="Inventory" type="VBoxContainer" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 0 +theme_override_constants/separation = 0 + +[node name="AugmentableSlot" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot2" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot3" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot4" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot5" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot6" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot7" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot8" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot9" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot10" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot11" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot12" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot13" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot14" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot15" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot16" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot17" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot18" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot19" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="AugmentableSlot20" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")] +layout_mode = 2 + +[node name="ConfirmAugmentContainer" type="Panel" parent="."] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="CenterContainer" type="CenterContainer" parent="ConfirmAugmentContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -40.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PanelContainer" type="PanelContainer" parent="ConfirmAugmentContainer/CenterContainer"] +layout_mode = 2 + +[node name="Panel" type="Panel" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer"] +custom_minimum_size = Vector2(400, 250) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_unikd") + +[node name="MarginContainer" type="MarginContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 5 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 5 +theme_override_constants/margin_bottom = 5 + +[node name="ReferenceRect" type="ReferenceRect" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/MarginContainer"] +layout_mode = 2 +border_color = Color(1, 1, 1, 1) +editor_only = false + +[node name="CenterContainer" type="CenterContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer"] +layout_mode = 2 +theme_override_constants/separation = 25 + +[node name="Label" type="Label" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer"] +layout_mode = 2 +text = "Augment Item?" +label_settings = SubResource("LabelSettings_unikd") +horizontal_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 20 +alignment = 1 + +[node name="CancelAugmentButton" type="Button" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +focus_neighbor_left = NodePath(".") +focus_neighbor_top = NodePath(".") +focus_neighbor_right = NodePath("../ConfirmAugmentButton") +focus_neighbor_bottom = NodePath(".") +theme_override_fonts/font = ExtResource("3_qtvkp") +theme_override_font_sizes/font_size = 25 +theme_override_styles/focus = ExtResource("4_p84pf") +theme_override_styles/disabled_mirrored = ExtResource("5_rxojm") +theme_override_styles/disabled = ExtResource("5_rxojm") +theme_override_styles/hover_pressed_mirrored = ExtResource("5_rxojm") +theme_override_styles/hover_pressed = ExtResource("5_rxojm") +theme_override_styles/hover_mirrored = ExtResource("5_rxojm") +theme_override_styles/hover = ExtResource("5_rxojm") +theme_override_styles/pressed_mirrored = ExtResource("5_rxojm") +theme_override_styles/pressed = ExtResource("5_rxojm") +theme_override_styles/normal_mirrored = ExtResource("5_rxojm") +theme_override_styles/normal = ExtResource("5_rxojm") +text = "Cancel" + +[node name="ConfirmAugmentButton" type="Button" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +focus_neighbor_left = NodePath("../CancelAugmentButton") +focus_neighbor_top = NodePath(".") +focus_neighbor_right = NodePath(".") +focus_neighbor_bottom = NodePath(".") +theme_override_fonts/font = ExtResource("3_qtvkp") +theme_override_font_sizes/font_size = 25 +theme_override_styles/focus = ExtResource("4_p84pf") +theme_override_styles/disabled_mirrored = ExtResource("5_rxojm") +theme_override_styles/disabled = ExtResource("5_rxojm") +theme_override_styles/hover_pressed_mirrored = ExtResource("5_rxojm") +theme_override_styles/hover_pressed = ExtResource("5_rxojm") +theme_override_styles/hover_mirrored = ExtResource("5_rxojm") +theme_override_styles/hover = ExtResource("5_rxojm") +theme_override_styles/pressed_mirrored = ExtResource("5_rxojm") +theme_override_styles/pressed = ExtResource("5_rxojm") +theme_override_styles/normal_mirrored = ExtResource("5_rxojm") +theme_override_styles/normal = ExtResource("5_rxojm") +text = "Confirm" diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs index 730262b11..5b701a493 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs @@ -27,6 +27,10 @@ public partial class InventoryMenu : Control, IInventoryMenu [Node] public VBoxContainer Inventory { get; set; } + [Node] public Control MenuPanel { get; set; } + + [Node] public AugmentableItemsMenu AugmentMenu { get; set; } + private List ItemSlots; private IItemSlot _currentlySelected; @@ -39,9 +43,31 @@ public partial class InventoryMenu : Control, IInventoryMenu VisibilityChanged += ResetInventoryState; ActionPanel.ActionPanelClosing += ActionPanel_ActionPanelClosing; ActionPanel.ReturnToGameAction += ActionPanel_ReturnToGameAction; - ItemName.Text = string.Empty; - ItemFlavor.Text = string.Empty; - ItemStats.Text = string.Empty; + ActionPanel.AugmentMenuRequested += ActionPanel_AugmentMenuRequested; + AugmentMenu.AugmentMenuClosing += AugmentMenu_AugmentMenuClosing; + AugmentMenu.FocusMode = FocusModeEnum.None; + ClearDescriptionBox(); + } + + public override void _Input(InputEvent @event) + { + if (Input.IsActionJustPressed(GameInputs.MoveUp) && _currentlySelected != ItemSlots.First()) + SfxDatabase.Instance.Play(SoundEffect.MoveUI); + if (Input.IsActionJustPressed(GameInputs.MoveDown) && _currentlySelected != ItemSlots.Last(x => x.Item.Value != null)) + SfxDatabase.Instance.Play(SoundEffect.MoveUI); + } + + private void ActionPanel_AugmentMenuRequested() + { + ReleaseFocus(); + ItemSlots.ForEach(x => x.ItemPressed -= ItemPressed); + ItemSlots.ForEach(x => x.ItemSelected -= ItemSelected); + MenuPanel.Hide(); + MenuPanel.FocusMode = FocusModeEnum.None; + AugmentMenu.FocusMode = FocusModeEnum.All; + SetProcessInput(false); + AugmentMenu.SetProcessInput(true); + AugmentMenu.OpenAugmentMenu(_currentlySelected.Item.Value as IAugmentItem); } private void ActionPanel_ReturnToGameAction() @@ -51,8 +77,11 @@ public partial class InventoryMenu : Control, IInventoryMenu private void ItemPressed(IItemSlot selectedItem) { + SetProcessInput(false); + ActionPanel.SetProcessInput(true); ActionPanel.ShowPanel(selectedItem.Item.Value); ActionPanel.FocusActionPanel(); + SfxDatabase.Instance.Play(SoundEffect.SelectUI); } private void ItemSelected(IItemSlot selectedItem) @@ -66,6 +95,7 @@ public partial class InventoryMenu : Control, IInventoryMenu { var inventory = _player.Inventory.Items; ItemSlots.ForEach(x => x.SetEmpty()); + ClearDescriptionBox(); for (var i = 0; i < inventory.Count; i++) ItemSlots[i].SetItemToSlot(inventory[i]); @@ -77,201 +107,33 @@ public partial class InventoryMenu : Control, IInventoryMenu ActionPanel.Hide(); } + private void ClearDescriptionBox() + { + ItemName.Text = string.Empty; + ItemFlavor.Text = string.Empty; + ItemStats.Text = string.Empty; + } + private void ActionPanel_ActionPanelClosing() { ActionPanel.Hide(); + SetProcessInput(true); + ActionPanel.SetProcessInput(false); + if (!_player.Inventory.Items.Contains(_currentlySelected.Item.Value)) + _currentlySelected = null; ResetInventoryState(); } - private void InteractButton_Pressed() + private void AugmentMenu_AugmentMenuClosing() { - //if (_currentlySelected != null) - //{ - // var item = _currentlySelected.Item.Value; - // if (_augmentMode) - // { - // _player.ApplyNewAugment(_augmentingJewel, item as EquipableItem); - // _augmentMode = false; - // ResetInventoryState(); - // } - // else if (item is EquipableItem equipable) - // { - // if (_player.EquipmentComponent.IsItemEquipped(equipable)) - // _player.Unequip(equipable); - // else - // { - // _player.Equip(equipable); - // } - // ResetInventoryState(); - // } - // else if (item is Plastique plastique) - // { - // _game.SetItem(plastique); - // ResetInventoryState(); - // } - // else if (item is Jewel jewel) - // { - // _augmentMode = true; - // AugmentMode(jewel); - // } - // else - // { - // _game.UseItem(_currentlySelected.Item.Value); - // ResetInventoryState(); - // } - - // CloseActionMenu(); - //} - } - - private void DropButton_Pressed() - { - //var previousItemInList = Mathf.Max(0, ItemSlots.IndexOf(_currentlySelected) - 1); - //_game.DropItem(_currentlySelected.Item.Value); - //CloseActionMenu(); - //_gameRepo.CloseInventory(); - //if (_currentlySelected != null && !_player.Inventory.Items.Contains(_currentlySelected.Item.Value)) - // _currentlySelected = ItemSlots[previousItemInList]; - } - - private void ThrowButton_Pressed() - { - //var previousItemInList = Mathf.Max(0, ItemSlots.IndexOf(_currentlySelected) - 1); - //_game.ThrowItem(_currentlySelected.Item.Value); - //CloseActionMenu(); - //_gameRepo.CloseInventory(); - //if (_currentlySelected != null && !_player.Inventory.Items.Contains(_currentlySelected.Item.Value)) - // _currentlySelected = ItemSlots[previousItemInList]; - } - - public override void _Input(InputEvent @event) - { - //if (ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.Interact)) - //{ - // CloseActionMenu(); - // SfxDatabase.Instance.Play(SoundEffect.CancelUI); - // GetViewport().SetInputAsHandled(); - //} - //else if (_augmentMode && !ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.Interact)) - //{ - // GetViewport().SetInputAsHandled(); - // _augmentMode = false; - // SfxDatabase.Instance.Play(SoundEffect.CancelUI); - // ResetInventoryState(); - //} - //if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.MoveUp)) - //{ - // if (ItemSlots.First(x => x.Visible) != _currentlySelected) - // SfxDatabase.Instance.Play(SoundEffect.MoveUI); - //} - //if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.MoveDown)) - //{ - // if (ItemSlots.Last(x => x.Visible) != _currentlySelected) - // SfxDatabase.Instance.Play(SoundEffect.MoveUI); - //} - - //if (Input.IsActionJustPressed(GameInputs.MoveDown) && ActionPanel.Visible && InteractButton.HasFocus() && !ThrowButton.Disabled) - // SfxDatabase.Instance.Play(SoundEffect.MoveUI); - //if (Input.IsActionJustPressed(GameInputs.MoveDown) && ActionPanel.Visible && ThrowButton.HasFocus() && !DropButton.Disabled) - // SfxDatabase.Instance.Play(SoundEffect.MoveUI); - //if (Input.IsActionJustPressed(GameInputs.MoveUp) && ActionPanel.Visible && ThrowButton.HasFocus() && !InteractButton.Disabled) - // SfxDatabase.Instance.Play(SoundEffect.MoveUI); - //if (Input.IsActionJustPressed(GameInputs.MoveUp) && ActionPanel.Visible && DropButton.HasFocus() && !ThrowButton.Disabled) - // SfxDatabase.Instance.Play(SoundEffect.MoveUI); - - //if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.InventorySort)) - //{ - // _player.Inventory.Sort(_player.EquipmentComponent.EquippedWeapon.Value, _player.EquipmentComponent.EquippedArmor.Value, _player.EquipmentComponent.EquippedAccessory.Value, _player.EquipmentComponent.EquippedAmmo.Value); - // SfxDatabase.Instance.Play(SoundEffect.SortInventory); - // ResetInventoryState(); - //} - } - - private void Slot_ItemPressed(IItemSlot slot) - { - //var item = slot.Item.Value; - - //InteractButton.Disabled = false; - //ThrowButton.Disabled = false; - //DropButton.Disabled = false; - //InteractButton.FocusMode = FocusModeEnum.All; - //ThrowButton.FocusMode = FocusModeEnum.All; - //DropButton.FocusMode = FocusModeEnum.All; - - //if (_augmentMode) - //{ - // InteractButton.Text = "Augment"; - // ThrowButton.Disabled = true; - // DropButton.Disabled = true; - // InteractButton.GrabFocus(); - //} - //else if (item is IEquipableItem equipable) - //{ - // var itemIsEquipped = _player.EquipmentComponent.IsItemEquipped(equipable); - // InteractButton.Text = itemIsEquipped ? "Unequip" : "Equip"; - // ThrowButton.Disabled = itemIsEquipped; - // ThrowButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All; - // DropButton.Disabled = itemIsEquipped; - // DropButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All; - // InteractButton.GrabFocus(); - - // if ((item is Weapon weapon && _player.EquipmentComponent.EquippedWeapon.Value.Glued) || - // (item is Armor && _player.EquipmentComponent.EquippedArmor.Value.Glued) || - // (item is Accessory && _player.EquipmentComponent.EquippedAccessory.Value.Glued)) - // { - // InteractButton.Disabled = true; - // InteractButton.FocusMode = FocusModeEnum.None; - // ThrowButton.GrabFocus(); - // } - //} - //else if (item is Plastique plastique) - //{ - // InteractButton.Text = "Set"; - // InteractButton.GrabFocus(); - //} - //else if (item is ThrowableItem throwable) - //{ - // InteractButton.Disabled = true; - // InteractButton.FocusMode = FocusModeEnum.None; - // ThrowButton.GrabFocus(); - //} - //else if (item is Jewel jewel) - //{ - // InteractButton.Text = "Augment"; - // InteractButton.GrabFocus(); - //} - //else - //{ - // InteractButton.Text = "Use"; - // InteractButton.GrabFocus(); - //} - - //ActionPanel.Show(); - } - - private void AugmentMode(Jewel jewel) - { - //_augmentingJewel = jewel; - - //foreach (var item in ItemSlots) - //{ - // item.Disabled = true; - // item.FocusMode = FocusModeEnum.None; - // if (item.Item.Value is EquipableItem equipable && equipable is not Ammo && equipable.Augment == null) - // { - // item.Disabled = false; - // item.FocusMode = FocusModeEnum.All; - // } - //} - - //var itemToSelect = ItemSlots.First(x => !x.Disabled); - //itemToSelect.GrabFocus(); - } - - private void CloseActionMenu() - { - //if (_currentlySelected != null) - // _currentlySelected.GrabFocus(); - //ActionPanel.Hide(); + ItemSlots.ForEach(x => x.ItemPressed += ItemPressed); + ItemSlots.ForEach(x => x.ItemSelected += ItemSelected); + MenuPanel.Show(); + MenuPanel.FocusMode = FocusModeEnum.All; + AugmentMenu.FocusMode = FocusModeEnum.None; + SetProcessInput(true); + AugmentMenu.SetProcessInput(false); + AugmentMenu.Hide(); + ResetInventoryState(); } } diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn index dc0ab0add..926d43b9e 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn @@ -1,12 +1,10 @@ -[gd_scene load_steps=19 format=3 uid="uid://cbxw70qa7gifp"] +[gd_scene load_steps=15 format=3 uid="uid://cbxw70qa7gifp"] [ext_resource type="Script" uid="uid://yh8qxmn058w2" path="res://src/ui/inventory_menu/InventoryMenu.cs" id="1_unikd"] -[ext_resource type="FontFile" uid="uid://beh6d5lo5ihq0" path="res://src/ui/fonts/georgiai.ttf" id="2_7co7g"] [ext_resource type="PackedScene" uid="uid://b648lhohtue70" path="res://src/ui/inventory_menu/ActionPanel.tscn" id="3_7co7g"] -[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="3_b6rkr"] -[ext_resource type="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="4_l0byb"] [ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="6_ldqki"] [ext_resource type="PackedScene" uid="uid://c005nd0m2eim" path="res://src/ui/inventory_menu/ItemSlot.tscn" id="6_unikd"] +[ext_resource type="PackedScene" uid="uid://tpqh7q0xh63c" path="res://src/ui/inventory_menu/AugmentableItemsMenu.tscn" id="6_xwkpe"] [ext_resource type="LabelSettings" uid="uid://b6f8ggy3ulonb" path="res://src/ui/label_settings/GeorgiaItalic.tres" id="7_we8a6"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7co7g"] @@ -33,16 +31,6 @@ outline_color = Color(0, 0, 0, 1) [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7co7g"] bg_color = Color(0, 0, 0, 0.745098) -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_unikd"] -bg_color = Color(0, 0, 0, 1) - -[sub_resource type="LabelSettings" id="LabelSettings_unikd"] -line_spacing = 1.0 -font = ExtResource("2_7co7g") -font_size = 40 -outline_size = 3 -outline_color = Color(0, 0, 0, 1) - [node name="InventoryMenu" type="PanelContainer"] process_mode = 2 visible = false @@ -75,6 +63,7 @@ layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxEmpty_b6rkr") [node name="MenuPanel" type="Panel" parent="Panel/MarginContainer/PanelContainer"] +unique_name_in_owner = true layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxEmpty_unikd") @@ -201,16 +190,16 @@ text = "Text Stats" label_settings = ExtResource("7_we8a6") [node name="InventoryList" type="PanelContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel"] -custom_minimum_size = Vector2(500, 100) +custom_minimum_size = Vector2(800, 100) layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -95.0 +offset_left = -120.0 offset_top = -515.0 -offset_right = 405.0 +offset_right = 680.0 offset_bottom = 510.0 grow_horizontal = 2 grow_vertical = 2 @@ -238,11 +227,11 @@ editor_only = false [node name="MarginContainer2" type="MarginContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/InventoryList/Panel"] layout_mode = 2 -offset_right = 500.0 +offset_right = 800.0 offset_bottom = 1050.0 -theme_override_constants/margin_left = 15 +theme_override_constants/margin_left = 25 theme_override_constants/margin_top = 15 -theme_override_constants/margin_right = 15 +theme_override_constants/margin_right = 25 theme_override_constants/margin_bottom = 15 [node name="Inventory" type="VBoxContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/InventoryList/Panel/MarginContainer2"] @@ -311,98 +300,7 @@ layout_mode = 2 [node name="ItemSlot20" parent="Panel/MarginContainer/PanelContainer/MenuPanel/InventoryList/Panel/MarginContainer2/Inventory" instance=ExtResource("6_unikd")] layout_mode = 2 -[node name="AugmentItemPanelContainer" type="Panel" parent="Panel/MarginContainer/PanelContainer/MenuPanel"] +[node name="AugmentMenu" parent="Panel/MarginContainer/PanelContainer" instance=ExtResource("6_xwkpe")] unique_name_in_owner = true visible = false -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="CenterContainer" type="CenterContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_right = -40.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="PanelContainer" type="PanelContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer"] -layout_mode = 2 - -[node name="Panel" type="Panel" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer"] -custom_minimum_size = Vector2(400, 250) -layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_unikd") - -[node name="MarginContainer" type="MarginContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer"] -layout_mode = 2 -theme_override_constants/margin_left = 5 -theme_override_constants/margin_top = 5 -theme_override_constants/margin_right = 5 -theme_override_constants/margin_bottom = 5 - -[node name="ReferenceRect" type="ReferenceRect" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer/MarginContainer"] -layout_mode = 2 -border_color = Color(1, 1, 1, 1) -editor_only = false - -[node name="CenterContainer" type="CenterContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer"] -layout_mode = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer/CenterContainer"] -layout_mode = 2 -theme_override_constants/separation = 25 - -[node name="Label" type="Label" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer"] -layout_mode = 2 -text = "Augment Item?" -label_settings = SubResource("LabelSettings_unikd") -horizontal_alignment = 1 - -[node name="HBoxContainer" type="HBoxContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer"] -layout_mode = 2 -theme_override_constants/separation = 20 -alignment = 1 - -[node name="CancelAugmentButton" type="Button" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer/HBoxContainer"] -unique_name_in_owner = true -layout_mode = 2 -theme_override_fonts/font = ExtResource("6_ldqki") -theme_override_font_sizes/font_size = 25 -theme_override_styles/focus = ExtResource("3_b6rkr") -theme_override_styles/disabled_mirrored = ExtResource("4_l0byb") -theme_override_styles/disabled = ExtResource("4_l0byb") -theme_override_styles/hover_pressed_mirrored = ExtResource("4_l0byb") -theme_override_styles/hover_pressed = ExtResource("4_l0byb") -theme_override_styles/hover_mirrored = ExtResource("4_l0byb") -theme_override_styles/hover = ExtResource("4_l0byb") -theme_override_styles/pressed_mirrored = ExtResource("4_l0byb") -theme_override_styles/pressed = ExtResource("4_l0byb") -theme_override_styles/normal_mirrored = ExtResource("4_l0byb") -theme_override_styles/normal = ExtResource("4_l0byb") -text = "Cancel" - -[node name="ConfirmAugmentButton" type="Button" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer/HBoxContainer"] -unique_name_in_owner = true -layout_mode = 2 -theme_override_fonts/font = ExtResource("6_ldqki") -theme_override_font_sizes/font_size = 25 -theme_override_styles/focus = ExtResource("3_b6rkr") -theme_override_styles/disabled_mirrored = ExtResource("4_l0byb") -theme_override_styles/disabled = ExtResource("4_l0byb") -theme_override_styles/hover_pressed_mirrored = ExtResource("4_l0byb") -theme_override_styles/hover_pressed = ExtResource("4_l0byb") -theme_override_styles/hover_mirrored = ExtResource("4_l0byb") -theme_override_styles/hover = ExtResource("4_l0byb") -theme_override_styles/pressed_mirrored = ExtResource("4_l0byb") -theme_override_styles/pressed = ExtResource("4_l0byb") -theme_override_styles/normal_mirrored = ExtResource("4_l0byb") -theme_override_styles/normal = ExtResource("4_l0byb") -text = "Confirm" - -[node name="PanelContainer2" type="PanelContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/AugmentItemPanelContainer/CenterContainer"] layout_mode = 2 diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs index 238d0766a..0eb39affd 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs @@ -37,7 +37,7 @@ public partial class ItemSlot : Control, IItemSlot { Item.Changed += Item_Changed; ItemName.Pressed += ItemSlot_Pressed; - ItemName.FocusEntered += FocusItem; + ItemName.FocusEntered += FocusItemInternal; } public void SetItemToSlot(IBaseInventoryItem item) @@ -54,6 +54,7 @@ public partial class ItemSlot : Control, IItemSlot { SetItemEquipmentStatus(_player.EquipmentComponent.IsItemEquipped(equipableItem)); ItemName.Disabled = equipableItem.Glued; + ItemName.FocusMode = ItemName.Disabled ? FocusModeEnum.None : FocusModeEnum.All; } if (item is IAugmentableItem augmentableItem) @@ -92,6 +93,12 @@ public partial class ItemSlot : Control, IItemSlot ItemSelected?.Invoke(this); } + private void FocusItemInternal() + { + ItemName.GrabFocus(); + ItemSelected?.Invoke(this); + } + private void ItemSlot_Pressed() { if (Item.Value == null) diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.tscn b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.tscn index 604187b98..c7b85d57f 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.tscn +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.tscn @@ -41,11 +41,14 @@ texture = ExtResource("2_rf22b") [node name="Control" type="HBoxContainer" parent="ItemInfo"] layout_mode = 2 +theme_override_constants/separation = 20 [node name="ItemName" type="Button" parent="ItemInfo/Control"] unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 4 +focus_neighbor_left = NodePath(".") +focus_neighbor_right = NodePath(".") theme_override_fonts/font = ExtResource("4_t6dim") theme_override_font_sizes/font_size = 25 theme_override_styles/focus = ExtResource("4_lt1pw") @@ -64,7 +67,6 @@ text = "Cross Sword" [node name="AugmentTexture" type="TextureRect" parent="ItemInfo/Control"] unique_name_in_owner = true -visible = false custom_minimum_size = Vector2(15, 20) layout_mode = 2 size_flags_horizontal = 4 diff --git a/Zennysoft.Game.Ma/src/ui/load_next_level/LoadNextLevel.cs b/Zennysoft.Game.Ma/src/ui/load_next_level/LoadNextLevel.cs index 9ceca3905..747e8fbb9 100644 --- a/Zennysoft.Game.Ma/src/ui/load_next_level/LoadNextLevel.cs +++ b/Zennysoft.Game.Ma/src/ui/load_next_level/LoadNextLevel.cs @@ -5,7 +5,6 @@ using Chickensoft.Introspection; using Godot; using System; using System.Linq; -using Zennysoft.Game.Abstractions; using Zennysoft.Game.Ma; using Zennysoft.Ma.Adapter; @@ -82,16 +81,16 @@ public partial class LoadNextLevel : Control, IFloorClearMenu private void ExitButton_Pressed() { - ContinueButton.Disabled = true; - ExitButton.Disabled = true; + ContinueButton.FocusMode = FocusModeEnum.None; + ExitButton.FocusMode = FocusModeEnum.None; FadeOut(); Exit?.Invoke(); } private void ContinueButton_Pressed() { - ContinueButton.Disabled = true; - ExitButton.Disabled = true; + ContinueButton.FocusMode = FocusModeEnum.None; + ExitButton.FocusMode = FocusModeEnum.None; GoToNextFloor?.Invoke(); } @@ -101,14 +100,13 @@ public partial class LoadNextLevel : Control, IFloorClearMenu { _fadingIn = true; _map.CurrentFloor.FadeOutAudio(); - ContinueButton.Disabled = true; - ExitButton.Disabled = true; - ContinueButton.CallDeferred(MethodName.GrabFocus); + ContinueButton.FocusMode = FocusModeEnum.None; + ExitButton.FocusMode = FocusModeEnum.None; } if (animName == "fade_out") { _fadingIn = false; - CallDeferred(MethodName.ReleaseFocus); + ContinueButton.CallDeferred(MethodName.ReleaseFocus); } } @@ -116,9 +114,10 @@ public partial class LoadNextLevel : Control, IFloorClearMenu { if (animName == "fade_in") { + ContinueButton.CallDeferred(MethodName.GrabFocus); _fadingIn = false; - ContinueButton.Disabled = false; - ExitButton.Disabled = false; + ContinueButton.FocusMode = FocusModeEnum.All; + ExitButton.FocusMode = FocusModeEnum.All; } if (animName == "fade_out") TransitionCompleted?.Invoke();