public HudTextBoard(string pText, float px, float py, int width, int height, int textSize, CenterMode hor = CenterMode.Min, CenterMode ver = CenterMode.Min) { this.x = px; this.y = py; this._text = pText; _easyDraw = new EasyDraw(width, height, false); _easyDraw.TextFont("data/Gaiatype.ttf", 12); if (!string.IsNullOrEmpty(pText)) { _easyDraw.TextSize(textSize); _easyDraw.TextDimensions(_text, out var w, out var h); var wr = Mathf.Round(w); var hr = Mathf.Round(h); if (wr <= 0) { wr = 10; } if (hr <= 0) { hr = 10; } _easyDraw = new EasyDraw(wr, hr, false); } _easyDraw.TextFont("data/Gaiatype.ttf", 12); _easyDraw.TextSize(textSize); _easyDraw.TextAlign(hor, ver); AddChild(_easyDraw); if (hor == CenterMode.Center) { _textX = _easyDraw.width * 0.5f; } else if (hor == CenterMode.Max) { _textX = _easyDraw.width; } if (ver == CenterMode.Center) { _textY = _easyDraw.height * 0.5f; } else if (ver == CenterMode.Max) { _textY = _easyDraw.height; } SetText(_text); }
void InititalizeText(string text) //For text to overlay over the HUD { if (text == null) { return; } textContainer = new EasyDraw(ElementTexture.width, ElementTexture.height, false); textContainer.TextAlign(CenterMode.Center, CenterMode.Center); UpdateString(text); AddChild(textContainer); }
public HudScore(string filename) : base(filename, false, false) { //Hud score text //"VAGRundschriftD" _scoreLabelEasyDraw = new EasyDraw(350, 40, false); AddChild(_scoreLabelEasyDraw); //78 115 _scoreLabelEasyDraw.SetXY(60, 70); _scoreLabelEasyDraw.Clear(Color.FromArgb(1, 1, 1, 1)); _scoreLabelEasyDraw.TextFont($"data/VAGRundschriftD.ttf", 32); _scoreLabelEasyDraw.Fill(Color.White); _scoreLabelEasyDraw.TextAlign(CenterMode.Min, CenterMode.Min); _scoreLabelEasyDraw.Text($"{_score:00000000000000}", 0, 0); //"00000000000000" 14 digits }