Пример #1
0
 private static void createFHProps(WzSubProperty fh, MapleDot FirstDot, MapleDot SecondDot)
 {
     fh.AddProperty(new WzCompressedIntProperty("x1", FirstDot.X));
     fh.AddProperty(new WzCompressedIntProperty("x2", SecondDot.X));
     fh.AddProperty(new WzCompressedIntProperty("y1", FirstDot.Y));
     fh.AddProperty(new WzCompressedIntProperty("y2", SecondDot.Y));
 }
Пример #2
0
        public UserObjectsManager(MultiBoard multiBoard)
        {
            this.multiBoard = multiBoard;

            if (Program.InfoManager == null)
            {
                // Prevents VS designer from crashing when rendering this control; there is no way that Program.InfoManager will be null
                // in the real execution of this code.
                return;
            }

            // Make sure that all our structures exist
            if (!Program.InfoManager.ObjectSets.ContainsKey(oS))
            {
                Program.InfoManager.ObjectSets[oS] = new WzImage(oS);
                Program.InfoManager.ObjectSets[oS].Changed = true;
            }
            WzImage osimg = Program.InfoManager.ObjectSets[oS];
            if (osimg[l0] == null)
            {
                osimg[l0] = new WzSubProperty();
            }
            WzImageProperty l0prop = osimg[l0];
            if (l0prop[l1] == null)
            {
                l0prop[l1] = new WzSubProperty();
            }
            l1prop = l0prop[l1];
        }
Пример #3
0
 public static string GetMapCategoryName(WzSubProperty mapProp)
 {
     if (mapProp == null)
     {
         return "";
     }
     return mapProp.Parent.Name;
 }
Пример #4
0
        public override WzImageProperty DeepClone()
        {
            WzSubProperty clone = new WzSubProperty(name);

            foreach (WzImageProperty prop in properties)
            {
                clone.AddProperty(prop.DeepClone());
            }
            return(clone);
        }
Пример #5
0
        public override IWzImageProperty DeepClone()
        {
            WzSubProperty clone = (WzSubProperty)MemberwiseClone();

            clone.properties = new List <IWzImageProperty>();
            foreach (IWzImageProperty prop in properties)
            {
                clone.properties.Add(prop.DeepClone());
            }
            return(clone);
        }
Пример #6
0
 public static string GetMapStreetName(WzSubProperty mapProp)
 {
     if (mapProp == null)
     {
         return "";
     }
     WzStringProperty streetName = (WzStringProperty)mapProp["streetName"];
     if (streetName == null)
     {
         return "";
     }
     return streetName.Value;
 }
Пример #7
0
 public void SaveBackgrounds()
 {
     WzSubProperty bgParent = new WzSubProperty();
     int backCount = board.BoardItems.BackBackgrounds.Count;
     int frontCount = board.BoardItems.FrontBackgrounds.Count;
     for (int i = 0; i < backCount + frontCount; i++)
     {
         BackgroundInstance bgInst = i < backCount ? board.BoardItems.BackBackgrounds[i] : board.BoardItems.FrontBackgrounds[i - backCount];
         BackgroundInfo bgInfo = (BackgroundInfo)bgInst.BaseInfo;
         WzSubProperty bgProp = new WzSubProperty();
         bgProp["x"] = InfoTool.SetInt(bgInst.UnflippedX);
         bgProp["y"] = InfoTool.SetInt(bgInst.BaseY);
         bgProp["rx"] = InfoTool.SetInt(bgInst.rx);
         bgProp["ry"] = InfoTool.SetInt(bgInst.ry);
         bgProp["cx"] = InfoTool.SetInt(bgInst.cx);
         bgProp["cy"] = InfoTool.SetInt(bgInst.cy);
         bgProp["a"] = InfoTool.SetInt(bgInst.a);
         bgProp["type"] = InfoTool.SetInt((int)bgInst.type);
         bgProp["front"] = InfoTool.SetOptionalBool(bgInst.front);
         bgProp["f"] = InfoTool.SetOptionalBool(bgInst.Flip);
         bgProp["bS"] = InfoTool.SetString(bgInfo.bS);
         bgProp["ani"] = InfoTool.SetBool(bgInfo.ani);
         bgProp["no"] = InfoTool.SetInt(int.Parse(bgInfo.no));
         bgParent[i.ToString()] = bgProp;
     }
     image["back"] = bgParent;
 }
Пример #8
0
 public static ObjectInfo Load(WzSubProperty parentObject)
 {
     string[] path = parentObject.FullPath.Split(@"\".ToCharArray());
     return Load(parentObject,WzInfoTools.RemoveExtension(path[path.Length - 4]), path[path.Length - 3], path[path.Length - 2], path[path.Length - 1]);
 }
Пример #9
0
        /// <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);

			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])
					{
                        ret = iwp;
						foundChild = true;
						break;
					}
				}
				if (!foundChild)
				{
					return null;
				}
			}
			return ret;
		}
Пример #10
0
        public void HandleInfo(int currentID, WzSubProperty pProp)
        {
            Dictionary<string, object> columns = new Dictionary<string, object>();
            columns.Add("itemid", currentID);
            if (idlist.Contains(currentID))
            {
                Console.WriteLine(pProp.AbsolutePath);
                // Already done...
                return;
            }
            idlist.Add(currentID);

            foreach (IWzImageProperty prop2 in pProp.WzProperties)
            {
                var prop = prop2;
                if (prop is WzUOLProperty)
                    prop = prop.ToUOLLink();
                if (prop == null)
                    continue;
                var name = prop.Name.ToLower();

                if (_columnFails.ContainsKey(name)) name = _columnFails[name];

                if (!_acceptedColumns.ContainsKey(name))
                {
                    if (!_failedColumns.Contains(name))
                    {
                        _failedColumns.Add(name);
                        Console.WriteLine("Failed column: {0} | {1}", name, prop.AbsolutePath);
                    }
                    continue;
                }

                if (columns.ContainsKey(name) || name == "islot" || name == "afterimage" || name == "vslot") continue;

                if (prop is WzCompressedIntProperty || prop is WzStringProperty ||
                    prop is WzByteFloatProperty || prop is WzDoubleProperty ||
                    prop is WzUnsignedShortProperty)
                {
                    object value = null;
                    if (prop is WzCompressedIntProperty) value = prop.ToInt();
                    else if (prop is WzStringProperty) value = prop.ToStringValue();
                    else if (prop is WzByteFloatProperty) value = prop.ToFloat();
                    else if (prop is WzDoubleProperty) value = prop.ToDouble();
                    else if (prop is WzUnsignedShortProperty) value = prop.ToUnsignedShort();
                    else Console.WriteLine("wut");

                    columns.Add(name, value);
                }
            }
            if (columns.Count > 1)
            {
                _items.Add(columns);
            }
        }
