public void SerializeDirectory(WzDirectory file, string path)
 {
     SerializeObject(file, path);
 }
 internal WzDirectory ParseXMLWzDir(XmlElement dirElement)
 {
     WzDirectory result = new WzDirectory(dirElement.GetAttribute("name"));
     foreach (XmlElement subelement in dirElement)
     {
         if (subelement.Name == "wzdir")
             result.AddDirectory(ParseXMLWzDir(subelement));
         else if (subelement.Name == "wzimg")
             result.AddImage(ParseXMLWzImg(subelement));
         else throw new InvalidDataException("unknown XML prop " + subelement.Name);
     }
     return result;
 }
 public void SerializeDirectory(WzDirectory dir, string outPath)
 {
     total = dir.CountImages();
     curr = 0;
     if (!Directory.Exists(outPath)) WzXmlSerializer.createDirSafe(ref outPath);
     if (outPath.Substring(outPath.Length -1, 1) != @"\") outPath += @"\";
     foreach (WzDirectory subdir in dir.WzDirectories) SerializeDirectory(subdir, outPath + subdir.Name + @"\");
     foreach (WzImage img in dir.WzImages) SerializeImage(img, outPath + img.Name);
 }
 internal void DumpDirectoryToXML(TextWriter tw, string depth, WzDirectory dir)
 {
     tw.Write(depth + "<wzdir name=\"" + XmlUtil.SanitizeText(dir.Name) + "\">" + lineBreak);
     foreach (WzDirectory subdir in dir.WzDirectories)
         DumpDirectoryToXML(tw, depth + indent, subdir);
     foreach (WzImage img in dir.WzImages)
         DumpImageToXML(tw, depth + indent, img);
     tw.Write(depth + "</wzdir>" + lineBreak);
 }
 public void SerializeDirectory(WzDirectory dir, string path)
 {
     total = dir.CountImages(); curr = 0;
     exportDirXmlInternal(dir, path);
 }
 private void exportDirXmlInternal(WzDirectory dir, string path)
 {
     if (!Directory.Exists(path)) createDirSafe(ref path);
     if (path.Substring(path.Length - 1) != @"\") path += @"\";
     foreach (WzDirectory subdir in dir.WzDirectories)
         exportDirXmlInternal(subdir, path + subdir.name + @"\");
     foreach (WzImage subimg in dir.WzImages)
         exportXmlInternal(subimg, path + subimg.Name + ".xml");
 }
 public void SerializeDirectory(WzDirectory dir, string path)
 {
     total = dir.CountImages(); curr = 0;
     exportDirXmlInternal(dir, path);
 }
Exemple #8
0
        private void HandleItemCategory(WzDirectory pDir)
        {
            string tmp = exDir;

            exDir += Path.DirectorySeparatorChar + pDir.Name; // Etc
            foreach (var collection in pDir.GetChildImages()) // 0400.img
            {
                exDir += Path.DirectorySeparatorChar + collection.Name;
                bool isNebuliteDir = collection.Name == "0306.img";
                foreach (var item in collection.WzProperties.Where(p => { return(p is WzSubProperty); })) // 04000000
                {
                    exDir += Path.DirectorySeparatorChar + item.Name + Path.DirectorySeparatorChar;

                    currentID = Convert.ToInt32(item.Name);

                    if (item["info"] != null)
                    {
                        ExportIfExists(exDir, item["info"]["icon"], "info");
                        ExportIfExists(exDir, item["info"]["iconRaw"], "info");
                        ExportIfExists(exDir, item["info"]["iconD"], "info");
                        ExportIfExists(exDir, item["info"]["iconRawD"], "info");
                        ItemInformation.Instance.HandleInfo(currentID, item["info"].ToSubProperty());
                    }
                    if (item["spec"] != null)
                    {
                        if (item["spec"]["slotCount"] != null)
                        {
                            SQLStrings.Instance.AppendRow("item_spec", currentID, "slotcount", item["spec"]["slotCount"].ToInt().ToString());
                        }
                        if (item["spec"]["slotPerLine"] != null)
                        {
                            SQLStrings.Instance.AppendRow("item_spec", currentID, "slotperline", item["spec"]["slotPerLine"].ToInt().ToString());
                        }
                        if (item["spec"]["type"] != null)
                        {
                            SQLStrings.Instance.AppendRow("item_spec", currentID, "type", item["spec"]["type"].ToInt().ToString());
                        }
                    }
                    if (item["effect"] != null)
                    {
                        foreach (var stance in CharacterExtractor.STANCES)
                        {
                            if (item["effect"][stance] != null)
                            {
                                HandleHairStyle(exDir, item["effect"][stance].ToSubProperty(), "effect." + stance);
                            }
                        }
                    }
                    if (isNebuliteDir && item["socket"] != null)
                    {
                        // Extract moar options
                        string description = item["socket"]["string"] != null ? item["socket"]["string"].ToStringValue() : "";

                        string optionlist = "";
                        foreach (var option in item["socket"]["option"].WzProperties)
                        {
                            if (optionlist != "")
                            {
                                optionlist += ';';
                            }
                            optionlist += option["optionString"].ToStringValue() + '=' + option["level"].ToInt();
                        }

                        SqlFileItemSocket.Instance.AppendRow(currentID, description, optionlist);
                    }

                    exDir = RemoveFromBackDirSlash(exDir);
                    exDir = RemoveFromBackDirSlash(exDir);
                }
                exDir = RemoveFromBackDirSlash(exDir);
            }
            exDir = RemoveFromBackDirSlash(exDir);
        }
 public void SerializeDirectory(WzDirectory file, string path)
 {
     SerializeObject(file, path);
 }
        /// <summary>
        /// Load game assets
        /// </summary>
        protected override void LoadContent()
        {
            WzDirectory MapWzFile = Program.WzManager["map"]; // Map.wz
            WzDirectory UIWZFile  = Program.WzManager["ui"];

            // BGM
            if (Program.InfoManager.BGMs.ContainsKey(mapBoard.MapInfo.bgm))
            {
                audio = new WzMp3Streamer(Program.InfoManager.BGMs[mapBoard.MapInfo.bgm], true);
                if (audio != null)
                {
                    audio.Volume = 0.3f;
                    audio.Play();
                }
            }
            if (mapBoard.VRRectangle == null)
            {
                vr_fieldBoundary = new Rectangle(0, 0, mapBoard.MapSize.X, mapBoard.MapSize.Y);
            }
            else
            {
                vr_fieldBoundary = new Rectangle(mapBoard.VRRectangle.X + mapBoard.CenterPoint.X, mapBoard.VRRectangle.Y + mapBoard.CenterPoint.Y, mapBoard.VRRectangle.Width, mapBoard.VRRectangle.Height);
            }
            //SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            // Background and objects
            List <WzObject> usedProps = new List <WzObject>();

            foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs)
            {
                WzImageProperty tileParent = (WzImageProperty)tileObj.BaseInfo.ParentObject;

                mapObjects[tileObj.LayerNumber].Add(
                    MapSimulatorLoader.CreateMapItemFromProperty(texturePool, tileParent, tileObj.X, tileObj.Y, mapBoard.CenterPoint, _DxDeviceManager.GraphicsDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false));
            }
            foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds)
            {
                WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject;

                backgrounds_back.Add(
                    MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip));
            }
            foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds)
            {
                WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject;

                backgrounds_front.Add(
                    MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip));
            }

            // Load reactors
            foreach (ReactorInstance reactor in mapBoard.BoardItems.Reactors)
            {
                //WzImage imageProperty = (WzImage)NPCWZFile[reactorInfo.ID + ".img"];

                ReactorItem reactorItem = MapSimulatorLoader.CreateReactorFromProperty(texturePool, reactor, _DxDeviceManager.GraphicsDevice, ref usedProps);
                mapObjects_Reactors.Add(reactorItem);
            }

            // Load NPCs
            foreach (NpcInstance npc in mapBoard.BoardItems.NPCs)
            {
                //WzImage imageProperty = (WzImage) NPCWZFile[npcInfo.ID + ".img"];

                NpcItem npcItem = MapSimulatorLoader.CreateNpcFromProperty(texturePool, npc, _DxDeviceManager.GraphicsDevice, ref usedProps);
                mapObjects_NPCs.Add(npcItem);
            }
            // Load Mobs
            foreach (MobInstance mob in mapBoard.BoardItems.Mobs)
            {
                //WzImage imageProperty = Program.WzManager.FindMobImage(mobInfo.ID); // Mob.wz Mob2.img Mob001.wz

                MobItem npcItem = MapSimulatorLoader.CreateMobFromProperty(texturePool, mob, _DxDeviceManager.GraphicsDevice, ref usedProps);
                mapObjects_Mobs.Add(npcItem);
            }

            // Load portals
            WzSubProperty portalParent = (WzSubProperty)MapWzFile["MapHelper.img"]["portal"];

            WzSubProperty gameParent = (WzSubProperty)portalParent["game"];

            //WzSubProperty editorParent = (WzSubProperty) portalParent["editor"];

            foreach (PortalInstance portal in mapBoard.BoardItems.Portals)
            {
                PortalItem portalItem = MapSimulatorLoader.CreatePortalFromProperty(texturePool, gameParent, portal, _DxDeviceManager.GraphicsDevice, ref usedProps);
                if (portalItem != null)
                {
                    mapObjects_Portal.Add(portalItem);
                }
            }

            // Load tooltips
            WzSubProperty farmFrameParent = (WzSubProperty)UIWZFile["UIToolTip.img"]?["Item"]?["FarmFrame"];

            foreach (ToolTipInstance tooltip in mapBoard.BoardItems.ToolTips)
            {
                TooltipItem item = MapSimulatorLoader.CreateTooltipFromProperty(texturePool, farmFrameParent, tooltip, _DxDeviceManager.GraphicsDevice);

                mapObjects_tooltips.Add(item);
            }

            // Cursor
            WzImageProperty cursorImageProperty = (WzImageProperty)UIWZFile["Basic.img"]?["Cursor"];

            this.mouseCursor = MapSimulatorLoader.CreateMouseCursorFromProperty(texturePool, cursorImageProperty, 0, 0, _DxDeviceManager.GraphicsDevice, ref usedProps, false);

            // Spine object
            skeletonMeshRenderer = new SkeletonMeshRenderer(GraphicsDevice)
            {
                PremultipliedAlpha = false
            };

            // Minimap
            WzSubProperty minimapFrameProperty = (WzSubProperty)UIWZFile["UIWindow2.img"]?["MiniMap"];

            if (minimapFrameProperty == null) // UIWindow2 not available pre-BB.
            {
                minimapFrameProperty = (WzSubProperty)UIWZFile["UIWindow.img"]?["MiniMap"];
            }
            miniMap = MapSimulatorLoader.CreateMinimapFromProperty(minimapFrameProperty, mapBoard, GraphicsDevice, mapBoard.MapInfo.strMapName, mapBoard.MapInfo.strStreetName);

            //
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // default positioning for character
            SetCameraMoveX(true, true, 0);
            SetCameraMoveY(true, true, 0);

            // Debug items
            System.Drawing.Bitmap bitmap_debug = new System.Drawing.Bitmap(1, 1);
            bitmap_debug.SetPixel(0, 0, System.Drawing.Color.White);
            texture_debugBoundaryRect = bitmap_debug.ToTexture2D(_DxDeviceManager.GraphicsDevice);

            // cleanup
            // clear used items
            foreach (WzObject obj in usedProps)
            {
                obj.MSTag      = null;
                obj.MSTagSpine = null; // cleanup
            }
            usedProps.Clear();
        }
