mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 17:56:04 +08:00
Read new atlas format that has width and height for each page.
This commit is contained in:
parent
3729bc1c88
commit
0295b0c169
@ -68,7 +68,12 @@ public class Atlas {
|
|||||||
page = new AtlasPage();
|
page = new AtlasPage();
|
||||||
page.name = line;
|
page.name = line;
|
||||||
|
|
||||||
page.format = Format[reader.readValue()];
|
if (reader.readTuple(tuple) == 2) { // size is only optional for an atlas packed with an old TexturePacker.
|
||||||
|
page.width = parseInt(tuple[0]);
|
||||||
|
page.height = parseInt(tuple[1]);
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
}
|
||||||
|
page.format = Format[tuple[0]];
|
||||||
|
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
page.minFilter = TextureFilter[tuple[0]];
|
page.minFilter = TextureFilter[tuple[0]];
|
||||||
@ -186,7 +191,7 @@ class Reader {
|
|||||||
return trim(line.substring(colon + 1));
|
return trim(line.substring(colon + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of tuple values read (2 or 4). */
|
/** Returns the number of tuple values read (1, 2 or 4). */
|
||||||
public function readTuple (tuple:Array) : int {
|
public function readTuple (tuple:Array) : int {
|
||||||
var line:String = readLine();
|
var line:String = readLine();
|
||||||
var colon:int = line.indexOf(":");
|
var colon:int = line.indexOf(":");
|
||||||
@ -195,11 +200,7 @@ class Reader {
|
|||||||
var i:int = 0, lastMatch:int = colon + 1;
|
var i:int = 0, lastMatch:int = colon + 1;
|
||||||
for (; i < 3; i++) {
|
for (; i < 3; i++) {
|
||||||
var comma:int = line.indexOf(",", lastMatch);
|
var comma:int = line.indexOf(",", lastMatch);
|
||||||
if (comma == -1) {
|
if (comma == -1) break;
|
||||||
if (i == 0)
|
|
||||||
throw new Error("Invalid line: " + line);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tuple[i] = trim(line.substr(lastMatch, comma - lastMatch));
|
tuple[i] = trim(line.substr(lastMatch, comma - lastMatch));
|
||||||
lastMatch = comma + 1;
|
lastMatch = comma + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1443,7 +1443,12 @@ spine.Atlas = function (atlasText, textureLoader) {
|
|||||||
page = new spine.AtlasPage();
|
page = new spine.AtlasPage();
|
||||||
page.name = line;
|
page.name = line;
|
||||||
|
|
||||||
page.format = spine.Atlas.Format[reader.readValue()];
|
if (reader.readTuple(tuple) == 2) { // size is only optional for an atlas packed with an old TexturePacker.
|
||||||
|
page.width = parseInt(tuple[0]);
|
||||||
|
page.height = parseInt(tuple[1]);
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
}
|
||||||
|
page.format = spine.Atlas.Format[tuple[0]];
|
||||||
|
|
||||||
reader.readTuple(tuple);
|
reader.readTuple(tuple);
|
||||||
page.minFilter = spine.Atlas.TextureFilter[tuple[0]];
|
page.minFilter = spine.Atlas.TextureFilter[tuple[0]];
|
||||||
@ -1617,7 +1622,7 @@ spine.AtlasReader.prototype = {
|
|||||||
if (colon == -1) throw "Invalid line: " + line;
|
if (colon == -1) throw "Invalid line: " + line;
|
||||||
return this.trim(line.substring(colon + 1));
|
return this.trim(line.substring(colon + 1));
|
||||||
},
|
},
|
||||||
/** Returns the number of tuple values read (2 or 4). */
|
/** Returns the number of tuple values read (1, 2 or 4). */
|
||||||
readTuple: function (tuple) {
|
readTuple: function (tuple) {
|
||||||
var line = this.readLine();
|
var line = this.readLine();
|
||||||
var colon = line.indexOf(":");
|
var colon = line.indexOf(":");
|
||||||
@ -1625,10 +1630,7 @@ spine.AtlasReader.prototype = {
|
|||||||
var i = 0, lastMatch = colon + 1;
|
var i = 0, lastMatch = colon + 1;
|
||||||
for (; i < 3; i++) {
|
for (; i < 3; i++) {
|
||||||
var comma = line.indexOf(",", lastMatch);
|
var comma = line.indexOf(",", lastMatch);
|
||||||
if (comma == -1) {
|
if (comma == -1) break;
|
||||||
if (i == 0) throw "Invalid line: " + line;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch));
|
tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch));
|
||||||
lastMatch = comma + 1;
|
lastMatch = comma + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user