Пример #11
0
 private static ObjectInfo Load(WzSubProperty parentObject, string oS, string l0, string l1, string l2)
 {
     WzCanvasProperty frame1 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]);
     ObjectInfo result = new ObjectInfo(frame1.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)frame1["origin"]), oS, l0, l1, l2, parentObject);
     WzImageProperty chairs = parentObject["seat"];
     WzImageProperty ropes = frame1["rope"];
     WzImageProperty ladders = frame1["ladder"];
     WzImageProperty footholds = frame1["foothold"];
     result.footholdOffsets = ParsePropToOffsetMap(footholds);
     result.ropeOffsets = ParsePropToOffsetMap(ropes);
     result.ladderOffsets = ParsePropToOffsetMap(ladders);
     if (chairs != null)
         result.chairOffsets = ParsePropToOffsetList(chairs);
     return result;
 }
Пример #12
0
		internal void ExtractMore(int eob, string name, string iname)
		{
			if (iname == "")
				iname = reader.ReadString();
			switch (iname)
			{
				case "Property":
					WzSubProperty subProp = new WzSubProperty(name) { Parent = parent, ParentImage = imgParent };
					reader.BaseStream.Position += 2;
					subProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, subProp, imgParent));
					extendedProperty = subProp;
					break;
				case "Canvas":
					WzCanvasProperty canvasProp = new WzCanvasProperty(name) { Parent = parent, ParentImage = imgParent };
					reader.BaseStream.Position++;
					if (reader.ReadByte() == 1)
					{
						reader.BaseStream.Position += 2;
						canvasProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, canvasProp, imgParent));
					}
					canvasProp.PngProperty = new WzPngProperty(reader) { Parent = canvasProp, ParentImage = imgParent };
					extendedProperty = canvasProp;
					break;
				case "Shape2D#Vector2D":
					WzVectorProperty vecProp = new WzVectorProperty(name) { Parent = parent, ParentImage = imgParent };
					vecProp.X = new WzCompressedIntProperty("X", reader.ReadCompressedInt()) { Parent = vecProp, ParentImage = imgParent };
					vecProp.Y = new WzCompressedIntProperty("Y", reader.ReadCompressedInt()) { Parent = vecProp, ParentImage = imgParent };
					extendedProperty = vecProp;
					break;
				case "Shape2D#Convex2D":
					WzConvexProperty convexProp = new WzConvexProperty(name) { Parent = parent, ParentImage = imgParent };
					int convexEntryCount = reader.ReadCompressedInt();
					for (int i = 0; i < convexEntryCount; i++)
					{
						WzExtendedProperty exProp = new WzExtendedProperty(offset, name) { Parent = convexProp, ParentImage = imgParent };
						exProp.ParseExtendedProperty(reader);
						convexProp.AddProperty(exProp);
					}
					extendedProperty = convexProp;
					break;
				case "Sound_DX8":
					WzSoundProperty soundProp = new WzSoundProperty(name) { Parent = parent, ParentImage = imgParent };
					soundProp.ParseSound(reader);
					extendedProperty = soundProp;
					break;
				case "UOL":
					reader.BaseStream.Position++;
                    extendedProperty = new WzUOLProperty(name, ExtractString()) { Parent = parent, ParentImage = imgParent };
                    /*
                    switch (reader.ReadByte())
					{
						case 0:
							extendedProperty = new WzUOLProperty(name, reader.ReadString()) { Parent = parent, ParentImage = imgParent };
							break;
						case 1:
							extendedProperty = new WzUOLProperty(name, reader.ReadStringAtOffset(offset + reader.ReadInt32())) { Parent = parent, ParentImage = imgParent };
							break;
					}
                    */
					break;
			}
		}
Пример #13
0
        private void HandleHairStyle(string pDir, WzSubProperty pProp, string pPrepend = "")
        {
            if (pProp == null) return;

            if (pProp["0"] == null)
            {
                if (pProp.WzProperties != null)
                {
                    foreach (var prop in pProp.WzProperties) // backDefault/backHair
                    {
                        ExportIfExists(pDir, prop, pPrepend);

                        ExportAnimatedObject(pDir, prop, pPrepend + "." + prop.Name);

                    }
                }
            }
            else
            {
                ExportAnimatedObject(pDir, pProp, pPrepend);
            }
        }
Пример #14
0
        public void SaveTooltips()
        {
            if (board.BoardItems.ToolTips.Count == 0)
            {
                return;
            }
            bool retainTooltipStrings = true;
            WzSubProperty tooltipParent = new WzSubProperty();
            WzImage strTooltipImg = (WzImage)Program.WzManager.String["ToolTipHelp.img"];
            WzSubProperty strTooltipCat = (WzSubProperty)strTooltipImg["Mapobject"];
            WzSubProperty strTooltipParent = (WzSubProperty)strTooltipCat[board.MapInfo.id.ToString()];
            if (strTooltipParent == null)
            {
                strTooltipParent = new WzSubProperty();
                strTooltipCat[board.MapInfo.id.ToString()] = strTooltipParent;
                Program.WzManager.SetUpdated("string", strTooltipImg);
                retainTooltipStrings = false;
            }

            HashSet<int> caughtNumbers = new HashSet<int>();

            // Check if the tooltips' original numbers can still be used
            if (retainTooltipStrings)
            {
                for (int i = 0; i < board.BoardItems.ToolTips.Count; i++)
                {
                    if (board.BoardItems.ToolTips[i].OriginalNumber == -1)
                    {
                        retainTooltipStrings = false;
                        break;
                    }
                }
            }

            // If they do not, we need to update string.wz and rebuild the string tooltip props
            if (!retainTooltipStrings)
            {
                Program.WzManager.SetUpdated("string", strTooltipImg);
                strTooltipParent.ClearProperties();
            }

            for (int i = 0; i < board.BoardItems.ToolTips.Count; i++)
            {
                ToolTipInstance ttInst = board.BoardItems.ToolTips[i];
                string tooltipPropStr = retainTooltipStrings ? ttInst.OriginalNumber.ToString() : i.ToString();
                tooltipParent[tooltipPropStr] = PackRectangle(ttInst);
                if (ttInst.CharacterToolTip != null)
                {
                    tooltipParent[tooltipPropStr + "char"] = PackRectangle(ttInst.CharacterToolTip);
                }

                if (retainTooltipStrings)
                {
                    // This prop must exist if we are retaining, otherwise the map would not load
                    WzSubProperty strTooltipProp = (WzSubProperty)strTooltipParent[tooltipPropStr];

                    if (ttInst.Title != null)
                    {
                        WzStringProperty titleProp = (WzStringProperty)strTooltipProp["Title"];
                        if (titleProp == null)
                        {
                            titleProp = new WzStringProperty();
                            Program.WzManager.SetUpdated("string", strTooltipImg);
                        }
                        UpdateString(titleProp, ttInst.Title, strTooltipImg);
                    }
                    if (ttInst.Desc != null)
                    {
                        WzStringProperty descProp = (WzStringProperty)strTooltipProp["Desc"];
                        if (descProp == null)
                        {
                            descProp = new WzStringProperty();
                            Program.WzManager.SetUpdated("string", strTooltipImg);
                        }
                        UpdateString(descProp, ttInst.Desc, strTooltipImg);
                    }
                }
                else
                {
                    WzSubProperty strTooltipProp = new WzSubProperty();
                    strTooltipProp["Title"] = InfoTool.SetOptionalString(ttInst.Title);
                    strTooltipProp["Desc"] = InfoTool.SetOptionalString(ttInst.Desc);
                    strTooltipParent[tooltipPropStr] = strTooltipProp;
                }
            }

            image["ToolTip"] = tooltipParent;
        }