Exemple #11
0
 public ItemWz(WzFile itemWZ)
 {
     itemWZ.ParseWzFile();
     ConsumeDirectory = itemWZ.WzDirectory.GetDirectoryByName("Consume");
     ConsumeImage     = ConsumeDirectory.GetImageByName("0286.img");
 }
Exemple #12
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            //Hide();
            WaitWindow ww = new WaitWindow("Loading...");

            ww.Show();
            Application.DoEvents();

            MapLoader     loader = new MapLoader();
            WzImage       mapImage = null;
            int           mapid = -1;
            string        mapName = null, streetName = "", categoryName = "";
            WzSubProperty strMapProp = null;


            if (HAMSelect.Checked)
            {
                loader.CreateMapFromHam(multiBoard, Tabs, File.ReadAllText(HAMBox.Text), rightClickHandler);
                DialogResult = DialogResult.OK;
                ww.EndWait();
                Close();
                return;
            }
            else if (XMLSelect.Checked)
            {
                try
                {
                    mapImage = (WzImage) new WzXmlDeserializer(false, null).ParseXML(XMLBox.Text)[0];
                }
                catch
                {
                    MessageBox.Show("Error while loading XML. Aborted.");
                    ww.EndWait();
                    Show();
                    return;
                }
            }
            else if (WZSelect.Checked)
            {
                string selectedName = mapBrowser.SelectedItem;

                if (selectedName.StartsWith("MapLogin")) // MapLogin, MapLogin1, MapLogin2, MapLogin3
                {
                    mapImage = (WzImage)Program.WzManager["ui"][selectedName + ".img"];
                    mapName  = streetName = categoryName = selectedName;
                }
                else if (mapBrowser.SelectedItem == "CashShopPreview")
                {
                    mapImage = (WzImage)Program.WzManager["ui"]["CashShopPreview.img"];
                    mapName  = streetName = categoryName = "CashShopPreview";
                }
                else
                {
                    string mapid_str = mapBrowser.SelectedItem.Substring(0, 9);
                    int.TryParse(mapid_str, out mapid);

                    string mapcat = "Map" + mapid_str.Substring(0, 1);

                    WzDirectory directory = Program.WzManager.FindMapWz(mapcat);
                    mapImage = (WzImage)directory[mapid_str + ".img"];

                    strMapProp   = WzInfoTools.GetMapStringProp(mapid_str);
                    mapName      = WzInfoTools.GetMapName(strMapProp);
                    streetName   = WzInfoTools.GetMapStreetName(strMapProp);
                    categoryName = WzInfoTools.GetMapCategoryName(strMapProp);
                }
            }
            loader.CreateMapFromImage(mapid, mapImage, mapName, streetName, categoryName, strMapProp, Tabs, multiBoard, rightClickHandler);
            DialogResult = DialogResult.OK;
            ww.EndWait();
            Close();
        }
Exemple #13
0
 public void DumpDir(WzDirectory mainDir)
 {
     DumpDir(mainDir, WzFolderName);
     InvalidDirs.Clear();
     InvalidDirs = null;
 }