[csharp] Minor formatting changes on Atlas.cs

This commit is contained in:
pharan 2017-02-27 00:30:02 +08:00
parent be9b522237
commit a56c22cb74

View File

@ -40,7 +40,7 @@ using Windows.Storage;
namespace Spine { namespace Spine {
public class Atlas { public class Atlas {
List<AtlasPage> pages = new List<AtlasPage>(); readonly List<AtlasPage> pages = new List<AtlasPage>();
List<AtlasRegion> regions = new List<AtlasRegion>(); List<AtlasRegion> regions = new List<AtlasRegion>();
TextureLoader textureLoader; TextureLoader textureLoader;
@ -58,12 +58,12 @@ namespace Spine {
} }
} }
public Atlas(String path, TextureLoader textureLoader) { public Atlas(string path, TextureLoader textureLoader) {
this.ReadFile(path, textureLoader).Wait(); this.ReadFile(path, textureLoader).Wait();
} }
#else #else
public Atlas (String path, TextureLoader textureLoader) { public Atlas (string path, TextureLoader textureLoader) {
#if WINDOWS_PHONE #if WINDOWS_PHONE
Stream stream = Microsoft.Xna.Framework.TitleContainer.OpenStream(path); Stream stream = Microsoft.Xna.Framework.TitleContainer.OpenStream(path);
@ -84,7 +84,7 @@ namespace Spine {
#endif // !(UNITY) #endif // !(UNITY)
public Atlas (TextReader reader, String dir, TextureLoader textureLoader) { public Atlas (TextReader reader, string dir, TextureLoader textureLoader) {
Load(reader, dir, textureLoader); Load(reader, dir, textureLoader);
} }
@ -94,14 +94,14 @@ namespace Spine {
this.textureLoader = null; this.textureLoader = null;
} }
private void Load (TextReader reader, String imagesDir, TextureLoader textureLoader) { private void Load (TextReader reader, string imagesDir, TextureLoader textureLoader) {
if (textureLoader == null) throw new ArgumentNullException("textureLoader cannot be null."); if (textureLoader == null) throw new ArgumentNullException("textureLoader cannot be null.");
this.textureLoader = textureLoader; this.textureLoader = textureLoader;
String[] tuple = new String[4]; string[] tuple = new string[4];
AtlasPage page = null; AtlasPage page = null;
while (true) { while (true) {
String line = reader.ReadLine(); string line = reader.ReadLine();
if (line == null) break; if (line == null) break;
if (line.Trim().Length == 0) if (line.Trim().Length == 0)
page = null; page = null;
@ -120,7 +120,7 @@ namespace Spine {
page.minFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[0], false); page.minFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[0], false);
page.magFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[1], false); page.magFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[1], false);
String direction = ReadValue(reader); string direction = ReadValue(reader);
page.uWrap = TextureWrap.ClampToEdge; page.uWrap = TextureWrap.ClampToEdge;
page.vWrap = TextureWrap.ClampToEdge; page.vWrap = TextureWrap.ClampToEdge;
if (direction == "x") if (direction == "x")
@ -189,16 +189,16 @@ namespace Spine {
} }
} }
static String ReadValue (TextReader reader) { static string ReadValue (TextReader reader) {
String line = reader.ReadLine(); string line = reader.ReadLine();
int colon = line.IndexOf(':'); int colon = line.IndexOf(':');
if (colon == -1) throw new Exception("Invalid line: " + line); if (colon == -1) throw new Exception("Invalid line: " + line);
return line.Substring(colon + 1).Trim(); return line.Substring(colon + 1).Trim();
} }
/// <summary>Returns the number of tuple values read (1, 2 or 4).</summary> /// <summary>Returns the number of tuple values read (1, 2 or 4).</summary>
static int ReadTuple (TextReader reader, String[] tuple) { static int ReadTuple (TextReader reader, string[] tuple) {
String line = reader.ReadLine(); string line = reader.ReadLine();
int colon = line.IndexOf(':'); int colon = line.IndexOf(':');
if (colon == -1) throw new Exception("Invalid line: " + line); if (colon == -1) throw new Exception("Invalid line: " + line);
int i = 0, lastMatch = colon + 1; int i = 0, lastMatch = colon + 1;
@ -223,7 +223,7 @@ namespace Spine {
/// <summary>Returns the first region found with the specified name. This method uses string comparison to find the region, so the result /// <summary>Returns the first region found with the specified name. This method uses string comparison to find the region, so the result
/// should be cached rather than calling this method multiple times.</summary> /// should be cached rather than calling this method multiple times.</summary>
/// <returns>The region, or null.</returns> /// <returns>The region, or null.</returns>
public AtlasRegion FindRegion (String name) { public AtlasRegion FindRegion (string name) {
for (int i = 0, n = regions.Count; i < n; i++) for (int i = 0, n = regions.Count; i < n; i++)
if (regions[i].name == name) return regions[i]; if (regions[i].name == name) return regions[i];
return null; return null;
@ -263,7 +263,7 @@ namespace Spine {
} }
public class AtlasPage { public class AtlasPage {
public String name; public string name;
public Format format; public Format format;
public TextureFilter minFilter; public TextureFilter minFilter;
public TextureFilter magFilter; public TextureFilter magFilter;
@ -275,7 +275,7 @@ namespace Spine {
public class AtlasRegion { public class AtlasRegion {
public AtlasPage page; public AtlasPage page;
public String name; public string name;
public int x, y, width, height; public int x, y, width, height;
public float u, v, u2, v2; public float u, v, u2, v2;
public float offsetX, offsetY; public float offsetX, offsetY;
@ -287,7 +287,7 @@ namespace Spine {
} }
public interface TextureLoader { public interface TextureLoader {
void Load (AtlasPage page, String path); void Load (AtlasPage page, string path);
void Unload (Object texture); void Unload (Object texture);
} }
} }