-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de7f029
commit 59095ba
Showing
4 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Basalt.Common.Components; | ||
using Basalt.Common.Entities; | ||
using System.Numerics; | ||
|
||
namespace Basalt.Raylib.Components | ||
{ | ||
public class Label : UIComponent | ||
{ | ||
public string Text { get; set; } = string.Empty; | ||
public float FontSize { get; set; } = 20; | ||
public float Spacing { get; set; } = 1; | ||
public float Rotation { get; set; } = 0; | ||
public Label(Entity entity) : base(entity) | ||
{ | ||
} | ||
|
||
public override void OnStart() | ||
{ | ||
|
||
} | ||
|
||
public override void OnUpdate() | ||
{ | ||
|
||
} | ||
|
||
public override void OnUIRender() | ||
{ | ||
var position = GetPivotedPosition(new(Raylib_cs.Raylib.GetScreenWidth(), Raylib_cs.Raylib.GetScreenHeight())) + Offset; | ||
var origin = new Vector2(0, 0); | ||
Raylib_cs.Raylib.DrawTextPro(Raylib_cs.Raylib.GetFontDefault(), | ||
Text, | ||
position, | ||
Raylib_cs.Raylib.MeasureTextEx(Raylib_cs.Raylib.GetFontDefault(), Text, FontSize, Spacing) / 2, | ||
Rotation, | ||
FontSize, | ||
Spacing, | ||
Raylib_cs.Color.White); | ||
Engine.Instance.Logger?.LogDebug($"Drawing label at {position}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Basalt.Common.Components; | ||
using Basalt.Common.Entities; | ||
using Raylib_cs; | ||
|
||
namespace Basalt.TestField.Components | ||
{ | ||
internal class TestUiComponent : UIComponent | ||
{ | ||
public TestUiComponent(Entity entity) : base(entity) | ||
{ | ||
} | ||
|
||
public override void OnStart() | ||
{ | ||
|
||
} | ||
|
||
public override void OnUpdate() | ||
{ | ||
|
||
} | ||
|
||
public override void OnUIRender() | ||
{ | ||
Raylib_cs.Raylib.DrawText("Hello, world!", 10, 10, 20, Color.White); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters