diff --git a/TestGame/TestGame.cs b/TestGame/TestGame.cs index caf1412..2d09539 100644 --- a/TestGame/TestGame.cs +++ b/TestGame/TestGame.cs @@ -12,14 +12,16 @@ public class TestGame : Game { public override string ResourceRoot => "Resources/"; + public TestGame() : base() + { + } + public override void Initialize() { _renderer = new RaylibRenderer(); _audioBackend = new FmodAudioBackend(); _inputHandler = new RaylibInputHandler(); - _resourceManager.AddResourceSaverAssociation(new SerializedSceneSaver()); - _renderer.CreateAndInitialize(new WindowSettings() { Title = "Test Game", @@ -37,29 +39,23 @@ public class TestGame : Game Renderer = _renderer, AudioBackend = _audioBackend, InputHandler = _inputHandler, - ResourceManager = _resourceManager + ResourceManager = ResourceManager }); _uiLayer = new UiLayer(); _worldLayer = new EntityLayer(); } - public override void Shutdown() - { - _renderer!.Shutdown(); - _audioBackend?.Shutdown(); - } - protected override void LoadResources() { - if (_resourceManager.TryLoad("my_sound", "sounds/test_sound.ogg")) + if (ResourceManager.TryLoad("my_sound", "sounds/test_sound.ogg")) { - _resourceManager.TryGetResource("my_sound", out _testSound); + ResourceManager.TryGetResource("my_sound", out _testSound); } - if (_resourceManager.TryLoad("inter_regular", "fonts/Inter-Regular.ttf")) + if (ResourceManager.TryLoad("inter_regular", "fonts/Inter-Regular.ttf")) { - _resourceManager.TryGetResource("inter_regular", out _font); + ResourceManager.TryGetResource("inter_regular", out _font); if (_font is not null) { @@ -93,8 +89,13 @@ public class TestGame : Game } } + public override void Shutdown() + { + _renderer!.Shutdown(); + _audioBackend?.Shutdown(); + } + private Renderer? _renderer; - private ResourceManager _resourceManager = new(); private Sound? _testSound; private Font? _font; private FmodAudioBackend? _audioBackend; diff --git a/Voile.sln b/Voile.sln index ce3376a..755126d 100644 --- a/Voile.sln +++ b/Voile.sln @@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Folder", "Solution README.md = README.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestGame", "TestGame\TestGame.csproj", "{DBA85D7B-0A91-405B-9078-5463F49AE47E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -28,5 +30,9 @@ Global {DA4FDEDC-AA81-4336-844F-562F9E763974}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA4FDEDC-AA81-4336-844F-562F9E763974}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA4FDEDC-AA81-4336-844F-562F9E763974}.Release|Any CPU.Build.0 = Release|Any CPU + {DBA85D7B-0A91-405B-9078-5463F49AE47E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DBA85D7B-0A91-405B-9078-5463F49AE47E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DBA85D7B-0A91-405B-9078-5463F49AE47E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DBA85D7B-0A91-405B-9078-5463F49AE47E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Voile/Source/Game.cs b/Voile/Source/Game.cs index 7cfc7e2..6d68552 100644 --- a/Voile/Source/Game.cs +++ b/Voile/Source/Game.cs @@ -1,8 +1,20 @@ +using Voile.Resources; + namespace Voile { public abstract class Game { + /// + /// The ResourceManager associated with this game. + /// + protected ResourceManager ResourceManager { get; private set; } public abstract string ResourceRoot { get; } + public virtual string EngineConfigPath => "engine.config"; + + public Game() + { + ResourceManager = new ResourceManager(); + } /// /// Starts the game application. @@ -10,6 +22,8 @@ namespace Voile /// public void Start() { + Configure(); + Initialize(); LoadResources(); Ready(); @@ -37,5 +51,10 @@ namespace Voile /// Called when the application quits and it's safe to clean up. /// public abstract void Shutdown(); + + private void Configure() + { + ResourceManager.ResourceRoot = ResourceRoot; + } } } \ No newline at end of file diff --git a/Voile/Source/Resources/ResourceManager.cs b/Voile/Source/Resources/ResourceManager.cs index de0b69d..cb16586 100644 --- a/Voile/Source/Resources/ResourceManager.cs +++ b/Voile/Source/Resources/ResourceManager.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using System.Linq; using Voile.Utils;