From 4c7a35179e76cd5ee130b90b7e15decfe0200484 Mon Sep 17 00:00:00 2001 From: John Pavek Date: Wed, 31 Jan 2024 00:15:06 -0600 Subject: [PATCH] Music fixes finally. --- NovemberPiratesEngine.cs | 10 +++++++--- Scenes/Menus/MainMenu/CreditsScene.cs | 7 +++++-- Scenes/Menus/MainMenu/HowToPlayScene.cs | 5 ++++- Scenes/Menus/MainMenu/MainMenuScene.cs | 12 ++++++++---- Scenes/Menus/MainMenu/SettingsScene.cs | 22 ++++++++++++---------- Scenes/Menus/Systems/MenuMusicSystem.cs | 1 - Utilities/SettingsManager.cs | 3 +-- 7 files changed, 37 insertions(+), 23 deletions(-) diff --git a/NovemberPiratesEngine.cs b/NovemberPiratesEngine.cs index 3141a9d..20ce74b 100644 --- a/NovemberPiratesEngine.cs +++ b/NovemberPiratesEngine.cs @@ -19,11 +19,15 @@ public void StartGame() //Raylib.SetConfigFlags(ConfigFlags.FLAG_WINDOW_TOPMOST); //Raylib.SetConfigFlags(ConfigFlags.FLAG_WINDOW_MAXIMIZED); //Raylib.SetConfigFlags(ConfigFlags.FLAG_WINDOW_UNDECORATED); + + Raylib.InitWindow(0,0, "November Pirates"); - var width = Raylib.GetMonitorWidth(0); - var height = Raylib.GetMonitorHeight(0); + var monitor = Raylib.GetCurrentMonitor(); + var width = Raylib.GetMonitorWidth(monitor); + var height = Raylib.GetMonitorHeight(monitor); + + Raylib.SetWindowSize(width, height); - Raylib.InitWindow(width, height, "November Pirates"); Raylib.SetTargetFPS(60); Raylib.InitAudioDevice(); Raylib.SetExitKey(0); diff --git a/Scenes/Menus/MainMenu/CreditsScene.cs b/Scenes/Menus/MainMenu/CreditsScene.cs index 837253f..49a64d0 100644 --- a/Scenes/Menus/MainMenu/CreditsScene.cs +++ b/Scenes/Menus/MainMenu/CreditsScene.cs @@ -1,4 +1,5 @@ -using NovemberPirates.Scenes.Menus.Components; +using NovemberPirates.Components; +using NovemberPirates.Scenes.Menus.Components; using NovemberPirates.Scenes.Menus.Systems; using Raylib_CsLo; @@ -6,11 +7,13 @@ namespace NovemberPirates.Scenes.Menus.MainMenu { internal class CreditsScene : BaseScene { - public CreditsScene() + public CreditsScene(Singleton singleton) { Systems.Add(new MenuSystem()); Systems.Add(new MenuMusicSystem()); + World.Create(singleton); + var index = 5; World.Create(new UiContainer { Rectangle = new Rectangle() }); diff --git a/Scenes/Menus/MainMenu/HowToPlayScene.cs b/Scenes/Menus/MainMenu/HowToPlayScene.cs index a55651b..a848b51 100644 --- a/Scenes/Menus/MainMenu/HowToPlayScene.cs +++ b/Scenes/Menus/MainMenu/HowToPlayScene.cs @@ -1,5 +1,6 @@ using Arch.Core; using Arch.Core.Extensions; +using NovemberPirates.Components; using NovemberPirates.Scenes.Menus.Components; using NovemberPirates.Scenes.Menus.Systems; using Raylib_CsLo; @@ -8,11 +9,13 @@ namespace NovemberPirates.Scenes.Menus.MainMenu { internal class HowToPlayScene : BaseScene { - public HowToPlayScene() + public HowToPlayScene(Singleton singleton) { Systems.Add(new MenuSystem()); Systems.Add(new MenuMusicSystem()); + World.Create(singleton); + var index = 5; World.Create(new UiContainer { Rectangle = new Rectangle() }); diff --git a/Scenes/Menus/MainMenu/MainMenuScene.cs b/Scenes/Menus/MainMenu/MainMenuScene.cs index 454dfc5..e956cd3 100644 --- a/Scenes/Menus/MainMenu/MainMenuScene.cs +++ b/Scenes/Menus/MainMenu/MainMenuScene.cs @@ -1,4 +1,6 @@ -using NovemberPirates.Components; +using Arch.Core.Extensions; +using NovemberPirates.Components; +using NovemberPirates.Extensions; using NovemberPirates.Scenes.Levels; using NovemberPirates.Scenes.Levels.Components; using NovemberPirates.Scenes.Menus.Components; @@ -13,10 +15,12 @@ internal class MainMenuScene : BaseScene { public MainMenuScene() { + Systems.Add(new MenuSystem()); Systems.Add(new MenuMusicSystem()); - World.Create(new Singleton() { Music = AudioKey.DreamingOfTreasure }); + var singleton = new Singleton() { Music = AudioKey.DreamingOfTreasure }; + World.Create(singleton); var width = Raylib.GetScreenWidth() * 0.7f; @@ -45,7 +49,7 @@ public MainMenuScene() Text = "HowToPlay", Action = () => { - NovemberPiratesEngine.Instance.ActiveScene = new HowToPlayScene(); + NovemberPiratesEngine.Instance.ActiveScene = new HowToPlayScene(singleton); }, Order = 2, TextSprite = new Sprite(TextureKey.Words, "Assets/Art/words") @@ -65,7 +69,7 @@ public MainMenuScene() Text = "Credits", Action = () => { - NovemberPiratesEngine.Instance.ActiveScene = new CreditsScene(); + NovemberPiratesEngine.Instance.ActiveScene = new CreditsScene(singleton); }, Order = 3, TextSprite = new Sprite(TextureKey.Words, "Assets/Art/words") diff --git a/Scenes/Menus/MainMenu/SettingsScene.cs b/Scenes/Menus/MainMenu/SettingsScene.cs index 65a8703..5bdc8cc 100644 --- a/Scenes/Menus/MainMenu/SettingsScene.cs +++ b/Scenes/Menus/MainMenu/SettingsScene.cs @@ -1,4 +1,5 @@ -using Arch.Core.Extensions; +using Arch.Core; +using NovemberPirates.Components; using NovemberPirates.Scenes.Menus.Components; using NovemberPirates.Scenes.Menus.Systems; using Raylib_CsLo; @@ -7,21 +8,22 @@ namespace NovemberPirates.Scenes.Menus.MainMenu { internal class SettingsScene : BaseScene { - public SettingsScene() + public SettingsScene(Singleton singleton) { Systems.Add(new MenuSystem()); Systems.Add(new MenuMusicSystem()); - - var index = 5; + World.Create(singleton); World.Create(new UiContainer { Rectangle = new Rectangle() }); - var instructions = World.Create(); - instructions.Set(new UiTitle { Text = @"WASD to move Q/E or Arrow keys to shoot", Order = index++ }); - var instructions2 = World.Create(); - instructions2.Set(new UiTitle { Text = @"f3 to change the wind", Order = index++ }); - var instructions3 = World.Create(); - instructions3.Set(new UiTitle { Text = @"F2 for the debugger I'm proud of", Order = index++ }); + var index = 5; + + //var instructions = World.Create(); + //instructions.Set(new UiTitle { Text = @"WASD to move Q/E or Arrow keys to shoot", Order = index++ }); + //var instructions2 = World.Create(); + //instructions2.Set(new UiTitle { Text = @"f3 to change the wind", Order = index++ }); + //var instructions3 = World.Create(); + //instructions3.Set(new UiTitle { Text = @"F2 for the debugger I'm proud of", Order = index++ }); World.Create(new UiButton { diff --git a/Scenes/Menus/Systems/MenuMusicSystem.cs b/Scenes/Menus/Systems/MenuMusicSystem.cs index 21b81f6..a251bdc 100644 --- a/Scenes/Menus/Systems/MenuMusicSystem.cs +++ b/Scenes/Menus/Systems/MenuMusicSystem.cs @@ -15,7 +15,6 @@ internal override void Update(World world) var singletonEntity = world.QueryFirst(); var singleton = singletonEntity.Get(); - var music = AudioManager.Instance.GetMusic(singleton.Music); if (Raylib.IsMusicStreamPlaying(music)) { diff --git a/Utilities/SettingsManager.cs b/Utilities/SettingsManager.cs index e6bfb9d..6203fda 100644 --- a/Utilities/SettingsManager.cs +++ b/Utilities/SettingsManager.cs @@ -1,5 +1,4 @@ -using System.Security.Cryptography.X509Certificates; -using System.Text.Json; +using System.Text.Json; namespace NovemberPirates.Utilities {