コード例 #1
0
		internal static void DumpPropertyList(StreamWriter writer, int level, IWzImageProperty[] properties)
		{
			foreach (IWzImageProperty prop in properties)
			{
				prop.ExportXml(writer, level + 1);
			}
		}
コード例 #2
0
        public List <IWzObject> GetObjectsFromProperty(IWzImageProperty prop)
        {
            List <IWzObject> objList = new List <IWzObject>();

            switch (prop.PropertyType)
            {
            case WzPropertyType.Canvas:
                foreach (IWzImageProperty canvasProp in ((WzCanvasProperty)prop).WzProperties)
                {
                    objList.AddRange(GetObjectsFromProperty(canvasProp));
                }
                objList.Add(((WzCanvasProperty)prop).PngProperty);
                break;

            case WzPropertyType.Convex:
                foreach (IWzImageProperty exProp in ((WzConvexProperty)prop).WzProperties)
                {
                    objList.AddRange(GetObjectsFromProperty(exProp));
                }
                break;

            case WzPropertyType.SubProperty:
                foreach (IWzImageProperty subProp in ((WzSubProperty)prop).WzProperties)
                {
                    objList.AddRange(GetObjectsFromProperty(subProp));
                }
                break;

            case WzPropertyType.Vector:
                objList.Add(((WzVectorProperty)prop).X);
                objList.Add(((WzVectorProperty)prop).Y);
                break;
            }
            return(objList);
        }
コード例 #3
0
ファイル: WzImage.cs プロジェクト: diamondo25/mapler.me
        /// <summary>
        /// Adds a property to the image
        /// </summary>
        /// <param name="prop">Property to add</param>
        public void AddProperty(IWzImageProperty prop)
        {
            if (reader != null)
            {
                if (!parsed)
                {
                    ParseImage();
                }
            }
            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;
            }
        }
コード例 #4
0
 /// <summary>
 /// Removes a property by name
 /// </summary>
 /// <param name="name">The name of the property to remove</param>
 public void RemoveProperty(IWzImageProperty prop)
 {
     if (reader != null && !parsed)
     {
         ParseImage();
     }
     prop.Parent = null;
     properties.Remove(prop);
 }
コード例 #5
0
 /// <summary>
 /// Adds a property to the image
 /// </summary>
 /// <param name="prop">Property to add</param>
 public void AddProperty(IWzImageProperty prop)
 {
     prop.Parent = this;
     if (reader != null && !parsed)
     {
         ParseImage();
     }
     properties.Add(prop);
 }
コード例 #6
0
ファイル: BaseExtractor.cs プロジェクト: diamondo25/mapler.me
 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);
     }
 }
コード例 #7
0
ファイル: BaseExtractor.cs プロジェクト: diamondo25/mapler.me
 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);
     }
 }
コード例 #8
0
		internal static void WritePropertyList(WzBinaryWriter writer, IWzImageProperty[] properties)
		{
			writer.Write((ushort)0);
			writer.WriteCompressedInt(properties.Length);
			for (int i = 0; i < properties.Length; i++)
			{
				writer.WriteStringValue(properties[i].Name, 0x00, 0x01);
				properties[i].WriteValue(writer);
			}
		}
コード例 #9
0
 public IWzImageProperty ToUOLLink(IWzImageProperty def)
 {
     if (this is WzUOLProperty)
     {
         return((IWzImageProperty)WzValue);
     }
     else
     {
         return(def);
     }
 }
コード例 #10
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);
         }
     }
 }
コード例 #11
0
 public void ExportXml(StreamWriter writer, bool oneFile, int level)
 {
     if (oneFile)
     {
         writer.WriteLine(XmlUtil.Indentation(level) + XmlUtil.OpenNamedTag("WzImage", this.name, true));
         IWzImageProperty.DumpPropertyList(writer, level, WzProperties);
         writer.WriteLine(XmlUtil.Indentation(level) + XmlUtil.CloseTag("WzImage"));
     }
     else
     {
         throw new Exception("Under Construction");
     }
 }
