public void End(OTAtlasData space) { width = 0; string dx = ""; for (int i = 0; i < atlasData.Count; i++) { dx = atlasData[i].GetMeta("dx"); if (dx == "") { width += (int)(atlasData[i].offset.x + atlasData[i].size.x); } else { width += System.Convert.ToUInt16(dx); } } if (space != null) { dx = space.GetMeta("dx"); if (dx == "") { this.space = (int)(space.offset.x + space.size.x); } else { this.space = System.Convert.ToUInt16(dx); } if (this.space == 0) { this.space = 30; } } }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.DocumentElement.Name == "Imageset") { XmlNodeList subTextures = xml.DocumentElement.SelectNodes("Image"); for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); ad.name = S("Name"); ad.position = new Vector2(I("XPos"), I("YPos")); ad.size = new Vector2(I("Width"), I("Height")); ad.frameSize = new Vector2(I("Width"), I("Height")); ad.offset = Vector2.zero; data.Add(ad); } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.rootName == "Imageset") { OTDataset dsTextures = xml.Dataset("Image"); while(!dsTextures.EOF) { OTAtlasData ad = new OTAtlasData(); ad.name = dsTextures.AsString("Name"); ad.position = new Vector2(dsTextures.AsInt("XPos"), dsTextures.AsInt("YPos")); ad.size = new Vector2(dsTextures.AsInt("Width"), dsTextures.AsInt("Height")); ad.frameSize = new Vector2(dsTextures.AsInt("Width"), dsTextures.AsInt("Height")); ad.offset = Vector2.zero; data.Add(ad); dsTextures.Next(); } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.rootName == "TextureAtlas") { OTDataset dsTextures = xml.Dataset("SubTexture"); while (!dsTextures.EOF) { OTAtlasData ad = new OTAtlasData(); ad.name = dsTextures.AsString("name"); ad.position = new Vector2(dsTextures.AsInt("x"), dsTextures.AsInt("y")); ad.size = new Vector2(dsTextures.AsInt("width"), dsTextures.AsInt("height")); ad.frameSize = new Vector2(dsTextures.AsInt("frameWidth"), dsTextures.AsInt("frameHeight")); ad.offset = new Vector2(dsTextures.AsInt("frameX"), dsTextures.AsInt("frameY")) * -1; data.Add(ad); dsTextures.Next(); } } return(data.ToArray()); } }
string GetDY() { OTSpriteAtlas atlas = (spriteContainer as OTSpriteAtlas); if (atlas == null) { return(""); } string dy = atlas.GetMeta("dy"); if (dy == "") { if (atlas.atlasData.Length > 0) { OTAtlasData d = atlas.DataByName("" + ((byte)'J')); if (d == null) { d = atlas.DataByName("J"); } if (d == null) { d = atlas.atlasData[0]; } if (d != null) { dy = "" + (d.offset.y + d.size.y); } } else { dy = "50"; } } return(dy); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.rootName == "Imageset") { OTDataset dsTextures = xml.Dataset("Image"); while (!dsTextures.EOF) { OTAtlasData ad = new OTAtlasData(); ad.name = dsTextures.AsString("Name"); ad.position = new Vector2(dsTextures.AsInt("XPos"), dsTextures.AsInt("YPos")); ad.size = new Vector2(dsTextures.AsInt("Width"), dsTextures.AsInt("Height")); ad.frameSize = new Vector2(dsTextures.AsInt("Width"), dsTextures.AsInt("Height")); ad.offset = Vector2.zero; data.Add(ad); dsTextures.Next(); } } return(data.ToArray()); } }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.DocumentElement.Name == "plist") { XmlNode frames = xml.DocumentElement.SelectSingleNode("dict/key"); if (frames != null && frames.InnerText == "frames") { XmlNodeList subTextureNames = xml.DocumentElement.SelectNodes("dict/dict/key"); XmlNodeList subTextures = xml.DocumentElement.SelectNodes("dict/dict/dict"); try { for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); bool rotated = GetBool("rotated"); Rect frame = GetRect("frame"); Rect colorRect = GetRect("sourceColorRect"); Vector2 sourceSize = GetVector2("sourceSize"); try { ad.name = subTextureNames[si].InnerText.Split('.')[0]; } catch (System.Exception) { ad.name = subTextureNames[si].InnerText; } ad.position = new Vector2(frame.xMin, frame.yMin); if (rotated) { ad.rotated = true; } ad.size = new Vector2(colorRect.width, colorRect.height); ad.frameSize = sourceSize; ad.offset = new Vector2(colorRect.xMin, colorRect.yMin); data.Add(ad); } } catch (System.Exception ERR) { Debug.LogError("Orthello : Cocos2D Atlas Import error!"); Debug.LogError(ERR.Message); } } } return(data.ToArray()); } }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.DocumentElement.Name == "TextureAtlas") { XmlNodeList subTextures = xml.DocumentElement.SelectNodes("SubTexture"); for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); ad.name = S("name"); ad.position = new Vector2(I("x"), I("y")); ad.size = new Vector2(I("width"), I("height")); ad.frameSize = new Vector2(I("frameWidth"), I("frameHeight")); ad.offset = new Vector2(I("frameX"), I("frameY")) * -1; data.Add(ad); } } return(data.ToArray()); } }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.rootName == "TextureAtlas") { OTDataset dsTextures = xml.Dataset("SubTexture"); while (!dsTextures.EOF) { OTAtlasData ad = new OTAtlasData(); ad.name = dsTextures.AsString("name"); ad.position = new Vector2(dsTextures.AsInt("x"), dsTextures.AsInt("y")); ad.size = new Vector2(dsTextures.AsInt("width"), dsTextures.AsInt("height")); ad.frameSize = new Vector2(dsTextures.AsInt("frameWidth"), dsTextures.AsInt("frameHeight")); ad.offset = new Vector2(dsTextures.AsInt("frameX"), dsTextures.AsInt("frameY")) * -1; data.Add(ad); dsTextures.Next(); } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!Parse()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); First(); if (Exists("info") && Exists("face")) { metaType = "FONT"; name = "Font "+Data("face")+"-"+Data ("size"); if (Data ("bold")=="1") name += "b"; if (Data ("italic")=="1") name += "i"; do { if (Exists ("char")) { OTAtlasData ad = new OTAtlasData(); ad.name = Data ("id"); ad.position = new Vector2(IData("x"), IData("y")); ad.size = new Vector2(IData("width"), IData("height")); ad.offset = new Vector2(IData("xoffset"), IData("yoffset")); ad.AddMeta("dx",Data("xadvance")); data.Add(ad); } } while (Next ()); } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.DocumentElement.Name == "TextureAtlas") { XmlNodeList subTextures = xml.DocumentElement.SelectNodes("SubTexture"); for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); ad.name = S("name"); ad.position = new Vector2(I("x"), I("y")); ad.size = new Vector2(I("width"), I("height")); ad.frameSize = new Vector2(I("frameWidth"), I("frameHeight")); ad.offset = new Vector2(I("frameX"), I("frameY")) * -1; data.Add(ad); } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.DocumentElement.Name == "Imageset") { XmlNodeList subTextures = xml.DocumentElement.SelectNodes("Image"); for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); ad.name = S("Name"); ad.position = new Vector2(I("XPos"), I("YPos")); ad.size = new Vector2(I("Width"), I("Height")); ad.frameSize = new Vector2(I("Width"), I("Height")); ad.offset = Vector2.zero; data.Add(ad); } } return(data.ToArray()); } }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!Parse()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); First(); if (Exists("info") && Exists("face")) { metaType = "FONT"; if (name.IndexOf("Container (id=") == 0) { name = "Font " + Data("face") + "-" + Data("size"); if (Data("bold") == "1") { name += "b"; } if (Data("italic") == "1") { name += "i"; } } do { if (Exists("common")) { if (lineHeight == 0) { lineHeight = System.Convert.ToInt16(Data("lineHeight")); } if (Data("scaleW") != "") { sheetSize = new Vector2(System.Convert.ToSingle(Data("scaleW")), System.Convert.ToSingle(Data("scaleH"))); } } if (Exists("char")) { OTAtlasData ad = new OTAtlasData(); ad.name = Data("id"); ad.position = new Vector2(IData("x"), IData("y")); ad.size = new Vector2(IData("width"), IData("height")); ad.offset = new Vector2(IData("xoffset"), IData("yoffset")); ad.AddMeta("dx", Data("xadvance")); ad.frameSize = new Vector2(IData("width"), lineHeight); data.Add(ad); } } while (Next()); } return(data.ToArray()); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.DocumentElement.Name == "font") { XmlNode info = xml.DocumentElement.SelectSingleNode("info"); if (info != null && AttrS(info, "face") != "") { if (name.IndexOf("Container (id=") == 0) { name = "Font " + AttrS(info, "face") + "-" + AttrS(info, "size"); if (AttrS(info, "bold") == "1") { name += "b"; } if (AttrS(info, "italic") == "1") { name += "i"; } } metaType = "FONT"; XmlNode charsNode = xml.DocumentElement.SelectSingleNode("chars"); if (charsNode != null) { XmlNodeList chars = charsNode.SelectNodes("char"); for (int si = 0; si < chars.Count; si++) { XmlNode charNode = chars[si]; OTAtlasData ad = new OTAtlasData(); ad.name = "" + AttrI(charNode, "id"); ad.position = new Vector2(AttrI(charNode, "x"), AttrI(charNode, "y")); ad.size = new Vector2(AttrI(charNode, "width"), AttrI(charNode, "height")); ad.offset = new Vector2(AttrI(charNode, "xoffset"), AttrI(charNode, "yoffset")); ad.AddMeta("dx", AttrS(charNode, "xadvance")); data.Add(ad); } } } } return(data.ToArray()); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.DocumentElement.Name == "plist") { XmlNode frames = xml.DocumentElement.SelectSingleNode("dict/key"); if (frames != null && frames.InnerText == "frames") { XmlNodeList subTextureNames = xml.DocumentElement.SelectNodes("dict/dict/key"); XmlNodeList subTextures = xml.DocumentElement.SelectNodes("dict/dict/dict"); try { for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); bool rotated = GetBool("textureRotated"); Rect frame = GetRect("textureRect"); Rect colorRect = GetRect("spriteColorRect"); Vector2 sourceSize = GetVector2("spriteSourceSize"); try { ad.name = subTextureNames[si].InnerText.Split('.')[0]; } catch (System.Exception) { ad.name = subTextureNames[si].InnerText; } ad.position = new Vector2(frame.xMin, frame.yMin); if (rotated) ad.rotated = true; ad.size = new Vector2(colorRect.width, colorRect.height); ad.frameSize = sourceSize; ad.offset = new Vector2(colorRect.xMin, colorRect.yMin); data.Add(ad); } } catch (System.Exception ERR) { Debug.LogError("Orthello : Zwoptex Atlas Import error!"); Debug.LogError(ERR.Message); } } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!Parse()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); First(); if (Exists("info") && Exists("face")) { metaType = "FONT"; if (name.IndexOf("Container (id=")==0) { name = "Font "+Data("face")+"-"+Data ("size"); if (Data ("bold")=="1") name += "b"; if (Data ("italic")=="1") name += "i"; } do { if (Exists ("common")) { if (lineHeight == 0) { lineHeight = System.Convert.ToInt16(Data ("lineHeight")); } if (Data("scaleW")!="") sheetSize = new Vector2(System.Convert.ToSingle(Data ("scaleW")),System.Convert.ToSingle(Data ("scaleH"))); } if (Exists ("char")) { OTAtlasData ad = new OTAtlasData(); ad.name = Data ("id"); ad.position = new Vector2(IData("x"), IData("y")); ad.size = new Vector2(IData("width"), IData("height")); ad.offset = new Vector2(IData("xoffset"), IData("yoffset")); ad.AddMeta("dx",Data("xadvance")); ad.frameSize = new Vector2(IData("width"), lineHeight); data.Add(ad); } } while (Next ()); } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.rootName == "font") { OTDataset dsInfo = xml.Dataset("info"); if (!dsInfo.EOF) { if (dsInfo.AsString("face") != "") { if (name.IndexOf("Container (id=") == 0) { name = "Font " + dsInfo.AsString("face") + "-" + dsInfo.AsString("size"); if (dsInfo.AsString("bold") == "1") { name += "b"; } if (dsInfo.AsString("italic") == "1") { name += "i"; } } metaType = "FONT"; OTDataset dsChars = xml.Dataset("chars"); while (!dsChars.EOF) { OTAtlasData ad = new OTAtlasData(); ad.name = "" + dsChars.AsInt("id"); ad.position = new Vector2(dsChars.AsInt("x"), dsChars.AsInt("y")); ad.size = new Vector2(dsChars.AsInt("width"), dsChars.AsInt("height")); ad.offset = new Vector2(dsChars.AsInt("xoffset"), dsChars.AsInt("yoffset")); ad.AddMeta("dx", dsChars.AsString("xadvance")); data.Add(ad); dsChars.Next(); } } } } return(data.ToArray()); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.DocumentElement.Name == "font") { XmlNode info = xml.DocumentElement.SelectSingleNode("info"); if (info!=null && AttrS(info,"face")!="") { if (name.IndexOf("Container (id=")==0) { name = "Font "+AttrS(info,"face")+"-"+AttrS(info,"size"); if (AttrS(info,"bold")=="1") name += "b"; if (AttrS(info,"italic")=="1") name += "i"; } metaType = "FONT"; XmlNode charsNode = xml.DocumentElement.SelectSingleNode("chars"); if (charsNode!=null) { XmlNodeList chars = charsNode.SelectNodes("char"); for (int si = 0; si < chars.Count; si++) { XmlNode charNode = chars[si]; OTAtlasData ad = new OTAtlasData(); ad.name = ""+AttrI(charNode,"id"); ad.position = new Vector2(AttrI(charNode,"x"), AttrI(charNode,"y")); ad.size = new Vector2(AttrI(charNode,"width"), AttrI(charNode,"height")); ad.offset = new Vector2(AttrI(charNode,"xoffset"), AttrI(charNode,"yoffset")); ad.AddMeta("dx",AttrS(charNode,"xadvance")); data.Add(ad); } } } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.rootName == "font") { OTDataset dsInfo = xml.Dataset("info"); if (!dsInfo.EOF) { if (dsInfo.AsString("face")!="") { if (name.IndexOf("Container (id=")==0) { name = "Font "+dsInfo.AsString("face")+"-"+dsInfo.AsString("size"); if (dsInfo.AsString("bold")=="1") name += "b"; if (dsInfo.AsString("italic")=="1") name += "i"; } metaType = "FONT"; OTDataset dsChars = xml.Dataset("chars"); while (!dsChars.EOF) { OTAtlasData ad = new OTAtlasData(); ad.name = ""+dsChars.AsInt("id"); ad.position = new Vector2(dsChars.AsInt("x"), dsChars.AsInt("y")); ad.size = new Vector2(dsChars.AsInt("width"), dsChars.AsInt("height")); ad.offset = new Vector2(dsChars.AsInt("xoffset"), dsChars.AsInt("yoffset")); ad.AddMeta("dx",dsChars.AsString("xadvance")); data.Add(ad); dsChars.Next(); } } } } return data.ToArray(); }
string GetDY() { OTSpriteAtlas atlas = (spriteContainer as OTSpriteAtlas); if (atlas == null) { return(""); } string dy = atlas.GetMeta("dy"); if (dy == "") { if (atlas.atlasData.Length > 0) { OTAtlasData d = atlas.DataByName("" + ((byte)'J')); if (d == null) { d = atlas.DataByName("J"); } if (d == null) { d = atlas.atlasData[0]; } if (d != null) { dy = "" + (d.offset.y + d.size.y); } } else { dy = "50"; } } float idy = (float)System.Convert.ToDouble(dy); idy *= lineHeightModifier; idy = Mathf.Round(idy); return("" + idy); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!Parse()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); First(); if (Exists("info") && Exists("face")) { metaType = "FONT"; name = "Font " + Data("face") + "-" + Data("size"); if (Data("bold") == "1") { name += "b"; } if (Data("italic") == "1") { name += "i"; } do { if (Exists("char")) { OTAtlasData ad = new OTAtlasData(); ad.name = Data("id"); ad.position = new Vector2(IData("x"), IData("y")); ad.size = new Vector2(IData("width"), IData("height")); ad.offset = new Vector2(IData("xoffset"), IData("yoffset")); ad.AddMeta("dx", Data("xadvance")); data.Add(ad); } } while (Next()); } return(data.ToArray()); }
public void Add(string c, OTAtlasData data, Vector3[] verts, Vector2[] uv) { text += c; int tx = 0; string dx = data.GetMeta("dx"); if (dx == "") { tx = (int)(data.offset.x + data.size.x); } else { tx = System.Convert.ToUInt16(dx); } txList.Add(tx); atlasData.Add(data); int tt = 0; for (int i = 0; i < txList.Count - 1; i++) { tt += txList[i]; } Matrix4x4 mx = new Matrix4x4(); mx.SetTRS(new Vector3(tt, 0, 0), Quaternion.identity, Vector3.one); for (int i = 0; i < verts.Length; i++) { verts[i] = mx.MultiplyPoint3x4(verts[i]); } System.Array.Resize <Vector3>(ref this.verts, this.verts.Length + verts.Length); verts.CopyTo(this.verts, this.verts.Length - verts.Length); System.Array.Resize <Vector2>(ref this.uv, this.uv.Length + uv.Length); uv.CopyTo(this.uv, this.uv.Length - uv.Length); }
public void End(OTAtlasData space) { width = 0; string dx = ""; for (int i=0; i<atlasData.Count; i++) { dx = atlasData[i].GetMeta("dx"); if (dx=="") width += (int)(atlasData[i].offset.x + atlasData[i].size.x); else width += System.Convert.ToUInt16(dx); } if (space!=null) { dx = space.GetMeta("dx"); if (dx=="") this.space = (int)(space.offset.x + space.size.x); else this.space = System.Convert.ToUInt16(dx); if (this.space == 0) this.space = 30; } }
public void Add(string c, OTAtlasData data, Vector3[] verts, Vector2[] uv) { text+=c; int tx = 0; string dx = data.GetMeta("dx"); if (dx=="") tx = (int)(data.offset.x + data.size.x); else tx = System.Convert.ToUInt16(dx); txList.Add(tx); atlasData.Add(data); int tt = 0; for (int i=0; i<txList.Count-1; i++) tt+=txList[i]; Matrix4x4 mx = new Matrix4x4(); mx.SetTRS(new Vector3(tt,0,0), Quaternion.identity, Vector3.one); for (int i=0; i<verts.Length; i++) verts[i] = mx.MultiplyPoint3x4(verts[i]); System.Array.Resize<Vector3>(ref this.verts, this.verts.Length + verts.Length); verts.CopyTo(this.verts, this.verts.Length - verts.Length); System.Array.Resize<Vector2>(ref this.uv, this.uv.Length + uv.Length); uv.CopyTo(this.uv, this.uv.Length - uv.Length); }
public void NextWord(OTAtlasData space) { word.End(space); Word(); }
public void Add(string c, OTAtlasData data, Vector3[] verts, Vector2[] uv ) { word.Add(c, data, verts, uv); }
public void NextWord(OTAtlasData space) { lines[lines.Count-1].NextWord(space); }
public void Add(string c, OTAtlasData data, Vector3[] verts, Vector2[] uv) { lines[lines.Count-1].Add(c, data, verts, uv); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.DocumentElement.Name == "plist") { XmlNodeList nodeList = xml.DocumentElement.SelectNodes("dict/key"); for (int i=0; i<nodeList.Count; i++) { XmlNode frames = nodeList[i]; if (frames != null && frames.InnerText == "frames") { XmlNodeList subTextureNames = xml.DocumentElement.SelectNodes("dict/dict/key"); XmlNodeList subTextures = xml.DocumentElement.SelectNodes("dict/dict/dict"); try { for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); bool rotated = GetBool("rotated"); Rect frame = GetRect("frame"); Rect colorRect = GetRect("sourceColorRect"); Vector2 sourceSize = GetVector2("sourceSize"); try { ad.name = subTextureNames[si].InnerText.Split('.')[0]; } catch (System.Exception) { ad.name = subTextureNames[si].InnerText; } ad.position = new Vector2(frame.xMin, frame.yMin); if (rotated) ad.rotated = true; ad.size = new Vector2(colorRect.width, colorRect.height); ad.frameSize = sourceSize; ad.offset = new Vector2(colorRect.xMin, colorRect.yMin); data.Add(ad); } } catch (System.Exception ERR) { Debug.LogError("Orthello : Cocos2D Atlas Import error!"); Debug.LogError(ERR.Message); } } else if (frames != null && frames.InnerText == "metadata") { XmlNode sizeNode = frames.NextSibling.SelectSingleNode("key[text()=\"size\"]"); if (sizeNode!=null) sheetSize = StringToVector2(sizeNode.NextSibling.InnerText); XmlNode nameNode = frames.NextSibling.SelectSingleNode("key[text()=\"realTextureFileName\"]"); if (nameNode==null) nameNode = frames.NextSibling.SelectSingleNode("key[text()=\"textureFileName\"]"); if (nameNode!=null) { string[] sa = nameNode.NextSibling.InnerText.Split('.'); if (sa.Length>0) name = sa[0]; } } } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.rootName == "plist") { OTDataset dsKeys = xml.Dataset("dict/key"); while (!dsKeys.EOF) { string nodeText = xml.Value(dsKeys); if (nodeText == "frames") { object dict = xml.Next(dsKeys); if (xml.Name(dict) == "dict") { OTDataset dsTextureNames = xml.Dataset(dict, "key"); OTDataset dsTextures = xml.Dataset(dict, "dict"); if (!dsTextureNames.EOF && !dsTextures.EOF && dsTextureNames.rowCount == dsTextures.rowCount) { try { while (!dsTextureNames.EOF && !dsTextures.EOF) { OTAtlasData ad = new OTAtlasData(); bool rotated = GetBool(dsTextures, "textureRotated"); Rect frame = GetRect(dsTextures, "textureRect"); Rect colorRect = GetRect(dsTextures, "spriteColorRect"); Vector2 sourceSize = GetVector2(dsTextures, "spriteSourceSize"); try { ad.name = xml.Value(dsTextureNames).Split('.')[0]; } catch (System.Exception) { ad.name = xml.Value(dsTextureNames); } ad.position = new Vector2(frame.xMin, frame.yMin); if (rotated) { ad.rotated = true; } ad.size = new Vector2(colorRect.width, colorRect.height); ad.frameSize = sourceSize; ad.offset = new Vector2(colorRect.xMin, colorRect.yMin); data.Add(ad); dsTextureNames.Next(); dsTextures.Next(); } } catch (System.Exception ERR) { Debug.LogError("Orthello : Zwoptext Atlas Import error!"); Debug.LogError(ERR.Message); break; } } } } else if (nodeText == "metadata") { object dict = xml.Next(dsKeys); if (xml.Name(dict) == "dict") { object el = xml.FindValue(dict, "key", "size"); if (el != null) { sheetSize = StringToVector2(xml.Value(xml.Next(el))); } el = xml.FindValue(dict, "key", "realTextureFileName"); if (el == null) { el = xml.FindValue(dict, "key", "textureFileName"); } if (el != null) { string[] sa = xml.Value(xml.Next(el)).Split('.'); if (sa.Length > 0 && (name == "" || name.IndexOf("(id=-") >= 0)) { name = sa[0]; } } } } dsKeys.Next(); } } return(data.ToArray()); } }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.rootName == "plist") { OTDataset dsKeys = xml.Dataset("dict/key"); while (!dsKeys.EOF) { string nodeText = xml.Value(dsKeys); if (nodeText == "frames") { object dict = xml.Next(dsKeys); if (xml.Name(dict) == "dict") { OTDataset dsTextureNames = xml.Dataset(dict,"key"); OTDataset dsTextures = xml.Dataset(dict,"dict"); if (!dsTextureNames.EOF && !dsTextures.EOF && dsTextureNames.rowCount == dsTextures.rowCount) { try { while (!dsTextureNames.EOF && !dsTextures.EOF) { OTAtlasData ad = new OTAtlasData(); bool rotated = GetBool(dsTextures, "rotated"); Rect frame = GetRect(dsTextures, "frame"); Rect colorRect = GetRect(dsTextures, "sourceColorRect"); Vector2 sourceSize = GetVector2(dsTextures, "sourceSize"); try { ad.name = xml.Value(dsTextureNames).Split('.')[0]; } catch (System.Exception) { ad.name = xml.Value(dsTextureNames); } ad.position = new Vector2(frame.xMin, frame.yMin); if (rotated) ad.rotated = true; ad.size = new Vector2(colorRect.width, colorRect.height); ad.frameSize = sourceSize; ad.offset = new Vector2(colorRect.xMin, colorRect.yMin); data.Add(ad); dsTextureNames.Next(); dsTextures.Next(); } } catch (System.Exception ERR) { Debug.LogError("Orthello : Cocos2D Atlas Import error!"); Debug.LogError(ERR.Message); break; } } } } else if (nodeText == "metadata") { object dict = xml.Next(dsKeys); if (xml.Name(dict) == "dict") { object el = xml.FindValue(dict,"key","size"); if (el!=null) sheetSize = StringToVector2(xml.Value(xml.Next(el))); el = xml.FindValue(dict,"key","realTextureFileName"); if (el==null) el = xml.FindValue(dict,"key","textureFileName"); if (el!=null) { string[] sa = xml.Value(xml.Next(el)).Split('.'); if (sa.Length>0 && (name=="" || name.IndexOf("(id=-")>=0)) name = sa[0]; } } } dsKeys.Next(); } } return data.ToArray(); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) { return new OTAtlasData[] { } } ; List <OTAtlasData> data = new List <OTAtlasData>(); if (xml.DocumentElement.Name == "plist") { XmlNodeList nodeList = xml.DocumentElement.SelectNodes("dict/key"); for (int i = 0; i < nodeList.Count; i++) { XmlNode frames = nodeList[i]; if (frames != null && frames.InnerText == "frames") { XmlNodeList subTextureNames = xml.DocumentElement.SelectNodes("dict/dict/key"); XmlNodeList subTextures = xml.DocumentElement.SelectNodes("dict/dict/dict"); try { for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); bool rotated = GetBool("rotated"); Rect frame = GetRect("frame"); Rect colorRect = GetRect("sourceColorRect"); Vector2 sourceSize = GetVector2("sourceSize"); try { ad.name = subTextureNames[si].InnerText.Split('.')[0]; } catch (System.Exception) { ad.name = subTextureNames[si].InnerText; } ad.position = new Vector2(frame.xMin, frame.yMin); if (rotated) { ad.rotated = true; } ad.size = new Vector2(colorRect.width, colorRect.height); ad.frameSize = sourceSize; ad.offset = new Vector2(colorRect.xMin, colorRect.yMin); data.Add(ad); } } catch (System.Exception ERR) { Debug.LogError("Orthello : Cocos2D Atlas Import error!"); Debug.LogError(ERR.Message); } } else if (frames != null && frames.InnerText == "metadata") { XmlNode sizeNode = frames.NextSibling.SelectSingleNode("key[text()=\"size\"]"); if (sizeNode != null) { sheetSize = StringToVector2(sizeNode.NextSibling.InnerText); } XmlNode nameNode = frames.NextSibling.SelectSingleNode("key[text()=\"realTextureFileName\"]"); if (nameNode == null) { nameNode = frames.NextSibling.SelectSingleNode("key[text()=\"textureFileName\"]"); } if (nameNode != null) { string[] sa = nameNode.NextSibling.InnerText.Split('.'); if (sa.Length > 0) { name = sa[0]; } } } } } return(data.ToArray()); } }
public void Add(string c, OTAtlasData data, Vector3[] verts, Vector2[] uv) { word.Add(c, data, verts, uv); }
public void NextWord(OTAtlasData space) { lines[lines.Count - 1].NextWord(space); }
public void Add(string c, OTAtlasData data, Vector3[] verts, Vector2[] uv) { lines[lines.Count - 1].Add(c, data, verts, uv); }
void ParseText() { _bytesLines = GetBytes(); char[] chars = text.ToCharArray(); if (textFile != null) { chars = textFile.text.ToCharArray(); } for (int p = 0; p < _parsed.Count; p++) { _parsed[p].Clean(); } _parsed.Clear(); int dy = System.Convert.ToUInt16(GetDY()); int yPosition = 0; OTSpriteAtlas atlas = (spriteContainer as OTSpriteAtlas); OTAtlasData data = atlas.atlasData[0]; if (data != null && data.frameSize.y > 0 && lineHeight == 0) { lineHeight = (int)data.frameSize.y; } sizeChars = new int[] {}; System.Array.Resize <int>(ref sizeChars, chars.Length); int ci = 0; OTTextAlinea alinea = new OTTextAlinea(yPosition, lineHeight); foreach (char c in chars) { if (c == '\r') { sizeChars[ci++] = 0; continue; } if (c == '\n') { alinea.End(); _parsed.Add(alinea); yPosition -= dy; alinea = new OTTextAlinea(yPosition, lineHeight); sizeChars[ci++] = 0; continue; } data = atlas.DataByName("" + c); OTContainer.Frame frame = atlas.FrameByName("" + c); if (data == null || frame.name == "") { string charName = ((int)c).ToString(); data = atlas.DataByName(charName); frame = atlas.FrameByName(charName); } if (data == null || frame.name == "") { data = atlas.DataByName("" + c + ".png"); frame = atlas.FrameByName("" + c + ".png"); } if (data == null || frame.name == "") { byte b = System.Text.Encoding.ASCII.GetBytes("?")[0]; data = atlas.DataByName("" + b); frame = atlas.FrameByName("" + b); } if (data == null || frame.name == "") { data = atlas.DataByName("32"); frame = atlas.FrameByName("32"); } if (data != null && data.frameSize.y > 0 && lineHeight == 0) { lineHeight = (int)data.frameSize.y; } if (data != null && frame.name == data.name) { if (data.name != "32") { Vector3[] verts = new Vector3[] { new Vector3(frame.offset.x, -frame.offset.y, 0), new Vector3(frame.offset.x + frame.size.x, -frame.offset.y, 0), new Vector3(frame.offset.x + frame.size.x, -frame.offset.y - frame.size.y, 0), new Vector3(frame.offset.x, -frame.offset.y - frame.size.y, 0) }; alinea.Add(((char)c).ToString(), data, verts, frame.uv); } else { alinea.NextWord(data); } string dx = data.GetMeta("dx"); int width = 0; if (dx == "") { width = (int)(data.offset.x + data.size.x); } else { width = System.Convert.ToUInt16(dx); } if (width == 0) { width = 30; } sizeChars[ci++] = width; } } alinea.End(); _parsed.Add(alinea); if (wordWrap > 0) { for (int p = 0; p < _parsed.Count; p++) { _parsed[p].WordWrap(wordWrap, dy); for (int pp = p + 1; pp < _parsed.Count; pp++) { _parsed[pp].lines[0].yPosition -= (dy * (_parsed[p].lines.Count - 1)); } } } }
override protected Frame[] GetFrames() { if (texture == null) { return new Frame[] { } } ; Vector2 texSize = sheetSize; if (Vector2.Equals(texSize, Vector2.zero) && texture != null) { texSize = new Vector2(texture.width, texture.height); } if (Vector2.Equals(texSize, Vector2.zero)) { return new Frame[] { } } ; if (atlasReady && atlasData.Length > 0) { // convert atlasData to frames Frame[] frames = new Frame[atlasData.Length]; dataByName.Clear(); for (int a = 0; a < atlasData.Length; a++) { OTAtlasData data = atlasData[a]; Frame frame = new Frame(); frame.name = data.name; if (!dataByName.ContainsKey(data.name)) { dataByName.Add(data.name, data); } if (offsetSizing) { frame.offset = data.offset; frame.size = data.size; } else { frame.offset = Vector2.zero; frame.size = data.frameSize; Vector2 vOffset = new Vector2(data.offset.x / frame.size.x, data.offset.y / frame.size.y); Vector2 vSize = new Vector2(data.size.x / frame.size.x, data.size.y / frame.size.y); Vector3 tl = new Vector3(((1f / 2f) * -1) + vOffset.x, (1f / 2f) - vOffset.y, 0); frame.vertices = new Vector3[] { tl, tl + new Vector3(vSize.x, 0, 0), tl + new Vector3(vSize.x, vSize.y * -1, 0), tl + new Vector3(0, vSize.y * -1, 0) }; } frame.imageSize = data.frameSize; frame.uv = new Vector2[4]; float sx = data.position.x / texSize.x; float sy = 1 - ((data.position.y + data.size.y) / texSize.y); float scx = data.size.x / texSize.x; float scy = data.size.y / texSize.y; if (data.rotated) { sy = 1 - ((data.position.y + data.size.x) / texSize.y); scx = data.size.y / texSize.x; scy = data.size.x / texSize.y; frame.uv[3] = new Vector2(sx, sy + scy); frame.uv[0] = new Vector2(sx + scx, sy + scy); frame.uv[1] = new Vector2(sx + scx, sy); frame.uv[2] = new Vector2(sx, sy); } else { frame.uv[0] = new Vector2(sx, sy + scy); frame.uv[1] = new Vector2(sx + scx, sy + scy); frame.uv[2] = new Vector2(sx + scx, sy); frame.uv[3] = new Vector2(sx, sy); } frames[a] = frame; } return(frames); } return(new Frame[] { }); } new protected void Start()
void ParseText() { _bytesLines = GetBytes(); byte[] chars = System.Text.Encoding.ASCII.GetBytes(text); if (textFile != null) { chars = System.Text.Encoding.ASCII.GetBytes(textFile.text); } for (int p = 0; p < _parsed.Count; p++) { _parsed[p].Clean(); } _parsed.Clear(); int dy = System.Convert.ToUInt16(GetDY()); int yPosition = 0; OTSpriteAtlas atlas = (spriteContainer as OTSpriteAtlas); OTTextAlinea alinea = new OTTextAlinea(yPosition); foreach (byte c in chars) { if (c == '\r') { continue; } if (c == '\n') { alinea.End(); _parsed.Add(alinea); yPosition -= dy; alinea = new OTTextAlinea(yPosition); continue; } OTAtlasData data = atlas.DataByName("" + c); OTContainer.Frame frame = atlas.FrameByName("" + c); if (data == null || frame.name == "") { data = atlas.DataByName("" + c + ".png"); frame = atlas.FrameByName("" + c + ".png"); } if (data == null || frame.name == "") { char[] ch = System.Text.ASCIIEncoding.ASCII.GetChars(new byte[] { c }); data = atlas.DataByName(ch[0].ToString()); frame = atlas.FrameByName(ch[0].ToString()); } if (data == null || frame.name == "") { char[] ch = System.Text.ASCIIEncoding.ASCII.GetChars(new byte[] { c }); data = atlas.DataByName(ch[0].ToString() + ".png"); frame = atlas.FrameByName(ch[0].ToString() + ".png"); } if (data == null || frame.name == "") { byte b = System.Text.Encoding.ASCII.GetBytes("?")[0]; data = atlas.DataByName("" + b); frame = atlas.FrameByName("" + b); } if (data == null || frame.name == "") { data = atlas.DataByName("32"); frame = atlas.FrameByName("32"); } if (data != null && frame.name == data.name) { if (data.name != "32") { Vector3[] verts = new Vector3[] { new Vector3(frame.offset.x, -frame.offset.y, 0), new Vector3(frame.offset.x + frame.size.x, -frame.offset.y, 0), new Vector3(frame.offset.x + frame.size.x, -frame.offset.y - frame.size.y, 0), new Vector3(frame.offset.x, -frame.offset.y - frame.size.y, 0) }; alinea.Add(((char)c).ToString(), data, verts, frame.uv); } else { alinea.NextWord(data); } } } alinea.End(); _parsed.Add(alinea); if (wordWrap > 0) { for (int p = 0; p < _parsed.Count; p++) { _parsed[p].WordWrap(wordWrap, dy); for (int pp = p + 1; pp < _parsed.Count; pp++) { _parsed[pp].lines[0].yPosition -= (dy * (_parsed[p].lines.Count - 1)); } } } }