-
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
0cc8f73
commit b482269
Showing
1 changed file
with
47 additions
and
0 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,47 @@ | ||
using Basalt.Common.Components; | ||
using Basalt.Common.Entities; | ||
using Basalt.Common.Utils; | ||
using Basalt.Raylib.Graphics; | ||
using Raylib_cs; | ||
|
||
namespace Basalt.Raylib.Components | ||
{ | ||
public class Image : UIComponent | ||
{ | ||
private string _textureKey = string.Empty; | ||
public string TextureKey | ||
{ | ||
get => _textureKey; | ||
set | ||
{ | ||
_textureKey = value; | ||
_texture = null; | ||
} | ||
} | ||
public float Scale { get; set; } = 1f; | ||
public Color Tint { get; set; } = Color.White; | ||
|
||
private Texture2D? _texture; | ||
public Image(Entity entity) : base(entity) | ||
{ | ||
} | ||
|
||
public override void OnStart() | ||
{ | ||
|
||
} | ||
|
||
public override void OnUpdate() | ||
{ | ||
|
||
} | ||
|
||
public override void OnUIRender() | ||
{ | ||
if (_texture == null) | ||
_texture = ResourceCache.Instance.GetTexture(TextureKey); | ||
var position = GetPivotedPosition(new(Raylib_cs.Raylib.GetScreenWidth(), Raylib_cs.Raylib.GetScreenHeight())) + Offset; | ||
Raylib_cs.Raylib.DrawTextureEx(_texture.Value, position, Rotation, Scale, Tint); | ||
} | ||
} | ||
} |