mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:45:33 +00:00
Fix for immediately closing inventory
This commit is contained in:
parent
f1b5251045
commit
c11acda1df
4 changed files with 93 additions and 26 deletions
|
|
@ -12,6 +12,7 @@
|
|||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACirno_002EScripts_002EComponents_002EActors_002EDamageReceiver3D_005FScriptSignals_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FTemp_003FSourceGeneratedDocuments_003F4DC97777E7037C0C573FE095_003FGodot_002ESourceGenerators_003FGodot_002ESourceGenerators_002EScriptSignalsGenerator_003FCirno_002EScripts_002EComponents_002EActors_002EDamageReceiver3D_005FScriptSignals_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACirno_002EScripts_002EControllers_002ERogueliteRoom_005FScriptMethods_002Egenerated_002Ecs_002Fl_003AF_0021_003Ftemp_003FSourceGeneratedDocuments_003F912EB5EC64EA35C30E40DC6E_003FGodot_002ESourceGenerators_003FGodot_002ESourceGenerators_002EScriptMethodsGenerator_003FCirno_002EScripts_002EControllers_002ERogueliteRoom_005FScriptMethods_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACirno_002EScripts_002EUI_002EInventoryMenu_005FScriptMethods_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F5ab35a8b9fadec7e5e6844898b6a96fc3e972d1_003FCirno_002EScripts_002EUI_002EInventoryMenu_005FScriptMethods_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACirno_002EScripts_002EUtils_002EGameStateManager_005FScriptSignals_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fbf24e34c55469ee29e3f7ed1bfccf60af99cb20_003FCirno_002EScripts_002EUtils_002EGameStateManager_005FScriptSignals_002Egenerated_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AContainer_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F8146f3e3f6341957cdf79e3ab90302acaa98c2e4c60a2f098a6fcc8a2c86c7_003FContainer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADisplayServer_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fb3649de1ae97d21ab4b9ce638d7b8c22417e735cc934a4dabd14d96863891772_003FDisplayServer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADisposablesTracker_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FDecompilerCache_003Fdecompiler_003F4fd22cd129a84c16b5d8004b467c426f518800_003Fb8_003Fee061233_003FDisposablesTracker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
|
@ -19,6 +20,8 @@
|
|||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGameManager_005FScriptMethods_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F642294f86639b2f8d4cb4d14e791d697e55369_003FGameManager_005FScriptMethods_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInputEvent_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F10e1ba49df151bbaf6853f9834601cecebdeade8465a9adb366b4a7b7c9524b0_003FInputEvent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInput_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F3e43a674e8a96aa8b4abdf97a31f18732060401d8285a17ee7109827a69cd18b_003FInput_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInput_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1c378f459c054fecaf4484a0fa6d44c055a800_003F6e_003Feb88d9fd_003FInput_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInput_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F33603a533b3e915194a5138a0aeef5b65bf44d22d38ffd9f165f094c699af21_003FInput_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F1b81cb3be224213a6a73519b6e340a628d9a1fb8629c351a186a26f6376669_003FList_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANativeCalls_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F4178b6f96a2e273c05bd023e0a7f4ff5c747b218af487b1ac979f58bafb30d_003FNativeCalls_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode2D_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F86db9cd834346aad02d74c1b66dd9c64d6ef3147435dd9c9c9477b48f7_003FNode2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ offset_right = 354.0
|
|||
offset_bottom = 198.0
|
||||
theme_override_styles/panel = ExtResource("20_0ncp3")
|
||||
|
||||
[node name="InventoryMenu" type="TabContainer" parent="Control"]
|
||||
[node name="InventoryMenu" type="TabContainer" parent="Control" node_paths=PackedStringArray("ParentContainer")]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
|
|
@ -345,6 +345,7 @@ theme = ExtResource("9_sx5r0")
|
|||
theme_override_fonts/font = ExtResource("6_sk1eq")
|
||||
current_tab = 4
|
||||
script = ExtResource("11_7pulb")
|
||||
ParentContainer = NodePath("..")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Weapons" type="ItemList" parent="Control/InventoryMenu"]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Components.Actors._3D;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
|
@ -62,7 +63,8 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
//_activationProvider.Enabled = true;
|
||||
//_interactionController.Enabled = true;
|
||||
|
||||
|
||||
_canOpenInventory = true;
|
||||
_inventoryCooldown = 0;
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
|
|
@ -74,11 +76,11 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
// _hitboxSpriteProvider.Hide();
|
||||
//
|
||||
DamageReceiver.Enabled = false;
|
||||
|
||||
_canOpenInventory = true;
|
||||
// _activationProvider.Enabled = false;
|
||||
// _interactionController.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void PhysicsProcessState(double delta)
|
||||
{
|
||||
|
|
@ -87,36 +89,54 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
|
||||
// Process modules
|
||||
base.PhysicsProcessState(delta);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void ProcessState(double delta)
|
||||
{
|
||||
base.ProcessState(delta);
|
||||
|
||||
HandleInputHotkeys();
|
||||
HandleInputHotkeys(delta);
|
||||
|
||||
AnimationProvider.SetAnimationSpeed(new Vector2(MainObject.Velocity.X, MainObject.Velocity.Z));
|
||||
AnimationProvider.SetAnimation(Storage.FacingDirection);
|
||||
}
|
||||
|
||||
private bool _canOpenInventory = true;
|
||||
private double _inventoryCooldown = 0;
|
||||
|
||||
private void HandleInputHotkeys()
|
||||
private void HandleInputHotkeys(double delta)
|
||||
{
|
||||
if (_inputProvider.GetInventoryJustPressed())
|
||||
if (_canOpenInventory && _inputProvider.GetInventoryJustPressed())
|
||||
{
|
||||
_canOpenInventory = false;
|
||||
|
||||
GameStateManager.SetState(GameState.Inventory);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_canOpenInventory)
|
||||
{
|
||||
_inventoryCooldown += delta;
|
||||
if (_inventoryCooldown >= 0.2)
|
||||
{
|
||||
_canOpenInventory = true;
|
||||
_inventoryCooldown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (_inputProvider.GetPauseJustPressed())
|
||||
{
|
||||
GameStateManager.Instance.Pause();
|
||||
//PauseDeferred();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void InventoryDeferred()
|
||||
{
|
||||
GameStateManager.SetState(GameState.Inventory);
|
||||
}
|
||||
|
||||
private void PauseDeferred()
|
||||
{
|
||||
GameStateManager.Instance.Pause();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
|
|
@ -18,17 +19,48 @@ public partial class InventoryMenu : TabContainer
|
|||
[Export]
|
||||
public StringName CancelActionName { get; private set; } = "ui_cancel";
|
||||
|
||||
[Export]
|
||||
public Control ParentContainer { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CallDeferred(MethodName.DeferredInitialize);
|
||||
this.Hide();
|
||||
|
||||
HideCommand();
|
||||
}
|
||||
|
||||
private void ShowCommand()
|
||||
{
|
||||
ParentContainer?.Show();
|
||||
|
||||
this.Show();
|
||||
}
|
||||
|
||||
private void HideCommand()
|
||||
{
|
||||
if (ParentContainer is not null)
|
||||
{
|
||||
ParentContainer.Hide();
|
||||
this.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private new bool IsVisible()
|
||||
{
|
||||
return ParentContainer?.Visible ?? Visible;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Input.IsActionJustPressed(InventoryActionName) || Input.IsActionJustPressed(PauseActionName) || Input.IsActionJustPressed(CancelActionName))
|
||||
if (Input.IsActionJustPressed(InventoryActionName) ||
|
||||
Input.IsActionJustPressed(PauseActionName) ||
|
||||
Input.IsActionJustPressed(CancelActionName))
|
||||
{
|
||||
if (Visible)
|
||||
if (IsVisible())
|
||||
{
|
||||
GameStateManager.Instance.ChangeState(GameState.Playing);
|
||||
//CallDeferred(MethodName.HideInventory);
|
||||
|
|
@ -63,37 +95,48 @@ public partial class InventoryMenu : TabContainer
|
|||
switch (state)
|
||||
{
|
||||
case GameState.Inventory:
|
||||
CallDeferred(MethodName.ShowInventory);
|
||||
//CallDeferred(MethodName.ShowInventory);
|
||||
ShowInventory();
|
||||
break;
|
||||
default:
|
||||
CallDeferred(MethodName.HideInventory);
|
||||
HideInventory();
|
||||
//_ = UnpauseAsync();
|
||||
// _ = new Task(async () =>
|
||||
// {
|
||||
// await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||
// HideInventory();
|
||||
// });
|
||||
//CallDeferred(MethodName.HideInventory);
|
||||
//HideInventory();
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task UnpauseAsync()
|
||||
{
|
||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||
HideInventory();
|
||||
}
|
||||
|
||||
private void HideInventory()
|
||||
{
|
||||
if (!Visible) return;
|
||||
GD.Print("Hiding inventory");
|
||||
this.Hide();
|
||||
if (!IsVisible()) return;
|
||||
|
||||
HideCommand();
|
||||
|
||||
foreach (var menu in _itemMenus)
|
||||
{
|
||||
menu.Empty();
|
||||
}
|
||||
|
||||
//_itemsDic.Clear();
|
||||
|
||||
//GameManager.Instance.ChangeState(GameState.Playing);
|
||||
}
|
||||
|
||||
private void ShowInventory()
|
||||
{
|
||||
if (Visible) return;
|
||||
this.Show();
|
||||
if (IsVisible()) return;
|
||||
|
||||
ShowCommand();
|
||||
|
||||
foreach (var menu in _itemMenus)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue