public TileSetBrowser(ListBox target)
        {
            InitializeComponent();
            targetListBox = target;
            List <string> sortedTileSets = new List <string>();

            foreach (KeyValuePair <string, WzImage> tS in Program.InfoManager.TileSets)
            {
                sortedTileSets.Add(tS.Key);
            }
            sortedTileSets.Sort();
            foreach (string tS in sortedTileSets)
            {
                WzImage tSImage = Program.InfoManager.TileSets[tS];
                if (!tSImage.Parsed)
                {
                    tSImage.ParseImage();
                }
                WzImageProperty enh0 = tSImage["enH0"];
                if (enh0 == null)
                {
                    continue;
                }
                WzCanvasProperty image = (WzCanvasProperty)enh0["0"];
                if (image == null)
                {
                    continue;
                }

                ImageViewer item = koolkLVContainer.Add(image.GetLinkedWzCanvasBitmap(), tS, true);
                item.MouseDown        += new MouseEventHandler(item_Click);
                item.MouseDoubleClick += new MouseEventHandler(item_DoubleClick);
            }
        }
예제 #2
0
        public void ExtractMaps()
        {
            WzImage mapStringsParent = (WzImage)String["Map.img"];

            if (!mapStringsParent.Parsed)
            {
                mapStringsParent.ParseImage();
            }
            foreach (WzSubProperty mapCat in mapStringsParent.WzProperties)
            {
                foreach (WzSubProperty map in mapCat.WzProperties)
                {
                    WzStringProperty mapName = (WzStringProperty)map["mapName"];
                    string           id;
                    if (map.Name.Length == 9)
                    {
                        id = map.Name;
                    }
                    else
                    {
                        id = WzInfoTools.AddLeadingZeros(map.Name, 9);
                    }

                    if (mapName == null)
                    {
                        Program.InfoManager.Maps[id] = "";
                    }
                    else
                    {
                        Program.InfoManager.Maps[id] = mapName.Value;
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Parse a WZ image from .img file/
        /// </summary>
        /// <param name="inPath"></param>
        /// <param name="iv"></param>
        /// <param name="name"></param>
        /// <param name="successfullyParsedImage"></param>
        /// <returns></returns>
        public WzImage WzImageFromIMGFile(string inPath, byte[] iv, string name, out bool successfullyParsedImage)
        {
            FileStream     stream   = File.OpenRead(inPath);
            WzBinaryReader wzReader = new WzBinaryReader(stream, iv);

            WzImage img = new WzImage(name, wzReader);

            img.BlockSize = (int)stream.Length;
            img.Checksum  = 0;
            byte[] bytes = new byte[stream.Length];
            stream.Read(bytes, 0, (int)stream.Length);
            stream.Position = 0;
            foreach (byte b in bytes)
            {
                img.Checksum += b;
            }
            img.Offset = 0;
            if (freeResources)
            {
                successfullyParsedImage = img.ParseImage(true);
                img.Changed             = true;
                wzReader.Close();
            }
            else
            {
                successfullyParsedImage = true;
            }
            return(img);
        }
        private void objSetListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (objSetListBox.SelectedItem == null)
            {
                return;
            }

            objL0ListBox.Items.Clear();
            objL1ListBox.Items.Clear();
            objImagesContainer.Controls.Clear();
            WzImage oSImage = Program.InfoManager.ObjectSets[(string)objSetListBox.SelectedItem];

            if (!oSImage.Parsed)
            {
                oSImage.ParseImage();
            }
            foreach (WzImageProperty l0Prop in oSImage.WzProperties)
            {
                objL0ListBox.Items.Add(l0Prop.Name);
            }
            // select the first item automatically
            if (objL0ListBox.Items.Count > 0)
            {
                objL0ListBox.SelectedIndex = 0;
            }
        }
예제 #5
0
        public void parseImage(WzImage image)
        {
            image.ParseImage();
            deep++;
            makeRealDir();
            string tempDir  = currentDir;
            string tempDir2 = currentDirdunno;

            /*
             * Form1.Instance.BeginInvoke((MethodInvoker)delegate
             * {
             *  Form1.Instance.progress.Maximum += image.WzProperties.Length;
             * });
             * */

            foreach (IWzImageProperty prop in image.WzProperties)
            {
                /*
                 *  Form1.Instance.BeginInvoke((MethodInvoker)delegate
                 *  {
                 *      Form1.Instance.progress.Value++;
                 *  });
                 * */
                currentDir      += prop.Name + ".";
                currentDirdunno += prop.Name + ".";
                parseProperties(prop, 1);
                currentDir      = tempDir;
                currentDirdunno = tempDir2;
            }
            image.UnparseImage();
            image.Dispose();
            deep--;
        }
예제 #6
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);
            }
        }
