Browse Source

Corrected struct property issue.

tags/v0.1
Starbeamrainbowlabs 3 years ago
parent
commit
d90b2b3744
3 changed files with 43 additions and 14 deletions
  1. 14
    14
      SpritePacker/Packer.cs
  2. 26
    0
      SpritePacker/Sprite.cs
  3. 3
    0
      SpritePacker/SpritePacker.csproj

+ 14
- 14
SpritePacker/Packer.cs View File

@@ -39,11 +39,11 @@ namespace SpritePacker
39 39
 						break;
40 40
 
41 41
 					// Scan along the X axis
42
-					cspr.Area.X = 0;
43
-					cspr.Area.Y = scanLines.Y;
42
+					cspr.X = 0;
43
+					cspr.Y = scanLines.Y;
44 44
 
45 45
 					bool foundPosition = false;
46
-					while(cspr.Area.X < scanLines.X)
46
+					while(cspr.X < scanLines.X)
47 47
 					{
48 48
 						if (!cspr.IntersectsWith(arrangedSprites))
49 49
 						{
@@ -56,24 +56,24 @@ namespace SpritePacker
56 56
 						Sprite rightProblem = problems[0];
57 57
 						foreach (Sprite probSpr in problems)
58 58
 						{
59
-							if (probSpr.Area.Right > rightProblem.Area.Right)
59
+							if (probSpr.Right > rightProblem.Right)
60 60
 								rightProblem = probSpr;
61
-							if (probSpr.Area.Top < nextScanLines.Y)
62
-								nextScanLines.Y = probSpr.Area.Top + 1;
61
+							if (probSpr.Top < nextScanLines.Y)
62
+								nextScanLines.Y = probSpr.Top + 1;
63 63
 						}
64 64
 
65 65
 						// Move up to the position furthest to the right
66 66
 						// NOTE: We may need to add one here.
67
-						cspr.Area.X = rightProblem.Area.Right + 1;
67
+						cspr.X = rightProblem.Right + 1;
68 68
 
69 69
 					}
70 70
 
71 71
 					if (!foundPosition)
72 72
 					{
73 73
 						// We didn't find anything along the x axis - let's scan the y axis next
74
-						cspr.Area.X = scanLines.X;
75
-						cspr.Area.Y = 0;
76
-						while (cspr.Area.Y < scanLines.Y)
74
+						cspr.X = scanLines.X;
75
+						cspr.Y = 0;
76
+						while (cspr.Y < scanLines.Y)
77 77
 						{
78 78
 							if (!cspr.IntersectsWith(arrangedSprites))
79 79
 							{
@@ -86,13 +86,13 @@ namespace SpritePacker
86 86
 							Sprite downProblem = problems[0];
87 87
 							foreach (Sprite probSpr in problems)
88 88
 							{
89
-								if (probSpr.Area.Bottom > downProblem.Area.Bottom)
89
+								if (probSpr.Bottom > downProblem.Bottom)
90 90
 									downProblem = probSpr;
91
-								if (probSpr.Area.Left < nextScanLines.X)
92
-									nextScanLines.X = probSpr.Area.Left + 1;
91
+								if (probSpr.Left < nextScanLines.X)
92
+									nextScanLines.X = probSpr.Left + 1;
93 93
 							}
94 94
 							// Move up to the position furthest downwards
95
-							cspr.Area.Y = downProblem.Area.Bottom + 1;
95
+							cspr.Y = downProblem.Bottom + 1;
96 96
 						}
97 97
 					}
98 98
 

+ 26
- 0
SpritePacker/Sprite.cs View File

@@ -20,6 +20,31 @@ namespace SpritePacker
20 20
 			set { filename = value; }
21 21
 		}
22 22
 
23
+		public int X
24
+		{
25
+			get { return area.X; }
26
+			set { area.X = value; }
27
+		}
28
+		public int Y
29
+		{
30
+			get { return area.Y; }
31
+			set { area.Y = value; }
32
+		}
33
+		public int Width
34
+		{
35
+			get { return area.Width; }
36
+			set { area.Width = value; }
37
+		}
38
+		public int Height
39
+		{
40
+			get { return area.Height; }
41
+			set { area.Height = value; }
42
+		}
43
+		public int Top { get { return area.Top; } }
44
+		public int Bottom { get { return area.Bottom; } }
45
+		public int Left { get { return area.Left; } }
46
+		public int Right { get { return area.Right; } }
47
+
23 48
 		public Sprite(string inFilename)
24 49
 		{
25 50
 			Filename = inFilename;
@@ -35,6 +60,7 @@ namespace SpritePacker
35 60
 				if (spr.Area.Width > largestSoFar)
36 61
 					largestSoFar = spr.Area.Width;
37 62
 			}
63
+			return largestSoFar;
38 64
 		}
39 65
 
40 66
 		public List<Sprite> GetIntersectors(List<Sprite> spriteList)

+ 3
- 0
SpritePacker/SpritePacker.csproj View File

@@ -40,4 +40,7 @@
40 40
     <Compile Include="Sprite.cs" />
41 41
   </ItemGroup>
42 42
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
43
+  <ItemGroup>
44
+    <EmbeddedResource Include="Help.txt" />
45
+  </ItemGroup>
43 46
 </Project>

Loading…
Cancel
Save