//number of titt values read public static int teeUp(String line) { int colon = line.IndexOf(':'); if (colon == -1) { ArchonGame.writeError(ERROR_TAG, "Invalid Line:" + line); ArchonGame.exit(); return(-1); } int i = 0; int lastMatch = colon + 1; for (i = 0; i < 3; i++) { int comma = line.IndexOf(',', lastMatch); if (comma == -1) { break; } tee[i] = line.Substring(lastMatch, comma - lastMatch).Trim(); lastMatch = comma + 1; } tee[i] = line.Substring(lastMatch).Trim(); return(i + 1); }
public static string readValue(String line) { int colon = line.IndexOf(':'); if (colon == -1) { ArchonGame.writeError(ERROR_TAG, "Invalid Line:" + line); ArchonGame.exit(); return(null); } return(line.Substring(colon + 1).Trim()); }
public AtlasData(FilePackage atlasFile, FilePackage imageDir, bool flip) { int lineIndex = 0; string[] lines = atlasFile.asString().Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); Page pageImage = null; while (lineIndex < lines.Length) { String line = lines[lineIndex]; if (line == null) { break; } if (line.Trim().Length == 0) { pageImage = null; } else if (pageImage == null) { FilePackage file = imageDir.child(line); float width = 0; float height = 0; lineIndex++; int v = teeUp(lines[lineIndex]); if (v == 2) //compatible with old texture packer { float.TryParse(tee[0], out width); float.TryParse(tee[1], out height); lineIndex++; teeUp(lines[lineIndex]); } SurfaceFormat format = TextureAtlas.formatFromString(tee[0]); lineIndex++; teeUp(lines[lineIndex]); //texture filters here ---- TextureFilter min = tee[0] // - ---------------------- TextureFilter max = tee[1] lineIndex++; string direction = readValue(lines[lineIndex]); //repeat stuff //TextureWrap rx = clampToEdge; //TextureWrap ry = ClampToEdge; //if direction = x then rx = repeat; //if direction = y then ry = repeat; //if direction = xy then rx = ry = repeat; pageImage = new Page(file, width, height, format); pages.Add(pageImage); } else { lineIndex++; bool rotate = bool.Parse(readValue(lines[lineIndex])); lineIndex++; teeUp(lines[lineIndex]); ArchonGame.writeLog("test:", tee[0]); int left = int.Parse(tee[0]); int top = int.Parse(tee[1]); lineIndex++; teeUp(lines[lineIndex]); int width = int.Parse(tee[0]); int height = int.Parse(tee[1]); Region region = new Region(); region.page = pageImage; region.left = left; region.top = top; region.width = width; region.height = height; region.name = line; region.rotate = rotate; lineIndex++; int v = teeUp(lines[lineIndex]); if (v == 4) //optional splits included { region.splits = new[] { int.Parse(tee[0]), int.Parse(tee[1]), int.Parse(tee[2]), int.Parse(tee[3]) }; lineIndex++; v = teeUp(lines[lineIndex]); if (v == 4)//optional pads included - only happens when there is splits { region.pads = new int[] { int.Parse(tee[0]), int.Parse(tee[1]), int.Parse(tee[2]), int.Parse(tee[3]) }; lineIndex++; teeUp(lines[lineIndex]); } } region.originalWidth = int.Parse(tee[0]); region.originalHeight = int.Parse(tee[1]); lineIndex++; teeUp(lines[lineIndex]); region.xOff = int.Parse(tee[0]); region.yOff = int.Parse(tee[1]); lineIndex++; region.index = int.Parse(readValue(lines[lineIndex])); region.flip = flip; regions.Add(region); } lineIndex++; } regions.Sort(TextureAtlas.indexComparison); }
public void Dispose() { ArchonGame.writeDebug("TextureAtlas:", "texture atlas disposed"); }