Пример #15
0
        private void SavePlatform(int layer, int zM, WzSubProperty prop)
        {
            foreach (FootholdLine line in board.BoardItems.FootholdLines)
            {
                // Save all footholds in the platform (same layer and zM)
                if (line.LayerNumber != layer || line.PlatformNumber != zM)
                {
                    continue;
                }

                FootholdOrientation orientation = GetFootholdOrientation(line);
                int prev = GetFootholdPrevNext(line, orientation, FootholdDirection.Prev);
                int next = GetFootholdPrevNext(line, orientation, FootholdDirection.Next);
                FootholdAnchor anchor1 = (FootholdAnchor)(orientation == FootholdOrientation.PrevFirstNextSecond ? line.FirstDot : line.SecondDot);
                FootholdAnchor anchor2 = (FootholdAnchor)(orientation == FootholdOrientation.PrevFirstNextSecond ? line.SecondDot : line.FirstDot);

                WzSubProperty fhProp = new WzSubProperty();
                fhProp["x1"] = InfoTool.SetInt(anchor1.X);
                fhProp["y1"] = InfoTool.SetInt(anchor1.Y);
                fhProp["x2"] = InfoTool.SetInt(anchor2.X);
                fhProp["y2"] = InfoTool.SetInt(anchor2.Y);
                fhProp["prev"] = InfoTool.SetInt(prev);
                fhProp["next"] = InfoTool.SetInt(next);
                fhProp["cantThrough"] = InfoTool.SetOptionalBool(line.CantThrough);
                fhProp["forbidFallDown"] = InfoTool.SetOptionalBool(line.ForbidFallDown);
                fhProp["piece"] = InfoTool.SetOptionalInt(line.Piece);
                fhProp["force"] = InfoTool.SetOptionalInt(line.Force);
                prop[line.num.ToString()] = fhProp;

                line.saved = true;
            }
        }
Пример #16
0
 private void SaveMiniMap()
 {
     if (board.MiniMap != null && board.MinimapRectangle != null)
     {
         WzSubProperty miniMap = new WzSubProperty();
         WzCanvasProperty canvas = new WzCanvasProperty();
         canvas.PngProperty = new WzPngProperty();
         canvas.PngProperty.SetPNG(board.MiniMap);
         miniMap["canvas"] = canvas;
         miniMap["width"] = InfoTool.SetInt(board.MinimapRectangle.Width);
         miniMap["height"] = InfoTool.SetInt(board.MinimapRectangle.Height);
         miniMap["centerX"] = InfoTool.SetInt(-board.MinimapPosition.X);
         miniMap["centerY"] = InfoTool.SetInt(-board.MinimapPosition.Y);
         miniMap["mag"] = InfoTool.SetInt(4);
         image["miniMap"] = miniMap;
     }
 }
Пример #17
0
        internal void ExtractMore(int eob, string name, string iname)
        {
            if (iname == "")
            {
                iname = reader.ReadString();
            }
            switch (iname)
            {
            case "Property":
                WzSubProperty subProp = new WzSubProperty(name)
                {
                    Parent = parent, ParentImage = imgParent
                };
                reader.BaseStream.Position += 2;
                subProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, subProp, imgParent));
                extendedProperty = subProp;
                break;

            case "Canvas":
                WzCanvasProperty canvasProp = new WzCanvasProperty(name)
                {
                    Parent = parent, ParentImage = imgParent
                };
                reader.BaseStream.Position++;
                if (reader.ReadByte() == 1)
                {
                    reader.BaseStream.Position += 2;
                    canvasProp.AddProperties(IWzImageProperty.ParsePropertyList(offset, reader, canvasProp, imgParent));
                }
                canvasProp.PngProperty = new WzPngProperty(reader)
                {
                    Parent = canvasProp, ParentImage = imgParent
                };
                extendedProperty = canvasProp;
                break;

            case "Shape2D#Vector2D":
                WzVectorProperty vecProp = new WzVectorProperty(name)
                {
                    Parent = parent, ParentImage = imgParent
                };
                vecProp.X = new WzCompressedIntProperty("X", reader.ReadCompressedInt())
                {
                    Parent = vecProp, ParentImage = imgParent
                };
                vecProp.Y = new WzCompressedIntProperty("Y", reader.ReadCompressedInt())
                {
                    Parent = vecProp, ParentImage = imgParent
                };
                extendedProperty = vecProp;
                break;

            case "Shape2D#Convex2D":
                WzConvexProperty convexProp = new WzConvexProperty(name)
                {
                    Parent = parent, ParentImage = imgParent
                };
                int convexEntryCount = reader.ReadCompressedInt();
                for (int i = 0; i < convexEntryCount; i++)
                {
                    WzExtendedProperty exProp = new WzExtendedProperty(offset, name)
                    {
                        Parent = convexProp, ParentImage = imgParent
                    };
                    exProp.ParseExtendedProperty(reader);
                    convexProp.AddProperty(exProp);
                }
                extendedProperty = convexProp;
                break;

            case "Sound_DX8":
                WzSoundProperty soundProp = new WzSoundProperty(name)
                {
                    Parent = parent, ParentImage = imgParent
                };
                soundProp.ParseSound(reader);
                extendedProperty = soundProp;
                break;

            case "UOL":
                reader.BaseStream.Position++;
                extendedProperty = new WzUOLProperty(name, ExtractString())
                {
                    Parent = parent, ParentImage = imgParent
                };

                /*
                 * switch (reader.ReadByte())
                 *                  {
                 *                          case 0:
                 *                                  extendedProperty = new WzUOLProperty(name, reader.ReadString()) { Parent = parent, ParentImage = imgParent };
                 *                                  break;
                 *                          case 1:
                 *                                  extendedProperty = new WzUOLProperty(name, reader.ReadStringAtOffset(offset + reader.ReadInt32())) { Parent = parent, ParentImage = imgParent };
                 *                                  break;
                 *                  }
                 */
                break;
            }
        }