예제 #7
0
        public WzImage WzImageFromIMGBytes(byte[] bytes, WzMapleVersion version, string name, bool freeResources)
        {
            byte[]         iv       = WzTool.GetIvByMapleVersion(version);
            MemoryStream   stream   = new MemoryStream(bytes);
            WzBinaryReader wzReader = new WzBinaryReader(stream, iv);
            WzImage        img      = new WzImage(name, wzReader);

            img.BlockSize = bytes.Length;
            img.Checksum  = 0;

            foreach (byte b in bytes)
            {
                img.Checksum += b;
            }

            img.Offset = 0;

            if (freeResources)
            {
                img.ParseImage(true);
                img.Changed = true;
                wzReader.Close();
            }

            return(img);
        }
예제 #8
0
        internal void DumpImageToXML(TextWriter tw, string depth, WzImage img)
        {
            bool parsed = img.Parsed || img.Changed;

            if (!parsed)
            {
                img.ParseImage();
            }

            curr++;
            tw.Write(depth + "<wzimg name=\"" + XmlUtil.SanitizeText(img.Name) + "\">" + lineBreak);
            string newDepth = depth + indent;

            foreach (WzImageProperty property in img.WzProperties)
            {
                WritePropertyToXML(tw, newDepth, property);
            }

            tw.Write(depth + "</wzimg>");

            if (!parsed)
            {
                img.UnparseImage();
            }
        }
예제 #9
0
        private void exportXmlInternal(WzImage img, string path)
        {
            bool parsed = img.Parsed || img.Changed;

            if (!parsed)
            {
                img.ParseImage();
            }
            curr++;
            TextWriter tw = new StreamWriter(path);

            tw.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + lineBreak);
            tw.Write("<imgdir name=\"" + XmlUtil.SanitizeText(img.Name) + "\">" + lineBreak);
            foreach (WzImageProperty property in img.WzProperties)
            {
                WritePropertyToXML(tw, indent, property);
            }
            tw.Write("</imgdir>" + lineBreak);
            tw.Close();

            if (!parsed)
            {
                img.UnparseImage();
            }
        }
예제 #10
0
파일: Form1.cs 프로젝트: odasm/WzPatcher
        void loadDifferences()
        {
            // here we would query a website for latest patch rev.
            WzMapleVersion vrs     = WzMapleVersion.GMS; // is classic old GMS??
            string         imgPath = textBox1.Text;
            string         wzPath  = textBox2.Text;

            Console.WriteLine("imgPath: " + imgPath + ", wzPath: " + wzPath);
            WzFile affected = new WzFile(wzPath, vrs);

            affected.ParseWzFile();
            char[] split   = { '\\', '/' };
            string imgName = imgPath.Split(split)[imgPath.Split(split).Length - 1].Trim();

            Console.WriteLine("imgName: " + imgName);
            WzImage    toPatch = affected.WzDirectory.GetImageByName(imgName);
            FileStream stream  = File.OpenRead(imgPath);
            WzImage    img     = new WzImage("-" + imgName, stream, vrs);

            img.ParseImage();
            toPatch.ParseImage();
            toPatch.ClearProperties();
            toPatch.AddProperties(img.WzProperties);
            affected.WzDirectory.GetImageByName(imgName).changed = true;
            affected.SaveToDisk(wzPath + ".new");
            affected.Dispose();
            stream.Close();
            while (!tryDelete(wzPath))
            {
                Thread.Sleep(1000);             // ensure that we can rename the file
            }
            File.Move(wzPath + ".new", wzPath); // rewrite w/ patched file
            button1.Text = "Done!";
        }
