Exemplo n.º 1
0
        public TileSetBrowser(ListBox target)
        {
            InitializeComponent();
            targetListBox             = target;
            styleManager.ManagerStyle = UserSettings.applicationStyle;
            List <string> sortedTileSets = new List <string>();

            foreach (DictionaryEntry tS in Program.InfoManager.TileSets)
            {
                sortedTileSets.Add((string)tS.Key);
            }
            sortedTileSets.Sort();
            foreach (string tS in sortedTileSets)
            {
                WzImage tSImage = Program.InfoManager.TileSets[tS];
                if (!tSImage.Parsed)
                {
                    tSImage.ParseImage();
                }
                IWzImageProperty enh0 = tSImage["enH0"];
                if (enh0 == null)
                {
                    continue;
                }
                WzCanvasProperty image = (WzCanvasProperty)enh0["0"];
                if (image == null)
                {
                    continue;
                }
                //image.PngProperty.GetPNG(true);
                KoolkLVItem item = koolkLVContainer.createItem(image.PngProperty.GetPNG(true), tS, true);
                item.MouseDown        += new MouseEventHandler(item_Click);
                item.MouseDoubleClick += new MouseEventHandler(item_DoubleClick);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a wz property by a path name
        /// </summary>
        /// <param name="path">path to property</param>
        /// <returns>the wz property with the specified name</returns>
        public override IWzImageProperty GetFromPath(string path)
        {
            string[] segments = path.Split(new char[1] {
                '/'
            }, System.StringSplitOptions.RemoveEmptyEntries);
            if (segments[0] == "..")
            {
                return(((IWzImageProperty)Parent)[path.Substring(name.IndexOf('/') + 1)]);
            }
            IWzImageProperty ret = this;

            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);
        }
Exemplo n.º 3
0
 public override void ExportXml(StreamWriter writer, int level)
 {
     writer.WriteLine(XmlUtil.Indentation(level) + XmlUtil.OpenNamedTag("WzCanvas", this.Name, false, false) +
                      XmlUtil.Attrib("width", PngProperty.Width.ToString()) +
                      XmlUtil.Attrib("height", PngProperty.Height.ToString(), true, false));
     IWzImageProperty.DumpPropertyList(writer, level, this.WzProperties);
     writer.WriteLine(XmlUtil.Indentation(level) + XmlUtil.CloseTag("WzCanvas"));
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public static void CreateMapFromImage(WzImage mapImage, string mapName, string streetName, PageCollection Tabs, MultiBoard multiBoard, EventHandler rightClickHandler)
        {
            if (!mapImage.Parsed)
            {
                mapImage.ParseImage();
            }
            VerifyMapPropsKnown(mapImage);
            MapInfo info = new MapInfo(mapImage, mapName, streetName);
            MapType type = GetMapType(mapImage);

            if (type == MapType.RegularMap)
            {
                info.id = int.Parse(WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)));
            }
            info.mapType = type;
            Point center = new Point();
            Point size   = new Point();

            if (mapImage["miniMap"] == null)
            {
                if (info.VR == null)
                {
                    if (!GetMapVR(mapImage, ref info.VR))
                    {
                        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;
                    }
                }
                size   = new Point(info.VR.Value.Width + 10, info.VR.Value.Height + 10); //leave 5 pixels on each side
                center = new Point(5 - info.VR.Value.Left, 5 - info.VR.Value.Top);
            }
            else
            {
                IWzImageProperty miniMap = mapImage["miniMap"];
                size   = new Point(InfoTool.GetInt(miniMap["width"]), InfoTool.GetInt(miniMap["height"]));
                center = new Point(InfoTool.GetInt(miniMap["centerX"]), InfoTool.GetInt(miniMap["centerY"]));
            }
            CreateMap(mapName, WzInfoTools.RemoveLeadingZeros(WzInfoTools.RemoveExtension(mapImage.Name)), CreateStandardMapMenu(rightClickHandler), size, center, 8, Tabs, multiBoard);
            Board mapBoard = multiBoard.SelectedBoard;

            mapBoard.MapInfo = info;
            if (mapImage["miniMap"] != null)
            {
                mapBoard.MiniMap = ((WzCanvasProperty)mapImage["miniMap"]["canvas"]).PngProperty.GetPNG(false);
            }
            LoadLayers(mapImage, mapBoard);
            LoadLife(mapImage, mapBoard);
            LoadFootholds(mapImage, mapBoard);
            LoadRopes(mapImage, mapBoard);
            LoadChairs(mapImage, mapBoard);
            LoadPortals(mapImage, mapBoard);
            LoadReactors(mapImage, mapBoard);
            LoadToolTips(mapImage, mapBoard);
            LoadBackgrounds(mapImage, mapBoard);
            mapBoard.BoardItems.Sort();
        }