Пример #18
0
 private static WzSubProperty PackRectangle(MapleRectangle rect)
 {
     WzSubProperty prop = new WzSubProperty();
     prop["x1"] = InfoTool.SetInt(rect.Left);
     prop["x2"] = InfoTool.SetInt(rect.Right);
     prop["y1"] = InfoTool.SetInt(rect.Top);
     prop["y2"] = InfoTool.SetInt(rect.Bottom);
     return prop;
 }
Пример #19
0
 public void SaveChairs()
 {
     if (board.BoardItems.Chairs.Count == 0)
     {
         return;
     }
     WzSubProperty chairParent = new WzSubProperty();
     for (int i = 0; i < board.BoardItems.Chairs.Count; i++)
     {
         Chair chairInst = board.BoardItems.Chairs[i];
         WzVectorProperty chair = new WzVectorProperty();
         chair.X = new WzIntProperty("X", chairInst.X);
         chair.Y = new WzIntProperty("Y", chairInst.Y);
         chairParent[i.ToString()] = chair;
     }
     image["seat"] = chairParent;
 }
Пример #20
0
 private static void ParseXML(XmlElement element, IPropertyContainer wo)
 {
     foreach (XmlNode node in element)
     {
         if (!(node is XmlElement)) continue;
         XmlElement childElement = (XmlElement)node;
         if (childElement.Name == "imgdir")
         {
             WzSubProperty sub = new WzSubProperty(childElement.GetAttribute("name"));
             wo.AddProperty(sub);
             ParseXML(childElement, (IPropertyContainer)sub);
         }
         else if (childElement.Name == "canvas")
         {
             WzCanvasProperty canvas = new WzCanvasProperty(childElement.GetAttribute("name"));
             canvas.PngProperty = new WzPngProperty();
             MemoryStream pngstream = new MemoryStream(Convert.FromBase64String(childElement.GetAttribute("basedata")));
             canvas.PngProperty.SetPNG((Bitmap)Image.FromStream(pngstream, true, true));
             wo.AddProperty(canvas);
             ParseXML(childElement, (IPropertyContainer)canvas);
         }
         if (childElement.Name == "int")
         {
             WzCompressedIntProperty compressedInt = new WzCompressedIntProperty(childElement.GetAttribute("name"), int.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(compressedInt);
         }
         if (childElement.Name == "double")
         {
             WzDoubleProperty doubleProp = new WzDoubleProperty(childElement.GetAttribute("name"), double.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(doubleProp);
         }
         if (childElement.Name == "null")
         {
             WzNullProperty nullProp = new WzNullProperty(childElement.GetAttribute("name"));
             wo.AddProperty(nullProp);
         }
         if (childElement.Name == "sound")
         {
             WzSoundProperty sound = new WzSoundProperty(childElement.GetAttribute("name"));
             sound.SetDataUnsafe(Convert.FromBase64String(childElement.GetAttribute("basedata")));
             wo.AddProperty(sound);
         }
         if (childElement.Name == "string")
         {
             string str = childElement.GetAttribute("value").Replace("&lt;", "<").Replace("&amp;", "&").Replace("&gt;", ">").Replace("&apos;", "'").Replace("&quot;", "\"");
             WzStringProperty stringProp = new WzStringProperty(childElement.GetAttribute("name"), str);
             wo.AddProperty(stringProp);
         }
         if (childElement.Name == "short")
         {
             WzUnsignedShortProperty shortProp = new WzUnsignedShortProperty(childElement.GetAttribute("name"), ushort.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(shortProp);
         }
         if (childElement.Name == "uol")
         {
             WzUOLProperty uol = new WzUOLProperty(childElement.GetAttribute("name"), childElement.GetAttribute("value"));
             wo.AddProperty(uol);
         }
         if (childElement.Name == "vector")
         {
             WzVectorProperty vector = new WzVectorProperty(childElement.GetAttribute("name"), new WzCompressedIntProperty("x", Convert.ToInt32(childElement.GetAttribute("x"))), new WzCompressedIntProperty("y", Convert.ToInt32(childElement.GetAttribute("y"))));
             wo.AddProperty(vector);
         }
         if (childElement.Name == "float")
         {
             WzByteFloatProperty floatProp = new WzByteFloatProperty(childElement.GetAttribute("name"), float.Parse(childElement.GetAttribute("value"), formattingInfo));
             wo.AddProperty(floatProp);
         }
         if (childElement.Name == "extended")
         {
             WzConvexProperty convex = new WzConvexProperty(childElement.GetAttribute("name"));
             wo.AddProperty(convex);
             ParseXML(childElement, (IPropertyContainer)convex);
         }
     }
 }
Пример #21
0
        public void SaveFootholds()
        {
            WzSubProperty fhParent = new WzSubProperty();
            board.BoardItems.FootholdLines.ForEach(x => x.saved = false);
            board.BoardItems.FootholdLines.Sort(FootholdLine.FHSorter);
            int fhIndex = 1;
            foreach (FootholdLine line in board.BoardItems.FootholdLines)
            {
                line.num = fhIndex++;
            }
            for (int layer = 0; layer <= 7; layer++)
            {
                WzSubProperty fhLayerProp = new WzSubProperty();
                foreach (FootholdLine fhInst in board.BoardItems.FootholdLines)
                {
                    // Search only footholds in our layer, that weren't already saved
                    if (fhInst.LayerNumber != layer || fhInst.saved)
                    {
                        continue;
                    }
                    int zM = fhInst.PlatformNumber;
                    WzSubProperty fhPlatProp = new WzSubProperty();
                    SavePlatform(layer, zM, fhPlatProp);
                    fhLayerProp[zM.ToString()] = fhPlatProp;
                }
                if (fhLayerProp.WzProperties.Count > 0)
                {
                    fhParent[layer.ToString()] = fhLayerProp;
                }
            }

            image["foothold"] = fhParent;
        }
Пример #22
0
        public void CreateMapFromImage(WzImage mapImage, string mapName, string streetName, string categoryName, WzSubProperty strMapProp, PageCollection Tabs, MultiBoard multiBoard, EventHandler[] rightClickHandler)
        {
            if (!mapImage.Parsed) mapImage.ParseImage();
            List<string> copyPropNames = VerifyMapPropsKnown(mapImage, false);
            MapInfo info = new MapInfo(mapImage, mapName, streetName, categoryName);
            foreach (string copyPropName in copyPropNames)
            {
                info.additionalNonInfoProps.Add(mapImage[copyPropName]);
            }
            MapType type = GetMapType(mapImage);
            if (type == MapType.RegularMap)
                info.id = int.Parse(WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)));
            info.mapType = type;

            Rectangle VR = new Rectangle();
            Point center = new Point();
            Point size = new Point();
            Point minimapSize = new Point();
            Point minimapCenter = new Point();
            bool hasMinimap = false;
            bool hasVR = false;

            try
            {
                GetMapDimensions(mapImage, out VR, out center, out size, out minimapCenter, out minimapSize, out hasVR, out hasMinimap);
            }
            catch (NoVRException)
            {
                MessageBox.Show("Error - map does not contain size information and HaCreator was unable to generate it. An error has been logged.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrorLogger.Log(ErrorLevel.IncorrectStructure, "no size @map " + info.id.ToString());
                return;
            }

            lock (multiBoard)
            {
                CreateMap(mapName, WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)), CreateStandardMapMenu(rightClickHandler), size, center, 8, Tabs, multiBoard);
                Board mapBoard = multiBoard.SelectedBoard;
                mapBoard.Loading = true; // prevents TS Change callbacks
                mapBoard.MapInfo = info;
                if (hasMinimap)
                {
                    mapBoard.MiniMap = ((WzCanvasProperty)mapImage["miniMap"]["canvas"]).PngProperty.GetPNG(false);
                    System.Drawing.Point mmPos = new System.Drawing.Point(-minimapCenter.X, -minimapCenter.Y);
                    mapBoard.MinimapPosition = mmPos;
                    mapBoard.MinimapRectangle = new MinimapRectangle(mapBoard, new Rectangle(mmPos.X, mmPos.Y, minimapSize.X, minimapSize.Y));
                }
                if (hasVR)
                {
                    mapBoard.VRRectangle = new VRRectangle(mapBoard, VR);
                }
                LoadLayers(mapImage, mapBoard);
                LoadLife(mapImage, mapBoard);
                LoadFootholds(mapImage, mapBoard);
                GenerateDefaultZms(mapBoard);
                LoadRopes(mapImage, mapBoard);
                LoadChairs(mapImage, mapBoard);
                LoadPortals(mapImage, mapBoard);
                LoadReactors(mapImage, mapBoard);
                LoadToolTips(mapImage, mapBoard);
                LoadBackgrounds(mapImage, mapBoard);
                LoadMisc(mapImage, mapBoard);

                mapBoard.BoardItems.Sort();
                mapBoard.Loading = false;
            }
            if (ErrorLogger.ErrorsPresent())
            {
                ErrorLogger.SaveToFile("errors.txt");
                if (UserSettings.ShowErrorsMessage)
                {
                    MessageBox.Show("Errors were encountered during the loading process. These errors were saved to \"errors.txt\". Please send this file to the author, either via mail (" + ApplicationSettings.AuthorEmail + ") or from the site you got this software from.\n\n(In the case that this program was not updated in so long that this message is now thrown on every map load, you may cancel this message from the settings)", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                ErrorLogger.ClearErrors();
            }
        }
Пример #23
0
        public void SaveLayers()
        {
            for (int layer = 0; layer <= 7; layer++)
            {
                WzSubProperty layerProp = new WzSubProperty();
                WzSubProperty infoProp = new WzSubProperty();

                // Info
                Layer l = board.Layers[layer];
                if (l.tS != null)
                {
                    infoProp["tS"] = InfoTool.SetString(l.tS);
                }
                layerProp["info"] = infoProp;

                // Organize items and save objects
                List<TileInstance> tiles = new List<TileInstance>();
                WzSubProperty objParent = new WzSubProperty();
                int objIndex = 0;
                foreach (LayeredItem item in l.Items)
                {
                    if (item is ObjectInstance)
                    {
                        WzSubProperty obj = new WzSubProperty();
                        ObjectInstance objInst = (ObjectInstance)item;
                        ObjectInfo objInfo = (ObjectInfo)objInst.BaseInfo;

                        obj["x"] = InfoTool.SetInt(objInst.UnflippedX);
                        obj["y"] = InfoTool.SetInt(objInst.Y);
                        obj["z"] = InfoTool.SetInt(objInst.Z);
                        obj["zM"] = InfoTool.SetInt(objInst.PlatformNumber);
                        obj["oS"] = InfoTool.SetString(objInfo.oS);
                        obj["l0"] = InfoTool.SetString(objInfo.l0);
                        obj["l1"] = InfoTool.SetString(objInfo.l1);
                        obj["l2"] = InfoTool.SetString(objInfo.l2);
                        obj["name"] = InfoTool.SetOptionalString(objInst.Name);
                        obj["r"] = InfoTool.SetOptionalBool(objInst.r);
                        obj["hide"] = InfoTool.SetOptionalBool(objInst.hide);
                        obj["reactor"] = InfoTool.SetOptionalBool(objInst.reactor);
                        obj["flow"] = InfoTool.SetOptionalBool(objInst.flow);
                        obj["rx"] = InfoTool.SetOptionalTranslatedInt(objInst.rx);
                        obj["ry"] = InfoTool.SetOptionalTranslatedInt(objInst.ry);
                        obj["cx"] = InfoTool.SetOptionalTranslatedInt(objInst.cx);
                        obj["cy"] = InfoTool.SetOptionalTranslatedInt(objInst.cy);
                        obj["tags"] = InfoTool.SetOptionalString(objInst.tags);
                        if (objInst.QuestInfo != null)
                        {
                            WzSubProperty questParent = new WzSubProperty();
                            foreach (ObjectInstanceQuest objQuest in objInst.QuestInfo)
                            {
                                questParent[objQuest.questId.ToString()] = InfoTool.SetInt((int)objQuest.state);
                            }
                            obj["quest"] = questParent;
                        }
                        obj["f"] = InfoTool.SetBool(objInst.Flip);

                        objParent[objIndex.ToString()] = obj;
                        objIndex++;
                    }
                    else if (item is TileInstance)
                    {
                        tiles.Add((TileInstance)item);
                    }
                    else
                    {
                        throw new Exception("Unkown type in layered lists");
                    }
                }
                layerProp["obj"] = objParent;

                // Save tiles
                tiles.Sort((a,b) => a.Z.CompareTo(b.Z));
                WzSubProperty tileParent = new WzSubProperty();
                for (int j = 0; j < tiles.Count; j++)
                {
                    TileInstance tileInst = tiles[j];
                    TileInfo tileInfo = (TileInfo)tileInst.BaseInfo;
                    WzSubProperty tile = new WzSubProperty();

                    tile["x"] = InfoTool.SetInt(tileInst.X);
                    tile["y"] = InfoTool.SetInt(tileInst.Y);
                    tile["zM"] = InfoTool.SetInt(tileInst.PlatformNumber);
                    tile["u"] = InfoTool.SetString(tileInfo.u);
                    tile["no"] = InfoTool.SetInt(int.Parse(tileInfo.no));

                    tileParent[j.ToString()] = tile;
                }
                layerProp["tile"] = tileParent;

                image[layer.ToString()] = layerProp;
            }
        }
        internal IWzImageProperty ParsePropertyFromXMLElement(XmlElement element)
        {
            switch (element.Name)
            {
                case "imgdir":
                    WzSubProperty sub = new WzSubProperty(element.GetAttribute("name"));
                    foreach (XmlElement subelement in element)
                        sub.AddProperty(ParsePropertyFromXMLElement(subelement));
                    return sub;

                case "canvas":
                    WzCanvasProperty canvas = new WzCanvasProperty(element.GetAttribute("name"));
                    if (!element.HasAttribute("basedata")) throw new NoBase64DataException("no base64 data in canvas element with name " + canvas.Name);
                    canvas.PngProperty = new WzPngProperty();
                    MemoryStream pngstream = new MemoryStream(Convert.FromBase64String(element.GetAttribute("basedata")));
                    canvas.PngProperty.SetPNG((Bitmap)Image.FromStream(pngstream, true, true));
                    foreach (XmlElement subelement in element)
                        canvas.AddProperty(ParsePropertyFromXMLElement(subelement));
                    return canvas;

                case "int":
                    WzCompressedIntProperty compressedInt = new WzCompressedIntProperty(element.GetAttribute("name"), int.Parse(element.GetAttribute("value"), formattingInfo));
                    return compressedInt;

                case "double":
                    WzDoubleProperty doubleProp = new WzDoubleProperty(element.GetAttribute("name"), double.Parse(element.GetAttribute("value"), formattingInfo));
                    return doubleProp;

                case "null":
                    WzNullProperty nullProp = new WzNullProperty(element.GetAttribute("name"));
                    return nullProp;

                case "sound":
                    if (!element.HasAttribute("basedata") || !element.HasAttribute("basehead") || !element.HasAttribute("length")) throw new NoBase64DataException("no base64 data in sound element with name " + element.GetAttribute("name"));
                    WzSoundProperty sound = new WzSoundProperty(element.GetAttribute("name"),
                        int.Parse(element.GetAttribute("length")),
                        Convert.FromBase64String(element.GetAttribute("basehead")),
                        Convert.FromBase64String(element.GetAttribute("basedata")));
                    return sound;

                case "string":
                    WzStringProperty stringProp = new WzStringProperty(element.GetAttribute("name"), element.GetAttribute("value"));
                    return stringProp;

                case "short":
                    WzUnsignedShortProperty shortProp = new WzUnsignedShortProperty(element.GetAttribute("name"), ushort.Parse(element.GetAttribute("value"), formattingInfo));
                    return shortProp;

                case "uol":
                    WzUOLProperty uol = new WzUOLProperty(element.GetAttribute("name"), element.GetAttribute("value"));
                    return uol;

                case "vector":
                    WzVectorProperty vector = new WzVectorProperty(element.GetAttribute("name"), new WzCompressedIntProperty("x", Convert.ToInt32(element.GetAttribute("x"))), new WzCompressedIntProperty("y", Convert.ToInt32(element.GetAttribute("y"))));
                    return vector;

                case "float":
                    WzByteFloatProperty floatProp = new WzByteFloatProperty(element.GetAttribute("name"), float.Parse(element.GetAttribute("value"), formattingInfo));
                    return floatProp;

                case "extended":
                    WzConvexProperty convex = new WzConvexProperty(element.GetAttribute("name"));
                    foreach (XmlElement subelement in element)
                        convex.AddProperty(ParsePropertyFromXMLElement(subelement));
                    return convex;
            }
            throw new InvalidDataException("unknown XML prop " + element.Name);
        }
Пример #25
0
        public void SaveLife()
        {
            WzSubProperty lifeParent = new WzSubProperty();
            int mobCount = board.BoardItems.Mobs.Count;
            int npcCount = board.BoardItems.NPCs.Count;
            for (int i = 0; i < mobCount + npcCount; i++)
            {
                bool mob = i < mobCount;
                LifeInstance lifeInst = mob ? (LifeInstance)board.BoardItems.Mobs[i] : (LifeInstance)board.BoardItems.NPCs[i - mobCount];
                WzSubProperty lifeProp = new WzSubProperty();

                lifeProp["id"] = InfoTool.SetString(mob ? ((MobInfo)lifeInst.BaseInfo).ID : ((NpcInfo)lifeInst.BaseInfo).ID);
                lifeProp["x"] = InfoTool.SetInt(lifeInst.UnflippedX);
                lifeProp["y"] = InfoTool.SetInt(lifeInst.Y - lifeInst.yShift);
                lifeProp["cy"] = InfoTool.SetInt(lifeInst.Y);
                lifeProp["mobTime"] = InfoTool.SetOptionalInt(lifeInst.MobTime);
                lifeProp["info"] = InfoTool.SetOptionalInt(lifeInst.Info);
                lifeProp["team"] = InfoTool.SetOptionalInt(lifeInst.Team);
                lifeProp["rx0"] = InfoTool.SetInt(lifeInst.X - lifeInst.rx0Shift);
                lifeProp["rx1"] = InfoTool.SetInt(lifeInst.X + lifeInst.rx1Shift);
                lifeProp["f"] = InfoTool.SetOptionalBool(lifeInst.Flip);
                lifeProp["hide"] = InfoTool.SetOptionalBool(lifeInst.Hide);
                lifeProp["type"] = InfoTool.SetString(mob ? "m" : "n");
                lifeProp["limitedname"] = InfoTool.SetOptionalString(lifeInst.LimitedName);
                lifeProp["fh"] = InfoTool.SetInt(GetFootholdBelow(lifeInst.X, lifeInst.Y));
                lifeParent[i.ToString()] = lifeProp;
            }
            image["life"] = lifeParent;
        }
 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);
     }
 }
