diff --git a/glue/glueatlas.monkey b/glue/glueatlas.monkey index 1d493e7..b2339a8 100644 --- a/glue/glueatlas.monkey +++ b/glue/glueatlas.monkey @@ -57,7 +57,7 @@ Class SpineDefaultAtlasLoader Implements SpineAtlasLoader Local imagesDir:String = SpineExtractDir(path) Local page:SpineDefaultAtlasPage - Local pageIndex:= 0 + Local pageIndex:= -1 Local pageNew:= True Local pageHasStart:= False Local pageHasHeader:= False @@ -98,13 +98,13 @@ Class SpineDefaultAtlasLoader Implements SpineAtlasLoader 'ignore blank lines If line.Length > 0 If pageHasStart = False + pageIndex += 1 'first line has no ':' it states the image file 'get image path pageFilePath = SpineCombinePaths(imagesDir, line) 'create new page page = SpineDefaultAtlasPage(atlas.AddPage(pageFilePath)) - 'check that page was loaded If page = Null Throw New SpineException("Invalid Image '" + pageFilePath + "' For Page '" + pageIndex + "' In Atlas '" + path + "'") @@ -143,6 +143,7 @@ Class SpineDefaultAtlasLoader Implements SpineAtlasLoader 'new region regionNew = True regionNextName = line + regionSave = True EndIf EndIf EndIf @@ -152,11 +153,13 @@ Class SpineDefaultAtlasLoader Implements SpineAtlasLoader 'page is finished pageNew = True pageHasHeader = False + pageHasStart = False + regionSave = True Else 'do reset of values If regionNew regionNew = False - + regionName = regionNextName regionIndex = -1 regionRotate = False @@ -246,7 +249,6 @@ Class SpineDefaultAtlasLoader Implements SpineAtlasLoader 'add the region region = SpineDefaultAtlasRegion(atlas.AddRegion(page, regionName, regionX, regionY, regionWidth, regionHeight, regionFrameX, regionFrameY, regionFrameWidth, regionFrameHeight)) - 'check to see if we failed to create this region? If region = Null Throw New SpineException("Invalid Region '" + regionName + "' For Page '" + pageIndex + "' In Atlas '" + path + "'") @@ -273,7 +275,7 @@ Class SpineMakeAtlasLoader Implements SpineAtlasLoader Local jsonPages:JSONArray Local fileStream:= fileLoader.LoadFile(path) If fileStream jsonPages = JSONArray(JSONData.ReadJSON(fileStream.ReadAll())) - If jsonPages = Null Throw New SpineException("Invalid Atlas '" + path + "'") + If jsonPages = Null Error SpineException("Invalid Atlas '" + path + "'") 'get images directory Local imagesDir:String = SpineExtractDir(path) @@ -507,7 +509,7 @@ Class SpineDefaultAtlas Implements SpineAtlas 'load the page image page.image = LoadImage(path) - If page.image = Null Throw New SpineException("Invalid atlas page image '" + path + "'") + If page.image = Null Error("Invalid atlas page image '" + path + "'") 'add to pages If pagesCount >= pages.Length pages = pages.Resize(pages.Length * 2 + 10) @@ -539,13 +541,13 @@ Class SpineDefaultAtlas Implements SpineAtlas region.image = region.page.image.GrabImage(x, y, width, height) 'figure out correct mid handle - region.image.SetHandle(0, 0)'offsetX + (originalWidth / 2.0), offsetY + (originalHeight / 2.0)) - + region.image.SetHandle(0, 0) + 'add to regions If regionsCount >= regions.Length regions = regions.Resize(regions.Length * 2 + 10) regions[regionsCount] = region regionsCount += 1 - + 'return it Return region End diff --git a/glue/gluefiles.monkey b/glue/gluefiles.monkey index 9c4ae9f..1e1e56c 100644 --- a/glue/gluefiles.monkey +++ b/glue/gluefiles.monkey @@ -30,8 +30,8 @@ Class SpineDefaultFileLoader Implements SpineFileLoader End Class SpineDefaultFileStream Implements SpineFileStream + Field originalString:String Field path:String - Field buffer:DataBuffer Field index:Int Field total:Int Field start:Int @@ -39,14 +39,13 @@ Class SpineDefaultFileStream Implements SpineFileStream Method Load:Bool(path:String) 'convert string into buffer Self.path = path - index = 0 - start = 0 + index = 1 + start = 1 'create buffer - Local data:String = LoadString(path) - total = data.Length - buffer = New DataBuffer(total) - buffer.PokeString(0, data) + originalString = LoadString(path) + + total = originalString.Length 'return success Return True @@ -57,16 +56,16 @@ Class SpineDefaultFileStream Implements SpineFileStream End Method ReadLine:String() - If buffer = Null or index >= total Return "" + If originalString = "" or index >= total Return "" - For index = index Until total + For index = index Until total 'check for end of line - If buffer.PeekByte(index) = 10 - Local result:String = buffer.PeekString(start, (index - start)) - index = index + 1 + If originalString[index] = 10 + Local result:String = originalString[start..index] + index += 1 start = index Return result - EndIf + End Next Return "" @@ -74,12 +73,11 @@ Class SpineDefaultFileStream Implements SpineFileStream Method ReadAll:String() 'just return the entire contents in a string - Local result:= buffer.PeekString(start) start = total - Return result + Return originalString End Method Eof:Bool() Return index >= total End -End \ No newline at end of file +End diff --git a/glue/gluespineentity.monkey b/glue/gluespineentity.monkey index 2eb9c17..0ff9e77 100644 --- a/glue/gluespineentity.monkey +++ b/glue/gluespineentity.monkey @@ -97,9 +97,12 @@ Class SpineEntity End Method Load:Bool(skeletonPath:String, atlas:SpineAtlas, fileLoader:SpineFileLoader) + Self.atlas = atlas + ' --- load a new spine entity --- 'load skeleton data 'we lock the atlas again + atlas.Lock() Local skeletonJson:= New SpineSkeletonJson(atlas) data = skeletonJson.ReadSkeletonData(skeletonPath) diff --git a/spineskeletonjson.monkey b/spineskeletonjson.monkey index 059af5f..17fd364 100644 --- a/spineskeletonjson.monkey +++ b/spineskeletonjson.monkey @@ -475,6 +475,8 @@ Class SpineSkeletonJson 'get the offset array jsonOffsetArray = JSONArray(jsonOrder.GetItem("offsets")) + If (jsonOffsetArray = Null) Then Continue + jsonOffsetTotal = jsonOffsetArray.values.Count() 'create draw order array and reset it diff --git a/spineskin.monkey b/spineskin.monkey index f07ef60..de9cc5f 100644 --- a/spineskin.monkey +++ b/spineskin.monkey @@ -68,7 +68,6 @@ Class SpineSkin End ' Attach all attachments from this if:skin the corresponding attachment from the old is:skin currently attached. - Private Method AttachAll:Void(skeleton:SpineSkeleton, oldSkin:SpineSkin) If oldSkin.attachments = Null Return