mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Read new atlas format that has width and height for each page.
This commit is contained in:
parent
21eade668b
commit
3729bc1c88
@ -48,7 +48,7 @@ void spAtlasPage_dispose (spAtlasPage* self) {
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
spAtlasRegion* spAtlasRegion_create () {
|
spAtlasRegion* spAtlasRegion_create () {
|
||||||
return NEW(spAtlasRegion) ;
|
return NEW(spAtlasRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spAtlasRegion_dispose (spAtlasRegion* self) {
|
void spAtlasRegion_dispose (spAtlasRegion* self) {
|
||||||
@ -117,7 +117,7 @@ static int readValue (const char* end, Str* str) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the number of tuple values read (2, 4, or 0 for failure). */
|
/* Returns the number of tuple values read (1, 2, 4, or 0 for failure). */
|
||||||
static int readTuple (const char* end, Str tuple[]) {
|
static int readTuple (const char* end, Str tuple[]) {
|
||||||
int i;
|
int i;
|
||||||
Str str;
|
Str str;
|
||||||
@ -126,10 +126,7 @@ static int readTuple (const char* end, Str tuple[]) {
|
|||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
tuple[i].begin = str.begin;
|
tuple[i].begin = str.begin;
|
||||||
if (!beginPast(&str, ',')) {
|
if (!beginPast(&str, ',')) break;
|
||||||
if (i == 0) return 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tuple[i].end = str.begin - 2;
|
tuple[i].end = str.begin - 2;
|
||||||
trim(&tuple[i]);
|
trim(&tuple[i]);
|
||||||
}
|
}
|
||||||
@ -208,8 +205,15 @@ spAtlas* spAtlas_create (const char* begin, int length, const char* dir, void* r
|
|||||||
self->pages = page;
|
self->pages = page;
|
||||||
lastPage = page;
|
lastPage = page;
|
||||||
|
|
||||||
if (!readValue(end, &str)) return abortAtlas(self);
|
switch (readTuple(end, tuple)) {
|
||||||
page->format = (spAtlasFormat)indexOf(formatNames, 7, &str);
|
case 0:
|
||||||
|
return abortAtlas(self);
|
||||||
|
case 2: /* size is only optional for an atlas packed with an old TexturePacker. */
|
||||||
|
page->width = toInt(tuple);
|
||||||
|
page->height = toInt(tuple + 1);
|
||||||
|
if (!readTuple(end, tuple)) return abortAtlas(self);
|
||||||
|
}
|
||||||
|
page->format = (spAtlasFormat)indexOf(formatNames, 7, tuple);
|
||||||
|
|
||||||
if (!readTuple(end, tuple)) return abortAtlas(self);
|
if (!readTuple(end, tuple)) return abortAtlas(self);
|
||||||
page->minFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple);
|
page->minFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user