private bool expand_package(string identity, int offset, int eob /*end of block*/, wzproperty host) { string type = reader.transit_string(offset); int index = wzproperty.index_of_type(type); wzproperty property = new wzproperty(identity, index, reader.position, null, host, reader); host.append(identity, property); switch (index) { case 0: return(expand_shape2d_Convex2D(offset, eob, property)); case 1: return(expand_shape2d_vector2d(property)); case 2: return(expand_sound_dx8(eob, property)); case 3: return(expand_property(offset, property)); case 4: return(expand_canvas(offset, property)); case 5: return(expand_uol(offset, property)); default: break; } return(false); }
protected virtual string StringValue(string type, string name, wzproperty prop) { var rgx = new System.Text.RegularExpressions.Regex("\\\\r\\\\n|\\\\n|\\\\r"); string value = rgx.Replace((prop.data + ""), "↵"); return("<" + type + " name=\"" + name + "\" value=\"" + (value) + "\"/>"); }
protected virtual void pod(string name, wzproperty prop, string current_path) { if (prop == null) { return; } try { var type = prop.type; switch (type) { case 3: // "Property" this.enum_property(prop, current_path); break; case 4: // Canvas this.Canvas(prop, current_path); break; case 5: // UOL this.pod(name, (prop.data as wzuol).target, current_path); break; } } catch (Exception ex) { Console.Write("<cs Error: " + ex.Message + "\n" + ex.StackTrace + ">"); } }
protected override StringBuilder Canvas(string name, wzproperty prop, string path) { StringBuilder sb = new StringBuilder(); var canvas = Tools.inspect_canvas1(prop); if (canvas != null) { //string prop_path = prop.absolute.Replace('\0', '/'); //var path = this.imgPath + prop_path; var sub_path = path + prop.identity; var canvas_path = Tools.get_canvas_path(prop, sub_path); sb.Append("<canvas name=\""); sb.Append(name); sb.Append("\" width=\""); sb.Append(canvas.width); sb.Append("\" height=\""); sb.Append(canvas.height); sb.Append("\" url=\""); sb.Append(canvas_path); sb.Append("\">"); sb.Append(this.enum_property(prop, sub_path + "/")); sb.Append("</canvas>"); } return(sb); }
public static string get_canvas_path(wzproperty property, string path) { property = inspect_canvas(property); if (null != property) { string link = property.query(null as string, "source") ?? property.query(null as string, "_outlink") ?? property.query(null as string, "_inlink"); if (null == link) { return(path); } else { int index = link.IndexOf(".img/"); if (0 <= index) //outlink { return(link.Substring(0, index) + link.Substring(index + 4)); } else if (path != null) //inlink { var result = path.Replace(property.absolute.Replace("\0", "/"), "/" + link); return(result); } } } return(path); }
public object pod_property(wzproperty prop, int deep = Int32.MaxValue) { if ((deep - 1) >= 0) { dynamic eo = new ExpandoObject(); var eoColl = (ICollection <KeyValuePair <string, object> >)eo; //foreach (var id in prop.identities) //{ // var i = prop[id]; foreach (var i in prop.values) { if (i.identity.StartsWith("_")) { continue; } var p = this.pod(i, deep - 1); eoColl.Add(new KeyValuePair <string, object>(i.identity, p)); } return(eo); } else { return("..."); } }
protected StringBuilder pod(string name, wzproperty prop) { StringBuilder sb = new StringBuilder(); if (prop == null) { return(sb); } try { var type = prop.type; switch (type) { case 1: // Shape2D#Vector2D sb.Append(this.Vector(name, prop.data as wzvector)); //return (prop.data as wzvector).content; break; case 3: // "Property" sb.Append(this.ImgDir(name, prop)); //return null; break; case 4: // Canvas sb.Append(this.Canvas(name, prop)); // break; case 5: // UOL sb.Append(this.pod(name, (prop.data as wzuol).target)); //return (prop.data as wzuol).link;//need inspect break; case 0x02 + 6: goto case 0x0b + 6; //int16 case 0x03 + 6: goto case 0x13 + 6; //int case 0x04 + 6: sb.Append(this.Value("float32", name, prop)); break; case 0x05 + 6: sb.Append(this.Value("float64", name, prop)); break; case 0x08 + 6: sb.Append(this.StringValue("string", name, prop)); break; case 0x09 + 6: break; // "{Package}"; case 0x0b + 6: sb.Append(this.Value("int16", name, prop)); break; case 0x13 + 6: sb.Append(this.Value("int", name, prop)); break; case 0x14 + 6: sb.Append(this.Value("int64", name, prop)); break; default: // undefined type System.Windows.Forms.MessageBox.Show(prop.decorate_absolute + "\n\ttype:" + type, "undefined type"); sb.Append("<undefined_type name=\"" + name + "\" value=\"" + (prop.data + "") + "\"/>"); break; } } catch (Exception ex) { Console.Write("<cs Error: " + ex.Message + "\n" + ex.StackTrace + ">"); } return(sb); }
public wzuol(uint unknow, string link, wzproperty host) { properties = new object[] { unknow, link, host, }; }
internal wzuol(uint unknow, string link, wzproperty owner) { properties = new object[] { unknow, link, owner, }; }
public static void get_data(string link, out wzpackage outPack, out wzproperty outProp) { _get_data(link, out outPack, out outProp); if (outProp != null && outProp.type == 5) // UOL { outProp = (outProp.data as wzuol).target; } }
protected object[] _getPropertyByLink(string link) { string name = null; wzproperty prop = null; try { if (link.EndsWith(".img")) { this.imgPath = link + "/"; var paths = link.Split('/'); name = paths[paths.Length - 1]; prop = DataSource.packages[paths].root[""]; return(new object[] { name, prop }); } else if (link.EndsWith(".img/")) { this.imgPath = link; var paths = link.Substring(0, link.Length - 1).Split('/'); name = paths[paths.Length - 1]; prop = DataSource.packages[paths].root[""]; return(new object[] { name, prop }); } else { var index = link.IndexOf(".img/"); var ns = link.Split('/'); if (index >= 0 && (index + 5) < link.Length) { this.imgPath = link.Substring(0, index + 5); DataSource.get_data(link, out prop); return(new object[] { ns[ns.Length - 1], prop }); } } System.Windows.Forms.MessageBox.Show(link); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\n\t" + ex.StackTrace); } return(null); }
protected virtual StringBuilder ImgDir(string name, wzproperty prop, string path) { StringBuilder sb = new StringBuilder(); sb.Append("<imgdir name=\""); sb.Append(name); sb.Append("\">"); sb.Append(this.enum_property(prop, path + name + "/")); sb.Append("</imgdir>"); return(sb); }
internal DataExtracter(string setting) { this.inspet = new Inspector_Base64(); if (setting != "no_string") { this.chara = DataSource.packages["Character"]; this.equip_names = DataSource.packages["String", "Eqp"].root[""]["Eqp"]; } }
protected virtual void Canvas(wzproperty prop, string current_path) { var canvas = this.inspect_canvas1(prop); if (canvas != null) { images.Push(new object[] { current_path, canvas }); //don't use current_path create directory //this.enum_property(prop, current_path); } }
protected override void enum_property(wzproperty prop, string current_path) { foreach (var i in prop.values) { //if (i.identity.StartsWith("_")) //{ // continue; //} this.pod(i.identity, i, current_path + "/" + i.identity); } }
private bool expand_sound_dx8(int eob, wzproperty property) { int unknow = reader.read <byte>(); int size = reader.upack <int>(); int unknow1 = reader.upack <int>(); reader.position = reader.position + 51; property.data = new wzaudio(unknow, size, unknow1, eob - size, reader.read <byte>(), reader); reader.position = eob; return(true); }
private bool expand_shape2d_Convex2D(int offset, int eob, wzproperty property) { int count = reader.upack <int>(); for (int index = 0; index < count; ++index) { if (!expand_package(index.ToString(), offset, eob, property)) { return(false); } } return(true); }
protected virtual void enum_property(wzproperty prop, string current_path) { System.IO.Directory.CreateDirectory(current_path); foreach (var i in prop.values) { //if (i.identity.StartsWith("_")) //{ // continue; //} this.pod(i.identity, i, current_path + "/" + i.identity); } }
string get_item_desc(wzproperty ss_prop, int id) { try { var ns = ss_prop[id + ""]; if (ns != null) { return((string)ns["desc"].data); } } catch (Exception) { } return(null); }
public static wzcanvas inspect_canvas1(wzproperty property) { property = Tools._inspect_canvas1(property); if (null != property) { wzcanvas source; source = property.query <wzcanvas>(null); return(source); } return(null); }
protected StringBuilder enum_property(wzproperty prop) { StringBuilder sb = new StringBuilder(); foreach (var i in prop.values) { if (i.identity.StartsWith("_")) { continue; } sb.Append(this.pod(i.identity, i)); } return(sb); }
public override void inspect_image(wzproperty prop, string path, ICollection <KeyValuePair <string, object> > eoColl) { var canvas = Tools.inspect_canvas1(prop); if (canvas != null) { eoColl.Add(new KeyValuePair <string, object>("", Tools.ImageToBase64PNG(canvas.image))); eoColl.Add(new KeyValuePair <string, object>("__w", canvas.width)); eoColl.Add(new KeyValuePair <string, object>("__h", canvas.height)); } else { eoColl.Add(new KeyValuePair <string, object>("__isEmpty", true)); } }
public static wzproperty inspect_canvas(wzproperty property) { if (null != property) { if (4 == property.type) { return(property); } if (5 == property.type) { return(inspect_canvas((property.data as wzuol).target)); } } return(null); }
string get_item_name(wzproperty ss_prop, int id) { try { var ns = ss_prop[id + ""]; if (ns != null) { return((string)ns["name"].data); } } catch (Exception ex) { Console.WriteLine("ID: " + id + " : item is not exist"); Console.WriteLine(ex.StackTrace); } return("[" + id + "]"); }
private bool expand_property(int offset, wzproperty property) { int unknow = reader.read <short>(); int count = reader.upack <int>(); for (int index = 0; index < count; ++index) { if (!expand_block(offset, property)) { return(false); } } property.data = unknow; return(true); }
protected StringBuilder enum_property(wzproperty prop, string path) { StringBuilder sb = new StringBuilder(); foreach (var sub_prop in prop.values) { #if !EQUIPLIST if (sub_prop.identity.StartsWith("_")) { continue; } #endif sb.Append(this.pod(sub_prop.identity, sub_prop, path)); } return(sb); }
//protected string _wzpropertyToXML(string name, wzproperty prop) //{ // StringBuilder sb = new StringBuilder(); // // sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); // // sb.Append("<?xml-stylesheet href=\"/wzproperty.xslt\" type=\"text/xsl\" ?>"); // // sb.Append("<xmldump><imgdir name=\""); // sb.Append(name); // sb.Append("\">"); // // sb.Append(this.enum_property(prop)); // // sb.Append("</imgdir></xmldump>"); // // return sb.ToString(); //} protected string _wzimgToXML(string name, wzproperty prop) { StringBuilder sb = new StringBuilder(); sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); sb.Append("<?xml-stylesheet href=\"/wzproperty.xslt\" type=\"text/xsl\" ?>"); sb.Append("<xmldump><wzimg name=\""); sb.Append(name); sb.Append("\">"); sb.Append(this.enum_property(prop)); sb.Append("</wzimg></xmldump>"); return(sb.ToString()); }
public override void inspect_image(wzproperty prop, string path, ICollection <KeyValuePair <string, object> > eoColl) { var canvas = Tools.inspect_canvas1(prop); if (canvas != null) { var _path = Tools.get_canvas_path(prop, path); eoColl.Add(new KeyValuePair <string, object>("", "/" + _path)); //Console.WriteLine(_path); eoColl.Add(new KeyValuePair <string, object>("__w", canvas.width)); eoColl.Add(new KeyValuePair <string, object>("__h", canvas.height)); } else { eoColl.Add(new KeyValuePair <string, object>("__isEmpty", true)); } }
private bool expand_canvas(int offset, wzproperty property) { wzcanvas canvas; int unknow = reader.read <byte>(); if (1 == reader.read <byte>()) { if (!expand_property(offset, property)) { return(false); } } canvas = new wzcanvas(unknow, reader.upack <int>(), reader.upack <int>(), reader.upack <int>() + reader.read <byte>(), reader.read <int>(), reader.read <int>(), reader.position, reader); property.data = canvas; reader.position = reader.position + canvas.size; return(true); }
//protected string _wzpropertyToXML(string name, wzproperty prop) //{ // StringBuilder sb = new StringBuilder(); // // sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); // // sb.Append("<?xml-stylesheet href=\"/wzproperty.xslt\" type=\"text/xsl\" ?>"); // // sb.Append("<xmldump><imgdir name=\""); // sb.Append(name); // sb.Append("\">"); // // sb.Append(this.enum_property(prop)); // // sb.Append("</imgdir></xmldump>"); // // return sb.ToString(); //} protected string _wzimgToXML(wzproperty prop, string path) { bool is_wzpackage = path.EndsWith("/"); string _path = (is_wzpackage ? path.Substring(0, path.Length - 1) : path); string raw_name = _path.Substring(_path.LastIndexOf("/") + 1) + (is_wzpackage ? ".img" : ""); StringBuilder sb = new StringBuilder(); sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); sb.Append("<?xml-stylesheet href=\"/wzproperty.xslt\" type=\"text/xsl\" ?>"); sb.Append("<xmldump><wzimg name=\""); sb.Append(raw_name); sb.Append("\">"); sb.Append(this.enum_property(prop, path + "/")); sb.Append("</wzimg></xmldump>"); return(sb.ToString()); }