Example #1
0
 public static int PropertySorter(WzCanvasProperty a, WzCanvasProperty b)
 {
     int aIndex = 0;
     int bIndex = 0;
     if (!int.TryParse(a.Name, out aIndex) || !int.TryParse(b.Name, out bIndex)) return 0;
     return aIndex.CompareTo(bIndex);
 }
Example #2
0
        public override WzImageProperty DeepClone()
        {
            WzCanvasProperty clone = new WzCanvasProperty(name);

            foreach (WzImageProperty prop in properties)
            {
                clone.AddProperty(prop.DeepClone());
            }
            clone.imageProp = (WzPngProperty)imageProp.DeepClone();
            return(clone);
        }
Example #3
0
        public override IWzImageProperty DeepClone()
        {
            WzCanvasProperty clone = (WzCanvasProperty)MemberwiseClone();

            clone.properties = new List <IWzImageProperty>();
            foreach (IWzImageProperty prop in properties)
            {
                clone.properties.Add(prop.DeepClone());
            }
            clone.imageProp = (WzPngProperty)imageProp.DeepClone();
            return(clone);
        }
Example #4
0
 /// <summary>
 /// Dispose the object
 /// </summary>
 public override void Dispose()
 {
     mName        = null;
     _inlink      = null;
     _inlinkValue = null;
     _outlink     = null;
     if (_outlinkValue != null)
     {
         mImgParent.AddReferencedImage(_outlinkValue.ParentImage);
     }
     _outlinkValue = null;
     mImageProp.Dispose();
     mImageProp = null;
     foreach (AWzImageProperty prop in mProperties)
     {
         prop.Dispose();
     }
     mProperties.Clear();
     mProperties = null;
 }
 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);
     }
 }
 private void CreateWzProp(IPropertyContainer parent, WzPropertyType propType, string propName, object value)
 {
     IWzImageProperty addedProp;
     switch (propType)
     {
         case WzPropertyType.ByteFloat:
             addedProp = new WzByteFloatProperty(propName);
             break;
         case WzPropertyType.Canvas:
             addedProp = new WzCanvasProperty(propName);
             ((WzCanvasProperty)addedProp).PngProperty = new WzPngProperty();
             break;
         case WzPropertyType.CompressedInt:
             addedProp = new WzCompressedIntProperty(propName);
             break;
         case WzPropertyType.Double:
             addedProp = new WzDoubleProperty(propName);
             break;
         /*case WzPropertyType.Sound:
             addedProp = new WzSoundProperty(propName);
             break;*/
         case WzPropertyType.String:
             addedProp = new WzStringProperty(propName);
             break;
         case WzPropertyType.UnsignedShort:
             addedProp = new WzUnsignedShortProperty(propName);
             break;
         case WzPropertyType.Vector:
             addedProp = new WzVectorProperty(propName);
             ((WzVectorProperty)addedProp).X = new WzCompressedIntProperty("X");
             ((WzVectorProperty)addedProp).Y = new WzCompressedIntProperty("Y");
             break;
         default:
             throw new NotSupportedException("not supported type");
     }
     addedProp.SetValue(value);
     parent.AddProperty(addedProp);
 }
        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);
        }
Example #8
0
        public ObjectInfo Add(Bitmap bmp, string name)
        {
            if (!IsNameValid(name))
                throw new NameAlreadyUsedException();

            Point origin = new Point(bmp.Width / 2, bmp.Height / 2);

            WzSubProperty prop = new WzSubProperty();
            WzCanvasProperty canvasProp = new WzCanvasProperty();
            canvasProp.PngProperty = new WzPngProperty();
            canvasProp.PngProperty.SetPNG(bmp);
            canvasProp["origin"] = new WzVectorProperty("", new WzIntProperty("X", origin.X), new WzIntProperty("Y", origin.Y));
            canvasProp["z"] = new WzIntProperty("", 0);
            prop["0"] = canvasProp;

            ObjectInfo oi = new ObjectInfo(bmp, origin, oS, l0, l1, name, prop);
            newObjects.Add(oi);
            newObjectsData.Add(name, SaveImageToBytes(bmp));
            SerializeObjects();
            l1prop[name] = prop;

            return oi;
        }