Пример #27
0
 public void SaveMisc()
 {
     WzSubProperty areaParent = new WzSubProperty();
     WzSubProperty buffParent = new WzSubProperty();
     WzSubProperty swimParent = new WzSubProperty();
     foreach (BoardItem item in board.BoardItems.MiscItems)
     {
         if (item is Clock)
         {
             Clock clock = (Clock)item;
             WzSubProperty clockProp = new WzSubProperty();
             clockProp["x"] = InfoTool.SetInt(item.Left);
             clockProp["y"] = InfoTool.SetInt(item.Top);
             clockProp["width"] = InfoTool.SetInt(item.Width);
             clockProp["height"] = InfoTool.SetInt(item.Height);
             image["clock"] = clockProp;
         }
         else if (item is ShipObject)
         {
             ShipObject ship = (ShipObject)item;
             ObjectInfo shipInfo = (ObjectInfo)ship.BaseInfo;
             WzSubProperty shipProp = new WzSubProperty();
             shipProp["shipObj"] = InfoTool.SetString("Map/Obj/" + shipInfo.oS + ".img/" + shipInfo.l0 + "/" + shipInfo.l1 + "/" + shipInfo.l2);
             shipProp["x"] = InfoTool.SetInt(ship.UnflippedX);
             shipProp["y"] = InfoTool.SetInt(ship.Y);
             shipProp["z"] = InfoTool.SetOptionalInt(ship.zValue);
             shipProp["x0"] = InfoTool.SetOptionalInt(ship.X0);
             shipProp["tMove"] = InfoTool.SetInt(ship.TimeMove);
             shipProp["shipKind"] = InfoTool.SetInt(ship.ShipKind);
             shipProp["f"] = InfoTool.SetBool(ship.Flip);
             image["shipObj"] = shipProp;
         }
         else if (item is Area)
         {
             Area area = (Area)item;
             areaParent[area.Identifier] = PackRectangle(area);
         }
         else if (item is Healer)
         {
             Healer healer = (Healer)item;
             ObjectInfo healerInfo = (ObjectInfo)healer.BaseInfo;
             WzSubProperty healerProp = new WzSubProperty();
             healerProp["healer"] = InfoTool.SetString("Map/Obj/" + healerInfo.oS + ".img/" + healerInfo.l0 + "/" + healerInfo.l1 + "/" + healerInfo.l2);
             healerProp["x"] = InfoTool.SetInt(healer.X);
             healerProp["yMin"] = InfoTool.SetInt(healer.yMin);
             healerProp["yMax"] = InfoTool.SetInt(healer.yMax);
             healerProp["healMin"] = InfoTool.SetInt(healer.healMin);
             healerProp["healMax"] = InfoTool.SetInt(healer.healMax);
             healerProp["fall"] = InfoTool.SetInt(healer.fall);
             healerProp["rise"] = InfoTool.SetInt(healer.rise);
             image["healer"] = healerProp;
         }
         else if (item is Pulley)
         {
             Pulley pulley = (Pulley)item;
             ObjectInfo pulleyInfo = (ObjectInfo)pulley.BaseInfo;
             WzSubProperty pulleyProp = new WzSubProperty();
             pulleyProp["pulley"] = InfoTool.SetString("Map/Obj/" + pulleyInfo.oS + ".img/" + pulleyInfo.l0 + "/" + pulleyInfo.l1 + "/" + pulleyInfo.l2);
             pulleyProp["x"] = InfoTool.SetInt(pulley.X);
             pulleyProp["y"] = InfoTool.SetInt(pulley.Y);
             image["pulley"] = pulleyProp;
         }
         else if (item is BuffZone)
         {
             BuffZone buff = (BuffZone)item;
             WzSubProperty buffProp = PackRectangle(buff);
             buffProp["ItemID"] = InfoTool.SetInt(buff.ItemID);
             buffProp["Interval"] = InfoTool.SetInt(buff.Interval);
             buffProp["Duration"] = InfoTool.SetInt(buff.Duration);
             buffParent[buff.ZoneName] = buffProp;
         }
         else if (item is SwimArea)
         {
             SwimArea swim = (SwimArea)item;
             swimParent[swim.Identifier] = PackRectangle(swim);
         }
     }
     if (areaParent.WzProperties.Count > 0)
     {
         image["area"] = areaParent;
     }
     if (buffParent.WzProperties.Count > 0)
     {
         image["BuffZone"] = buffParent;
     }
     if (swimParent.WzProperties.Count > 0)
     {
         image["swimArea"] = swimParent;
     }
 }