예제 #11
0
        private void exportJsonInternal(WzImage img, string path)
        {
            bool parsed = img.Parsed || img.Changed;

            if (!parsed)
            {
                img.ParseImage();
            }
            curr++;
            TextWriter tw = new StreamWriter(path);

            tw.Write($"{{\"name\":\"{XmlUtil.SanitizeText(img.Name)}\"," +
                     $"\"payload\":{{");
            var last = img.WzProperties.Last();

            foreach (WzImageProperty p in img.WzProperties)
            {
                WritePropertyToJson(tw, p);
                if (!p.Equals(last))
                {
                    tw.Write(",");
                }
            }
            tw.Write("}}");
            tw.Close();
            if (!parsed)
            {
                img.UnparseImage();
            }
            File.WriteAllText(path, pretty(File.ReadAllText(path)), Encoding.GetEncoding("ISO-8859-1"));
        }
예제 #12
0
        public void ExtractStringWzMaps()
        {
            WzImage mapStringsParent = (WzImage)String["Map.img"];

            if (!mapStringsParent.Parsed)
            {
                mapStringsParent.ParseImage();
            }
            foreach (WzSubProperty mapCat in mapStringsParent.WzProperties)
            {
                foreach (WzSubProperty map in mapCat.WzProperties)
                {
                    WzStringProperty streetName = (WzStringProperty)map["streetName"];
                    WzStringProperty mapName    = (WzStringProperty)map["mapName"];
                    string           id;
                    if (map.Name.Length == 9)
                    {
                        id = map.Name;
                    }
                    else
                    {
                        id = WzInfoTools.AddLeadingZeros(map.Name, 9);
                    }

                    if (mapName == null)
                    {
                        Program.InfoManager.Maps[id] = new Tuple <string, string>("", "");
                    }
                    else
                    {
                        Program.InfoManager.Maps[id] = new Tuple <string, string>(streetName?.Value == null ? string.Empty : streetName.Value, mapName.Value);
                    }
                }
            }
        }
예제 #13
0
        private void debugButton_Click(object sender, EventArgs e)
        {
            // This function iterates over all maps in the game and verifies that we recognize all their props
            // It is meant to use by the developer(s) to speed up the process of adjusting this program for different MapleStory versions
            string         wzPath      = pathBox.Text;
            short          version     = -1;
            WzMapleVersion fileVersion = WzTool.DetectMapleVersion(Path.Combine(wzPath, "Item.wz"), out version);

            InitializeWzFiles(wzPath, fileVersion);
            MultiBoard mb = new MultiBoard();
            Board      b  = new Board(new Microsoft.Xna.Framework.Point(), new Microsoft.Xna.Framework.Point(), mb, null, MapleLib.WzLib.WzStructure.Data.ItemTypes.None, MapleLib.WzLib.WzStructure.Data.ItemTypes.None);

            foreach (string mapid in Program.InfoManager.Maps.Keys)
            {
                MapLoader loader   = new MapLoader();
                string    mapcat   = "Map" + mapid.Substring(0, 1);
                WzImage   mapImage = null;

                foreach (var dir in Program.WzManager.GetDirsStartsWith("map"))
                {
                    if (dir["Map"] != null && dir["Map"][mapcat] != null)
                    {
                        mapImage = (WzImage)dir["Map"][mapcat][mapid + ".img"];
                    }

                    if (mapImage != null)
                    {
                        break;
                    }
                }

                if (mapImage == null)
                {
                    continue;
                }

                mapImage.ParseImage();

                if (mapImage["info"]["link"] != null)
                {
                    mapImage.UnparseImage();
                    continue;
                }

                loader.VerifyMapPropsKnown(mapImage, true);
                MapInfo info = new MapInfo(mapImage, null, null, null);
                loader.LoadMisc(mapImage, b);

                if (ErrorLogger.ErrorsPresent())
                {
                    ErrorLogger.SaveToFile("debug_errors.txt");
                    ErrorLogger.ClearErrors();
                }

                mapImage.UnparseImage(); // To preserve memory, since this is a very memory intensive test
            }

            MessageBox.Show("Done");
        }
