mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Make font drawing more generic (#5533)
* make richtextentry more generic * font * oops
This commit is contained in:
@@ -362,6 +362,11 @@ namespace Robust.Client.Graphics.Clyde
|
||||
rect.BottomLeft, rect.BottomRight, color, subRegion);
|
||||
}
|
||||
|
||||
public override void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
{
|
||||
base.DrawTexture(texture, position, modulate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws an entity.
|
||||
/// </summary>
|
||||
|
||||
@@ -211,6 +211,8 @@ namespace Robust.Client.Graphics
|
||||
public abstract void DrawLine(Vector2 from, Vector2 to, Color color);
|
||||
|
||||
public abstract void RenderInRenderTarget(IRenderTarget target, Action a, Color? clearColor);
|
||||
|
||||
public abstract void DrawTexture(Texture texture, Vector2 position, Color? modulate = null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Robust.Client.Graphics
|
||||
|
||||
public abstract void DrawTextureRectRegion(Texture texture, UIBox2 rect, UIBox2? subRegion = null, Color? modulate = null);
|
||||
|
||||
public void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
public override void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Robust.Client.Graphics
|
||||
/// <remarks>
|
||||
/// The sprite will have it's local dimensions calculated so that it has <see cref="EyeManager.PixelsPerMeter"/> texels per meter in the world.
|
||||
/// </remarks>
|
||||
public void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
public override void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Robust.Client.Graphics
|
||||
/// <param name="fallback">If the character is not available, render "<22>" instead.</param>
|
||||
/// <returns>How much to advance the cursor to draw the next character.</returns>
|
||||
public abstract float DrawChar(
|
||||
DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale,
|
||||
DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale,
|
||||
Color color, bool fallback=true);
|
||||
|
||||
/// <summary>
|
||||
@@ -109,7 +109,7 @@ namespace Robust.Client.Graphics
|
||||
public override int GetDescent(float scale) => Handle.GetDescent(scale);
|
||||
public override int GetLineHeight(float scale) => Handle.GetLineHeight(scale);
|
||||
|
||||
public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
{
|
||||
var metrics = Handle.GetCharMetrics(rune, scale);
|
||||
if (!metrics.HasValue)
|
||||
@@ -132,7 +132,10 @@ namespace Robust.Client.Graphics
|
||||
}
|
||||
|
||||
baseline += new Vector2(metrics.Value.BearingX, -metrics.Value.BearingY);
|
||||
handle.DrawTexture(texture, baseline, color);
|
||||
if(handle is DrawingHandleWorld worldhandle)
|
||||
worldhandle.DrawTextureRect(texture, Box2.FromDimensions(baseline, texture.Size));
|
||||
else
|
||||
handle.DrawTexture(texture, baseline, color);
|
||||
return metrics.Value.Advance;
|
||||
}
|
||||
|
||||
@@ -169,7 +172,7 @@ namespace Robust.Client.Graphics
|
||||
public override int GetLineHeight(float scale) => _main.GetLineHeight(scale);
|
||||
|
||||
// DrawChar just proxies to the stack, or invokes _main's fallback.
|
||||
public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
{
|
||||
foreach (var f in Stack)
|
||||
{
|
||||
@@ -207,7 +210,7 @@ namespace Robust.Client.Graphics
|
||||
public override int GetDescent(float scale) => default;
|
||||
public override int GetLineHeight(float scale) => default;
|
||||
|
||||
public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
{
|
||||
// Nada, it's a dummy after all.
|
||||
return 0;
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace Robust.Client.UserInterface
|
||||
|
||||
public readonly void Draw(
|
||||
MarkupTagManager tagManager,
|
||||
DrawingHandleScreen handle,
|
||||
DrawingHandleBase handle,
|
||||
Font defaultFont,
|
||||
UIBox2 drawBox,
|
||||
float verticalOffset,
|
||||
|
||||
Reference in New Issue
Block a user