Пример #28
0
 public static void ExtractAnimation(WzSubProperty parent, string savePath, bool apngFirstFrame)
 {
     List<Bitmap> bmpList = new List<Bitmap>(parent.WzProperties.Count);
     List<int> delayList = new List<int>(parent.WzProperties.Count);
     Point biggestPng = new Point(0, 0);
     Point SmallestEmptySpace = new Point(65535, 65535);
     Point MaximumPngMappingEndingPts = new Point(0, 0);
     foreach (WzImageProperty subprop in parent.WzProperties)
     {
         if (subprop is WzCanvasProperty)
         {
             //WzVectorProperty origin = (WzVectorProperty)subprop["origin"];
             WzPngProperty png = ((WzCanvasProperty)subprop).PngProperty;
             if (png.Height > biggestPng.Y)
                 biggestPng.Y = png.Height;
             if (png.Width > biggestPng.X)
                 biggestPng.X = png.Width;
         }
     }
     List<WzCanvasProperty> sortedProps = new List<WzCanvasProperty>();
     foreach (WzImageProperty subprop in parent.WzProperties)
     {
         if (subprop is WzCanvasProperty)
         {
             sortedProps.Add((WzCanvasProperty)subprop);
             WzPngProperty png = ((WzCanvasProperty)subprop).PngProperty;
             WzVectorProperty origin = (WzVectorProperty)subprop["origin"];
             Point StartPoints = new Point(biggestPng.X - origin.X.Value, biggestPng.Y - origin.Y.Value);
             Point PngMapppingEndingPts = new Point(StartPoints.X + png.Width, StartPoints.Y + png.Height);
             if (StartPoints.X < SmallestEmptySpace.X)
                 SmallestEmptySpace.X = StartPoints.X;
             if (StartPoints.Y < SmallestEmptySpace.Y)
                 SmallestEmptySpace.Y = StartPoints.Y;
             if (PngMapppingEndingPts.X > MaximumPngMappingEndingPts.X)
                 MaximumPngMappingEndingPts.X = PngMapppingEndingPts.X;
             if (PngMapppingEndingPts.Y > MaximumPngMappingEndingPts.Y)
                 MaximumPngMappingEndingPts.Y = PngMapppingEndingPts.Y;
         }
     }
     sortedProps.Sort(new Comparison<WzCanvasProperty>(PropertySorter));
     for (int i = 0; i<sortedProps.Count; i++)
     {
         WzCanvasProperty subprop = sortedProps[i];
         if (i.ToString() != subprop.Name)
         {
             Warning.Error(string.Format(Properties.Resources.AnimError, i.ToString()));
             return;
         }
         Bitmap bmp = subprop.PngProperty.GetPNG(false);
         WzVectorProperty origin = (WzVectorProperty)subprop["origin"];
         bmpList.Add(OptimizeBitmapTransparent(bmp, origin, biggestPng, SmallestEmptySpace, MaximumPngMappingEndingPts));
         WzIntProperty delayProp = (WzIntProperty)subprop["delay"];
         int delay =100;
         if (delayProp != null) delay = delayProp.Value;
         delayList.Add(delay);
     }
     Apng apngBuilder = new Apng();
     if (apngFirstFrame)
     {
         apngBuilder.AddFrame(new Frame(CreateIncompatibilityFrame(new Size(bmpList[0].Width, bmpList[0].Height)),1,1));
     }
     for (int i = 0; i < bmpList.Count; i++)
     {
         apngBuilder.AddFrame(new Frame(bmpList[i], getNumByDelay(delayList[i]), getDenByDelay(delayList[i])));
     }
     apngBuilder.WriteApng(savePath, apngFirstFrame, true);
 }