コード例 #12
0
ファイル: WzImage.cs プロジェクト: diamondo25/mapler.me
        /// <summary>
        /// Gets a WzImageProperty from a path
        /// </summary>
        /// <param name="path">path to object</param>
        /// <returns>the selected WzImageProperty</returns>
        public IWzImageProperty GetFromPath(string path)
        {
            if (reader != null)
            {
                if (!parsed)
                {
                    ParseImage();
                }
            }

            string[] segments = path.Split(new char[1] {
                '/'
            }, System.StringSplitOptions.RemoveEmptyEntries);
            if (segments[0] == "..")
            {
                return(null);
            }

            //hack method of adding the properties
            WzSubProperty childProperties = new WzSubProperty();

            childProperties.AddProperties(properties.ToArray());

            IWzImageProperty ret = childProperties;

            for (int x = 0; x < segments.Length; x++)
            {
                bool foundChild = false;
                foreach (IWzImageProperty iwp in ret.WzProperties)
                {
                    if (iwp.Name == segments[x])
                    {
                        if (iwp.PropertyType == WzPropertyType.Extended)
                        {
                            ret = ((WzExtendedProperty)iwp).ExtendedProperty;
                        }
                        else
                        {
                            ret = iwp;
                        }
                        foundChild = true;
                        break;
                    }
                }
                if (!foundChild)
                {
                    return(null);
                }
            }
            return(ret);
        }
コード例 #13
0
ファイル: BaseExtractor.cs プロジェクト: diamondo25/mapler.me
        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);
                    }

                }
            }
        }
コード例 #14
0
ファイル: WzImage.cs プロジェクト: diamondo25/mapler.me
        /// <summary>
        /// Parses the image from the wz filetod
        /// </summary>
        /// <param name="wzReader">The BinaryReader that is currently reading the wz file</param>
        public void ParseImage()
        {
            long originalPos = reader.BaseStream.Position;

            reader.BaseStream.Position = offset;
            byte   b    = reader.ReadByte();
            string tmp  = reader.ReadString();
            ushort tmp2 = reader.ReadUInt16();

            if (b != 0x73 || tmp != "Property" || tmp2 != 0)
            {
                return;
            }
            properties.AddRange(IWzImageProperty.ParsePropertyList(offset, reader, this, this));
            parsed = true;
        }
コード例 #15
0
ファイル: WzFile.cs プロジェクト: diamondo25/mapler.me
        internal string[] GetPathsFromProperty(IWzImageProperty prop, string curPath)
        {
            List <string> objList = new List <string>();

            switch (prop.PropertyType)
            {
            case WzPropertyType.Canvas:
                foreach (IWzImageProperty canvasProp in ((WzCanvasProperty)prop).WzProperties)
                {
                    objList.Add(curPath + "/" + canvasProp.Name);
                    objList.AddRange(GetPathsFromProperty(canvasProp, curPath + "/" + canvasProp.Name));
                }
                objList.Add(curPath + "/PNG");
                break;

            case WzPropertyType.Convex:
                foreach (WzExtendedProperty exProp in ((WzConvexProperty)prop).WzProperties)
                {
                    objList.Add(curPath + "/" + exProp.Name);
                    objList.AddRange(GetPathsFromProperty(exProp, curPath + "/" + exProp.Name));
                }
                break;

            case WzPropertyType.Extended:
                objList.AddRange(GetPathsFromProperty(((WzExtendedProperty)prop).ExtendedProperty, curPath));
                break;

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

            case WzPropertyType.Vector:
                objList.Add(curPath + "/X");
                objList.Add(curPath + "/Y");
                break;
            }
            return(objList.ToArray());
        }
コード例 #16
0
ファイル: WzSettings.cs プロジェクト: odasm/WzPatcher
        private void SetWzProperty(WzImage parentImage, string propName, WzPropertyType propType, object value)
        {
            IWzImageProperty property = parentImage[propName];

            if (property != null)
            {
                if (property.PropertyType == propType)
                {
                    property.SetValue(value);
                }
                else
                {
                    property.Remove();
                    CreateWzProp(parentImage, propType, propName, value);
                }
            }
            else
            {
                CreateWzProp(parentImage, propType, propName, value);
            }
        }
