/// <summary> /// Sets the character positions relative to the string's position on screen. /// </summary> public void setCharacterPositions(bool useRightPadding = true) { int index = 0; TexturedCharacter lastSeenChar = new TexturedCharacter(); foreach (var c in characters) { if (index == 0) { c.position = new Vector2(this.position.X + c.spacing.LeftPadding, this.position.Y); } else { if (useRightPadding) { c.position = new Vector2(this.position.X + c.spacing.LeftPadding + lastSeenChar.spacing.RightPadding + lastSeenChar.texture.Width * index, this.position.Y); } else { c.position = new Vector2(this.position.X + c.spacing.LeftPadding + lastSeenChar.texture.Width * index, this.position.Y); } } //StardustCore.ModCore.ModMonitor.Log(c.character.ToString()); //StardustCore.ModCore.ModMonitor.Log(c.position.ToString()); lastSeenChar = c; index++; } }
public static TexturedCharacter Copy(TexturedCharacter original) { return(new TexturedCharacter(original.character, original.pathToTexture, original.drawColor) { spacing = new CharacterSpacing(original.spacing.LeftPadding, original.spacing.RightPadding, original.spacing.TopPadding, original.spacing.BottomPadding) }); }
public static TexturedCharacter Copy(TexturedCharacter original) { if (string.IsNullOrEmpty(original.pathToTexture)) { Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice, original.texture.Width, original.texture.Height); Color[] colors = new Color[text.Width * text.Height]; original.texture.GetData(colors); text.SetData(colors); return(new TexturedCharacter(original.character, text, original.drawColor) { spacing = new CharacterSpacing(original.spacing.LeftPadding, original.spacing.RightPadding, original.spacing.TopPadding, original.spacing.BottomPadding) }); } return(new TexturedCharacter(original.character, original.pathToTexture, original.drawColor) { spacing = new CharacterSpacing(original.spacing.LeftPadding, original.spacing.RightPadding, original.spacing.TopPadding, original.spacing.BottomPadding) }); }
/// <summary> /// Adds a textured character to a textured string. /// </summary> /// <param name="ch"></param> public void addCharacterToEnd(TexturedCharacter ch, bool useRightPadding = true) { this.characters.Add(ch); this.setCharacterPositions(useRightPadding); }
/// <summary> /// Adds a textured character to a textured string. /// </summary> /// <param name="ch"></param> public void addCharacterToEnd(TexturedCharacter ch) { this.characters.Add(ch); this.setCharacterPositions(); }