Пример #29
0
        public void SavePortals()
        {
            WzSubProperty portalParent = new WzSubProperty();
            for (int i = 0; i < board.BoardItems.Portals.Count; i++)
            {
                PortalInstance portalInst = board.BoardItems.Portals[i];
                WzSubProperty portal = new WzSubProperty();

                portal["x"] = InfoTool.SetInt(portalInst.X);
                portal["y"] = InfoTool.SetInt(portalInst.Y);
                portal["pt"] = InfoTool.SetInt(Program.InfoManager.PortalIdByType[portalInst.pt]);
                portal["tm"] = InfoTool.SetInt(portalInst.tm);
                portal["tn"] = InfoTool.SetString(portalInst.tn);
                portal["pn"] = InfoTool.SetString(portalInst.pn);
                portal["image"] = InfoTool.SetOptionalString(portalInst.image);
                portal["script"] = InfoTool.SetOptionalString(portalInst.script);
                portal["verticalImpact"] = InfoTool.SetOptionalInt(portalInst.verticalImpact);
                portal["horizontalImpact"] = InfoTool.SetOptionalInt(portalInst.horizontalImpact);
                portal["hRange"] = InfoTool.SetOptionalInt(portalInst.hRange);
                portal["vRange"] = InfoTool.SetOptionalInt(portalInst.vRange);
                portal["delay"] = InfoTool.SetOptionalInt(portalInst.delay);
                portal["hideTooltip"] = InfoTool.SetOptionalBool(portalInst.hideTooltip);
                portal["onlyOnce"] = InfoTool.SetOptionalBool(portalInst.onlyOnce);

                portalParent[i.ToString()] = portal;
            }
            image["portal"] = portalParent;
        }
