Support opening monster viewer screen from main menu

This commit is contained in:
2025-09-25 03:55:20 -07:00
parent 84f0f8338f
commit 78e08bec5c
7 changed files with 36 additions and 32 deletions

View File

@@ -14,6 +14,7 @@ public partial class AppLogic
} }
public Transition On(in Input.NewGame input) => To<GameStarted>(); public Transition On(in Input.NewGame input) => To<GameStarted>();
public Transition On(in Input.EnemyViewerOpened input) => To<EnemyViewer>(); public Transition On(in Input.EnemyViewerOpened input) => To<EnemyViewer>();
} }
} }

View File

@@ -186,11 +186,13 @@ Interact={
Next={ Next={
"deadzone": 0.2, "deadzone": 0.2,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null) "events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
] ]
} }
Previous={ Previous={
"deadzone": 0.2, "deadzone": 0.2,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null) "events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
] ]
} }
Save={ Save={

View File

@@ -36,7 +36,9 @@ public partial class App : Node, IApp
private Array _progress; private Array _progress;
private AutoProp<bool> _loaded = new(false); private AutoProp<string> _loadedScene = new(string.Empty);
private bool _loadingGame = false;
private bool _loadingEnemyViewer = false;
public void Initialize() public void Initialize()
{ {
@@ -47,8 +49,9 @@ public partial class App : Node, IApp
MainMenu.NewGame += OnNewGame; MainMenu.NewGame += OnNewGame;
MainMenu.LoadGame += OnLoadGame; MainMenu.LoadGame += OnLoadGame;
MainMenu.EnemyViewer += OnEnemyViewer;
MainMenu.Quit += OnQuit; MainMenu.Quit += OnQuit;
_loaded.Sync += OnGameLoaded; _loadedScene.Changed += OnGameLoaded;
Instantiator = new Instantiator(GetTree()); Instantiator = new Instantiator(GetTree());
@@ -63,17 +66,14 @@ public partial class App : Node, IApp
this.Provide(); this.Provide();
} }
private void OnGameLoaded(bool gameLoaded) private void OnGameLoaded(string sceneName)
{
if (gameLoaded)
{ {
Loading.Hide(); Loading.Hide();
var gameScene = (PackedScene)ResourceLoader.LoadThreadedGet(GAME_SCENE_PATH); var scene = (PackedScene)ResourceLoader.LoadThreadedGet(sceneName);
var game = gameScene.Instantiate(); var node = scene.Instantiate();
AddChild(game); AddChild(node);
Instantiator.SceneTree.Paused = false; Instantiator.SceneTree.Paused = false;
} }
}
public void OnReady() public void OnReady()
{ {
@@ -88,7 +88,8 @@ public partial class App : Node, IApp
}) })
.Handle((in AppLogic.Output.SetupGameScene _) => .Handle((in AppLogic.Output.SetupGameScene _) =>
{ {
ResourceLoader.LoadThreadedRequest(GAME_SCENE_PATH, useSubThreads: true, cacheMode: ResourceLoader.CacheMode.Ignore); ResourceLoader.LoadThreadedRequest(GAME_SCENE_PATH);
_loadingGame = true;
MainMenu.Hide(); MainMenu.Hide();
}) })
.Handle((in AppLogic.Output.ShowMainMenu _) => .Handle((in AppLogic.Output.ShowMainMenu _) =>
@@ -102,7 +103,9 @@ public partial class App : Node, IApp
}) })
.Handle((in AppLogic.Output.EnemyViewerOpened _) => .Handle((in AppLogic.Output.EnemyViewerOpened _) =>
{ {
Instantiator.LoadAndInstantiate<Node>(ENEMY_VIEWER_PATH); ResourceLoader.LoadThreadedRequest(ENEMY_VIEWER_PATH);
_loadingEnemyViewer = true;
MainMenu.Hide();
}) })
.Handle((in AppLogic.Output.ExitGame _) => .Handle((in AppLogic.Output.ExitGame _) =>
{ {
@@ -115,16 +118,25 @@ public partial class App : Node, IApp
public override void _Process(double delta) public override void _Process(double delta)
{ {
if (!_loaded.Value) if (_loadingGame)
{ {
ResourceLoader.LoadThreadedGetStatus(GAME_SCENE_PATH, _progress); ResourceLoader.LoadThreadedGetStatus(GAME_SCENE_PATH, _progress);
if ((double)_progress.Single() == 1) if ((double)_progress.Single() == 1)
_loaded.OnNext(true); _loadedScene.OnNext(GAME_SCENE_PATH);
}
if (_loadingEnemyViewer)
{
ResourceLoader.LoadThreadedGetStatus(ENEMY_VIEWER_PATH, _progress);
if ((double)_progress.Single() == 1)
_loadedScene.OnNext(ENEMY_VIEWER_PATH);
} }
} }
public void OnNewGame() => AppLogic.Input(new AppLogic.Input.NewGame()); public void OnNewGame() => AppLogic.Input(new AppLogic.Input.NewGame());
private void OnEnemyViewer() => AppLogic.Input(new AppLogic.Input.EnemyViewerOpened());
private void OnLoadGame() => AppLogic.Input(new AppLogic.Input.LoadGame()); private void OnLoadGame() => AppLogic.Input(new AppLogic.Input.LoadGame());
public void OnQuit() => AppLogic.Input(new AppLogic.Input.QuitGame()); public void OnQuit() => AppLogic.Input(new AppLogic.Input.QuitGame());

View File

@@ -152,11 +152,10 @@ offset_top = -228.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
theme = ExtResource("2_bef6s") theme = ExtResource("2_bef6s")
text = "Switch: L1/R1 text = "Switch: L1/R1 or <- ->
Primary Attack: X Primary Attack: X (Space)
Secondary Attack: ◻ Secondary Attack: ◻ (RMB)
Activate: △ Activate: △ (E)"
Press ○ to exit"
[node name="DataViewerRepository" parent="." instance=ExtResource("3_ejdn0")] [node name="DataViewerRepository" parent="." instance=ExtResource("3_ejdn0")]
unique_name_in_owner = true unique_name_in_owner = true

View File

@@ -41,8 +41,6 @@ public partial class Game : Node3D, IGame
[Node] private DeathMenu DeathMenu { get; set; } = default!; [Node] private DeathMenu DeathMenu { get; set; } = default!;
[Node] private IPauseMenu PauseMenu { get; set; } = default!; [Node] private IPauseMenu PauseMenu { get; set; } = default!;
[Node] private Timer DoubleEXPTimer { get; set; } = default!;
#endregion #endregion
#region Save #region Save
@@ -238,8 +236,6 @@ public partial class Game : Node3D, IGame
GameRepo.RestorativePickedUp += GameEventDepot_RestorativePickedUp; GameRepo.RestorativePickedUp += GameEventDepot_RestorativePickedUp;
DoubleEXPTimer.Timeout += DoubleEXPTimer_Timeout;
DeathMenu.NewGame += OnContinueGame; DeathMenu.NewGame += OnContinueGame;
DeathMenu.QuitGame += OnQuit; DeathMenu.QuitGame += OnQuit;
@@ -398,8 +394,6 @@ public partial class Game : Node3D, IGame
private void IsPaused_Sync(bool isPaused) => GetTree().Paused = isPaused; private void IsPaused_Sync(bool isPaused) => GetTree().Paused = isPaused;
private void DoubleEXPTimer_Timeout() => GameRepo.EndDoubleExp();
private void FinishedLoadingSaveFile() => EmitSignal(SignalName.SaveFileLoaded); private void FinishedLoadingSaveFile() => EmitSignal(SignalName.SaveFileLoaded);
private void EnactConsumableItemEffects(ConsumableItem consumableItem) private void EnactConsumableItemEffects(ConsumableItem consumableItem)

View File

@@ -42,12 +42,6 @@ render_target_update_mode = 4
unique_name_in_owner = true unique_name_in_owner = true
process_mode = 1 process_mode = 1
[node name="StatusEffectTimers" type="Node" parent="SubViewportContainer/SubViewport/PauseContainer"]
[node name="DoubleEXPTimer" type="Timer" parent="SubViewportContainer/SubViewport/PauseContainer/StatusEffectTimers"]
unique_name_in_owner = true
wait_time = 30.0
[node name="InGameUI" parent="." instance=ExtResource("5_lxtnp")] [node name="InGameUI" parent="." instance=ExtResource("5_lxtnp")]
unique_name_in_owner = true unique_name_in_owner = true
custom_minimum_size = Vector2(1280, 720) custom_minimum_size = Vector2(1280, 720)

View File

@@ -9,6 +9,8 @@ public interface IMainMenu : IControl
{ {
event MainMenu.NewGameEventHandler NewGame; event MainMenu.NewGameEventHandler NewGame;
event MainMenu.LoadGameEventHandler LoadGame; event MainMenu.LoadGameEventHandler LoadGame;
event MainMenu.EnemyViewerEventHandler EnemyViewer;
event MainMenu.GalleryEventHandler Gallery;
event MainMenu.QuitEventHandler Quit; event MainMenu.QuitEventHandler Quit;
void FadeIn(); void FadeIn();