Exemplo n.º 6
0
 protected void ExportObject(IWzImageProperty pProp, string pPrepend)
 {
     foreach (var prop in pProp.WzProperties.Where(
                  ip => { return(ip is WzCompressedIntProperty || ip is WzByteFloatProperty || ip is WzDoubleProperty || ip is WzStringProperty); }
                  ))
     {
         SaveInfo(prop, pPrepend);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Adds a WzExtendedProperty to the list of properties
 /// </summary>
 /// <param name="prop">The property to add</param>
 public void AddProperty(IWzImageProperty prop)
 {
     if (!(prop is IExtended))
     {
         throw new Exception("Property is not IExtended");
     }
     prop.Parent = this;
     properties.Add((IExtended)prop);
 }
Exemplo n.º 8
0
        protected void ExportAnimatedObject(string pDir, IWzImageProperty pProp, string pPrepend, bool pOnlyImages = false)
        {
            if (pProp is WzUOLProperty)
            {
                if (((WzUOLProperty)pProp).LinkValue == null)
                {
                    return;                                           // nexan
                }
                SaveInfo(pProp, pPrepend);
                return;
            }

            ExportObject(pProp, pPrepend);

            if (pProp["0"] == null)
            {
                // Try to export non-animated object
                foreach (var prop in pProp.WzProperties)
                {
                    ExportIfExists(pDir, prop, pPrepend); // Will export [pPrepend].[prop.Name].png, if needed. alert.0.arm.png
                }

                return;
            }

            for (int i = 0; ; i++)
            {
                string frame = i.ToString();
                if (pProp[frame] == null)
                {
                    break;
                }

                var frameNode = pProp[frame];              // .../N/

                ExportIfExists(pDir, frameNode, pPrepend); // Will export [pPrepend].[frameNode.Name].png, if needed. alert.0.png
                if (pProp[frame].WzProperties == null)
                {
                    continue;
                }
                foreach (var prop in frameNode.WzProperties)
                {
                    ExportIfExists(pDir, prop, pPrepend + "." + frame); // Will export [pPrepend].[frame].[prop.Name].png, if needed. alert.0.arm.png
                }

                if (!(frameNode is WzUOLProperty))
                {
                    foreach (var prop in frameNode.WzProperties.Where(
                                 ip => { return(ip is WzCompressedIntProperty || ip is WzByteFloatProperty || ip is WzDoubleProperty || ip is WzStringProperty); }
                                 ))
                    {
                        SaveInfo(prop, pPrepend + "." + frame);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public static int?GetOptionalTranslatedInt(IWzImageProperty source)
        {
            string str = InfoTool.GetOptionalString(source);

            if (str == null)
            {
                return(null);
            }
            return(int.Parse(str));
        }
Exemplo n.º 10
0
 public static IWzImageProperty GetRealProperty(IWzImageProperty prop)
 {
     if (prop is WzUOLProperty)
     {
         return((IWzImageProperty)ResolveUOL((WzUOLProperty)prop));
     }
     else
     {
         return(prop);
     }
 }
Exemplo n.º 11
0
 public static MapleBool GetOptionalBool(IWzImageProperty source)
 {
     if (source == null)
     {
         return(MapleBool.NotExist);
     }
     else
     {
         return(((WzCompressedIntProperty)source).Value == 1);
     }
 }
Exemplo n.º 12
0
 private void ExportProperties(IWzImageProperty pProp, string pName)
 {
     foreach (IWzImageProperty prop in pProp.WzProperties)
     {
         ExportIfExists(exDir, prop, pName + "." + prop.Name);
         if (prop.WzProperties != null)
         {
             ExportAnimatedObject(exDir, prop, pName);
             ExportProperties(prop, pName + "." + prop.Name);
         }
     }
 }
Exemplo n.º 13
0
 public void ExportProps(IWzImageProperty pProp, string pName)
 {
     if (pProp.WzProperties == null)
     {
         return;
     }
     ExportObject(pProp, pName);
     foreach (IWzImageProperty prop in pProp.WzProperties)
     {
         ExportProps(prop, pName + "." + prop.Name);
     }
 }
Exemplo n.º 14
0
        public void parseProperties(IWzImageProperty iwip, int proploop)
        {
            switch (iwip.PropertyType)
            {
            case WzPropertyType.SubProperty: parseSubProperty(iwip, proploop); break;

            case WzPropertyType.String: parseString(iwip); break;

            case WzPropertyType.Canvas: parseImage(iwip); break;

            case WzPropertyType.Vector: parseVector(iwip); break;
            }
        }
Exemplo n.º 15
0
        public void parseImage(IWzImageProperty iwip)
        {
            if (!currentDir.EndsWith("\\") || !currentDir.EndsWith("."))
            {
                currentDir += (Program.isCharacterWZ ? "." : "\\");
            }

            if (!currentDirdunno.EndsWith("\\") || !currentDirdunno.EndsWith("."))
            {
                currentDir      += (Program.isCharacterWZ ? "." : "\\");
                currentDirdunno += (Program.isCharacterWZ ? "." : "\\");
            }

            if (!Program.isCharacterWZ)
            {
                makeRealDir();
            }



            if (false && !File.Exists(correctName(currentDir + iwip.Name + ".png", true)))
            {
                iwip.ToBitmap().Save(correctName(currentDir + iwip.Name + ".png", true), System.Drawing.Imaging.ImageFormat.Png);
            }



            string tempDir  = currentDir;
            string tempDir2 = currentDirdunno;

            foreach (IWzImageProperty prop in iwip.WzProperties)
            {
                currentDir      += prop.Name + ".";
                currentDirdunno += prop.Name + ".";
                parseProperties(prop, 1);
                currentDir      = tempDir;
                currentDirdunno = tempDir2;
            }

            /*
             * if (iwip["origin"] != null)
             * {
             *  parseVector(iwip["origin"], "origin");
             * }
             *
             * if (iwip["map"] != null)
             * {
             *  parseVector(iwip["map"], "map_brow");
             * }
             */
        }
Exemplo n.º 16
0
        public void parseString(IWzImageProperty iwip)
        {
            int itemId = getImageItemid();

            if (itemId > 0)
            {
                if (!currentDir.EndsWith("_"))
                {
                    currentDir += "_";
                }
                currentDir += iwip.Name;
                SQLData.Instance.AppendRow(itemId, getInfo().TrimEnd('_'), iwip.ToStringValue());
            }
        }
Exemplo n.º 17
0
        private void objL0ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (objL0ListBox.SelectedItem == null)
            {
                return;
            }
            objL1ListBox.Items.Clear();
            objImagesContainer.Controls.Clear();
            IWzImageProperty l0Prop = Program.InfoManager.ObjectSets[(string)objSetListBox.SelectedItem][(string)objL0ListBox.SelectedItem];

            foreach (IWzImageProperty l1Prop in l0Prop.WzProperties)
            {
                objL1ListBox.Items.Add(l1Prop.Name);
            }
        }
Exemplo n.º 18
0
        protected void SaveInfo(IWzImageProperty pValue, string pName)
        {
            if (pValue == null)
            {
                return;
            }
            pName = pName.Trim('.').Replace('.', '_');
            string value = pValue.WzValue.ToString();

            if (pValue is WzUOLProperty)
            {
                value = "{UOL}" + ((WzUOLProperty)pValue).Value;
            }
            SQLData.Instance.AppendRow(currentID, pName + "_" + pValue.Name, value);
        }
Exemplo n.º 19
0
        private void bgSetListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (bgSetListBox.SelectedItem == null)
            {
                return;
            }
            bgImageContainer.Controls.Clear();
            WzImage bgSetImage = Program.InfoManager.BackgroundSets[(string)bgSetListBox.SelectedItem];

            if (!bgSetImage.Parsed)
            {
                bgSetImage.ParseImage();
            }
            if (aniBg.Checked)
            {
                IWzImageProperty aniProp = bgSetImage["ani"];
                if (aniProp == null || aniProp.WzProperties == null)
                {
                    return;
                }
                foreach (WzSubProperty aniBgProp in aniProp.WzProperties)
                {
                    if (aniBgProp.HCTag == null)
                    {
                        aniBgProp.HCTag = BackgroundInfo.Load(aniBgProp, (string)bgSetListBox.SelectedItem, true, aniBgProp.Name);
                    }
                    KoolkLVItem aniItem = bgImageContainer.createItem(((BackgroundInfo)aniBgProp.HCTag).Image, aniBgProp.Name, true);
                    aniItem.Tag        = aniBgProp.HCTag;
                    aniItem.MouseDown += new MouseEventHandler(bgItem_Click);
                    aniItem.MouseUp   += new MouseEventHandler(item_MouseUp);
                }
            }
            else
            {
                IWzImageProperty backProp = bgSetImage["back"];
                foreach (WzCanvasProperty backBg in backProp.WzProperties)
                {
                    if (backBg.HCTag == null)
                    {
                        backBg.HCTag = BackgroundInfo.Load(backBg, (string)bgSetListBox.SelectedItem, false, backBg.Name);
                    }
                    KoolkLVItem aniItem = bgImageContainer.createItem(((BackgroundInfo)backBg.HCTag).Image, backBg.Name, true);
                    aniItem.Tag        = backBg.HCTag;
                    aniItem.MouseDown += new MouseEventHandler(bgItem_Click);
                    aniItem.MouseUp   += new MouseEventHandler(item_MouseUp);
                }
            }
        }
Exemplo n.º 20
0
        public void parseVector(IWzImageProperty iwip)
        {
            int x      = ((WzVectorProperty)iwip).X.ToInt();
            int y      = ((WzVectorProperty)iwip).Y.ToInt();
            int itemId = getImageItemid();

            if (itemId > 0)
            {
                if (!currentDir.EndsWith("_"))
                {
                    currentDir += "_";
                }
                currentDir += iwip.Name;
                SQLData.Instance.AppendRow(itemId, getInfo().TrimEnd('_') + "_X", x.ToString());
                SQLData.Instance.AppendRow(itemId, getInfo().TrimEnd('_') + "_Y", y.ToString());
            }
        }
Exemplo n.º 21
0
 public static BackgroundItem CreateBackgroundFromProperty(IWzImageProperty source, int x, int y, int rx, int ry, int cx, int cy, int a, BackgroundType type, bool front, int mapCenterX, int mapCenterY, GraphicsDevice device, ref List <IWzObject> usedProps, bool flip)
 {
     source = WzInfoTools.GetRealProperty(source);
     if (source is WzSubProperty && ((WzSubProperty)source).WzProperties.Count == 1)
     {
         source = ((WzSubProperty)source).WzProperties[0];
     }
     if (source is WzCanvasProperty) //one-frame
     {
         WzVectorProperty origin = (WzVectorProperty)source["origin"];
         if (source.MSTag == null)
         {
             source.MSTag = BoardItem.TextureFromBitmap(device, ((WzCanvasProperty)source).PngProperty.GetPNG(false));
             usedProps.Add(source);
         }
         return(new BackgroundItem(cx, cy, rx, ry, type, a, front, new DXObject(x - origin.X.Value /* - mapCenterX*/, y - origin.Y.Value /* - mapCenterY*/, (Texture2D)source.MSTag), flip));
     }
     else if (source is WzSubProperty) //animooted
     {
         WzCanvasProperty frameProp;
         int             i      = 0;
         List <DXObject> frames = new List <DXObject>();
         while ((frameProp = (WzCanvasProperty)WzInfoTools.GetRealProperty(source[(i++).ToString()])) != null)
         {
             int?delay = InfoTool.GetOptionalInt(frameProp["delay"]);
             if (delay == null)
             {
                 delay = 100;
             }
             if (frameProp.MSTag == null)
             {
                 frameProp.MSTag = BoardItem.TextureFromBitmap(device, frameProp.PngProperty.GetPNG(false));
                 usedProps.Add(frameProp);
             }
             WzVectorProperty origin = (WzVectorProperty)frameProp["origin"];
             frames.Add(new DXObject(x - origin.X.Value /* - mapCenterX*/, y - origin.Y.Value /* - mapCenterY*/, (int)delay, (Texture2D)frameProp.MSTag));
         }
         return(new BackgroundItem(cx, cy, rx, ry, type, a, front, frames, flip));
     }
     else
     {
         throw new Exception("unsupported property type in map simulator");
     }
 }
Exemplo n.º 22
0
        internal string[] GetPathsFromProperty(IWzImageProperty prop, string curPath)
        {
            List <string> list = new List <string>();

            switch (prop.PropertyType)
            {
            case WzPropertyType.Extended:
                list.AddRange(this.GetPathsFromProperty(((WzExtendedProperty)prop).ExtendedProperty, curPath));
                break;

            case WzPropertyType.SubProperty:
                foreach (IWzImageProperty property3 in ((WzSubProperty)prop).WzProperties)
                {
                    list.Add(curPath + "/" + property3.Name);
                    list.AddRange(this.GetPathsFromProperty(property3, curPath + "/" + property3.Name));
                }
                break;

            case WzPropertyType.Canvas:
                foreach (IWzImageProperty property in ((WzCanvasProperty)prop).WzProperties)
                {
                    list.Add(curPath + "/" + property.Name);
                    list.AddRange(this.GetPathsFromProperty(property, curPath + "/" + property.Name));
                }
                list.Add(curPath + "/PNG");
                break;

            case WzPropertyType.Vector:
                list.Add(curPath + "/X");
                list.Add(curPath + "/Y");
                break;

            case WzPropertyType.Convex:
                foreach (WzExtendedProperty property2 in ((WzConvexProperty)prop).WzProperties)
                {
                    list.Add(curPath + "/" + property2.Name);
                    list.AddRange(this.GetPathsFromProperty(property2, curPath + "/" + property2.Name));
                }
                break;
            }
            return(list.ToArray());
        }
Exemplo n.º 23
0
 public void AddProperty(IWzImageProperty prop)
 {
     prop.Parent      = this;
     prop.ParentImage = this.ParentImage;
     switch (prop.PropertyType)
     {
     case WzPropertyType.SubProperty:
     case WzPropertyType.Canvas:
     case WzPropertyType.Vector:
     case WzPropertyType.Convex:
     case WzPropertyType.Sound:
     case WzPropertyType.UOL:
         this.properties.Add(new WzExtendedProperty(prop.Name)
         {
             ExtendedProperty = prop
         });
         return;
     }
     this.properties.Add(prop);
 }
Exemplo n.º 24
0
        /// <summary>
        /// Adds a property to the list
        /// </summary>
        /// <param name="prop">The property to add</param>
        public void AddProperty(IWzImageProperty prop)
        {
            switch (prop.PropertyType)
            {
            case WzPropertyType.SubProperty:
            case WzPropertyType.Vector:
            case WzPropertyType.UOL:
            case WzPropertyType.Canvas:
            case WzPropertyType.Convex:
            case WzPropertyType.Sound:
                properties.Add(new WzExtendedProperty(prop.Name)
                {
                    ExtendedProperty = prop
                });
                return;

            default:
                properties.Add(prop);
                return;
            }
        }
Exemplo n.º 25
0
 public override void WriteValue(MapleLib.WzLib.Util.WzBinaryWriter writer)
 {
     writer.WriteStringValue("Canvas", 0x73, 0x1B);
     writer.Write((byte)0);
     if (properties.Count > 0)
     {
         writer.Write((byte)1);
         IWzImageProperty.WritePropertyList(writer, properties.ToArray());
     }
     else
     {
         writer.Write((byte)0);
     }
     writer.WriteCompressedInt(PngProperty.Width);
     writer.WriteCompressedInt(PngProperty.Height);
     writer.WriteCompressedInt(PngProperty.format);
     writer.Write((byte)PngProperty.format2);
     writer.Write(0);
     writer.Write(PngProperty.CompressedBytes.Length + 1);
     writer.Write((byte)0);
     writer.Write(PngProperty.CompressedBytes);
 }
Exemplo n.º 26
0
        public IWzObject[] GetObjectsFromProperty(IWzImageProperty prop)
        {
            List <IWzObject> list = new List <IWzObject>();

            switch (prop.PropertyType)
            {
            case WzPropertyType.Extended:
                list.AddRange(this.GetObjectsFromProperty(((WzExtendedProperty)prop).ExtendedProperty));
                break;

            case WzPropertyType.SubProperty:
                foreach (IWzImageProperty property3 in ((WzSubProperty)prop).WzProperties)
                {
                    list.AddRange(this.GetObjectsFromProperty(property3));
                }
                break;

            case WzPropertyType.Canvas:
                foreach (IWzImageProperty property in ((WzCanvasProperty)prop).WzProperties)
                {
                    list.AddRange(this.GetObjectsFromProperty(property));
                }
                list.Add(((WzCanvasProperty)prop).PngProperty);
                break;

            case WzPropertyType.Vector:
                list.Add(((WzVectorProperty)prop).X);
                list.Add(((WzVectorProperty)prop).Y);
                break;

            case WzPropertyType.Convex:
                foreach (WzExtendedProperty property2 in ((WzConvexProperty)prop).WzProperties)
                {
                    list.AddRange(this.GetObjectsFromProperty(property2));
                }
                break;
            }
            return(list.ToArray());
        }
Exemplo n.º 27
0
        private void objL1ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (objL1ListBox.SelectedItem == null)
            {
                return;
            }
            objImagesContainer.Controls.Clear();
            IWzImageProperty l1Prop = Program.InfoManager.ObjectSets[(string)objSetListBox.SelectedItem][(string)objL0ListBox.SelectedItem][(string)objL1ListBox.SelectedItem];

            foreach (WzSubProperty l2Prop in l1Prop.WzProperties)
            {
                if (l2Prop.HCTag == null)
                {
                    l2Prop.HCTag = ObjectInfo.Load(l2Prop, (string)objSetListBox.SelectedItem, (string)objL0ListBox.SelectedItem, (string)objL1ListBox.SelectedItem, l2Prop.Name);
                }
                ObjectInfo       info      = (ObjectInfo)l2Prop.HCTag;
                WzCanvasProperty objCanvas = (WzCanvasProperty)l2Prop["0"];
                KoolkLVItem      item      = objImagesContainer.createItem(objCanvas.PngProperty.GetPNG(false), l2Prop.Name, true);
                item.Tag        = l2Prop.HCTag;
                item.MouseDown += new MouseEventHandler(objItem_Click);
                item.MouseUp   += new MouseEventHandler(item_MouseUp);
            }
        }
Exemplo n.º 28
0
        private static void LoadBackgrounds(WzImage mapImage, Board mapBoard)
        {
            WzSubProperty bgParent = (WzSubProperty)mapImage["back"];
            WzSubProperty bgProp;
            int           i = 0;

            while ((bgProp = (WzSubProperty)bgParent[(i++).ToString()]) != null)
            {
                int            x     = InfoTool.GetInt(bgProp["x"]);
                int            y     = InfoTool.GetInt(bgProp["y"]);
                int            rx    = InfoTool.GetInt(bgProp["rx"]);
                int            ry    = InfoTool.GetInt(bgProp["ry"]);
                int            cx    = InfoTool.GetInt(bgProp["cx"]);
                int            cy    = InfoTool.GetInt(bgProp["cy"]);
                int            a     = InfoTool.GetInt(bgProp["a"]);
                BackgroundType type  = (BackgroundType)InfoTool.GetInt(bgProp["type"]);
                bool           front = InfoTool.GetBool(bgProp["front"]);
                bool           flip  = InfoTool.GetBool(bgProp["f"]);
                string         bS    = InfoTool.GetString(bgProp["bS"]);
                bool           ani   = InfoTool.GetBool(bgProp["ani"]);
                string         no    = InfoTool.GetInt(bgProp["no"]).ToString();
                WzImage        bsImg = Program.InfoManager.BackgroundSets[bS];
                if (bsImg == null)
                {
                    continue;
                }
                IWzImageProperty bgInfoProp = bsImg[ani ? "ani" : "back"][no];
                if (bgInfoProp.HCTag == null)
                {
                    bgInfoProp.HCTag = BackgroundInfo.Load(bgInfoProp, bS, ani, no);
                }
                BackgroundInfo bgInfo = (BackgroundInfo)bgInfoProp.HCTag;
                IList          list   = front ? mapBoard.BoardItems.FrontBackgrounds : mapBoard.BoardItems.BackBackgrounds;
                list.Add((BackgroundInstance)bgInfo.CreateInstance(mapBoard, x, y, i, rx, ry, cx, cy, type, a, front, flip, false));
            }
        }
Exemplo n.º 29
0
 public void AddProperty(IWzImageProperty prop)
 {
     if ((this.wzReader != null) && !this.parsed)
     {
         this.ParseImage();
     }
     prop.Parent      = this;
     prop.ParentImage = this;
     switch (prop.PropertyType)
     {
     case WzPropertyType.SubProperty:
     case WzPropertyType.Canvas:
     case WzPropertyType.Vector:
     case WzPropertyType.Convex:
     case WzPropertyType.Sound:
     case WzPropertyType.UOL:
         this.properties.Add(new WzExtendedProperty(prop.Name)
         {
             ExtendedProperty = prop
         });
         return;
     }
     this.properties.Add(prop);
 }
Exemplo n.º 30
0
 public void parseSubProperty(IWzImageProperty iwip, int propLoop)
 {
     if (!currentDir.EndsWith("\\") && !currentDir.EndsWith("."))
     {
         currentDir += (Program.isCharacterWZ ? "." : "\\");
     }
     if (!currentDirdunno.EndsWith("\\") && !currentDirdunno.EndsWith("."))
     {
         currentDirdunno += (Program.isCharacterWZ ? "." : "\\");
     }
     if (isCorrectProperty(iwip.Name) || isCorrectSubProperty(iwip.Name))
     {
         string tempDir  = currentDir;
         string tempDir2 = currentDirdunno;
         foreach (IWzImageProperty prop in iwip.WzProperties)
         {
             currentDir      += prop.Name + ".";
             currentDirdunno += prop.Name + ".";
             parseProperties(prop, propLoop + 1);
             currentDir      = tempDir;
             currentDirdunno = tempDir2;
         }
     }
 }
Exemplo n.º 31
0
 public void RemoveProperty(IWzImageProperty prop)
 {
     prop.Parent = null;
     properties.Remove(prop);
 }
Exemplo n.º 32
0
		/// <summary>
		/// Adds a WzExtendedProperty to the list of properties
		/// </summary>
		/// <param name="prop">The property to add</param>
        public void AddProperty(IWzImageProperty prop)
		{
            if (!(prop is IExtended))
                throw new Exception("Property is not IExtended");
            prop.Parent = this;
			properties.Add((IExtended)prop);
		}
Exemplo n.º 33
0
		public void AddProperties(IWzImageProperty[] props)
		{
			foreach (IWzImageProperty prop in props)
			{
				AddProperty(prop);
			}
		}
Exemplo n.º 34
0
		/// <summary>
		/// Adds a property to the property list of this property
		/// </summary>
		/// <param name="prop">The property to add</param>
		public void AddProperty(IWzImageProperty prop)
		{
			switch (prop.PropertyType)
			{
				case WzPropertyType.SubProperty:
				case WzPropertyType.Vector:
				case WzPropertyType.UOL:
				case WzPropertyType.Canvas:
				case WzPropertyType.Convex:
				case WzPropertyType.Sound:
					properties.Add(new WzExtendedProperty(prop.Name) { ExtendedProperty = prop });
					return;
				default:
					properties.Add(prop);
					return;
			}
		}
Exemplo n.º 35
0
 protected void WritePropertyToXML(TextWriter tw, string depth, IWzImageProperty prop)
 {
     if (prop is WzCanvasProperty)
     {
         WzCanvasProperty property3 = (WzCanvasProperty)prop;
         if (ExportBase64Data)
         {
             MemoryStream stream = new MemoryStream();
             property3.PngProperty.GetPNG(false).Save(stream, System.Drawing.Imaging.ImageFormat.Png);
             byte[] pngbytes = stream.ToArray();
             stream.Close();
             tw.Write(string.Concat(new object[] { depth, "<canvas name=\"", XmlUtil.SanitizeText(property3.Name), "\" width=\"", property3.PngProperty.Width, "\" height=\"", property3.PngProperty.Height, "\" basedata=\"", Convert.ToBase64String(pngbytes), "\">" }) + lineBreak);
         }
         else
             tw.Write(string.Concat(new object[] { depth, "<canvas name=\"", XmlUtil.SanitizeText(property3.Name), "\" width=\"", property3.PngProperty.Width, "\" height=\"", property3.PngProperty.Height, "\">" }) + lineBreak);
         string newDepth = depth + indent;
         foreach (IWzImageProperty property in property3.WzProperties)
             WritePropertyToXML(tw, newDepth, property);
         tw.Write(depth + "</canvas>" + lineBreak);
     }
     else if (prop is WzCompressedIntProperty)
     {
         WzCompressedIntProperty property4 = (WzCompressedIntProperty)prop;
         tw.Write(string.Concat(new object[] { depth, "<int name=\"", XmlUtil.SanitizeText(property4.Name), "\" value=\"", property4.Value, "\"/>" }) + lineBreak);
     }
     else if (prop is WzDoubleProperty)
     {
         WzDoubleProperty property5 = (WzDoubleProperty)prop;
         tw.Write(string.Concat(new object[] { depth, "<double name=\"", XmlUtil.SanitizeText(property5.Name), "\" value=\"", property5.Value, "\"/>" }) + lineBreak);
     }
     else if (prop is WzNullProperty)
     {
         WzNullProperty property6 = (WzNullProperty)prop;
         tw.Write(depth + "<null name=\"" + XmlUtil.SanitizeText(property6.Name) + "\"/>" + lineBreak);
     }
     else if (prop is WzSoundProperty)
     {
         WzSoundProperty property7 = (WzSoundProperty)prop;
         if (ExportBase64Data)
             tw.Write(string.Concat(new object[] { depth, "<sound name=\"", XmlUtil.SanitizeText(property7.Name), "\" length=\"", property7.Length.ToString(), "\" basehead=\"", Convert.ToBase64String(property7.Header), "\" basedata=\"", Convert.ToBase64String(property7.GetBytes(false)), "\"/>" }) + lineBreak);
         else
             tw.Write(depth + "<sound name=\"" + XmlUtil.SanitizeText(property7.Name) + "\"/>" + lineBreak);
     }
     else if (prop is WzStringProperty)
     {
         WzStringProperty property8 = (WzStringProperty)prop;
         string str = XmlUtil.SanitizeText(property8.Value);
         tw.Write(depth + "<string name=\"" + XmlUtil.SanitizeText(property8.Name) + "\" value=\"" + str + "\"/>" + lineBreak);
     }
     else if (prop is WzSubProperty)
     {
         WzSubProperty property9 = (WzSubProperty)prop;
         tw.Write(depth + "<imgdir name=\"" + XmlUtil.SanitizeText(property9.Name) + "\">" + lineBreak);
         string newDepth = depth + indent;
         foreach (IWzImageProperty property in property9.WzProperties)
             WritePropertyToXML(tw, newDepth, property);
         tw.Write(depth + "</imgdir>" + lineBreak);
     }
     else if (prop is WzUnsignedShortProperty)
     {
         WzUnsignedShortProperty property10 = (WzUnsignedShortProperty)prop;
         tw.Write(string.Concat(new object[] { depth, "<short name=\"", XmlUtil.SanitizeText(property10.Name), "\" value=\"", property10.Value, "\"/>" }) + lineBreak);
     }
     else if (prop is WzUOLProperty)
     {
         WzUOLProperty property11 = (WzUOLProperty)prop;
         tw.Write(depth + "<uol name=\"" + property11.Name + "\" value=\"" + XmlUtil.SanitizeText(property11.Value) + "\"/>" + lineBreak);
     }
     else if (prop is WzVectorProperty)
     {
         WzVectorProperty property12 = (WzVectorProperty)prop;
         tw.Write(string.Concat(new object[] { depth, "<vector name=\"", XmlUtil.SanitizeText(property12.Name), "\" x=\"", property12.X.Value, "\" y=\"", property12.Y.Value, "\"/>" }) + lineBreak);
     }
     else if (prop is WzByteFloatProperty)
     {
         WzByteFloatProperty property13 = (WzByteFloatProperty)prop;
         string str2 = Convert.ToString(property13.Value, formattingInfo);
         if (!str2.Contains("."))
             str2 = str2 + ".0";
         tw.Write(depth + "<float name=\"" + XmlUtil.SanitizeText(property13.Name) + "\" value=\"" + str2 + "\"/>" + lineBreak);
     }
     else if (prop is WzConvexProperty)
     {
         tw.Write(depth + "<extended name=\"" + XmlUtil.SanitizeText(prop.Name) + "\">" + lineBreak);
         WzConvexProperty property14 = (WzConvexProperty)prop;
         string newDepth = depth + indent;
         foreach (IWzImageProperty property in property14.WzProperties)
             WritePropertyToXML(tw, newDepth, property);
         tw.Write(depth + "</extended>" + lineBreak);
     }
 }
Exemplo n.º 36
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;
			}
		}
Exemplo n.º 37
0
		/// <summary>
		/// Adds a property to the property list of this property
		/// </summary>
		/// <param name="prop">The property to add</param>
		public void AddProperty(IWzImageProperty prop)
		{
            prop.Parent = this;
            properties.Add(prop);
		}