/// <summary> /// Scrolls all text up. /// </summary> /*public void ScrollTextUp() * { * foreach (RenderableText2 Txt in m_RenderableLines) * Txt.Position.Y -= m_LineHeight; * * m_RenderableLines[m_VisibilityIndex].Visible = false; * m_VisibilityIndex++; * }*/ /// <summary> /// Removes a character of renderable text from the input at the specified index. /// </summary> /// <param name="Index">The index at which to remove a renderable character.</param> public void RemoveAt(int Index) { if (Index > 0 && m_CurrentLine.Count >= 1) { m_CurrentTextPosition.X -= m_Font.MeasureString(m_CurrentLine[Index].Char).X; RenderableCharacter RenderChar = m_CurrentLine[Index]; RenderChar.Char = ""; m_CurrentLine.RemoveAt(Index); m_CurrentLine.Insert(Index, RenderChar); } }
/// <summary> /// Inserts a character into this TextRenderer instance. /// </summary> /// <param name="Index">The index at which to insert text.</param> /// <param name="Char">The character to insert.</param> public void Insert(int Index, string Char) { if (m_MultiLine) { if (m_CurrentTextPosition.X < m_TextboxSize.X) { m_CurrentTextPosition.X += m_Font.MeasureString(Char).X; RenderableCharacter RenderChar = new RenderableCharacter(); RenderChar.Position = m_CurrentTextPosition; RenderChar.Visible = true; RenderChar.Char = Char; if (m_CurrentLine.Capacity <= Index) { m_CurrentLine.Capacity++; } m_CurrentLine.Insert(Index, RenderChar); } else { RenderableText2 Line = new RenderableText2(); Line.Text = GetCurrentLine(); Line.Position = new Vector2(m_TextboxPosition.X + 2, m_CurrentTextPosition.Y); Line.Visible = true; m_RenderableLines.Add(Line); if (m_CurrentTextPosition.Y <= m_TextboxPosition.Y + ((m_NumLines - 2) * m_Font.LineSpacing)) { m_CurrentTextPosition.Y += m_Font.LineSpacing; } m_CurrentLine.Clear(); m_CurrentTextPosition.X = m_TextboxPosition.X; RenderableCharacter RenderChar = new RenderableCharacter(); RenderChar.Position = m_CurrentTextPosition; RenderChar.Visible = true; RenderChar.Char = Char; if (m_CurrentTextPosition.Y >= m_TextboxPosition.Y + ((m_NumLines - 2) * m_Font.LineSpacing)) { foreach (RenderableText2 Txt in m_RenderableLines) { Txt.Position.Y -= m_Font.LineSpacing; } m_RenderableLines[m_VisibilityIndex].Visible = false; m_VisibilityIndex++; } m_CurrentLine.Insert(0, RenderChar); } } else { if (m_CurrentTextPosition.X < m_TextboxSize.X) { m_CurrentTextPosition.X += m_Font.MeasureString(Char).X; } else { ScrollTextLeft(); } RenderableCharacter RenderChar = new RenderableCharacter(); RenderChar.Position = m_CurrentTextPosition; RenderChar.Char = Char; m_CurrentLine.Insert(Index, RenderChar); } }