Example #9
0
 public static TileInfo Load(WzCanvasProperty parentObject, string tS, string u, string no)
 {
     TileInfo result = new TileInfo(parentObject.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)parentObject["origin"]), tS,u,no, parentObject);
     WzConvexProperty footholds = (WzConvexProperty)parentObject["foothold"];
     if (footholds != null)
         foreach (WzVectorProperty foothold in footholds.WzProperties)
             result.footholdOffsets.Add(WzInfoTools.VectorToXNAPoint(foothold));
     return result;
 }
Example #10
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;
     }
 }
Example #11
0
 private static TileInfo Load(WzCanvasProperty parentObject, string tS, string u, string no, int? mag)
 {
     WzImageProperty zProp = parentObject["z"];
     int z = zProp == null ? 0 : InfoTool.GetInt(zProp);
     TileInfo result = new TileInfo(parentObject.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)parentObject["origin"]), tS, u, no, mag.HasValue ? mag.Value : 1, z, parentObject);
     WzConvexProperty footholds = (WzConvexProperty)parentObject["foothold"];
     if (footholds != null)
         foreach (WzVectorProperty foothold in footholds.WzProperties)
             result.footholdOffsets.Add(WzInfoTools.VectorToXNAPoint(foothold));
     if (UserSettings.FixFootholdMispositions)
     {
         FixFootholdMispositions(result);
     }
     return result;
 }
Example #12
0
 public static PortalInfo Load(WzCanvasProperty parentObject)
 {
     PortalInfo portal = new PortalInfo(parentObject.Name, parentObject.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)parentObject["origin"]), parentObject);
     Program.InfoManager.Portals.Add(portal.type, portal);
     return portal;
 }
Example #13
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;
            }
        }
