mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 00:56:19 +02:00
Add MaxWidth property for text rendering in UI controls and fix maxWidth parameter in canvas extension methods
This commit is contained in:
@@ -304,10 +304,11 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
Color color = Get(cmd.Properties, "Color", Color.White);
|
||||
string content = Get(cmd.Properties, "Content", string.Empty);
|
||||
int fontSize = Get(cmd.Properties, "FontSize", 12);
|
||||
int maxWidth = Get(cmd.Properties, "MaxWidth", int.MaxValue);
|
||||
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
canvas.DrawStringHeight(content, PCScreenFont.DefaultFont, color, cmd.Position.X, cmd.Position.Y, fontSize);
|
||||
canvas.DrawStringHeight(content, PCScreenFont.DefaultFont, color, cmd.Position.X, cmd.Position.Y, fontSize, maxWidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public class RenderCommand
|
||||
byte[] utf8 = Encoding.UTF8.GetBytes(text);
|
||||
WriteVarint(s, utf8.Length);
|
||||
s.Write(utf8, 0, utf8.Length);
|
||||
WriteVarint(s, GetProp("MaxWidth", int.MaxValue));
|
||||
break;
|
||||
|
||||
case RenderCommandType.DrawLine:
|
||||
@@ -142,6 +143,7 @@ public class RenderCommand
|
||||
int textLen = ReadVarint(data, ref offset);
|
||||
props["Content"] = Encoding.UTF8.GetString(data, offset, textLen);
|
||||
offset += textLen;
|
||||
props["MaxWidth"] = ReadVarint(data, ref offset);
|
||||
break;
|
||||
|
||||
case RenderCommandType.DrawLine:
|
||||
|
||||
@@ -67,6 +67,7 @@ public class Button() : Control("Button")
|
||||
["Color"] = TextColor,
|
||||
["Content"] = Text,
|
||||
["FontSize"] = Size.Height - 8,
|
||||
["MaxWidth"] = Size.Width,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ public class CheckBox() : Control("CheckBox")
|
||||
["Color"] = TextColor,
|
||||
["Content"] = Text,
|
||||
["FontSize"] = boxSize,
|
||||
["MaxWidth"] = Size.Width - boxSize - 5,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class RadioButton() : Control("RadioButton")
|
||||
["Color"] = TextColor,
|
||||
["Content"] = Text,
|
||||
["FontSize"] = Size.Height,
|
||||
["MaxWidth"] = Size.Width - Size.Height - 5,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user