Exemplo n.º 1
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");
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
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--;
        }
Exemplo n.º 4
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();
            }
        }
Exemplo n.º 5
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"));
        }
Exemplo n.º 6
0
Arquivo: Load.cs Projeto: 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();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Check map errors
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void debugButton_Click(object sender, EventArgs e)
        {
            const string OUTPUT_ERROR_FILENAME = "Debug_errors.txt";

            // 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      mapBoard = 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)
            {
                string mapcat = "Map" + mapid.Substring(0, 1);

                WzImage mapImage = Program.WzManager.FindMapImage(mapid, mapcat);
                if (mapImage == null)
                {
                    continue;
                }
                mapImage.ParseImage();
                if (mapImage["info"]["link"] != null)
                {
                    mapImage.UnparseImage();
                    continue;
                }
                MapLoader.VerifyMapPropsKnown(mapImage, true);
                MapInfo info = new MapInfo(mapImage, null, null, null);
                try
                {
                    mapBoard.CreateMapLayers();

                    MapLoader.LoadLayers(mapImage, mapBoard);
                    MapLoader.LoadLife(mapImage, mapBoard);
                    MapLoader.LoadFootholds(mapImage, mapBoard);
                    MapLoader.GenerateDefaultZms(mapBoard);
                    MapLoader.LoadRopes(mapImage, mapBoard);
                    MapLoader.LoadChairs(mapImage, mapBoard);
                    MapLoader.LoadPortals(mapImage, mapBoard);
                    MapLoader.LoadReactors(mapImage, mapBoard);
                    MapLoader.LoadToolTips(mapImage, mapBoard);
                    MapLoader.LoadBackgrounds(mapImage, mapBoard);
                    MapLoader.LoadMisc(mapImage, mapBoard);

                    //MapLoader.LoadBackgrounds(mapImage, board);
                    //MapLoader.LoadMisc(mapImage, board);

                    // Check background to ensure that its correct
                    List <BackgroundInstance> allBackgrounds = new List <BackgroundInstance>();
                    allBackgrounds.AddRange(mapBoard.BoardItems.BackBackgrounds);
                    allBackgrounds.AddRange(mapBoard.BoardItems.FrontBackgrounds);

                    foreach (BackgroundInstance bg in allBackgrounds)
                    {
                        if (bg.type != MapleLib.WzLib.WzStructure.Data.BackgroundType.Regular)
                        {
                            if (bg.cx < 0 || bg.cy < 0)
                            {
                                string error = string.Format("Negative CX/ CY moving background object. CX='{0}', CY={1}, Type={2}, {3}{4}", bg.cx, bg.cy, bg.type.ToString(), Environment.NewLine, mapImage.ToString() /*overrides, see WzImage.ToString*/);
                                ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
                            }
                        }
                    }
                    allBackgrounds.Clear();
                }
                catch (Exception exp)
                {
                    string error = string.Format("Exception occured loading {0}{1}{2}{3}{4}", mapcat, Environment.NewLine, mapImage.ToString() /*overrides, see WzImage.ToString*/, Environment.NewLine, exp.ToString());
                    ErrorLogger.Log(ErrorLevel.Crash, error);
                }
                finally
                {
                    mapBoard.Dispose();

                    mapBoard.BoardItems.BackBackgrounds.Clear();
                    mapBoard.BoardItems.FrontBackgrounds.Clear();

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

                if (ErrorLogger.NumberOfErrorsPresent() > 200)
                {
                    ErrorLogger.SaveToFile(OUTPUT_ERROR_FILENAME);
                }
            }
            ErrorLogger.SaveToFile(OUTPUT_ERROR_FILENAME);


            MessageBox.Show(string.Format("Check for map errors completed. See '{0}' for more information.", OUTPUT_ERROR_FILENAME));
        }
 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();
 }
 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();
 }
        private void ExportRecursion(WzObject currObj, string outPath)
        {
            if (currObj is WzFile)
            {
                ExportRecursion(((WzFile)currObj).WzDirectory, outPath);
            }
            else if (currObj is WzDirectory)
            {
                outPath += ProgressingWzSerializer.EscapeInvalidFilePathNames(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 + ProgressingWzSerializer.EscapeInvalidFilePathNames(currObj.Name) + ".png";

                bmp.Save(path, ImageFormat.Png);
                //curr++;
            }
            else if (currObj is WzBinaryProperty)
            {
                string path = outPath + ProgressingWzSerializer.EscapeInvalidFilePathNames(currObj.Name) + ".mp3";
                ((WzBinaryProperty)currObj).SaveToFile(path);
            }
            else if (currObj is WzImage)
            {
                WzImage wzImage = ((WzImage)currObj);

                outPath += ProgressingWzSerializer.EscapeInvalidFilePathNames(currObj.Name) + @"\";
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }

                bool parse = wzImage.Parsed || wzImage.Changed;
                if (!parse)
                {
                    wzImage.ParseImage();
                }
                foreach (WzImageProperty subprop in wzImage.WzProperties)
                {
                    ExportRecursion(subprop, outPath);
                }
                if (!parse)
                {
                    wzImage.UnparseImage();
                }
                curr++;
            }
            else if (currObj is IPropertyContainer)
            {
                outPath += ProgressingWzSerializer.EscapeInvalidFilePathNames(currObj.Name) + ".";
                foreach (WzImageProperty subprop in ((IPropertyContainer)currObj).WzProperties)
                {
                    ExportRecursion(subprop, outPath);
                }
            }
            else if (currObj is WzUOLProperty)
            {
                ExportRecursion(((WzUOLProperty)currObj).LinkValue, outPath);
            }
        }