コード例 #17
0
        /// <summary>
        /// Parses the image from the wz filetod
        /// </summary>
        /// <param name="wzReader">The BinaryReader that is currently reading the wz file</param>
        public void ParseImage()
        {
            if (Parsed)
            {
                return;
            }
            else if (Changed)
            {
                Parsed = true; return;
            }
            this.parseEverything = false;
            long originalPos = reader.BaseStream.Position;

            reader.BaseStream.Position = offset;
            byte b = reader.ReadByte();

            if (b != 0x73 || reader.ReadString() != "Property" || reader.ReadUInt16() != 0)
            {
                return;
            }
            properties.AddRange(IWzImageProperty.ParsePropertyList(offset, reader, this, this));
            parsed = true;
        }
コード例 #18
0
ファイル: BaseExtractor.cs プロジェクト: diamondo25/mapler.me
        protected void ExportIfExists(string pDir, IWzImageProperty pCanvas, string pName = null, string pDataName = null)
        {
            if (pCanvas == null || pCanvas.WzValue == null)
                return;

            if (pName == null)
                pName = pCanvas.Name;
            else
                pName += "." + pCanvas.Name;

            if (pDataName == null)
                pDataName = pName;

            if (pCanvas is WzUOLProperty)
            {
                if (((WzUOLProperty)pCanvas).LinkValue == null) return; // nexan
                SaveInfo(pCanvas, pName.Substring(0, pName.LastIndexOf('.')));
                return;
                pCanvas = (IWzImageProperty)((WzUOLProperty)pCanvas).LinkValue;
            }

            for (int i = 0; i < pName.Length; i++)
                if (pName[i] > sbyte.MaxValue)
                {
                    Console.WriteLine("Found korean text: {0}", pName);
                    return;
                }
            
            if (pName.Count(c => { return c > sbyte.MaxValue; }) > 0)
            {
                Console.WriteLine("Found korean text: {0}", pName);
                return;
            }
            
            string tmp = pDir + pName + ".png";
            string tmptmp = RemoveFromBackDirSlash(tmp);
            if (pCanvas is WzCanvasProperty)
            {
                Directory.CreateDirectory(tmptmp);
                if (!File.Exists(tmp))
                {
                    // Save to temp folder (new things)
                    string newfile = tmp.Replace("P:\\Result\\", "P:\\Result\\extract_" + DateTime.Now.ToShortDateString() + "\\");
                    Directory.CreateDirectory(RemoveFromBackDirSlash(newfile));

                    pCanvas.ToPngProperty().PNG.Save(newfile, System.Drawing.Imaging.ImageFormat.Png);


                    pCanvas.ToPngProperty().PNG.Save(tmp, System.Drawing.Imaging.ImageFormat.Png);
                    //Console.WriteLine("New file: {0}", tmp);
                }
            }

            if (pCanvas["origin"] != null)
            {
                SaveVector(pCanvas["origin"] as WzVectorProperty, pDataName + ".origin");
            }

            if (pCanvas["z"] != null)
            {
                SaveInfo(pCanvas["z"], pDataName);
            }

            if (pCanvas["map"] != null)
            {
                foreach (var prop in pCanvas["map"].WzProperties.Where(p => { return p is WzVectorProperty; }))
                {
                    SaveVector(prop as WzVectorProperty, pDataName + ".map." + prop.Name);
                }
            }
        }
コード例 #19
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static string GetOptionalString(IWzImageProperty source)
 {
     return source == null ? null : ((WzStringProperty)source).Value;
 }
コード例 #20
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static int? GetOptionalTranslatedInt(IWzImageProperty source)
 {
     string str = InfoTool.GetOptionalString(source);
     if (str == null) return null;
     return int.Parse(str);
 }
コード例 #21
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static float GetFloat(IWzImageProperty source)
 {
     return ((WzByteFloatProperty)source).Value;
 }
コード例 #22
0
ファイル: WzImage.cs プロジェクト: diamondo25/mapler.me
		/// <summary>
		/// Adds a property to the image
		/// </summary>
		/// <param name="prop">Property to add</param>
		public void AddProperty(IWzImageProperty prop)
		{
			if (reader != null) if (!parsed) ParseImage();
			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;
			}
		}