예제 #14
0
 private static void SetParsed(WzImage image)
 {
     if (image.Parsed)
     {
         return;
     }
     image.ParseImage();
 }
예제 #15
0
        public void LoadToolTips(WzImage mapImage, Board mapBoard)
        {
            WzSubProperty tooltipsParent = (WzSubProperty)mapImage["ToolTip"];

            if (tooltipsParent == null)
            {
                return;
            }

            WzImage tooltipsStringImage = (WzImage)Program.WzManager.String["ToolTipHelp.img"];

            if (!tooltipsStringImage.Parsed)
            {
                tooltipsStringImage.ParseImage();
            }

            WzSubProperty tooltipStrings = (WzSubProperty)tooltipsStringImage["Mapobject"][mapBoard.MapInfo.id.ToString()];

            if (tooltipStrings == null)
            {
                return;
            }

            for (int i = 0; true; i++)
            {
                string        num           = i.ToString();
                WzSubProperty tooltipString = (WzSubProperty)tooltipStrings[num];
                WzSubProperty tooltipProp   = (WzSubProperty)tooltipsParent[num];
                WzSubProperty tooltipChar   = (WzSubProperty)tooltipsParent[num + "char"];
                if (tooltipString == null && tooltipProp == null)
                {
                    break;
                }
                if (tooltipString == null ^ tooltipProp == null)
                {
                    continue;
                }
                string title = InfoTool.GetOptionalString(tooltipString["Title"]);
                string desc  = InfoTool.GetOptionalString(tooltipString["Desc"]);
                int    x1    = InfoTool.GetInt(tooltipProp["x1"]);
                int    x2    = InfoTool.GetInt(tooltipProp["x2"]);
                int    y1    = InfoTool.GetInt(tooltipProp["y1"]);
                int    y2    = InfoTool.GetInt(tooltipProp["y2"]);
                Microsoft.Xna.Framework.Rectangle tooltipPos = new Microsoft.Xna.Framework.Rectangle(x1, y1, x2 - x1, y2 - y1);
                ToolTipInstance tt = new ToolTipInstance(mapBoard, tooltipPos, title, desc, i);
                mapBoard.BoardItems.ToolTips.Add(tt);
                if (tooltipChar != null)
                {
                    x1         = InfoTool.GetInt(tooltipChar["x1"]);
                    x2         = InfoTool.GetInt(tooltipChar["x2"]);
                    y1         = InfoTool.GetInt(tooltipChar["y1"]);
                    y2         = InfoTool.GetInt(tooltipChar["y2"]);
                    tooltipPos = new Microsoft.Xna.Framework.Rectangle(x1, y1, x2 - x1, y2 - y1);
                    ToolTipChar ttc = new ToolTipChar(mapBoard, tooltipPos, tt);
                    mapBoard.BoardItems.CharacterToolTips.Add(ttc);
                }
            }
        }
예제 #16
0
파일: MapLoader.cs 프로젝트: xnum/hasuite
        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();
        }
