summaryrefslogtreecommitdiff
path: root/source/screens/TextTestScreen.cs
diff options
context:
space:
mode:
authorhazel <hazel@hazelthats.me>2026-01-26 22:04:39 +0100
committerhazel <hazel@hazelthats.me>2026-01-26 22:04:39 +0100
commit567c422f8cd42eba2437f9a8c2522716a1649be7 (patch)
tree93c5b296f3b7c14b626d0aadf5cad37764c41c74 /source/screens/TextTestScreen.cs
downloadcelesteia-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/screens/TextTestScreen.cs')
-rw-r--r--source/screens/TextTestScreen.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/source/screens/TextTestScreen.cs b/source/screens/TextTestScreen.cs
new file mode 100644
index 0000000..2e772df
--- /dev/null
+++ b/source/screens/TextTestScreen.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Diagnostics;
+using Celesteia.Game.Input;
+using Celesteia.Resources;
+using Celesteia.UI;
+using Celesteia.UI.Elements;
+using Celesteia.UI.Properties;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using MonoGame.Extended.Screens;
+
+namespace Celesteia.Screens {
+ public class TextTestScreen : GameScreen {
+ private new GameInstance Game => (GameInstance) base.Game;
+ public TextTestScreen(GameInstance game) : base(game) {}
+
+ private IContainer Root;
+
+ private Label topLeft;
+ //private Label topCenter;
+ //private Label topRight;
+ //private Label middleLeft;
+ //private Label middle;
+ //private Label middleRight;
+ //private Label bottomLeft;
+ //private Label bottom;
+ private Label bottomRight;
+
+ private TextProperties properties;
+ private float _fontSize = 24f;
+
+ public override void LoadContent()
+ {
+ base.LoadContent();
+
+ Root = new Container(Rect.ScreenFull);
+
+ properties = new TextProperties().SetColor(Color.White).SetFont(ResourceManager.Fonts.GetFontType("Hobo")).SetText("Hello, world!");
+
+ topLeft = new Label(new Rect(AbsoluteUnit.WithValue(50), AbsoluteUnit.WithValue(50), AbsoluteUnit.WithValue(100), AbsoluteUnit.WithValue(100)));
+ Root.AddChild(topLeft);
+ bottomRight = new Label(new Rect(AbsoluteUnit.WithValue(50), AbsoluteUnit.WithValue(150), AbsoluteUnit.WithValue(100), AbsoluteUnit.WithValue(100)));
+ Root.AddChild(bottomRight);
+ }
+
+ public override void Update(GameTime gameTime) {
+ _fontSize += MouseHelper.ScrollDelta;
+ _fontSize = Math.Clamp(_fontSize, 1f, 100f);
+
+ topLeft.SetTextProperties(properties.Clone().SetTextAlignment(TextAlignment.Top | TextAlignment.Left).SetFontSize(_fontSize));
+ bottomRight.SetTextProperties(properties.Clone().SetTextAlignment(TextAlignment.Bottom | TextAlignment.Right).SetFontSize(_fontSize));
+ }
+
+ public override void Draw(GameTime gameTime)
+ {
+ GraphicsDevice.Clear(Color.Black);
+
+ Game.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp);
+
+ Root.Draw(Game.SpriteBatch);
+
+ Game.SpriteBatch.End();
+ }
+
+ public override void Dispose()
+ {
+ Debug.WriteLine("Unloading TextTestScreen content...");
+ base.UnloadContent();
+ Debug.WriteLine("Disposing TextTestScreen...");
+ base.Dispose();
+ }
+ }
+} \ No newline at end of file