Updated text button to use new centering setup. Also minor refactor.

This commit is contained in:
Harrison Deng 2019-03-08 10:17:37 -06:00
parent 5ffdc3a9d6
commit 2d73d204e1
2 changed files with 4 additions and 3 deletions

View File

@ -35,6 +35,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
{ {
this.text = new Text(font, text); this.text = new Text(font, text);
this.text.autoScale = true; this.text.autoScale = true;
this.text.centered = true;
} }
/// <summary> /// <summary>
@ -49,6 +50,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition<TextButtonSkinDefinition>(definitionName); TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition<TextButtonSkinDefinition>(definitionName);
this.text = new Text(font, text); this.text = new Text(font, text);
this.text.autoScale = true; this.text.autoScale = true;
this.text.centered = true;
FontColor = skin.GetColor(skinDefinition.fontColor); FontColor = skin.GetColor(skinDefinition.fontColor);
} }
@ -76,7 +78,6 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
{ {
text.bounds = bounds; text.bounds = bounds;
text.Update(gameTime); text.Update(gameTime);
text.CenterIn(TrueBounds);
base.Update(gameTime); base.Update(gameTime);
} }

View File

@ -22,7 +22,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// <summary> /// <summary>
/// Centers the text int bounds. /// Centers the text int bounds.
/// </summary> /// </summary>
public bool center; public bool centered;
/// <summary> /// <summary>
/// Whether or not to try and wrap text automatically. Meaning will check and attempt to wrap every update. /// Whether or not to try and wrap text automatically. Meaning will check and attempt to wrap every update.
@ -73,7 +73,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
if (useEllipses) AttemptToApplyEllipsis(); if (useEllipses) AttemptToApplyEllipsis();
if (autoWrap) AttemptToWrapText(); if (autoWrap) AttemptToWrapText();
if (autoScale) AttemptToScaleFont(); if (autoScale) AttemptToScaleFont();
if (center) Center(); if (centered) Center();
base.Update(gameTime); base.Update(gameTime);
} }