예제 #17
0
파일: Load.cs 프로젝트: xnum/hasuite
        private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((string)mapNamesBox.SelectedItem == "MapLogin" ||
                (string)mapNamesBox.SelectedItem == "MapLogin1" ||
                (string)mapNamesBox.SelectedItem == "CashShopPreview" ||
                mapNamesBox.SelectedItem == null)
            {
                linkLabel.Visible   = false;
                mapNotExist.Visible = false;
                minimapBox.Image    = (Image) new Bitmap(1, 1);
                loadButton.Enabled  = true;
                return;
            }
            string  mapid    = ((string)mapNamesBox.SelectedItem).Substring(0, 9);
            string  mapcat   = "Map" + mapid.Substring(0, 1);
            WzImage mapImage = (WzImage)Program.WzManager["map"].GetObjectFromPath("Map.wz/Map/" + mapcat + "/" + mapid + ".img");

            if (mapImage == null)
            {
                linkLabel.Visible   = false;
                mapNotExist.Visible = true;
                minimapBox.Image    = (Image) new Bitmap(1, 1);
                loadButton.Enabled  = false;
                return;
            }
            if (!mapImage.Parsed)
            {
                mapImage.ParseImage();
            }
            if (mapImage["info"]["link"] != null)
            {
                linkLabel.Visible   = true;
                mapNotExist.Visible = false;
                minimapBox.Image    = (Image) new Bitmap(1, 1);
                loadButton.Enabled  = false;
            }
            else
            {
                linkLabel.Visible   = false;
                mapNotExist.Visible = false;
                loadButton.Enabled  = true;
                WzCanvasProperty minimap = (WzCanvasProperty)mapImage.GetFromPath("miniMap/canvas");
                if (minimap != null)
                {
                    minimapBox.Image = (Image)minimap.PngProperty.GetPNG(false);
                }
                else
                {
                    minimapBox.Image = (Image) new Bitmap(1, 1);
                }
            }
            mapImage.UnparseImage();
            GC.Collect();
        }
예제 #18
0
파일: Character.cs 프로젝트: xnum/hasuite
        //.cctor
        static Character()
        {
            WzImage physicsImage = (WzImage)Program.WzManager["map"]["Physics.img"];

            if (!physicsImage.Parsed)
            {
                physicsImage.ParseImage();
            }
            jumpSpeed  = InfoTool.GetDouble(physicsImage["jumpSpeed"]);
            walkSpeed  = InfoTool.GetDouble(physicsImage["walkSpeed"]);
            fallSpeed  = InfoTool.GetDouble(physicsImage["fallSpeed"]);
            gravityAcc = InfoTool.GetDouble(physicsImage["gravityAcc"]);
        }
예제 #19
0
 private void SearchTV(WzNode node)
 {
     foreach (WzNode subnode in node.Nodes)
     {
         if (0 <= subnode.Text.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase))
         {
             if (listSearchResults)
             {
                 searchResultsList.Add(subnode.FullPath.Replace(";", @"\"));
             }
             else if (currentidx == searchidx)
             {
                 //if (subnode.Style == null) subnode.Style = new ElementStyle();
                 subnode.BackColor = Color.Yellow;
                 coloredNode       = subnode;
                 subnode.EnsureVisible();
                 //DataTree.Focus();
                 finished = true;
                 searchidx++;
                 return;
             }
             else
             {
                 currentidx++;
             }
         }
         if (subnode.Tag is WzImage)
         {
             WzImage img = (WzImage)subnode.Tag;
             if (img.Parsed)
             {
                 SearchWzProperties(img);
             }
             else if (extractImages)
             {
                 img.ParseImage();
                 SearchWzProperties(img);
             }
             if (finished)
             {
                 return;
             }
         }
         else
         {
             SearchTV(subnode);
         }
     }
 }
예제 #20
0
        public void ExtractNpcFile()
        {
            WzImage npcImage = (WzImage)String["Npc.img"];

            if (!npcImage.Parsed)
            {
                npcImage.ParseImage();
            }
            foreach (WzSubProperty npc in npcImage.WzProperties)
            {
                WzStringProperty nameProp = (WzStringProperty)npc["name"];
                string           name     = nameProp == null ? "" : nameProp.Value;
                Program.InfoManager.NPCs.Add(WzInfoTools.AddLeadingZeros(npc.Name, 7), name);
            }
        }
예제 #21
0
        public void ExtractItems()
        {
            WzImage consImage = (WzImage)String["Consume.img"];

            if (!consImage.Parsed)
            {
                consImage.ParseImage();
            }
            foreach (WzSubProperty item in consImage.WzProperties)
            {
                WzStringProperty nameProp = (WzStringProperty)item["name"];
                string           name     = nameProp == null ? "" : nameProp.Value;
                Program.InfoManager.Items.Add(WzInfoTools.AddLeadingZeros(item.Name, 7), name);
            }
        }
예제 #22
0
        public void ExtractMobFile()
        {
            WzImage mobImage = (WzImage)String["Mob.img"];

            if (!mobImage.Parsed)
            {
                mobImage.ParseImage();
            }
            foreach (WzSubProperty mob in mobImage.WzProperties)
            {
                WzStringProperty nameProp = (WzStringProperty)mob["name"];
                string           name     = nameProp == null ? "" : nameProp.Value;
                Program.InfoManager.Mobs.Add(WzInfoTools.AddLeadingZeros(mob.Name, 7), name);
            }
        }
예제 #23
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);
                }
            }
        }
