From 44a366f475a103cc589f08fd39d38b042826a92d Mon Sep 17 00:00:00 2001 From: Syntriax Date: Fri, 25 Jul 2025 21:53:38 +0300 Subject: [PATCH] refactor: implemented engine's ILoadContent for loading content --- Engine | 2 +- Shared/Behaviours/ScoreLabel.cs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Engine b/Engine index 65cfaf1..ad365dc 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 65cfaf1b4a0d09eb396b3fdc98c52539af384f36 +Subproject commit ad365dc7225df5df0d8be0729f6c62490c845f77 diff --git a/Shared/Behaviours/ScoreLabel.cs b/Shared/Behaviours/ScoreLabel.cs index 397163b..c709c6d 100644 --- a/Shared/Behaviours/ScoreLabel.cs +++ b/Shared/Behaviours/ScoreLabel.cs @@ -1,3 +1,4 @@ +using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Syntriax.Engine.Core; @@ -5,7 +6,7 @@ using Syntriax.Engine.Integration.MonoGame; namespace Pong.Behaviours; -public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate +public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate, ILoadContent { public readonly bool IsLeft = IsLeft; @@ -13,9 +14,6 @@ public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate public void FirstActiveFrame() { - MonoGameWindow monoGameWindow = Universe.FindRequiredBehaviour().Window; - Font = monoGameWindow.Content.Load("UbuntuMono"); - pongManager = Universe.FindRequiredBehaviour(); pongManager.OnScoreUpdated += UpdateScores; @@ -24,6 +22,11 @@ public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate UpdateScores(pongManager); } + public void LoadContent(ContentManager content) + { + Font = content.Load("UbuntuMono"); + } + private void UpdateScores(PongManager pongManager) { if (IsLeft)