From e1553ca6d872ca3e8869e988548ef7cf91065a9a Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 21 Jul 2019 17:12:06 -0700 Subject: [PATCH] Updated texture string to basically be able to change it's text a lot easier. --- .../SSCMenus/HUD/CharacterHUD.cs | 4 +++ .../Fonts/Components/TexturedString.cs | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/HUD/CharacterHUD.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/HUD/CharacterHUD.cs index e699368b..fc3f7f3c 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/HUD/CharacterHUD.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCMenus/HUD/CharacterHUD.cs @@ -41,6 +41,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus.HUD if (SeasideScramble.self.getPlayer(this.playerID) != null) { this.background.color = SeasideScramble.self.getPlayer(this.playerID).playerColor; + if (this.str.getText() != "345") + { + this.str.setText("345", SeasideScramble.self.gameFont, Color.White); + } } } diff --git a/GeneralMods/StardustCore/UIUtilities/SpriteFonts/Fonts/Components/TexturedString.cs b/GeneralMods/StardustCore/UIUtilities/SpriteFonts/Fonts/Components/TexturedString.cs index 8eebc878..0a9c832a 100644 --- a/GeneralMods/StardustCore/UIUtilities/SpriteFonts/Fonts/Components/TexturedString.cs +++ b/GeneralMods/StardustCore/UIUtilities/SpriteFonts/Fonts/Components/TexturedString.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using StardustCore.UIUtilities.SpriteFonts.Fonts; namespace StardustCore.UIUtilities.SpriteFonts.Components { @@ -10,11 +11,17 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components public Vector2 position; public string label; public float scale; + public string displayText; public TexturedString(string Label, Vector2 Position, List Characters, bool useRightPadding = true,float Scale=1f) { this.label = Label; this.characters = Characters; + foreach(TexturedCharacter c in Characters) + { + this.displayText += c.character; + } + this.position = Position; this.scale = Scale; this.setCharacterPositions(useRightPadding); @@ -49,6 +56,25 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components this.position = pos; this.setCharacterPositions(); } + public string getText() + { + return this.displayText; + } + + /// + /// Sets the new text for this string. Basically this just creates a new string and copies the fields over. + /// + /// + /// + /// + public void setText(string text, GenericFont font,Color color) + { + TexturedString other= font.ParseString(text, this.position, color, true, this.scale); + this.characters = other.characters; + this.scale = other.scale; + this.position = other.position; + this.label = other.label; + } /// Adds a textured character to a textured string. public void addCharacterToEnd(TexturedCharacter ch, bool useRightPadding = true) @@ -86,6 +112,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components return newString; } + /// Removes the characters from the textured word. public void removeCharactersFromEnd(int index, int howMany) {