예제 #24
0
        /// <summary>
        /// Loads the Data.wz file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="encVersion"></param>
        /// <param name="panel"></param>
        /// <returns></returns>
        public WzImage LoadDataWzHotfixFile(string path, WzMapleVersion encVersion, HaRepackerMainPanel panel)
        {
            FileStream fs = File.Open(path, FileMode.Open);

            WzImage img = new WzImage(Path.GetFileName(path), fs, encVersion);

            img.ParseImage(true);

            WzNode node = new WzNode(img);

            panel.DataTree.Nodes.Add(node);
            if (UserSettings.Sort)
            {
                SortNodesRecursively(node);
            }
            return(img);
        }
        /// <summary>
        /// Loads the Data.wz file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="encVersion"></param>
        /// <param name="panel"></param>
        /// <returns></returns>
        public WzImage LoadDataWzHotfixFile(string path, WzMapleVersion encVersion, MainPanel panel)
        {
            WzImage img;

            using (FileStream fs = File.Open(path, FileMode.Open))
            {
                img = new WzImage(Path.GetFileName(path), fs, encVersion);
                img.ParseImage(true);

                WzNode node = new WzNode(img);
                panel.DataTree.Nodes.Add(node);
                if (Program.ConfigurationManager.UserSettings.Sort)
                {
                    SortNodesRecursively(node);
                }
            }

            return(img);
        }
        /// <summary>
        /// Loads the Data.wz file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="encVersion"></param>
        /// <param name="panel"></param>
        /// <returns></returns>
        public WzImage LoadDataWzHotfixFile(string path, WzMapleVersion encVersion, MainPanel panel)
        {
            FileStream fs = File.Open(path, FileMode.Open); // dont close this file stream until it is unloaded from memory

            WzImage img = new WzImage(Path.GetFileName(path), fs, encVersion);

            img.ParseImage(true);

            WzNode node = new WzNode(img);

            panel.DataTree.BeginUpdate();
            panel.DataTree.Nodes.Add(node);
            panel.DataTree.EndUpdate();

            if (Program.ConfigurationManager.UserSettings.Sort)
            {
                SortNodesRecursively(node);
            }
            return(img);
        }
