3 using System.Collections.Immutable;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Graphics;
12 public bool HasText => !
string.IsNullOrEmpty(previewText);
17 private string previewText =
string.Empty;
18 private Vector2 textSize;
20 private bool isSectioned;
21 private ImmutableArray<RichTextData>? richTextData;
30 textSize = Vector2.Zero;
31 previewText =
string.Empty;
36 public void UpdateText(
string text,
int start,
int length)
38 isSectioned = start >= 0 && length > 0;
41 if (
string.IsNullOrEmpty(text))
51 if (!isSectioned) {
return; }
53 string coloredText = ToolBox.ColorSectionOfString(text, start, length, GUIStyle.Orange);
65 int inflate = GUI.IntScale(3);
67 RectangleF rect =
new RectangleF(position, textSize);
68 rect.Inflate(inflate, inflate);
70 RectangleF borderRect = rect;
71 borderRect.Inflate(1, 1);
73 GUI.DrawFilledRectangle(spriteBatch, borderRect, Color.White, depth: 0.02f);
74 GUI.DrawFilledRectangle(spriteBatch, rect, Color.Black, depth: 0.01f);
79 color: isSectioned ? GUIStyle.TextColorNormal : GUIStyle.Orange,
83 spriteEffects: SpriteEffects.None,
85 richTextData: richTextData,
Vector2 MeasureString(LocalizedString str, bool removeExtraSpacing=false)
void DrawStringWithColors(SpriteBatch sb, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects spriteEffects, float layerDepth, in ImmutableArray< RichTextData >? richTextData, int rtdOffset=0, Alignment alignment=Alignment.TopLeft, ForceUpperCase forceUpperCase=Barotrauma.ForceUpperCase.Inherit)
ForceUpperCase ForceUpperCase
void UpdateText(string text, int start, int length)
void DrawIMEPreview(SpriteBatch spriteBatch, Vector2 position, GUITextBlock textBlock)
IMEPreviewTextHandler(GUIFont font)
ImmutableArray< RichTextData >? RichTextData
static RichString Rich(LocalizedString str, Func< string, string >? postProcess=null)