Example #14
0
        /// <summary>
        /// Overwrites the .img being edited, based on the Map open inside the Board
        /// </summary>
        /// <param name="mapBoard">Board containing everything about the map</param>
        public static string WriteToMap(Board mapBoard)
        {
            #region Info
            if (mapBoard.MapInfo.mapImage["info"] != null)
                mapBoard.MapInfo.mapImage["info"].Remove();
            WzSubProperty info = new WzSubProperty("info");
            info.AddProperty(new WzStringProperty("bgm", mapBoard.MapInfo.bgm));
            if (mapBoard.MapInfo.MapMark != null)
                info.AddProperty(new WzStringProperty("mapMark", mapBoard.MapInfo.MapMark));
            else
                info.AddProperty(new WzStringProperty("mapMark", "None"));
            info.AddProperty(new WzCompressedIntProperty("cloud", (MapleBool)mapBoard.MapInfo.cloud));
            info.AddProperty(new WzCompressedIntProperty("version", 10));
            info.AddProperty(new WzCompressedIntProperty("town", (MapleBool)mapBoard.MapInfo.town));
            info.AddProperty(new WzCompressedIntProperty("returnMap", mapBoard.MapInfo.returnMap));
            try
            {
                info.AddProperty(new WzByteFloatProperty("mobRate", mapBoard.MapInfo.mobRate));
            }
            catch
            {
                info.AddProperty(new WzByteFloatProperty("mobRate", 1.5f));
            }
            info.AddProperty(new WzCompressedIntProperty("swim", (MapleBool)mapBoard.MapInfo.swim));
            info.AddProperty(new WzCompressedIntProperty("hideMinimap", (MapleBool)mapBoard.MapInfo.hideMinimap));
            try
            {
                info.AddProperty(new WzCompressedIntProperty("fieldLimit", Convert.ToInt32(mapBoard.MapInfo.fieldLimit)));
            }
            catch
            {
                info.AddProperty(new WzCompressedIntProperty("fieldLimit", 0));
            }
            try
            {
                info.AddProperty(new WzCompressedIntProperty("forcedReturn", mapBoard.MapInfo.forcedReturn));
            }
            catch
            {
                info.AddProperty(new WzCompressedIntProperty("forcedReturn", 999999999));
            }
            info.AddProperty(new WzCompressedIntProperty("VRTop", mapBoard.MapInfo.VR.Value.Y));
            info.AddProperty(new WzCompressedIntProperty("VRLeft", mapBoard.MapInfo.VR.Value.X));
            info.AddProperty(new WzCompressedIntProperty("VRBottom", mapBoard.MapInfo.VR.Value.Height + mapBoard.MapInfo.VR.Value.Y));
            info.AddProperty(new WzCompressedIntProperty("VRRight", mapBoard.MapInfo.VR.Value.Width + mapBoard.MapInfo.VR.Value.X));
            mapBoard.MapInfo.mapImage.AddProperty(info);
            #endregion

            #region Back
            if (mapBoard.MapInfo.mapImage["back"] != null)
                mapBoard.MapInfo.mapImage["back"].Remove();
            WzSubProperty back = new WzSubProperty("back");
            int backcount = 0;
            foreach (BackgroundInstance backInst in mapBoard.BoardItems.BackBackgrounds)
            {
                WzSubProperty backParent = new WzSubProperty(Convert.ToString(backcount));
                backParent.AddProperty(new WzCompressedIntProperty("a", backInst.a));
                backParent.AddProperty(new WzCompressedIntProperty("ani", (MapleBool)((BackgroundInfo)backInst.BaseInfo).ani));
                backParent.AddProperty(new WzStringProperty("bS", ((BackgroundInfo)backInst.BaseInfo).bS));
                backParent.AddProperty(new WzCompressedIntProperty("cx", backInst.cx));
                backParent.AddProperty(new WzCompressedIntProperty("cy", backInst.cy));
                backParent.AddProperty(new WzCompressedIntProperty("f", (MapleBool)backInst.Flip));
                backParent.AddProperty(new WzCompressedIntProperty("front", (MapleBool)backInst.front));
                backParent.AddProperty(new WzCompressedIntProperty("no", Convert.ToInt32(((BackgroundInfo)backInst.BaseInfo).no)));
                backParent.AddProperty(new WzCompressedIntProperty("rx", backInst.rx));
                backParent.AddProperty(new WzCompressedIntProperty("ry", backInst.ry));
                backParent.AddProperty(new WzCompressedIntProperty("type", Convert.ToInt32(backInst.type)));
                backParent.AddProperty(new WzCompressedIntProperty("x", backInst.X));
                backParent.AddProperty(new WzCompressedIntProperty("y", backInst.Y));
                backcount++;
                back.AddProperty(backParent);
            }

            foreach (BackgroundInstance backInst in mapBoard.BoardItems.FrontBackgrounds)
            {
                WzSubProperty backParent = new WzSubProperty(Convert.ToString(backcount));
                backParent.AddProperty(new WzCompressedIntProperty("a", backInst.a));
                backParent.AddProperty(new WzCompressedIntProperty("ani", (MapleBool)((BackgroundInfo)backInst.BaseInfo).ani));
                backParent.AddProperty(new WzStringProperty("bS", ((BackgroundInfo)backInst.BaseInfo).bS));
                backParent.AddProperty(new WzCompressedIntProperty("cx", backInst.cx));
                backParent.AddProperty(new WzCompressedIntProperty("cy", backInst.cy));
                backParent.AddProperty(new WzCompressedIntProperty("f", (MapleBool)backInst.Flip));
                backParent.AddProperty(new WzCompressedIntProperty("front", (MapleBool)backInst.front));
                backParent.AddProperty(new WzCompressedIntProperty("no", Convert.ToInt32(((BackgroundInfo)backInst.BaseInfo).no)));
                backParent.AddProperty(new WzCompressedIntProperty("rx", backInst.rx));
                backParent.AddProperty(new WzCompressedIntProperty("ry", backInst.ry));
                backParent.AddProperty(new WzCompressedIntProperty("type", Convert.ToInt32(backInst.type)));
                backParent.AddProperty(new WzCompressedIntProperty("x", backInst.X));
                backParent.AddProperty(new WzCompressedIntProperty("y", backInst.Y));
                backcount++;
                back.AddProperty(backParent);
            }
            mapBoard.MapInfo.mapImage.AddProperty(back);
            #endregion

            #region Minimap
            if (mapBoard.MapInfo.mapImage["miniMap"] != null)
                mapBoard.MapInfo.mapImage["miniMap"].Remove();
            WzSubProperty mmSub = new WzSubProperty("miniMap");
            WzCanvasProperty canvas = new WzCanvasProperty("canvas");
            canvas.PngProperty = new WzPngProperty();
            canvas.PngProperty.SetPNG(mapBoard.MiniMap);
            mmSub.AddProperty(canvas);
            mmSub.AddProperty(new WzCompressedIntProperty("centerX", mapBoard.CenterPoint.X));
            mmSub.AddProperty(new WzCompressedIntProperty("centerY", mapBoard.CenterPoint.Y));
            mmSub.AddProperty(new WzCompressedIntProperty("height", mapBoard.MapSize.Y));
            mmSub.AddProperty(new WzCompressedIntProperty("width", mapBoard.MapSize.X));
            mmSub.AddProperty(new WzCompressedIntProperty("mag", 4));
            mapBoard.MapInfo.mapImage.AddProperty(mmSub);
            #endregion

            #region ladderRope
            if (mapBoard.MapInfo.mapImage["ladderRope"] != null)
                mapBoard.MapInfo.mapImage["ladderRope"].Remove();
            WzSubProperty ladderRope = new WzSubProperty("ladderRope");
            int ropeCounter = 1;
            foreach (Rope rope in mapBoard.BoardItems.Ropes)
            {
                WzSubProperty ropeParent = new WzSubProperty(Convert.ToString(ropeCounter));
                ropeParent.AddProperty(new WzCompressedIntProperty("l", (MapleBool)rope.ladder));
                ropeParent.AddProperty(new WzCompressedIntProperty("uf", 1));
                ropeParent.AddProperty(new WzCompressedIntProperty("x", rope.FirstAnchor.X));
                if (rope.FirstAnchor.Y < rope.SecondAnchor.Y)
                {
                    ropeParent.AddProperty(new WzCompressedIntProperty("y1", rope.FirstAnchor.Y));
                    ropeParent.AddProperty(new WzCompressedIntProperty("y2", rope.SecondAnchor.Y));
                }
                else
                {
                    ropeParent.AddProperty(new WzCompressedIntProperty("y1", rope.SecondAnchor.Y));
                    ropeParent.AddProperty(new WzCompressedIntProperty("y2", rope.FirstAnchor.Y));
                }
                ropeParent.AddProperty(new WzCompressedIntProperty("page", rope.page));
                ropeCounter++;
                ladderRope.AddProperty(ropeParent);
            }
            mapBoard.MapInfo.mapImage.AddProperty(ladderRope);
            #endregion

            #region Remove/Re-add obj/tile
            removeLayerProps(mapBoard.MapInfo.mapImage);
            #endregion

            #region TileObj
            foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs)
            {

                IWzImageProperty curTileObj = mapBoard.MapInfo.mapImage[tileObj.LayerNumber.ToString()];
                if (objNums[tileObj.LayerNumber] == null) objNums[tileObj.LayerNumber] = 0;
                if (tileNums[tileObj.LayerNumber] == null) tileNums[tileObj.LayerNumber] = 0;
                #region Object
                if (tileObj is ObjectInstance)
                {
                    String objName = objNums[tileObj.LayerNumber].ToString();
                    IWzImageProperty curObj = curTileObj["obj"];
                    AddMapObj((WzSubProperty)curObj, objName, tileObj);
                    objNums[tileObj.LayerNumber] = Convert.ToInt32(objNums[tileObj.LayerNumber]) + 1;
                }
                #endregion

                #region Tile
                else if (tileObj is TileInstance)
                {
                    String tileName = tileNums[tileObj.LayerNumber].ToString();
                    IWzImageProperty curTile = curTileObj["tile"];
                    AddMapTile((WzSubProperty)curTile, tileName, tileObj);
                    tileNums[tileObj.LayerNumber] = Convert.ToInt32(tileNums[tileObj.LayerNumber]) + 1;
                }
                #endregion
            }
            #endregion

            #region Vars
            if (mapBoard.MapInfo.mapImage["portal"] != null)
                mapBoard.MapInfo.mapImage["portal"].Remove();
            WzSubProperty portal = new WzSubProperty("portal");
            int portalCount = 0;
            if (mapBoard.MapInfo.mapImage["seat"] != null)
                mapBoard.MapInfo.mapImage["seat"].Remove();
            WzSubProperty seatParent = new WzSubProperty("seat");
            int seatCounter = 0;
            if (mapBoard.MapInfo.mapImage["life"] != null)
                mapBoard.MapInfo.mapImage["life"].Remove();
            WzSubProperty lifeParent = new WzSubProperty("life");
            int lifeCounter = 0;
            if (mapBoard.MapInfo.mapImage["reactor"] != null)
                mapBoard.MapInfo.mapImage["reactor"].Remove();
            WzSubProperty reactorParent = new WzSubProperty("reactor");
            int reactorCounter = 0;
            #endregion

            #region Portal
            foreach (PortalInstance portall in mapBoard.BoardItems.Portals)
            {
                WzSubProperty portalX = new WzSubProperty(Convert.ToString(portalCount));
                portalX.AddProperty(new WzStringProperty("pn", portall.pn));
                portalX.AddProperty(new WzCompressedIntProperty("pt", Convert.ToInt32(portall.pt)));
                portalX.AddProperty(new WzCompressedIntProperty("tm", portall.tm));
                portalX.AddProperty(new WzStringProperty("tn", portall.tn));
                portalX.AddProperty(new WzCompressedIntProperty("x", portall.X));
                portalX.AddProperty(new WzCompressedIntProperty("y", portall.Y));
                if ((!String.IsNullOrEmpty(portall.script)) || (!String.IsNullOrWhiteSpace(portall.script)))
                    portalX.AddProperty(new WzStringProperty("script", portall.script));
                portal.AddProperty(portalX);
                portalCount++;
            }
            #endregion

            #region Life
            #region NPCs
            foreach (LifeInstance npcInst in mapBoard.BoardItems.NPCs)
            {
                WzSubProperty life = new WzSubProperty(Convert.ToString(lifeCounter));
                life.AddProperty(new WzCompressedIntProperty("cy", npcInst.Y));
                life.AddProperty(new WzCompressedIntProperty("y", npcInst.Y));
                life.AddProperty(new WzCompressedIntProperty("x", npcInst.X));
                /*if (((LifeInstance)obj.obj).baseVar is MobInfo && ((MobInfo)((LifeInstance)obj.obj).baseVar).flying)
                    life.AddProperty(new WzCompressedIntProperty("fh", 0));
                else
                {*/
                    FootholdLine fhBelow = FootholdLine.findBelow(new Point(npcInst.X, npcInst.Y), mapBoard);
                    if (fhBelow == null)
                    {
                        Form msgBox = new YesNoBox("No foothold detected", "Auto foothold detection error: No foothold found for the NPC (Name: " + ((NpcInfo)npcInst.BaseInfo).Name + ", ID: " + ((NpcInfo)npcInst.BaseInfo).ID + ") at point " + (npcInst.X).ToString() + "," + (npcInst.Y).ToString() + " (Center-related).\r\nPlease make sure that all Life objects (NPCs/Mobs) are right above a foothold!\r\nClick \"Continue\" if you wish to ignore this problem and continue (could cause map to crash)\r\nClick \"Cancel\" if you would like to cancel saving.", "Continue", "Cancel");
                        if (msgBox.DialogResult != DialogResult.Yes) return "cancel";
                    }
                    else
                    {
                        life.AddProperty(new WzCompressedIntProperty("fh", fhBelow.num));
                    }
                //}
                /*if (((LifeInstance)obj.obj).baseVar is MobInfo)
                {
                    life.AddProperty(new WzCompressedIntProperty("mobTime", Convert.ToInt32(((LifeInstance)npcInst.BaseInfo).MobTime)));
                    life.AddProperty(new WzStringProperty("type", "m"));
                    life.AddProperty(new WzStringProperty("id", ((MobInfo)((LifeInstance)obj.obj).baseVar).ID));
                }
                else
                {*/
                    life.AddProperty(new WzStringProperty("type", "n"));
                    life.AddProperty(new WzStringProperty("id", ((NpcInfo)npcInst.BaseInfo).ID));

                //}
                life.AddProperty(new WzCompressedIntProperty("rx0", npcInst.rx0));
                life.AddProperty(new WzCompressedIntProperty("rx1", npcInst.rx1));
                lifeCounter++;
                lifeParent.AddProperty(life);
            }
            #endregion

            #region Mobs
            foreach (LifeInstance mobInst in mapBoard.BoardItems.Mobs)
            {
                WzSubProperty life = new WzSubProperty(Convert.ToString(lifeCounter));
                life.AddProperty(new WzCompressedIntProperty("cy", mobInst.Y));
                life.AddProperty(new WzCompressedIntProperty("y", mobInst.Y));
                life.AddProperty(new WzCompressedIntProperty("x", mobInst.X));
                //if (mobInst.BaseInfo is MobInfo && ((MobInfo)mobInst.BaseInfo))
                //    life.AddProperty(new WzCompressedIntProperty("fh", 0));
                //else
                //{
                    FootholdLine fhBelow = FootholdLine.findBelow(new Point(mobInst.X, mobInst.Y), mapBoard);
                    if (fhBelow == null)
                    {
                        Form msgBox = new YesNoBox("No foothold detected", "Auto foothold detection error: No foothold found for the Mob (Name: " + ((MobInfo)mobInst.BaseInfo).Name + ", ID: " + ((MobInfo)mobInst.BaseInfo).ID + ") at point " + (mobInst.X).ToString() + "," + (mobInst.Y).ToString() + " (Center-related).\r\nPlease make sure that all Life objects (NPCs/Mobs) are right above a foothold!\r\nClick \"Continue\" if you wish to ignore this problem and continue (could cause map to crash)\r\nClick \"Cancel\" if you would like to cancel saving.", "Continue", "Cancel");
                        if (msgBox.DialogResult != DialogResult.Yes) return "cancel";
                    }
                    life.AddProperty(new WzCompressedIntProperty("fh", fhBelow.fh.num));
                //}
                life.AddProperty(new WzCompressedIntProperty("mobTime", Convert.ToInt32(mobInst.MobTime)));
                life.AddProperty(new WzStringProperty("type", "m"));
                life.AddProperty(new WzStringProperty("id", ((MobInfo)mobInst.BaseInfo).ID));
                life.AddProperty(new WzCompressedIntProperty("rx0", mobInst.rx0));
                life.AddProperty(new WzCompressedIntProperty("rx1", mobInst.rx1));
                lifeCounter++;
                lifeParent.AddProperty(life);
            }
            #endregion
            #endregion

            #region Reactor
            foreach (ReactorInstance reactorInst in mapBoard.BoardItems.Reactors)
            {
                WzSubProperty reactor = new WzSubProperty(Convert.ToString(reactorCounter));
                reactor.AddProperty(new WzCompressedIntProperty("x", reactorInst.X));
                reactor.AddProperty(new WzCompressedIntProperty("y", reactorInst.Y));
                reactor.AddProperty(new WzCompressedIntProperty("f", 0));
                reactor.AddProperty(new WzStringProperty("id", WzInfoTools.AddLeadingZeros(((ReactorInfo)reactorInst.BaseInfo).ID, 7)));
                reactor.AddProperty(new WzCompressedIntProperty("reactorTime", reactorInst.ReactorTime));
                reactor.AddProperty(new WzStringProperty("name", reactorInst.Name));
                reactorCounter++;
                reactorParent.AddProperty(reactor);
            }
            #endregion

            #region Seat/portal check
            #region Portal check
            if (portal.WzProperties.Count == 0)
            {
                Form msgbox = new GUI.YesNoBox("No portals", "No portals were detected in your map.\r\nMaking a map without at least one \"sp\" portal will cause the game to crash.\r\n\r\nClick \"Continue\" to continue building as-is\r\nClick \"Cancel\" to cancel and go back to the editor", "Continue", "Cancel");
                if (msgbox.DialogResult != DialogResult.Yes) return "cancel";
            }
            #endregion
            #region Seat
            foreach (Chair seat in mapBoard.BoardItems.Chairs)
            {
                seatParent.AddProperty(new WzVectorProperty(Convert.ToString(seatCounter), new WzCompressedIntProperty("X", seat.X), new WzCompressedIntProperty("Y", seat.Y)));
                seatCounter++;
            }
            #endregion
            #endregion

            #region Adding P/S/L/R
            mapBoard.MapInfo.mapImage.AddProperty(portal);
            mapBoard.MapInfo.mapImage.AddProperty(seatParent);
            mapBoard.MapInfo.mapImage.AddProperty(lifeParent);
            mapBoard.MapInfo.mapImage.AddProperty(reactorParent);
            #endregion

            #region FootHolds
            saveFootholds(mapBoard);
            #endregion

            return "fine";
        }