Пример #30
0
		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;
            }
		}
Пример #31
0
        public void SaveReactors()
        {
            WzSubProperty reactorParent = new WzSubProperty();
            for (int i = 0; i < board.BoardItems.Reactors.Count; i++)
            {
                ReactorInstance reactorInst = board.BoardItems.Reactors[i];
                WzSubProperty reactor = new WzSubProperty();

                reactor["x"] = InfoTool.SetInt(reactorInst.UnflippedX);
                reactor["y"] = InfoTool.SetInt(reactorInst.Y);
                reactor["reactorTime"] = InfoTool.SetInt(reactorInst.ReactorTime);
                reactor["name"] = InfoTool.SetOptionalString(reactorInst.Name);
                reactor["id"] = InfoTool.SetString(((ReactorInfo)reactorInst.BaseInfo).ID);
                reactor["f"] = InfoTool.SetBool(reactorInst.Flip);

                reactorParent[i.ToString()] = reactor;
            }
            image["reactor"] = reactorParent;
        }
Пример #32
0
 public static ObjectInfo Load(WzSubProperty parentObject, string oS, string l0, string l1, string l2)
 {
     WzCanvasProperty frame1 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]);
     ObjectInfo result = new ObjectInfo(frame1.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)frame1["origin"]),oS,l0,l1,l2, parentObject);
     WzSubProperty chairs = (WzSubProperty)parentObject["seat"];
     IWzImageProperty footholds = (IWzImageProperty)frame1["foothold"];
     if (footholds != null)
     {
         if (footholds is WzConvexProperty)
         {
             result.fullFootholdInfo = false;
             result.footholdOffsets = new List<XNA.Point>();
             foreach (WzVectorProperty fhAnchor in footholds.WzProperties)
                 result.footholdOffsets.Add(WzInfoTools.VectorToXNAPoint(fhAnchor));
         }
         else
         {
             result.fullFootholdInfo = true;
             result.footholdFullOffsets = new List<List<XNA.Point>>();
             List<XNA.Point> fhAnchorList = new List<XNA.Point>();
             foreach (WzConvexProperty fh in footholds.WzProperties)
             {
                 foreach (WzVectorProperty fhAnchor in fh.WzProperties)
                     fhAnchorList.Add(WzInfoTools.VectorToXNAPoint(fhAnchor));
                 result.footholdFullOffsets.Add(fhAnchorList);
                 fhAnchorList = new List<XNA.Point>();
             }
         }
     }
     //IWzImageProperty ropes = (IWzImageProperty)frame1["ladder"];
     if (chairs != null)
     {
         result.chairOffsets = new List<XNA.Point>();
         foreach (WzVectorProperty chair in chairs.WzProperties)
             result.chairOffsets.Add(WzInfoTools.VectorToXNAPoint(chair));
     }
     /*if (footholds != null)
         foreach (WzVectorProperty foothold in footholds.WzProperties)
             result.footholdOffsets.Add(WzInfoTools.VectorToXNAPoint(foothold));*/
     /*if (ropes != null && ropes.WzProperties.Count > 0)
         if (ropes.WzProperties[0] is WzVectorProperty)
             foreach (WzVectorProperty rope in ropes.WzProperties)
                 result.ropeOffsets.Add(WzInfoTools.VectorToXNAPoint(rope));
         else if (ropes.WzProperties[0] is WzConvexProperty)
             foreach (WzConvexProperty convex in ropes.WzProperties)
                 foreach (WzVectorProperty rope in convex.WzProperties)
                     result.ropeOffsets.Add(WzInfoTools.VectorToXNAPoint(rope));
         else throw new Exception("wrong rope anchor type at ObjectInfo Load");*/
     return result;
 }
Пример #33
0
        public void SaveRopes()
        {
            WzSubProperty ropeParent = new WzSubProperty();
            for (int i = 0; i < board.BoardItems.Ropes.Count; i++)
            {
                Rope ropeInst = board.BoardItems.Ropes[i];
                WzSubProperty rope = new WzSubProperty();

                rope["x"] = InfoTool.SetInt(ropeInst.FirstAnchor.X);
                rope["y1"] = InfoTool.SetInt(Math.Min(ropeInst.FirstAnchor.Y, ropeInst.SecondAnchor.Y));
                rope["y2"] = InfoTool.SetInt(Math.Max(ropeInst.FirstAnchor.Y, ropeInst.SecondAnchor.Y));
                rope["uf"] = InfoTool.SetBool(ropeInst.uf);
                rope["page"] = InfoTool.SetInt(ropeInst.LayerNumber);
                rope["l"] = InfoTool.SetBool(ropeInst.ladder);

                ropeParent[(i + 1).ToString()] = rope;
            }
            image["ladderRope"] = ropeParent;
        }