/// <summary> /// Gets a WzImageProperty from a path /// </summary> /// <param name="path">path to object</param> /// <returns>the selected WzImageProperty</returns> public IWzImageProperty GetFromPath(string path) { if (reader != null) { if (!parsed) { ParseImage(); } } string[] segments = path.Split(new char[1] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); if (segments[0] == "..") { return(null); } //hack method of adding the properties WzSubProperty childProperties = new WzSubProperty(); childProperties.AddProperties(properties.ToArray()); IWzImageProperty ret = childProperties; for (int x = 0; x < segments.Length; x++) { bool foundChild = false; foreach (IWzImageProperty iwp in ret.WzProperties) { if (iwp.Name == segments[x]) { if (iwp.PropertyType == WzPropertyType.Extended) { ret = ((WzExtendedProperty)iwp).ExtendedProperty; } else { ret = iwp; } foundChild = true; break; } } if (!foundChild) { return(null); } } return(ret); }
internal void SaveImage(WzBinaryWriter writer) { if (reader != null && !parsed) { ParseImage(); } WzSubProperty imgProp = new WzSubProperty(); long startPos = writer.BaseStream.Position; imgProp.AddProperties(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); size = (int)(writer.BaseStream.Position - startPos); }
internal void SaveImage(WzBinaryWriter writer) { if (changed) { if (reader != null && !parsed) { ParseImage(); } WzSubProperty imgProp = new WzSubProperty(); long startPos = writer.BaseStream.Position; imgProp.AddProperties(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); size = (int)(writer.BaseStream.Position - startPos); } else { long pos = reader.BaseStream.Position; reader.BaseStream.Position = offset; writer.Write(reader.ReadBytes(size)); reader.BaseStream.Position = pos; } }
internal void SaveImage(WzBinaryWriter writer) { if (Changed) { if (reader != null && !Parsed) { ParseImage(); } var imgProp = new WzSubProperty(); var startPos = writer.BaseStream.Position; imgProp.AddProperties(WzProperties); imgProp.WriteValue(writer); writer.StringCache.Clear(); BlockSize = (int)(writer.BaseStream.Position - startPos); } else { var pos = reader.BaseStream.Position; reader.BaseStream.Position = Offset; writer.Write(reader.ReadBytes(BlockSize)); reader.BaseStream.Position = pos; } }
internal static IExtended ExtractMore(WzBinaryReader reader, uint offset, int eob, string name, string iname, IWzObject parent, WzImage imgParent) { if (iname == "") { iname = reader.ReadString(); } switch (iname) { case "Property": WzSubProperty subProp = new WzSubProperty(name) { Parent = parent }; reader.BaseStream.Position += 2; subProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, subProp, imgParent)); return(subProp); case "Canvas": WzCanvasProperty canvasProp = new WzCanvasProperty(name) { Parent = parent }; reader.BaseStream.Position++; if (reader.ReadByte() == 1) { reader.BaseStream.Position += 2; canvasProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, canvasProp, imgParent)); } canvasProp.PngProperty = new WzPngProperty(reader, imgParent.parseEverything) { Parent = canvasProp }; return(canvasProp); case "Shape2D#Vector2D": WzVectorProperty vecProp = new WzVectorProperty(name) { Parent = parent }; vecProp.X = new WzCompressedIntProperty("X", reader.ReadCompressedInt()) { Parent = vecProp }; vecProp.Y = new WzCompressedIntProperty("Y", reader.ReadCompressedInt()) { Parent = vecProp }; return(vecProp); case "Shape2D#Convex2D": WzConvexProperty convexProp = new WzConvexProperty(name) { Parent = parent }; int convexEntryCount = reader.ReadCompressedInt(); convexProp.WzProperties.Capacity = convexEntryCount; //performance thing for (int i = 0; i < convexEntryCount; i++) { convexProp.AddProperty(ParseExtendedProp(reader, offset, 0, name, convexProp, imgParent)); } return(convexProp); case "Sound_DX8": WzSoundProperty soundProp = new WzSoundProperty(name, reader, imgParent.parseEverything) { Parent = parent }; return(soundProp); case "UOL": reader.BaseStream.Position++; switch (reader.ReadByte()) { case 0: return(new WzUOLProperty(name, reader.ReadString()) { Parent = parent }); case 1: return(new WzUOLProperty(name, reader.ReadStringAtOffset(offset + reader.ReadInt32())) { Parent = parent }); } throw new Exception("Unsupported UOL type"); default: throw new Exception("Unknown iname: " + iname); } }
/// <summary> /// Save MapInfo variables to WzImage /// </summary> /// <param name="dest"></param> /// <param name="VR"></param> public void Save(WzImage dest, Rectangle?VR) { WzSubProperty info = new WzSubProperty(); info["bgm"] = InfoTool.SetString(bgm); info["cloud"] = InfoTool.SetBool(cloud); info["swim"] = InfoTool.SetBool(swim); info["forcedReturn"] = InfoTool.SetInt(forcedReturn); info["hideMinimap"] = InfoTool.SetBool(hideMinimap); info["mapDesc"] = InfoTool.SetOptionalString(mapDesc); info["mapName"] = InfoTool.SetOptionalString(mapDesc); info["mapMark"] = InfoTool.SetString(mapMark); info["mobRate"] = InfoTool.SetFloat(mobRate); info["moveLimit"] = InfoTool.SetOptionalInt(moveLimit); info["returnMap"] = InfoTool.SetInt(returnMap); info["town"] = InfoTool.SetBool(town); info["version"] = InfoTool.SetInt(version); info["fieldLimit"] = InfoTool.SetInt((int)fieldLimit); info["timeLimit"] = InfoTool.SetOptionalInt(timeLimit); info["lvLimit"] = InfoTool.SetOptionalInt(lvLimit); info["VRTop"] = InfoTool.SetOptionalInt(VRTop); info["VRBottom"] = InfoTool.SetOptionalInt(VRBottom); info["VRLeft"] = InfoTool.SetOptionalInt(VRLeft); info["VRRight"] = InfoTool.SetOptionalInt(VRRight); info["onFirstUserEnter"] = InfoTool.SetOptionalString(onFirstUserEnter); info["onUserEnter"] = InfoTool.SetOptionalString(onUserEnter); info["fly"] = InfoTool.SetOptionalBool(fly); info["noMapCmd"] = InfoTool.SetOptionalBool(noMapCmd); info["partyOnly"] = InfoTool.SetOptionalBool(partyOnly); info["fieldType"] = InfoTool.SetOptionalInt((int?)fieldType); info["miniMapOnOff"] = InfoTool.SetOptionalBool(miniMapOnOff); info["reactorShuffle"] = InfoTool.SetOptionalBool(reactorShuffle); info["reactorShuffleName"] = InfoTool.SetOptionalString(reactorShuffleName); info["personalShop"] = InfoTool.SetOptionalBool(personalShop); info["entrustedShop"] = InfoTool.SetOptionalBool(entrustedShop); info["effect"] = InfoTool.SetOptionalString(effect); info["lvForceMove"] = InfoTool.SetOptionalInt(lvForceMove); info["mirror_Bottom"] = InfoTool.SetOptionalBool(mirror_Bottom); // Time mob if (timeMob != null) { WzSubProperty prop = new WzSubProperty(); prop["startHour"] = InfoTool.SetOptionalInt(timeMob.Value.startHour); prop["endHour"] = InfoTool.SetOptionalInt(timeMob.Value.endHour); prop["id"] = InfoTool.SetOptionalInt(timeMob.Value.id); prop["message"] = InfoTool.SetOptionalString(timeMob.Value.message); info["timeMob"] = prop; } info["help"] = InfoTool.SetOptionalString(help); info["snow"] = InfoTool.SetOptionalBool(snow); info["rain"] = InfoTool.SetOptionalBool(rain); info["dropExpire"] = InfoTool.SetOptionalInt(dropExpire); info["decHP"] = InfoTool.SetOptionalInt(decHP); info["decInterval"] = InfoTool.SetOptionalInt(decInterval); // Lie detector if (autoLieDetector != null) { WzSubProperty prop = new WzSubProperty(); prop["startHour"] = InfoTool.SetOptionalInt(autoLieDetector.startHour); prop["endHour"] = InfoTool.SetOptionalInt(autoLieDetector.endHour); prop["interval"] = InfoTool.SetOptionalInt(autoLieDetector.interval); prop["prop"] = InfoTool.SetOptionalInt(autoLieDetector.prop); info["autoLieDetector"] = prop; } info["expeditionOnly"] = InfoTool.SetOptionalBool(expeditionOnly); info["fs"] = InfoTool.SetOptionalFloat(fs); info["protectItem"] = InfoTool.SetOptionalInt(protectItem); info["createMobInterval"] = InfoTool.SetOptionalInt(createMobInterval); info["fixedMobCapacity"] = InfoTool.SetOptionalInt(fixedMobCapacity); info["streetName"] = InfoTool.SetOptionalString(streetName); info["noRegenMap"] = InfoTool.SetOptionalBool(noRegenMap); if (allowedItem != null) { WzSubProperty prop = new WzSubProperty(); for (int i = 0; i < allowedItem.Count; i++) { prop[i.ToString()] = InfoTool.SetInt(allowedItem[i]); } info["allowedItem"] = prop; } info["recovery"] = InfoTool.SetOptionalFloat(recovery); info["blockPBossChange"] = InfoTool.SetOptionalBool(blockPBossChange); info["everlast"] = InfoTool.SetOptionalBool(everlast); info["damageCheckFree"] = InfoTool.SetOptionalBool(damageCheckFree); info["dropRate"] = InfoTool.SetOptionalFloat(dropRate); info["scrollDisable"] = InfoTool.SetOptionalBool(scrollDisable); info["needSkillForFly"] = InfoTool.SetOptionalBool(needSkillForFly); info["zakum2Hack"] = InfoTool.SetOptionalBool(zakum2Hack); info["allMoveCheck"] = InfoTool.SetOptionalBool(allMoveCheck); info["VRLimit"] = InfoTool.SetOptionalBool(VRLimit); info["consumeItemCoolTime"] = InfoTool.SetOptionalBool(consumeItemCoolTime); info["zeroSideOnly"] = InfoTool.SetOptionalBool(zeroSideOnly); foreach (WzImageProperty prop in additionalProps) { info.AddProperty(prop); } if (VR.HasValue) { info["VRLeft"] = InfoTool.SetInt(VR.Value.Left); info["VRRight"] = InfoTool.SetInt(VR.Value.Right); info["VRTop"] = InfoTool.SetInt(VR.Value.Top); info["VRBottom"] = InfoTool.SetInt(VR.Value.Bottom); } // Add back all unsupported properties info.AddProperties(unsupportedInfoProperties); // dest["info"] = info; }
internal static AWzImageProperty ExtractMore(WzBinaryReader pReader, uint pOffset, int pEndOfBlock, string pName, string pImageName, AWzObject pParent, WzImage pImgParent) { switch (pImageName) { case "Property": WzSubProperty subProp = new WzSubProperty(pName) { Parent = pParent, ParentImage = pImgParent }; pReader.BaseStream.Position += 2; subProp.AddProperties(ParsePropertyList(pOffset, pReader, subProp, pImgParent)); return(subProp); case "Canvas": WzCanvasProperty canvasProp = new WzCanvasProperty(pName) { Parent = pParent, ParentImage = pImgParent }; pReader.BaseStream.Position++; if (pReader.ReadByte() == 1) { pReader.BaseStream.Position += 2; canvasProp.AddProperties(ParsePropertyList(pOffset, pReader, canvasProp, pImgParent)); } canvasProp.PngProperty = new WzPngProperty(pReader) { Parent = canvasProp, ParentImage = pImgParent }; return(canvasProp); case "Shape2D#Vector2D": WzVectorProperty vecProp = new WzVectorProperty(pName) { Parent = pParent, ParentImage = pImgParent }; vecProp.X = new WzCompressedIntProperty("X", pReader.ReadCompressedInt()) { Parent = vecProp, ParentImage = pImgParent }; vecProp.Y = new WzCompressedIntProperty("Y", pReader.ReadCompressedInt()) { Parent = vecProp, ParentImage = pImgParent }; return(vecProp); case "Shape2D#Convex2D": WzConvexProperty convexProp = new WzConvexProperty(pName) { Parent = pParent, ParentImage = pImgParent }; int convexEntryCount = pReader.ReadCompressedInt(); for (int i = 0; i < convexEntryCount; i++) { AWzImageProperty imgProp = ParseExtendedProp(pReader, pOffset, 0, pName, convexProp, pImgParent); if (imgProp != null) { convexProp.AddProperty(imgProp); } } return(convexProp); case "Sound_DX8": WzSoundProperty soundProp = new WzSoundProperty(pName) { Parent = pParent, ParentImage = pImgParent }; soundProp.ParseSound(pReader); return(soundProp); case "UOL": pReader.BaseStream.Position++; byte b = pReader.ReadByte(); switch (b) { case 0: return(new WzUOLProperty(pName, pReader.ReadString()) { Parent = pParent, ParentImage = pImgParent }); case 1: return(new WzUOLProperty(pName, pReader.ReadStringAtOffset(pOffset + pReader.ReadInt32())) { Parent = pParent, ParentImage = pImgParent }); default: throw new Exception("Unsupported UOL type: " + b); } default: throw new Exception("Unknown image name: " + pImageName); } }