diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs b/RecrownedAthenaeum/UI/Modular/Modules/Image.cs index d473912..74dff9f 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/Image.cs @@ -23,12 +23,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// /// Scale of of the X axis. /// - public float ScaleX { get { return (float)bounds.Width / texture.Width; } set { bounds.Width = (int)(texture.Width * value); } } + public float ScaleX { get { return (float)situation.Width / texture.Width; } set { situation.Width = (int)(texture.Width * value); } } /// /// Scale of the Y axis. /// - public float ScaleY { get { return (float)bounds.Height / texture.Height; } set { bounds.Height = (int)(texture.Height * value); } } + public float ScaleY { get { return (float)situation.Height / texture.Height; } set { situation.Height = (int)(texture.Height * value); } } /// /// Sets scale of X and Y. @@ -42,7 +42,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules public Image(Texture2D texture) { this.texture = texture ?? throw new ArgumentException("Image requires a texture."); - bounds = texture.Bounds; + situation = texture.Bounds; } /// @@ -51,7 +51,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// The batch to use. public override void Draw(SpriteBatch batch) { - batch.Draw(texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f); + batch.Draw(texture, situation, null, color, rotation, origin, SpriteEffects.None, 0f); base.Draw(batch); } @@ -68,7 +68,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules this.color = color; this.rotation = rotation; this.origin = origin; - bounds = destination; + situation = destination; Draw(spriteBatch); } } diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs index 67fd775..3eddd25 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs @@ -69,12 +69,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive /// /// The skin the definition is defined in. /// The definition itself. - public Button(ISkin skin, ButtonSkinDefinition skinDefinition) : - this(skin.GetTextureAtlasRegion(skinDefinition.downRegion, true), - skin.GetTextureAtlasRegion(skinDefinition.upRegion, true), - skin.GetTextureAtlasRegion(skinDefinition.disabledRegion), + public Button(ISkin skin, ButtonSkinDefinition skinDefinition) : + this(skin.GetTextureAtlasRegion(skinDefinition.downRegion, true), + skin.GetTextureAtlasRegion(skinDefinition.upRegion, true), + skin.GetTextureAtlasRegion(skinDefinition.disabledRegion), skin.GetTextureAtlasRegion(skinDefinition.selectedRegion)) - {} + { } /// /// Draws the button. @@ -84,17 +84,21 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive { if (disabled) { - disabledTexture?.Draw(batch, bounds, color); + disabledTexture?.Draw(batch, Boundaries, color); } else { if (pressed) { - downTexture.Draw(batch, bounds, color); + downTexture.Draw(batch, Boundaries, color); + } + else if (Highlighted) + { + highlightedTexture?.Draw(batch, Boundaries, color); } else { - upTexture.Draw(batch, bounds, color); + upTexture.Draw(batch, Boundaries, color); } } @@ -108,7 +112,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive /// Whether or not to continue calling the next mouse change listener. public sealed override bool MouseStateChanged(MouseState state) { - if (InputUtilities.MouseWithinBoundries(bounds)) + if (InputUtilities.MouseWithinBoundries(Boundaries)) { if (state.LeftButton == ButtonState.Pressed) { diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs index 229ac62..135f2f6 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs @@ -76,7 +76,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive /// Snapshot of information about time for game. public override void Update(GameTime gameTime) { - text.bounds = bounds; + text.situation = Boundaries; text.Update(gameTime); base.Update(gameTime); } diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs b/RecrownedAthenaeum/UI/Modular/Modules/Text.cs index 78e4360..bb10fd1 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/Text.cs @@ -67,8 +67,8 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// The game time. public override void Update(GameTime gameTime) { - position.X = bounds.X; - position.Y = bounds.Y; + position.X = situation.X; + position.Y = situation.Y; if (useEllipses) AttemptToApplyEllipsis(); if (autoWrap) AttemptToWrapText(); @@ -84,7 +84,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// Batch to use. public override void Draw(SpriteBatch batch) { - batch.DrawString(font, Content, position, color, 0f, origin, scale, SpriteEffects.None, 0f); + batch.DrawString(font, Content, position, color, 0f, default(Vector2), scale, SpriteEffects.None, 0f); base.Draw(batch); } @@ -93,7 +93,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// public void AttemptToApplyEllipsis() { - if (modifiedTextSize.X * scale > bounds.Width && ModifiedText.Length > ellipsis.Length + 1) + if (modifiedTextSize.X * scale > situation.Width && ModifiedText.Length > ellipsis.Length + 1) { RemoveLineBreaks(); StringBuilder stringBuilder = new StringBuilder(ModifiedText); @@ -102,7 +102,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules stringBuilder.Remove(stringBuilder.Length, ellipsis.Length - 1); stringBuilder.Insert(stringBuilder.Length, ellipsis); } - while (font.MeasureString(stringBuilder).X * scale > bounds.Width); + while (font.MeasureString(stringBuilder).X * scale > situation.Width); ModifiedText = stringBuilder.ToString(); } @@ -114,18 +114,18 @@ namespace RecrownedAthenaeum.UI.Modular.Modules public void AttemptToScaleFont() { - if (bounds.Width < bounds.Height) + if (situation.Width < situation.Height) { - if (Math.Round(modifiedTextSize.X * scale ) != bounds.Width) + if (Math.Round(modifiedTextSize.X * scale ) != situation.Width) { - scale = bounds.Width / modifiedTextSize.X; + scale = situation.Width / modifiedTextSize.X; } } else { - if (Math.Round(modifiedTextSize.Y * scale ) != bounds.Height) + if (Math.Round(modifiedTextSize.Y * scale ) != situation.Height) { - scale = bounds.Height / (modifiedTextSize.Y); + scale = situation.Height / (modifiedTextSize.Y); } } } @@ -153,7 +153,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules public void AttemptToWrapText(bool unwrap = false) { if (unwrap) RemoveLineBreaks(); - if (modifiedTextSize.X * scale > bounds.Width) + if (modifiedTextSize.X * scale > situation.Width) { ModifiedText = ModifiedText.Replace("\n", " "); string[] words = ModifiedText.Split(' '); @@ -165,7 +165,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules string word = words[w]; float scaledWidth = font.MeasureString(word).X * scale; - if (currentScaledLineWidth + scaledWidth <= bounds.Width) + if (currentScaledLineWidth + scaledWidth <= situation.Width) { stringBuilder.Append(word); currentScaledLineWidth += scaledWidth; @@ -184,18 +184,18 @@ namespace RecrownedAthenaeum.UI.Modular.Modules { Vector2 textSize = new Vector2(modifiedTextSize.X * scale, modifiedTextSize.Y * scale); - if (textSize.X <= bounds.Width) + if (textSize.X <= situation.Width) { - position.X = bounds.X + (bounds.Width - textSize.X) / 2f; + position.X = situation.X + (situation.Width - textSize.X) / 2f; } else { return false; } - if (textSize.Y <= bounds.Height) + if (textSize.Y <= situation.Height) { - position.Y = bounds.Y + (bounds.Height - textSize.Y) / 2f; + position.Y = situation.Y + (situation.Height - textSize.Y) / 2f; } else { diff --git a/RecrownedAthenaeum/UI/Modular/UIModule.cs b/RecrownedAthenaeum/UI/Modular/UIModule.cs index d5b16f3..332ebd8 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModule.cs +++ b/RecrownedAthenaeum/UI/Modular/UIModule.cs @@ -16,16 +16,16 @@ namespace RecrownedAthenaeum.UI.Modular /// /// The bounds before factoring in the origin. /// - public Rectangle bounds; + public Rectangle situation; /// /// Bounds of this module (after factoring in the origin). /// - public Rectangle FinalBounds + public Rectangle Boundaries { get { - return new Rectangle((int)(bounds.X - origin.X), (int)(bounds.Y - origin.Y), bounds.Width, bounds.Height); + return new Rectangle((int)(situation.X - origin.X), (int)(situation.Y - origin.Y), situation.Width, situation.Height); } } @@ -120,8 +120,8 @@ namespace RecrownedAthenaeum.UI.Modular /// public void CenterOrigin() { - origin.X = bounds.Width / 2f; - origin.Y = bounds.Height / 2f; + origin.X = situation.Width / 2f; + origin.Y = situation.Height / 2f; } /// @@ -131,9 +131,9 @@ namespace RecrownedAthenaeum.UI.Modular /// True if possible and false if not. public bool CenterHorizontally(Rectangle rectangle) { - if (rectangle.Width >= bounds.Width) + if (rectangle.Width >= Boundaries.Width) { - bounds.X = rectangle.Width / 2 + rectangle.X; + situation.X = rectangle.Width / 2 + situation.X; return true; } return false; @@ -146,9 +146,9 @@ namespace RecrownedAthenaeum.UI.Modular /// True if possible. public bool CenterVertically(Rectangle rectangle) { - if (rectangle.Height >= bounds.Height) + if (rectangle.Height >= Boundaries.Height) { - bounds.Y = rectangle.Height / 2 + rectangle.Y; + situation.Y = rectangle.Height / 2 + situation.Y; return true; } return false; diff --git a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs index dfaebe5..27caebf 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs +++ b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs @@ -49,10 +49,10 @@ namespace RecrownedAthenaeum.UI.Modular { batch.End(); batch.Begin(effect: camera?.BasicEffect); - scissorBounds.Width = bounds.Width; - scissorBounds.Height = bounds.Height; - scissorBounds.X = bounds.X; - scissorBounds.Y = bounds.Y; + scissorBounds.Width = situation.Width; + scissorBounds.Height = situation.Height; + scissorBounds.X = situation.X; + scissorBounds.Y = situation.Y; Rectangle scissor = scissorBounds; scissorBounds = batch.GraphicsDevice.ScissorRectangle; batch.GraphicsDevice.ScissorRectangle = scissor; @@ -60,13 +60,13 @@ namespace RecrownedAthenaeum.UI.Modular foreach (UIModule module in modules) { - int offsetX = module.bounds.X; - int offsetY = module.bounds.Y; - module.bounds.X = bounds.X + offsetX; - module.bounds.Y = bounds.Y + offsetY; + int offsetX = module.situation.X; + int offsetY = module.situation.Y; + module.situation.X = situation.X + offsetX; + module.situation.Y = situation.Y + offsetY; module.Draw(batch); - module.bounds.X = offsetX; - module.bounds.Y = offsetY; + module.situation.X = offsetX; + module.situation.Y = offsetY; } if (scissorBounds != null)