예제 #27
0
        private void LoadFromImg()
        {
            var mapleVersion = WzTool.DetectMapleVersion("Data\\Etc", "Commodity.img");

            if (mapleVersion == -1)
            {
                MessageBox.Show(Resources.ErrorWzEncryption, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var etc = Wz.Etc.LoadFile($"Data\\Etc", (WzMapleVersion)mapleVersion);

            Wz.Character.LoadFile($"Data\\Character", (WzMapleVersion)mapleVersion);
            Wz.Item.LoadFile($"Data\\Item", (WzMapleVersion)mapleVersion);

            commodityImg = etc.WzDirectory.GetImageByName("Commodity.img");
            commodityImg.ParseImage();

            AddItems(commodityImg.WzProperties);
        }
예제 #28
0
        public static NpcInfo Get(string id)
        {
            WzImage npcImage = (WzImage)Program.WzManager["npc"][id + ".img"];

            if (npcImage == null)
            {
                return(null);
            }
            if (!npcImage.Parsed)
            {
                npcImage.ParseImage();
            }
            if (npcImage.HCTag == null)
            {
                npcImage.HCTag = NpcInfo.Load(npcImage);
            }
            NpcInfo result = (NpcInfo)npcImage.HCTag;

            result.ParseImageIfNeeded();
            return(result);
        }
예제 #29
0
        private void LoadFromWz()
        {
            var   mapleVersion = WzTool.DetectMapleVersion("Etc.wz", out var detectVersion);
            short?nVersion     = null;

            if (WzTool.GetDecryptionSuccessRate("Etc.wz", mapleVersion, ref nVersion) < 0.8)
            {
                MessageBox.Show(Resources.ErrorWzEncryption, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var etc = Wz.Etc.LoadFile("Etc", mapleVersion);

            Wz.Character.LoadFile("Character", mapleVersion);
            Wz.Item.LoadFile("Item", mapleVersion);

            commodityImg = etc.WzDirectory.GetImageByName("Commodity.img");
            commodityImg.ParseImage();

            AddItems(commodityImg.WzProperties);
        }
예제 #30
0
파일: MobInfo.cs 프로젝트: Aeopp/Github
        public static MobInfo Get(string id)
        {
            WzImage mobImage = (WzImage)Program.WzManager["mob"][id + ".img"];

            if (mobImage == null)
            {
                return(null);
            }
            if (!mobImage.Parsed)
            {
                mobImage.ParseImage();
            }
            if (mobImage.HCTag == null)
            {
                mobImage.HCTag = MobInfo.Load(mobImage);
            }
            MobInfo result = (MobInfo)mobImage.HCTag;

            result.ParseImageIfNeeded();
            return(result);
        }
 private void exportXmlInternal(WzImage img, string path)
 {
     bool parsed = img.Parsed;
     if (!parsed) img.ParseImage();
     curr++;
     TextWriter tw = new StreamWriter(path);
     tw.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + lineBreak);
     tw.Write("<imgdir name=\"" + XmlUtil.SanitizeText(img.Name) + "\">" + lineBreak);
     foreach (IWzImageProperty property in img.WzProperties)
         WritePropertyToXML(tw, indent, property);
     tw.Write("</imgdir>" + lineBreak);
     tw.Close();
     if (!parsed) img.UnparseImage();
 }
 public WzImage WzImageFromIMGBytes(byte[] bytes, WzMapleVersion version, string name, bool freeResources)
 {
     byte[] iv = WzTool.GetIvByMapleVersion(version);
     MemoryStream stream = new MemoryStream(bytes);
     WzBinaryReader wzReader = new WzBinaryReader(stream, iv);
     WzImage img = new WzImage(name, wzReader);
     img.BlockSize = bytes.Length;
     img.Checksum = 0;
     foreach (byte b in bytes) img.Checksum += b;
     img.Offset = 0;
     if (freeResources)
     {
         img.ParseImage(true);
         img.Changed = true;
         wzReader.Close();
     }
     return img;
 }
 public WzImage WzImageFromIMGFile(string inPath, byte[] iv, string name)
 {
     FileStream stream = File.OpenRead(inPath);
     WzBinaryReader wzReader = new WzBinaryReader(stream, iv);
     WzImage img = new WzImage(name, wzReader);
     img.BlockSize = (int)stream.Length;
     img.Checksum = 0;
     byte[] bytes = new byte[stream.Length];
     stream.Read(bytes, 0, (int)stream.Length);
     stream.Position = 0;
     foreach (byte b in bytes) img.Checksum += b;
     img.Offset = 0;
     if (freeResources)
     {
         img.ParseImage(true);
         img.Changed = true;
         wzReader.Close();
     }
     return img;
 }
 internal void DumpImageToXML(TextWriter tw, string depth, WzImage img)
 {
     bool parsed = img.Parsed;
     if (!parsed) img.ParseImage();
     curr++;
     tw.Write(depth + "<wzimg name=\"" + XmlUtil.SanitizeText(img.Name) + "\">" + lineBreak);
     string newDepth = depth + indent;
     foreach (IWzImageProperty property in img.WzProperties)
         WritePropertyToXML(tw, newDepth, property);
     tw.Write(depth + "</wzimg>");
     if (!parsed) img.UnparseImage();
 }