From eedc083e03e97f0edc22938ae7fb9b2bc50aa056 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Sat, 29 Dec 2018 00:29:31 -0600 Subject: [PATCH] Improved variable naming for ninepatch classes. --- .../NinePatch/NinePatchData.cs | 12 +- RecrownedAthenaeum/DataTypes/NinePatch.cs | 146 +++++++++--------- .../Pipeline/TextureAtlasDataReader.cs | 2 +- 3 files changed, 80 insertions(+), 80 deletions(-) diff --git a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs index 9fa9806..47007b7 100644 --- a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs +++ b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs @@ -9,15 +9,15 @@ namespace RecrownedAthenaeum.Pipeline.NinePatch public class NinePatchData { public string textureName; - public int a, b, c, d; + public int left, right, down, top; - public NinePatchData(string textureName, int a, int b, int c, int d) + public NinePatchData(string textureName, int left, int right, int down, int top) { this.textureName = textureName; - this.a = a; - this.b = b; - this.c = c; - this.d = d; + this.left = left; + this.right = right; + this.down = down; + this.top = top; } } } diff --git a/RecrownedAthenaeum/DataTypes/NinePatch.cs b/RecrownedAthenaeum/DataTypes/NinePatch.cs index d506d45..a1f9496 100644 --- a/RecrownedAthenaeum/DataTypes/NinePatch.cs +++ b/RecrownedAthenaeum/DataTypes/NinePatch.cs @@ -14,26 +14,26 @@ namespace RecrownedAthenaeum.DataTypes public Color color; public Rectangle textureRegion; readonly Texture2D texture; - readonly int a, b, c, d; + readonly int left, right, bottom, top; /// /// A nine patch object. /// /// Texture used for the nine patch. Dimensions must be greater than their sum border counter parts. If used as part of texture atlas, the texture should be the texture of the entire atlas. - /// Left side. - /// Right side. - /// Bottom side. - /// Top side. - public NinePatch(Texture2D texture, int a, int b, int c, int d) + /// Left side. + /// Right side. + /// Bottom side. + /// Top side. + public NinePatch(Texture2D texture, int left, int right, int bottom, int top) { this.texture = texture; textureRegion = texture.Bounds; - if (a + b >= textureRegion.Width) throw new ArgumentOutOfRangeException("a and b cannot be greater than or equal to the width of region."); - if (c + d >= textureRegion.Height) throw new ArgumentOutOfRangeException("c and d cannot be greater or equal to the height of the texture."); - this.a = a; - this.b = b; - this.c = c; - this.d = d; + if (left + right >= textureRegion.Width) throw new ArgumentOutOfRangeException("a and b cannot be greater than or equal to the width of region."); + if (bottom + top >= textureRegion.Height) throw new ArgumentOutOfRangeException("c and d cannot be greater or equal to the height of the texture."); + this.left = left; + this.right = right; + this.bottom = bottom; + this.top = top; color = Color.White; } @@ -46,13 +46,13 @@ namespace RecrownedAthenaeum.DataTypes //1x1 drawnRectangle.X = destination.X; drawnRectangle.Y = destination.Y; - drawnRectangle.Width = a; - drawnRectangle.Height = c; + drawnRectangle.Width = left; + drawnRectangle.Height = bottom; sourceRectangle.X = 0; sourceRectangle.Y = 0; - sourceRectangle.Width = a; - sourceRectangle.Height = c; + sourceRectangle.Width = left; + sourceRectangle.Height = bottom; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; @@ -60,30 +60,30 @@ namespace RecrownedAthenaeum.DataTypes spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color); //2x1 - drawnRectangle.X = destination.X + a; + drawnRectangle.X = destination.X + left; drawnRectangle.Y = destination.Y; - drawnRectangle.Width = destination.Width - a - b; - drawnRectangle.Height = c; + drawnRectangle.Width = destination.Width - left - right; + drawnRectangle.Height = bottom; - sourceRectangle.X = a; + sourceRectangle.X = left; sourceRectangle.Y = 0; - sourceRectangle.Width = textureRegion.Width - a - b; - sourceRectangle.Height = c; + sourceRectangle.Width = textureRegion.Width - left - right; + sourceRectangle.Height = bottom; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color); //3x1 - drawnRectangle.X = destination.X + destination.Width - b; + drawnRectangle.X = destination.X + destination.Width - right; drawnRectangle.Y = destination.Y; - drawnRectangle.Width = b; - drawnRectangle.Height = c; + drawnRectangle.Width = right; + drawnRectangle.Height = bottom; - sourceRectangle.X = textureRegion.Width - b; + sourceRectangle.X = textureRegion.Width - right; sourceRectangle.Y = 0; - sourceRectangle.Width = b; - sourceRectangle.Height = c; + sourceRectangle.Width = right; + sourceRectangle.Height = bottom; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; @@ -91,44 +91,44 @@ namespace RecrownedAthenaeum.DataTypes //1x2 drawnRectangle.X = destination.X; - drawnRectangle.Y = destination.Y + c; - drawnRectangle.Width = a; - drawnRectangle.Height = destination.Height - d - c; + drawnRectangle.Y = destination.Y + bottom; + drawnRectangle.Width = left; + drawnRectangle.Height = destination.Height - top - bottom; sourceRectangle.X = 0; - sourceRectangle.Y = c; - sourceRectangle.Width = a; - sourceRectangle.Height = textureRegion.Height - c - d; + sourceRectangle.Y = bottom; + sourceRectangle.Width = left; + sourceRectangle.Height = textureRegion.Height - bottom - top; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color); //2x2 - drawnRectangle.X = destination.X + a; - drawnRectangle.Y = destination.Y + c; - drawnRectangle.Width = destination.Width - a - b; - drawnRectangle.Height = destination.Height - c - d; + drawnRectangle.X = destination.X + left; + drawnRectangle.Y = destination.Y + bottom; + drawnRectangle.Width = destination.Width - left - right; + drawnRectangle.Height = destination.Height - bottom - top; - sourceRectangle.X = a; - sourceRectangle.Y = c; - sourceRectangle.Width = textureRegion.Width - a - b; - sourceRectangle.Height = textureRegion.Height - c - d; + sourceRectangle.X = left; + sourceRectangle.Y = bottom; + sourceRectangle.Width = textureRegion.Width - left - right; + sourceRectangle.Height = textureRegion.Height - bottom - top; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color); //3x2 - drawnRectangle.X = destination.X + destination.Width - b; - drawnRectangle.Y = destination.Y + c; - drawnRectangle.Width = b; - drawnRectangle.Height = destination.Height - c - d; + drawnRectangle.X = destination.X + destination.Width - right; + drawnRectangle.Y = destination.Y + bottom; + drawnRectangle.Width = right; + drawnRectangle.Height = destination.Height - bottom - top; - sourceRectangle.X = textureRegion.Width - b; - sourceRectangle.Y = c; - sourceRectangle.Width = b; - sourceRectangle.Height = textureRegion.Height - c - d; + sourceRectangle.X = textureRegion.Width - right; + sourceRectangle.Y = bottom; + sourceRectangle.Width = right; + sourceRectangle.Height = textureRegion.Height - bottom - top; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; @@ -136,44 +136,44 @@ namespace RecrownedAthenaeum.DataTypes //1x3 drawnRectangle.X = destination.X; - drawnRectangle.Y = destination.Height - d; - drawnRectangle.Width = a; - drawnRectangle.Height = d; + drawnRectangle.Y = destination.Height - top; + drawnRectangle.Width = left; + drawnRectangle.Height = top; - sourceRectangle.X = a; - sourceRectangle.Y = textureRegion.Height - d; - sourceRectangle.Width = a; - sourceRectangle.Height = d; + sourceRectangle.X = left; + sourceRectangle.Y = textureRegion.Height - top; + sourceRectangle.Width = left; + sourceRectangle.Height = top; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color); //2x3 - drawnRectangle.X = destination.X + a; - drawnRectangle.Y = destination.Height - d; - drawnRectangle.Width = destination.Width - a - b; - drawnRectangle.Height = d; + drawnRectangle.X = destination.X + left; + drawnRectangle.Y = destination.Height - top; + drawnRectangle.Width = destination.Width - left - right; + drawnRectangle.Height = top; - sourceRectangle.X = a; - sourceRectangle.Y = textureRegion.Height - d; - sourceRectangle.Width = textureRegion.Width - a - b; - sourceRectangle.Height = d; + sourceRectangle.X = left; + sourceRectangle.Y = textureRegion.Height - top; + sourceRectangle.Width = textureRegion.Width - left - right; + sourceRectangle.Height = top; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color); //3x3 - drawnRectangle.X = destination.X + destination.Width - b; - drawnRectangle.Y = destination.Height - d; - drawnRectangle.Width = b; - drawnRectangle.Height = d; + drawnRectangle.X = destination.X + destination.Width - right; + drawnRectangle.Y = destination.Height - top; + drawnRectangle.Width = right; + drawnRectangle.Height = top; - sourceRectangle.X = textureRegion.Width - b; - sourceRectangle.Y = textureRegion.Height - d; - sourceRectangle.Width = b; - sourceRectangle.Height = d; + sourceRectangle.X = textureRegion.Width - right; + sourceRectangle.Y = textureRegion.Height - top; + sourceRectangle.Width = right; + sourceRectangle.Height = top; sourceRectangle.X += textureRegion.X; sourceRectangle.Y += textureRegion.Y; diff --git a/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs b/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs index 7ef1b5f..ffb1708 100644 --- a/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs +++ b/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs @@ -33,7 +33,7 @@ namespace RecrownedAthenaeum.Pipeline if (regionData.ninePatchData != null) { NinePatchData nPatchData = regionData.ninePatchData; - nPatch = new DataTypes.NinePatch(atlasTexture, nPatchData.a, nPatchData.b, nPatchData.c, nPatchData.d); + nPatch = new DataTypes.NinePatch(atlasTexture, nPatchData.left, nPatchData.right, nPatchData.down, nPatchData.down); } regions[regionID] = new DataTypes.TextureAtlas.TextureAtlasRegion(regionData.name, regionData.location, nPatch, atlasTexture);