Esempio n. 1
0
 public void DoCopy()
 {
     if (!Warning.Warn("Copy WZ nodes to clipboard? (warning - can take a lot of time if many nodes are selected)"))
     {
         return;
     }
     clipboard.Clear();
     foreach (WzNode node in DataTree.SelectedNodes)
     {
         IWzObject clone = null;
         if (node.Tag is WzDirectory)
         {
             Warning.Error("You can't copy directories because they require too much memory");
             continue;
         }
         else if (node.Tag is WzImage)
         {
             clone = ((WzImage)node.Tag).DeepClone();
         }
         else if (node.Tag is IWzImageProperty)
         {
             clone = ((IWzImageProperty)node.Tag).DeepClone();
         }
         else
         {
             continue;
         }
         clipboard.Add(clone);
     }
 }
Esempio n. 2
0
 public static IWzObject GetObjectByRelativePath(IWzObject currentObject, string path)
 {
     foreach (string directive in path.Split("/".ToCharArray()))
     {
         if (directive == "..")
         {
             currentObject = currentObject.Parent;
         }
         else if (currentObject is IWzImageProperty)
         {
             currentObject = ((IWzImageProperty)currentObject)[directive];
         }
         else if (currentObject is WzImage)
         {
             currentObject = ((WzImage)currentObject)[directive];
         }
         else if (currentObject is WzDirectory)
         {
             currentObject = ((WzDirectory)currentObject)[directive];
         }
         else
         {
             throw new Exception("invalid type");
         }
     }
     return(currentObject);
 }
