From fa8a8f169c19fbea53de3d09806ac3c3b877517d Mon Sep 17 00:00:00 2001 From: Recrown Date: Sun, 27 Jan 2019 18:06:55 -0600 Subject: [PATCH] Added convenience function for UI modules that centers the origin relative to the bounds. --- RecrownedAthenaeum/UI/Modular/UIModule.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/RecrownedAthenaeum/UI/Modular/UIModule.cs b/RecrownedAthenaeum/UI/Modular/UIModule.cs index c9f9606..f41445d 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModule.cs +++ b/RecrownedAthenaeum/UI/Modular/UIModule.cs @@ -78,10 +78,7 @@ namespace RecrownedAthenaeum.UI.Modular /// public void RemoveFromParent() { - if (Parent == null) - { - throw new InvalidOperationException("Parent is null."); - } + if (Parent == null) throw new InvalidOperationException("Parent is null."); Parent.RemoveModule(this); } @@ -104,5 +101,14 @@ namespace RecrownedAthenaeum.UI.Modular { return true; } + + /// + /// Sets the origin to be the center of the bounds. + /// + public void CenterOrigin() + { + origin.X = bounds.Width / 2f; + origin.Y = bounds.Height / 2f; + } } }