コード例 #23
0
ファイル: MapleInfo.cs プロジェクト: hanistory/hasuite
 public static BackgroundInfo Load(IWzImageProperty parentObject)
 {
     string[] path = parentObject.FullPath.Split(@"\".ToCharArray());
     return Load(parentObject,WzInfoTools.RemoveExtension(path[path.Length - 3]), path[path.Length - 2] == "ani", path[path.Length - 1]);
 }
コード例 #24
0
        internal static List <IWzImageProperty> ParsePropertyList(uint offset, WzBinaryReader reader, IWzObject parent, WzImage parentImg)
        {
            int entryCount = reader.ReadCompressedInt();
            List <IWzImageProperty> properties = new List <IWzImageProperty>(entryCount);

            for (int i = 0; i < entryCount; i++)
            {
                string name = reader.ReadStringBlock(offset);
                switch (reader.ReadByte())
                {
                case 0:
                    properties.Add(new WzNullProperty(name)
                    {
                        Parent = parent                                                                  /*, ParentImage = parentImg*/
                    });
                    break;

                case 0x0B:
                case 2:
                    properties.Add(new WzUnsignedShortProperty(name, reader.ReadUInt16())
                    {
                        Parent = parent                                                                                                /*, ParentImage = parentImg*/
                    });
                    break;

                case 3:
                    properties.Add(new WzCompressedIntProperty(name, reader.ReadCompressedInt())
                    {
                        Parent = parent                                                                                                       /*, ParentImage = parentImg*/
                    });
                    break;

                case 4:
                    byte type = reader.ReadByte();
                    if (type == 0x80)
                    {
                        properties.Add(new WzByteFloatProperty(name, reader.ReadSingle())
                        {
                            Parent = parent                                                                                                /*, ParentImage = parentImg*/
                        });
                    }
                    else if (type == 0)
                    {
                        properties.Add(new WzByteFloatProperty(name, 0f)
                        {
                            Parent = parent                                                                               /*, ParentImage = parentImg*/
                        });
                    }
                    break;

                case 5:
                    properties.Add(new WzDoubleProperty(name, reader.ReadDouble())
                    {
                        Parent = parent                                                                                         /*, ParentImage = parentImg*/
                    });
                    break;

                case 8:
                    properties.Add(new WzStringProperty(name, reader.ReadStringBlock(offset))
                    {
                        Parent = parent
                    });
                    break;

                case 9:
                    int eob = (int)(reader.ReadUInt32() + reader.BaseStream.Position);
                    IWzImageProperty exProp = ParseExtendedProp(reader, offset, eob, name, parent, parentImg);
                    properties.Add(exProp);
                    if (reader.BaseStream.Position != eob)
                    {
                        reader.BaseStream.Position = eob;
                    }
                    break;

                default:
                    throw new Exception("Unknown property type at ParsePropertyList");
                }
            }
            return(properties);
        }
コード例 #25
0
ファイル: WzImage.cs プロジェクト: Bc1151/trapatcher
 /// <summary>
 /// Adds a property to the image
 /// </summary>
 /// <param name="prop">Property to add</param>
 public void AddProperty(IWzImageProperty prop)
 {
     prop.Parent = this;
     if (reader != null && !parsed) ParseImage();
     properties.Add(prop);
 }
コード例 #26
0
 static bool containsSubNode(IWzImageProperty prop, string name)
 {
     foreach (IWzImageProperty p in prop.WzProperties) {
         if (p.Name.Equals(name)) {
             return true;
         }
     }
     return false;
 }
コード例 #27
0
ファイル: MapSimulator.cs プロジェクト: hanistory/hasuite
 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");
 }
コード例 #28
0
ファイル: WzImage.cs プロジェクト: diamondo25/mapler.me
		public void AddProperties(IWzImageProperty[] props)
		{
			foreach (IWzImageProperty prop in props)
			{
				AddProperty(prop);
			}
		}
コード例 #29
0
ファイル: BaseExtractor.cs プロジェクト: diamondo25/mapler.me
 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);
 }
