diff options
| author | hazel <hazel@hazelthats.me> | 2026-01-26 22:04:39 +0100 |
|---|---|---|
| committer | hazel <hazel@hazelthats.me> | 2026-01-26 22:04:39 +0100 |
| commit | 567c422f8cd42eba2437f9a8c2522716a1649be7 (patch) | |
| tree | 93c5b296f3b7c14b626d0aadf5cad37764c41c74 /source/ui/guis/GUI.cs | |
| download | celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.tar.gz celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.tar.bz2 celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.zip | |
celesteia archive, last updated april 9th 2024
Signed-off-by: hazel <hazel@hazelthats.me>
Diffstat (limited to 'source/ui/guis/GUI.cs')
| -rw-r--r-- | source/ui/guis/GUI.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/ui/guis/GUI.cs b/source/ui/guis/GUI.cs new file mode 100644 index 0000000..6d00070 --- /dev/null +++ b/source/ui/guis/GUI.cs @@ -0,0 +1,48 @@ +using System.Diagnostics; +using Celesteia.UI; +using Celesteia.UI.Elements; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; + +namespace Celesteia.GUIs { + public class GUI { + public GameInstance Game; + + public IContainer Root; + + public GUI(GameInstance Game, Rect rect) { + this.Game = Game; + this.Root = new Container(rect); + } + + public virtual void LoadContent(ContentManager Content) { + Debug.WriteLine("Loaded GUI."); + } + + public virtual void Update(GameTime gameTime, out bool clickedAnything) { + if (!Game.IsActive) { + clickedAnything = false; + return; + } + + Root.Update(gameTime, out clickedAnything); + } + + // Draw all elements. + public virtual void Draw(GameTime gameTime) { + + Game.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointWrap, null, null, null); + + if (UIReferences.GUIEnabled) Root.Draw(Game.SpriteBatch); + + Game.SpriteBatch.End(); + } + + // If the menu is referred to as a boolean, return whether it is non-null (true) or null (false). + public static implicit operator bool(GUI gui) + { + return !object.ReferenceEquals(gui, null); + } + } +}
\ No newline at end of file |