Esempio n. 3
0
        private void addObjInternal(IWzObject obj)
        {
            IWzObject TaggedObject = (IWzObject)Tag;

            if (TaggedObject is WzFile)
            {
                TaggedObject = ((WzFile)TaggedObject).WzDirectory;
            }
            if (TaggedObject is WzDirectory)
            {
                if (obj is WzDirectory)
                {
                    ((WzDirectory)TaggedObject).AddDirectory((WzDirectory)obj);
                }
                else if (obj is WzImage)
                {
                    ((WzDirectory)TaggedObject).AddImage((WzImage)obj);
                }
                else
                {
                    return;
                }
            }
            else if (TaggedObject is WzImage)
            {
                if (!((WzImage)TaggedObject).Parsed)
                {
                    ((WzImage)TaggedObject).ParseImage();
                }
                if (obj is IWzImageProperty)
                {
                    ((WzImage)TaggedObject).AddProperty((IWzImageProperty)obj);
                }
                else
                {
                    return;
                }
            }
            else if (TaggedObject is IPropertyContainer)
            {
                if (obj is IWzImageProperty)
                {
                    ((IPropertyContainer)TaggedObject).AddProperty((IWzImageProperty)obj);
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
Esempio n. 4
0
        private int CalculateTotal(IWzObject currObj)
        {
            int result = 0;

            if (currObj is WzFile)
            {
                result += ((WzFile)currObj).WzDirectory.CountImages();
            }
            else if (currObj is WzDirectory)
            {
                result += ((WzDirectory)currObj).CountImages();
            }
            return(result);
        }
Esempio n. 5
0
        public void SerializeObject(IWzObject obj, string outPath)
        {
            //imagesToUnparse.Clear();
            total        = 0; curr = 0;
            this.outPath = outPath;
            if (!Directory.Exists(outPath))
            {
                WzXmlSerializer.createDirSafe(ref outPath);
            }
            if (outPath.Substring(outPath.Length - 1, 1) != @"\")
            {
                outPath += @"\";
            }
            total = CalculateTotal(obj);
            ExportRecursion(obj, outPath);

            /*foreach (WzImage img in imagesToUnparse)
             *  img.UnparseImage();
             * imagesToUnparse.Clear();*/
        }
Esempio n. 6
0
 private void ParseChilds(IWzObject SourceObject)
 {
     if (SourceObject == null)
     {
         throw new NullReferenceException("Cannot create a null WzNode");
     }
     Tag = SourceObject;
     SourceObject.HRTag = this;
     if (SourceObject is WzFile)
     {
         SourceObject = ((WzFile)SourceObject).WzDirectory;
     }
     if (SourceObject is WzDirectory)
     {
         foreach (WzDirectory dir in ((WzDirectory)SourceObject).WzDirectories)
         {
             Nodes.Add(new WzNode(dir));
         }
         foreach (WzImage img in ((WzDirectory)SourceObject).WzImages)
         {
             Nodes.Add(new WzNode(img));
         }
     }
     else if (SourceObject is WzImage)
     {
         if (((WzImage)SourceObject).Parsed)
         {
             foreach (IWzImageProperty prop in ((WzImage)SourceObject).WzProperties)
             {
                 Nodes.Add(new WzNode(prop));
             }
         }
     }
     else if (SourceObject is IPropertyContainer)
     {
         foreach (IWzImageProperty prop in ((IPropertyContainer)SourceObject).WzProperties)
         {
             Nodes.Add(new WzNode(prop));
         }
     }
 }
Esempio n. 7
0
        public static bool CanNodeBeInserted(WzNode parentNode, string name)
        {
            IWzObject obj = (IWzObject)parentNode.Tag;

            if (obj is IPropertyContainer)
            {
                return(((IPropertyContainer)obj)[name] == null);
            }
            else if (obj is WzDirectory)
            {
                return(((WzDirectory)obj)[name] == null);
            }
            else if (obj is WzFile)
            {
                return(((WzFile)obj).WzDirectory[name] == null);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 8
0
        public ContextMenuStrip CreateMenu(IWzObject Tag)
        {
            ContextMenuStrip menu = null;

            if (Tag is WzImage || Tag is IPropertyContainer)
            {
                if (Tag is WzSubProperty)
                {
                    menu = new ContextMenuStrip();
                    menu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/ Remove });
                }
                else
                {
                    menu = new ContextMenuStrip();
                    menu.Items.AddRange(new ToolStripItem[] { AddPropsSubMenu, /*export, import,*/ Remove });
                }
            }
            else if (Tag is IWzImageProperty)
            {
                menu = new ContextMenuStrip();
                menu.Items.AddRange(new ToolStripItem[] { /*export, import,*/ Remove });
            }
            else if (Tag is WzDirectory)
            {
                menu = new ContextMenuStrip();
                menu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, /*export, import,*/ Remove });
            }
            else if (Tag is WzFile)
            {
                menu = new ContextMenuStrip();
                menu.Items.AddRange(new ToolStripItem[] { AddDirsSubMenu, SaveFile, Unload, Reload });
            }
            else if (Tag is WzListFile)
            {
                menu = new ContextMenuStrip();
                menu.Items.AddRange(new ToolStripItem[] { AddListSubMenu, SaveFile, Unload, Reload });
            }
            return(menu);
        }
Esempio n. 9
0
        public void DoPaste()
        {
            if (!Warning.Warn("Paste WZ nodes from clipboard? (warning - can take a lot of time if many nodes are pasted)"))
            {
                return;
            }
            yesToAll = false;
            noToAll  = false;
            WzNode    parent    = (WzNode)DataTree.SelectedNode;
            IWzObject parentObj = (IWzObject)parent.Tag;

            if (parentObj is WzFile)
            {
                parentObj = ((WzFile)parentObj).WzDirectory;
            }

            foreach (IWzObject obj in clipboard)
            {
                if (((obj is WzDirectory || obj is WzImage) && parentObj is WzDirectory) || (obj is IWzImageProperty && parentObj is IPropertyContainer))
                {
                    WzNode node  = new WzNode(obj);
                    WzNode child = WzNode.GetChildNode(parent, node.Text);
                    if (child != null)
                    {
                        if (ShowReplaceDialog(node.Text))
                        {
                            child.Delete();
                        }
                        else
                        {
                            return;
                        }
                    }
                    parent.AddNode(node);
                }
            }
        }
Esempio n. 10
0
 public bool AddObject(IWzObject obj, UndoRedoManager undoRedoMan)
 {
     if (CanNodeBeInserted(this, obj.Name))
     {
         TryParseImage();
         addObjInternal(obj);
         WzNode node = new WzNode(obj);
         Nodes.Add(node);
         if (node.Tag is IWzImageProperty)
         {
             ((IWzImageProperty)node.Tag).ParentImage.Changed = true;
         }
         undoRedoMan.AddUndoBatch(new System.Collections.Generic.List <UndoRedoAction> {
             UndoRedoManager.ObjectAdded(this, node)
         });
         node.EnsureVisible();
         return(true);
     }
     else
     {
         MessageBox.Show("Cannot insert object \"" + obj.Name + "\" because an object with the same name already exists. Skipping.", "Skipping Object", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
 }
Esempio n. 11
0
 public WzNode(IWzObject SourceObject)
     : base(SourceObject.Name)
 {
     ParseChilds(SourceObject);
 }
Esempio n. 12
0
 public ReactorInfo(Bitmap image, System.Drawing.Point origin, string id, IWzObject parentObject)
     : base(image, origin, parentObject)
 {
     this.id = id;
 }
Esempio n. 13
0
 public PortalInfo(PortalType type, Bitmap image, System.Drawing.Point origin, IWzObject parentObject)
     : base(image, origin, parentObject)
 {
     this.type = type;
 }
Esempio n. 14
0
 public NpcInfo(Bitmap image, System.Drawing.Point origin, string id, string name, IWzObject parentObject)
     : base(image, origin, parentObject)
 {
     this.id   = id;
     this.name = name;
 }
Esempio n. 15
0
 public MapleDrawableInfo(Bitmap image, System.Drawing.Point origin, IWzObject parentObject)
 {
     this.image        = image;
     this.origin       = origin;
     this.parentObject = parentObject;
 }
Esempio n. 16
0
 public TileInfo(Bitmap image, System.Drawing.Point origin, string tS, string u, string no, IWzObject parentObject)
     : base(image, origin, parentObject)
 {
     this._tS = tS;
     this._u  = u;
     this._no = no;
 }
Esempio n. 17
0
 public ObjectInfo(Bitmap image, System.Drawing.Point origin, string oS, string l0, string l1, string l2, IWzObject parentObject)
     : base(image, origin, parentObject)
 {
     this._oS = oS;
     this._l0 = l0;
     this._l1 = l1;
     this._l2 = l2;
 }
Esempio n. 18
0
 public MapleExtractableInfo(Bitmap image, System.Drawing.Point origin, IWzObject parentObject)
     : base(image, origin, parentObject)
 {
 }
 private int CalculateTotal(IWzObject currObj)
 {
     int result = 0;
     if (currObj is WzFile)
         result += ((WzFile)currObj).WzDirectory.CountImages();
     else if (currObj is WzDirectory)
         result += ((WzDirectory)currObj).CountImages();
     return result;
 }
Esempio n. 20
0
        public IWzObject GetObjectFromPath(string path)
        {
            string[] strArray = path.Split("/".ToCharArray());
            if (strArray[0] != this.name)
            {
                return(null);
            }
            if (strArray.Length == 1)
            {
                return(this.WzDirectory);
            }
            IWzObject wzDirectory = this.WzDirectory;

            for (int i = 1; i < strArray.Length; i++)
            {
                switch (wzDirectory.ObjectType)
                {
                case WzObjectType.Image:
                {
                    wzDirectory = ((WzImage)wzDirectory)[strArray[i]];
                    continue;
                }

                case WzObjectType.Directory:
                {
                    wzDirectory = ((WzLib.WzDirectory)wzDirectory)[strArray[i]];
                    continue;
                }

                case WzObjectType.Property:
                    switch (((IWzImageProperty)wzDirectory).PropertyType)
                    {
                    case WzPropertyType.Extended:
                        goto Label_00D4;

                    case WzPropertyType.SubProperty:
                        goto Label_00E6;

                    case WzPropertyType.Vector:
                        goto Label_00F7;

                    case WzPropertyType.Convex:
                        goto Label_00C3;
                    }
                    return(null);

                default:
                {
                    continue;
                }
                }
                wzDirectory = ((WzCanvasProperty)wzDirectory)[strArray[i]];
                continue;
Label_00C3:
                wzDirectory = ((WzConvexProperty)wzDirectory)[strArray[i]];
                continue;
Label_00D4:
                wzDirectory = ((WzExtendedProperty)wzDirectory).ExtendedProperty;
                i--;
                continue;
Label_00E6:
                wzDirectory = ((WzSubProperty)wzDirectory)[strArray[i]];
                continue;
Label_00F7:
                if (strArray[i] == "X")
                {
                    return(((WzVectorProperty)wzDirectory).X);
                }
                if (strArray[i] == "Y")
                {
                    return(((WzVectorProperty)wzDirectory).Y);
                }
                return(null);
            }
            if ((wzDirectory.ObjectType == WzObjectType.Property) && (((IWzImageProperty)wzDirectory).PropertyType == WzPropertyType.Extended))
            {
                wzDirectory = ((WzExtendedProperty)wzDirectory).ExtendedProperty;
            }
            return(wzDirectory);
        }
Esempio n. 21
0
 private void ShowObjectValue(IWzObject obj)
 {
     mp3Player.SoundProperty = null;
     nameBox.Text            = obj is WzFile ? ((WzFile)obj).Header.Copyright : obj.Name;
     nameBox.ButtonEnabled   = false;
     if (obj is WzFile || obj is WzDirectory || obj is WzImage || obj is WzNullProperty || obj is WzSubProperty || obj is WzConvexProperty)
     {
         nameBox.Visible            = true;
         canvasPropBox.Visible      = false;
         pictureBoxPanel.Visible    = false;
         textPropBox.Visible        = false;
         mp3Player.Visible          = false;
         vectorPanel.Visible        = false;
         applyChangesButton.Visible = false;
         changeImageButton.Visible  = false;
         saveImageButton.Visible    = false;
         changeSoundButton.Visible  = false;
         saveSoundButton.Visible    = false;
     }
     else if (obj is WzCanvasProperty)
     {
         nameBox.Visible            = true;
         canvasPropBox.Visible      = true;
         pictureBoxPanel.Visible    = true;
         textPropBox.Visible        = false;
         mp3Player.Visible          = false;
         canvasPropBox.Image        = (Bitmap)obj;
         vectorPanel.Visible        = false;
         applyChangesButton.Visible = false;
         changeImageButton.Visible  = true;
         saveImageButton.Visible    = true;
         changeSoundButton.Visible  = false;
         saveSoundButton.Visible    = false;
     }
     else if (obj is WzSoundProperty)
     {
         nameBox.Visible            = true;
         canvasPropBox.Visible      = false;
         pictureBoxPanel.Visible    = false;
         textPropBox.Visible        = false;
         mp3Player.Visible          = true;
         mp3Player.SoundProperty    = (WzSoundProperty)obj;
         vectorPanel.Visible        = false;
         applyChangesButton.Visible = false;
         changeImageButton.Visible  = false;
         saveImageButton.Visible    = false;
         changeSoundButton.Visible  = true;
         saveSoundButton.Visible    = true;
     }
     else if (obj is WzStringProperty || obj is WzCompressedIntProperty || obj is WzDoubleProperty || obj is WzByteFloatProperty || obj is WzUnsignedShortProperty || obj is WzUOLProperty)
     {
         nameBox.Visible            = true;
         canvasPropBox.Visible      = false;
         pictureBoxPanel.Visible    = false;
         textPropBox.Visible        = true;
         mp3Player.Visible          = false;
         textPropBox.Text           = (string)obj;
         vectorPanel.Visible        = false;
         applyChangesButton.Visible = true;
         changeImageButton.Visible  = false;
         saveImageButton.Visible    = false;
         changeSoundButton.Visible  = false;
         saveSoundButton.Visible    = false;
     }
     else if (obj is WzVectorProperty)
     {
         nameBox.Visible            = true;
         canvasPropBox.Visible      = false;
         pictureBoxPanel.Visible    = false;
         textPropBox.Visible        = false;
         mp3Player.Visible          = false;
         vectorPanel.Visible        = true;
         vectorPanel.X              = ((WzVectorProperty)obj).X.Value;
         vectorPanel.Y              = ((WzVectorProperty)obj).Y.Value;
         applyChangesButton.Visible = true;
         changeImageButton.Visible  = false;
         saveImageButton.Visible    = false;
         changeSoundButton.Visible  = false;
         saveSoundButton.Visible    = false;
     }
     else
     {
     }
 }
Esempio n. 22
0
 private void ExportRecursion(IWzObject currObj, string outPath)
 {
     if (currObj is WzFile)
     {
         ExportRecursion(((WzFile)currObj).WzDirectory, outPath);
     }
     else if (currObj is WzDirectory)
     {
         outPath += currObj.Name + @"\";
         if (!Directory.Exists(outPath))
         {
             Directory.CreateDirectory(outPath);
         }
         foreach (WzDirectory subdir in ((WzDirectory)currObj).WzDirectories)
         {
             ExportRecursion(subdir, outPath + subdir.Name + @"\");
         }
         foreach (WzImage subimg in ((WzDirectory)currObj).WzImages)
         {
             ExportRecursion(subimg, outPath + subimg.Name + @"\");
         }
     }
     else if (currObj is WzCanvasProperty)
     {
         Bitmap bmp  = ((WzCanvasProperty)currObj).PngProperty.GetPNG(false);
         string path = outPath + currObj.Name + ".png";
         bmp.Save(path, ImageFormat.Png);
         //curr++;
     }
     else if (currObj is WzSoundProperty)
     {
         string path = outPath + currObj.Name + ".mp3";
         ((WzSoundProperty)currObj).SaveToFile(path);
     }
     else if (currObj is WzImage)
     {
         outPath += currObj.Name + @"\";
         if (!Directory.Exists(outPath))
         {
             Directory.CreateDirectory(outPath);
         }
         bool parse = ((WzImage)currObj).Parsed;
         if (!parse)
         {
             ((WzImage)currObj).ParseImage();
         }
         foreach (IWzImageProperty subprop in ((IPropertyContainer)currObj).WzProperties)
         {
             ExportRecursion(subprop, outPath);
         }
         if (!parse)
         {
             ((WzImage)currObj).UnparseImage();
         }
         curr++;
     }
     else if (currObj is IPropertyContainer)
     {
         outPath += currObj.Name + ".";
         foreach (IWzImageProperty subprop in ((IPropertyContainer)currObj).WzProperties)
         {
             ExportRecursion(subprop, outPath);
         }
     }
     else if (currObj is WzUOLProperty)
     {
         ExportRecursion(((WzUOLProperty)currObj).LinkValue, outPath);
     }
 }
 public void SerializeObject(IWzObject obj, string outPath)
 {
     //imagesToUnparse.Clear();
     total = 0; curr = 0;
     this.outPath = outPath;
     if (!Directory.Exists(outPath)) WzXmlSerializer.createDirSafe(ref outPath);
     if (outPath.Substring(outPath.Length - 1,1) != @"\") outPath += @"\";
     total = CalculateTotal(obj);
     ExportRecursion(obj, outPath);
     /*foreach (WzImage img in imagesToUnparse)
         img.UnparseImage();
     imagesToUnparse.Clear();*/
 }
Esempio n. 24
0
 public BackgroundInfo(Bitmap image, System.Drawing.Point origin, string bS, bool ani, string no, IWzObject parentObject)
     : base(image, origin, parentObject)
 {
     _bS  = bS;
     _ani = ani;
     _no  = no;
 }
 private void ExportRecursion(IWzObject currObj, string outPath)
 {
     if (currObj is WzFile)
         ExportRecursion(((WzFile)currObj).WzDirectory, outPath);
     else if (currObj is WzDirectory)
     {
         outPath += currObj.Name + @"\";
         if (!Directory.Exists(outPath)) Directory.CreateDirectory(outPath);
         foreach (WzDirectory subdir in ((WzDirectory)currObj).WzDirectories)
             ExportRecursion(subdir, outPath + subdir.Name + @"\");
         foreach (WzImage subimg in ((WzDirectory)currObj).WzImages)
             ExportRecursion(subimg, outPath + subimg.Name + @"\");
     }
     else if (currObj is WzCanvasProperty)
     {
         Bitmap bmp = ((WzCanvasProperty)currObj).PngProperty.GetPNG(false);
         string path = outPath + currObj.Name + ".png";
         bmp.Save(path, ImageFormat.Png);
         //curr++;
     }
     else if (currObj is WzSoundProperty)
     {
         string path = outPath + currObj.Name + ".mp3";
         ((WzSoundProperty)currObj).SaveToFile(path);
     }
     else if (currObj is WzImage)
     {
         outPath += currObj.Name + @"\";
         if (!Directory.Exists(outPath)) Directory.CreateDirectory(outPath);
         bool parse = ((WzImage)currObj).Parsed;
         if (!parse) ((WzImage)currObj).ParseImage();
         foreach (IWzImageProperty subprop in ((IPropertyContainer)currObj).WzProperties)
             ExportRecursion(subprop, outPath);
         if (!parse) ((WzImage)currObj).UnparseImage();
         curr++;
     }
     else if (currObj is IPropertyContainer)
     {
         outPath += currObj.Name + ".";
         foreach (IWzImageProperty subprop in ((IPropertyContainer)currObj).WzProperties)
             ExportRecursion(subprop, outPath);
     }
     else if (currObj is WzUOLProperty)
         ExportRecursion(((WzUOLProperty)currObj).LinkValue, outPath);
 }
Esempio n. 26
0
        private void applyChangesButton_Click(object sender, EventArgs e)
        {
            if (DataTree.SelectedNode == null)
            {
                return;
            }
            IWzObject obj = (IWzObject)DataTree.SelectedNode.Tag;

            if (obj is IWzImageProperty)
            {
                ((IWzImageProperty)obj).ParentImage.Changed = true;
            }
            if (obj is WzVectorProperty)
            {
                ((WzVectorProperty)obj).X.Value = vectorPanel.X;
                ((WzVectorProperty)obj).Y.Value = vectorPanel.Y;
            }
            else if (obj is WzStringProperty)
            {
                ((WzStringProperty)obj).Value = textPropBox.Text;
            }
            else if (obj is WzByteFloatProperty)
            {
                float val;
                if (!float.TryParse(textPropBox.Text, out val))
                {
                    Warning.Error("Could not convert \"" + textPropBox.Text + "\" to the required type");
                    return;
                }
                ((WzByteFloatProperty)obj).Value = val;
            }
            else if (obj is WzCompressedIntProperty)
            {
                int val;
                if (!int.TryParse(textPropBox.Text, out val))
                {
                    Warning.Error("Could not convert \"" + textPropBox.Text + "\" to the required type");
                    return;
                }
                ((WzCompressedIntProperty)obj).Value = val;
            }
            else if (obj is WzDoubleProperty)
            {
                double val;
                if (!double.TryParse(textPropBox.Text, out val))
                {
                    Warning.Error("Could not convert \"" + textPropBox.Text + "\" to the required type");
                    return;
                }
                ((WzDoubleProperty)obj).Value = val;
            }
            else if (obj is WzUnsignedShortProperty)
            {
                ushort val;
                if (!ushort.TryParse(textPropBox.Text, out val))
                {
                    Warning.Error("Could not convert \"" + textPropBox.Text + "\" to the required type");
                    return;
                }
                ((WzUnsignedShortProperty)obj).Value = val;
            }
            else if (obj is WzUOLProperty)
            {
                ((WzUOLProperty)obj).Value = textPropBox.Text;
            }
        }