コード例 #30
0
ファイル: WzFile.cs プロジェクト: diamondo25/mapler.me
		public IWzObject[] GetObjectsFromProperty(IWzImageProperty prop)
		{
			List<IWzObject> objList = new List<IWzObject>();
			switch (prop.PropertyType)
			{
				case WzPropertyType.Canvas:
					foreach (IWzImageProperty canvasProp in ((WzCanvasProperty)prop).WzProperties)
						objList.AddRange(GetObjectsFromProperty(canvasProp));
					objList.Add(((WzCanvasProperty)prop).PngProperty);
					break;
				case WzPropertyType.Convex:
					foreach (WzExtendedProperty exProp in ((WzConvexProperty)prop).WzProperties)
						objList.AddRange(GetObjectsFromProperty(exProp));
					break;
				case WzPropertyType.Extended:
					objList.AddRange(GetObjectsFromProperty(((WzExtendedProperty)prop).ExtendedProperty));
					break;
				case WzPropertyType.SubProperty:
					foreach (IWzImageProperty subProp in ((WzSubProperty)prop).WzProperties)
						objList.AddRange(GetObjectsFromProperty(subProp));
					break;
				case WzPropertyType.Vector:
					objList.Add(((WzVectorProperty)prop).X);
					objList.Add(((WzVectorProperty)prop).Y);
					break;
			}
			return objList.ToArray();
		}
コード例 #31
0
ファイル: WzSettings.cs プロジェクト: odasm/WzPatcher
        private void ExtractSettingsImage(WzImage settingsImage, Type settingsHolderType)
        {
            if (!settingsImage.Parsed)
            {
                settingsImage.ParseImage();
            }
            foreach (FieldInfo fieldInfo in settingsHolderType.GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                string           settingName = fieldInfo.Name;
                IWzImageProperty settingProp = settingsImage[settingName];
                byte[]           argb;
                if (settingProp == null)
                {
                    SaveField(settingsImage, fieldInfo);
                }
                else if (fieldInfo.FieldType.BaseType != null && fieldInfo.FieldType.BaseType.FullName == "System.Enum")
                {
                    fieldInfo.SetValue(null, InfoTool.GetInt(settingProp));
                }
                else
                {
                    switch (fieldInfo.FieldType.FullName)
                    {
                    //case "Microsoft.Xna.Framework.Graphics.Color":
                    case "Microsoft.Xna.Framework.Color":
                        if (xnaColorType == null)
                        {
                            throw new InvalidDataException("XNA color detected, but XNA type activator is null");
                        }
                        argb = BitConverter.GetBytes((uint)((WzDoubleProperty)settingProp).Value);
                        fieldInfo.SetValue(null, Activator.CreateInstance(xnaColorType, argb[0], argb[1], argb[2], argb[3]));
                        break;

                    case "System.Drawing.Color":
                        argb = BitConverter.GetBytes((uint)((WzDoubleProperty)settingProp).Value);
                        fieldInfo.SetValue(null, System.Drawing.Color.FromArgb(argb[3], argb[2], argb[1], argb[0]));
                        break;

                    case "System.Int32":
                        fieldInfo.SetValue(null, InfoTool.GetInt(settingProp));
                        break;

                    case "System.Double":
                        fieldInfo.SetValue(null, ((WzDoubleProperty)settingProp).Value);
                        break;

                    case "System.Boolean":
                        fieldInfo.SetValue(null, InfoTool.GetBool(settingProp));
                        //bool a = (bool)fieldInfo.GetValue(null);
                        break;

                    case "System.Single":
                        fieldInfo.SetValue(null, ((WzByteFloatProperty)settingProp).Value);
                        break;

                    /*case "WzMapleVersion":
                     *  fieldInfo.SetValue(null, (WzMapleVersion)InfoTool.GetInt(settingProp));
                     *  break;
                     * case "ItemTypes":
                     *  fieldInfo.SetValue(null, (ItemTypes)InfoTool.GetInt(settingProp));
                     *  break;*/
                    case "System.Drawing.Size":
                        fieldInfo.SetValue(null, new System.Drawing.Size(((WzVectorProperty)settingProp).X.Value, ((WzVectorProperty)settingProp).Y.Value));
                        break;

                    case "System.String":
                        fieldInfo.SetValue(null, InfoTool.GetString(settingProp));
                        break;

                    case "System.Drawing.Bitmap":
                        fieldInfo.SetValue(null, ((WzCanvasProperty)settingProp).PngProperty.GetPNG(false));
                        break;

                    default:
                        throw new Exception("unrecognized setting type");
                    }
                }
            }
        }
コード例 #32
0
        public void ExtractItems(IWzImageProperty[] pSubProperties, string pTypeName)
        {
            foreach (var key in pSubProperties.Where(val => { return val is WzSubProperty && (val as WzSubProperty).WzProperties.Length != 0 && val["name"] != null; }))
            {
                int id = Convert.ToInt32(key.Name);
                string name = key["name"].ToStringValue();
                SQLStrings.Instance.AppendRow(pTypeName, id, "name", name);

                var desc = key["desc"];
                if (desc != null)
                    SQLStrings.Instance.AppendRow(pTypeName, id, "desc", desc.ToStringValue());
            }
        }