Example #15
0
 public override WzImageProperty DeepClone()
 {
     WzCanvasProperty clone = new WzCanvasProperty(name);
     foreach (WzImageProperty prop in properties)
         clone.AddProperty(prop.DeepClone());
     clone.imageProp = (WzPngProperty)imageProp.DeepClone();
     return clone;
 }
Example #16
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);
         }
     }
 }
Example #17
0
 public static TileInfo Load(WzCanvasProperty parentObject)
 {
     string[] path = parentObject.FullPath.Split(@"\".ToCharArray());
     return Load(parentObject,WzInfoTools.RemoveExtension(path[path.Length - 3]), path[path.Length - 2], path[path.Length - 1]);
 }
		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;
			}
		}
Example #19
0
 public static PortalInfo Load(WzCanvasProperty parentObject)
 {
    PortalInfo portal = new PortalInfo((PortalType)ptByShortName[parentObject.Name], parentObject.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)parentObject["origin"]), parentObject);
    Program.InfoManager.Portals[(int)ptByShortName[parentObject.Name]] = portal;
    return portal;
 }
Example #20
0
        /*private ToolStripMenuItem ExportPropertySubMenu;
        private ToolStripMenuItem ExportAnimationSubMenu;
        private ToolStripMenuItem ExportDirectorySubMenu;
        private ToolStripMenuItem ExportPServerXML;
        private ToolStripMenuItem ExportDataXML;
        private ToolStripMenuItem ExportImgData;
        private ToolStripMenuItem ExportRawData;
        private ToolStripMenuItem ExportGIF;
        private ToolStripMenuItem ExportAPNG;

        private ToolStripMenuItem ImportSubMenu;
        private ToolStripMenuItem ImportXML;
        private ToolStripMenuItem ImportImgData;*/
        public ContextMenuManager(UndoRedoManager undoMan)
        {
            //this.parent = parent;
            SaveFile = new ToolStripMenuItem("Save...", Properties.Resources.disk, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    foreach (WzNode node in GetNodes(sender))
                    {
                        HaRepackerMainPanel parent = ((HaRepackerMainPanel)node.TreeView.Parent.Parent.Parent);
                        new SaveForm(parent, node).ShowDialog();
                    }
                }));
            Remove = new ToolStripMenuItem("Remove", Properties.Resources.delete, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    if (!Warning.Warn("Are you sure you want to remove this node?")) return;
                    foreach (WzNode node in GetNodes(sender))
                    {
                        if (!(node.Tag is WzFile))
                        {
                            node.Delete();
                        }
                    }
                }));
            Unload = new ToolStripMenuItem("Unload", Properties.Resources.delete, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    if (!Warning.Warn("Are you sure you want to unload this file?")) return;
                    foreach (WzNode node in GetNodes(sender))
                    {
                        Program.WzMan.UnloadWzFile((WzFile)node.Tag);
                    }
                }));
            Reload = new ToolStripMenuItem("Reload", Properties.Resources.arrow_refresh, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    if (!Warning.Warn("Are you sure you want to reload this file?")) return;
                    foreach (WzNode node in GetNodes(sender))
                    {
                        HaRepackerMainPanel parent = ((HaRepackerMainPanel)node.TreeView.Parent.Parent.Parent);
                        Program.WzMan.ReloadWzFile((WzFile)node.Tag, parent);
                    }
                }));

            AddImage = new ToolStripMenuItem("Image", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name;
                    if (NameInputBox.Show("Add Image", out name))
                        nodes[0].AddObject(new WzImage(name) { Changed = true }, undoMan);
                }));
            AddDirectory = new ToolStripMenuItem("Directory", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name;
                    if (NameInputBox.Show("Add Directory", out name))
                        nodes[0].AddObject(new WzDirectory(name), undoMan);
                }));
            AddByteFloat = new ToolStripMenuItem("Float", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name; double? val;
                    if (FloatingPointInputBox.Show("Add Float", out name, out val))
                        nodes[0].AddObject(new WzFloatProperty(name, (float)val), undoMan);
                }));
            AddCanvas = new ToolStripMenuItem("Canvas", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name; Bitmap bmp;
                    if (BitmapInputBox.Show("Add Canvas", out name, out bmp))
                    {
                        WzCanvasProperty prop = new WzCanvasProperty(name);
                        prop.PngProperty = new WzPngProperty();
                        prop.PngProperty.SetPNG(bmp);
                        nodes[0].AddObject(new WzCanvasProperty(name), undoMan);
                    }
                }));
            AddInt = new ToolStripMenuItem("Int", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name; int? val;
                    if (IntInputBox.Show("Add Int", out name, out val))
                        nodes[0].AddObject(new WzIntProperty(name, (int)val), undoMan);
                }));
            AddConvex = new ToolStripMenuItem("Convex", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name;
                    if (NameInputBox.Show("Add Convex", out name))
                        nodes[0].AddObject(new WzConvexProperty(name), undoMan);
                }));
            AddDouble = new ToolStripMenuItem("Double", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name; double? val;
                    if (FloatingPointInputBox.Show("Add Double", out name, out val))
                        nodes[0].AddObject(new WzDoubleProperty(name, (double)val), undoMan);
                }));
            AddNull = new ToolStripMenuItem("Null", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name;
                    if (NameInputBox.Show("Add Null", out name))
                        nodes[0].AddObject(new WzNullProperty(name), undoMan);
                }));
            AddSound = new ToolStripMenuItem("Sound", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name, path;
                    if (SoundInputBox.Show("Add Sound", out name, out path))
                    {
                        try { nodes[0].AddObject(new WzSoundProperty(name, path), undoMan); }
                        catch (Exception ex) { MessageBox.Show("Exception caught while adding property: \"" + ex.Message + "\"", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                    }
                }));
            AddString = new ToolStripMenuItem("String", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name, value;
                    if (NameValueInputBox.Show("Add String", out name, out value))
                        nodes[0].AddObject(new WzStringProperty(name, value), undoMan);
                }));
            AddSub = new ToolStripMenuItem("Sub", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name;
                    if (NameInputBox.Show("Add Sub", out name))
                        nodes[0].AddObject(new WzSubProperty(name), undoMan);
                }));
            AddUshort = new ToolStripMenuItem("Short", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name; int? val;
                    if (IntInputBox.Show("Add Unsigned Short", out name, out val))
                        nodes[0].AddObject(new WzShortProperty(name, (short)val), undoMan);
                }));
            AddUOL = new ToolStripMenuItem("UOL", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name, value;
                    if (NameValueInputBox.Show("Add UOL", out name, out value))
                        nodes[0].AddObject(new WzUOLProperty(name, value), undoMan);
                }));
            AddVector = new ToolStripMenuItem("Vector", null, new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    WzNode[] nodes = GetNodes(sender);
                    if (nodes.Length != 1) { MessageBox.Show("Please select only ONE node"); return; }
                    string name; Point? pt;
                    if (VectorInputBox.Show("Add Vector", out name, out pt))
                        nodes[0].AddObject(new WzVectorProperty(name, new WzIntProperty("X", pt.Value.X), new WzIntProperty("Y", pt.Value.Y)), undoMan);
                }));

            AddConvexSubMenu = new ToolStripMenuItem("Add", Properties.Resources.add, AddVector);
            AddDirsSubMenu = new ToolStripMenuItem("Add", Properties.Resources.add, AddDirectory, AddImage);
            AddPropsSubMenu = new ToolStripMenuItem("Add", Properties.Resources.add, AddCanvas, AddConvex, AddDouble, AddByteFloat, AddInt, AddNull, AddUshort, AddSound, AddString, AddSub, AddUOL, AddVector);

            WzFileMenu = new ContextMenuStrip();
            WzFileMenu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, SaveFile, Unload, Reload });
            WzDirectoryMenu = new ContextMenuStrip();
            WzDirectoryMenu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, /*export, import,*/Remove });
            PropertyContainerMenu = new ContextMenuStrip();
            PropertyContainerMenu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/Remove });
            PropertyMenu = new ContextMenuStrip();
            PropertyMenu.Items.AddRange(new ToolStripItem[] { /*export, import,*/Remove });
            SubPropertyMenu = new ContextMenuStrip();
            SubPropertyMenu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/Remove });
        }