From 04ec3cd7935e30a19f7d8993eb0539d568c32cbe Mon Sep 17 00:00:00 2001 From: Recrown Date: Sun, 10 Mar 2019 00:49:25 -0600 Subject: [PATCH] Variable name refactor. --- RecrownedAthenaeum/UI/BookSystem/Book.cs | 4 +- RecrownedAthenaeum/UI/BookSystem/Page.cs | 2 +- RecrownedAthenaeum/UI/Modular/UIModule.cs | 42 +++++++++++-------- .../UI/Modular/UIModuleGroup.cs | 19 +++++---- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/RecrownedAthenaeum/UI/BookSystem/Book.cs b/RecrownedAthenaeum/UI/BookSystem/Book.cs index ef41f96..0963c71 100644 --- a/RecrownedAthenaeum/UI/BookSystem/Book.cs +++ b/RecrownedAthenaeum/UI/BookSystem/Book.cs @@ -98,7 +98,7 @@ namespace RecrownedAthenaeum.UI.BookSystem page.camera = camera; page.Initialize(assets, skin); orderedPages.Add(page); - this.pages.Add(page.Name, page); + this.pages.Add(page.name, page); } } @@ -108,7 +108,7 @@ namespace RecrownedAthenaeum.UI.BookSystem /// Page to remove. public void RemovePage(Page page) { - RemovePage(page.Name); + RemovePage(page.name); } /// diff --git a/RecrownedAthenaeum/UI/BookSystem/Page.cs b/RecrownedAthenaeum/UI/BookSystem/Page.cs index 710b616..d5dcc05 100644 --- a/RecrownedAthenaeum/UI/BookSystem/Page.cs +++ b/RecrownedAthenaeum/UI/BookSystem/Page.cs @@ -25,7 +25,7 @@ namespace RecrownedAthenaeum.UI.BookSystem this.pageX = pageX; this.pageY = pageY; requiresSizeUpdate = true; - Name = ToString(); + name = ToString(); } /// diff --git a/RecrownedAthenaeum/UI/Modular/UIModule.cs b/RecrownedAthenaeum/UI/Modular/UIModule.cs index 332ebd8..a48cffb 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModule.cs +++ b/RecrownedAthenaeum/UI/Modular/UIModule.cs @@ -37,12 +37,12 @@ namespace RecrownedAthenaeum.UI.Modular /// /// The parent of this module. May be null. /// - public UIModuleGroup Parent; + public UIModuleGroup parent; /// /// Name of this module. For organizational/referencial purposes mostly. /// - public string Name; + public string name; /// /// The color tint of this module. @@ -73,9 +73,9 @@ namespace RecrownedAthenaeum.UI.Modular /// public Rectangle ConvertToParentCoordinates(Rectangle rectangle) { - if (Parent != null) + if (parent != null) { - Rectangle parentHitbox = Parent.ConvertToParentCoordinates(rectangle); + Rectangle parentHitbox = parent.ConvertToParentCoordinates(rectangle); int tX = rectangle.X + parentHitbox.X; int tY = rectangle.Y + parentHitbox.Y; return new Rectangle(tX, tY, rectangle.Width, rectangle.Height); @@ -91,8 +91,8 @@ namespace RecrownedAthenaeum.UI.Modular /// public void RemoveFromParent() { - if (Parent == null) throw new InvalidOperationException("Parent is null."); - Parent.RemoveModule(this); + if (parent == null) throw new InvalidOperationException("Parent is null."); + parent.RemoveModule(this); } /// @@ -125,31 +125,37 @@ namespace RecrownedAthenaeum.UI.Modular } /// - /// Centers this module's origin on the horizontal axis relative to the given rectangle. + /// Centers this module's origin on the horizontal axis relative to the parent . /// - /// The rectangle to center it in. /// True if possible and false if not. - public bool CenterHorizontally(Rectangle rectangle) + public bool CenterHorizontally() { - if (rectangle.Width >= Boundaries.Width) + if (parent != null) { - situation.X = rectangle.Width / 2 + situation.X; - return true; + Rectangle rectangle = parent.Boundaries; + if (parent != null && rectangle.Width >= Boundaries.Width) + { + situation.X = rectangle.Width / 2 + situation.X; + return true; + } } return false; } /// - /// Center's this module's origin on the vertical axis relative to the given rectangle. + /// Centers this module's origin on the vertical axis relative to the parent . /// - /// The rectangle to center in. /// True if possible. - public bool CenterVertically(Rectangle rectangle) + public bool CenterVertically() { - if (rectangle.Height >= Boundaries.Height) + if (parent != null) { - situation.Y = rectangle.Height / 2 + situation.Y; - return true; + Rectangle rectangle = parent.Boundaries; + if (rectangle.Height >= Boundaries.Height) + { + 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 b680700..7652025 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs +++ b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using RecrownedAthenaeum.Camera; +using RecrownedAthenaeum.Render; using RecrownedAthenaeum.ScreenSystem; namespace RecrownedAthenaeum.UI.Modular @@ -17,7 +18,7 @@ namespace RecrownedAthenaeum.UI.Modular List modules = new List(); Rectangle scissorBounds; RasterizerState scissorRasterizer; - BeginBatch beginBatch; + SpriteBatchSettings spriteBatchSettings; /// /// Camera used by the module for cropping. @@ -29,12 +30,12 @@ namespace RecrownedAthenaeum.UI.Modular /// /// Whether or not to crop out of bounds. Default is false. /// What camera to use for cropping. Default is null and will use 's camera if crop is enabled. - /// The function to be called that begins the batch. - public UIModuleGroup(bool crop = false, Camera2D camera = null, BeginBatch beginBatchFunction = null) + /// The settings to be used that begins the batch. + public UIModuleGroup(bool crop = false, Camera2D camera = null, SpriteBatchSettings? spriteBatchSettings = null) { - if (beginBatchFunction == null) beginBatchFunction = Configuration.BeginBatchFunction; + if (spriteBatchSettings == null) spriteBatchSettings = Configuration.spriteBatchSettings; if (crop && camera == null) camera = Configuration.Camera2D; - this.beginBatch = beginBatchFunction; + this.spriteBatchSettings = spriteBatchSettings.Value; this.camera = camera; if (crop) { @@ -53,7 +54,7 @@ namespace RecrownedAthenaeum.UI.Modular if (scissorBounds != null) { batch.End(); - beginBatch(batch); + spriteBatchSettings.BeginSpriteBatch(batch); scissorBounds.Width = situation.Width; scissorBounds.Height = situation.Height; scissorBounds.X = situation.X; @@ -78,7 +79,7 @@ namespace RecrownedAthenaeum.UI.Modular { batch.GraphicsDevice.ScissorRectangle = scissorBounds; batch.End(); - beginBatch(batch); + spriteBatchSettings.BeginSpriteBatch(batch); } } @@ -106,7 +107,7 @@ namespace RecrownedAthenaeum.UI.Modular { throw new InvalidOperationException(module.ToString() + " already exists in " + this.ToString()); } - module.Parent = this; + module.parent = this; modules.Add(module); } } @@ -117,7 +118,7 @@ namespace RecrownedAthenaeum.UI.Modular /// module to remove. public void RemoveModule(UIModule module) { - module.Parent = null; + module.parent = null; modules.Remove(module); }