コード例 #33
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static int? GetOptionalInt(IWzImageProperty source)
 {
     return source == null ? (int?)null : ((WzCompressedIntProperty)source).Value;
 }
コード例 #34
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static MapleBool GetOptionalBool(IWzImageProperty source)
 {
     if (source == null) return MapleBool.NotExist;
     else return ((WzCompressedIntProperty)source).Value == 1;
 }
コード例 #35
0
ファイル: WzFile.cs プロジェクト: diamondo25/mapler.me
		internal string[] GetPathsFromProperty(IWzImageProperty prop, string curPath)
		{
			List<string> objList = new List<string>();
			switch (prop.PropertyType)
			{
				case WzPropertyType.Canvas:
					foreach (IWzImageProperty canvasProp in ((WzCanvasProperty)prop).WzProperties)
					{
						objList.Add(curPath + "/" + canvasProp.Name);
						objList.AddRange(GetPathsFromProperty(canvasProp, curPath + "/" + canvasProp.Name));
					}
					objList.Add(curPath + "/PNG");
					break;
				case WzPropertyType.Convex:
					foreach (WzExtendedProperty exProp in ((WzConvexProperty)prop).WzProperties)
					{
						objList.Add(curPath + "/" + exProp.Name);
						objList.AddRange(GetPathsFromProperty(exProp, curPath + "/" + exProp.Name));
					}
					break;
				case WzPropertyType.Extended:
					objList.AddRange(GetPathsFromProperty(((WzExtendedProperty)prop).ExtendedProperty, curPath));
					break;
				case WzPropertyType.SubProperty:
					foreach (IWzImageProperty subProp in ((WzSubProperty)prop).WzProperties)
					{
						objList.Add(curPath + "/" + subProp.Name);
						objList.AddRange(GetPathsFromProperty(subProp, curPath + "/" + subProp.Name));
					}
					break;
				case WzPropertyType.Vector:
					objList.Add(curPath + "/X");
					objList.Add(curPath + "/Y");
					break;
			}
			return objList.ToArray();
		}
コード例 #36
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static bool GetBool(IWzImageProperty source)
 {
     return ((WzCompressedIntProperty)source).Value == 1;
 }
コード例 #37
0
 static IWzImageProperty getSubNode(IWzImageProperty prop, string name)
 {
     foreach (IWzImageProperty p in prop.WzProperties) {
         if (p.Name.Equals(name)) {
             return p;
         }
     }
     return null;
 }
コード例 #38
0
		public IWzImageProperty ToUOLLink(IWzImageProperty def)
		{
			if (this is WzUOLProperty) return (IWzImageProperty)WzValue;
			else return def;
		}
コード例 #39
0
        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);
            }
        }
コード例 #40
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static string GetString(IWzImageProperty source)
 {
     return ((WzStringProperty)source).Value;
 }
コード例 #41
0
ファイル: WzImage.cs プロジェクト: Bc1151/trapatcher
 /// <summary>
 /// Removes a property by name
 /// </summary>
 /// <param name="name">The name of the property to remove</param>
 public void RemoveProperty(IWzImageProperty prop)
 {
     if (reader != null && !parsed) ParseImage();
     prop.Parent = null;
     properties.Remove(prop);
 }
コード例 #42
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static double GetDouble(IWzImageProperty source)
 {
     return ((WzDoubleProperty)source).Value;
 }
コード例 #43
0
ファイル: MapleInfo.cs プロジェクト: hanistory/hasuite
 public static BackgroundInfo Load(IWzImageProperty parentObject, string bS, bool ani, string no)
 {
     WzCanvasProperty frame0 = ani ?(WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]) : (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject);
     return new BackgroundInfo(frame0.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)frame0["origin"]), bS, ani, no, parentObject);
 }
コード例 #44
0
ファイル: InfoTool.cs プロジェクト: hanistory/maplelib2
 public static int GetInt(IWzImageProperty source)
 {
     return ((WzCompressedIntProperty)source).Value;
 }