private void AddHairRow(WzImage image) { string imgName = Path.GetFileNameWithoutExtension(image.Name); int id = int.Parse(imgName); WzCanvasProperty icon = (WzCanvasProperty)image.GetFromPath("default/hairOverHead"); if (icon == null) { icon = (WzCanvasProperty)image.GetFromPath("default/hair"); } string name = StringUtility.GetEqp(id); EquipHairsView.GridView.Rows.Add(id, icon?.GetBitmap(), name, ""); }
/// <summary> /// Attempts to render the map and save the progress /// </summary> /// <param name="img"></param> /// <param name="zoom"></param> /// <param name="errorList"></param> public bool TryRenderMapAndSave(WzImage img, double zoom, ref List <string> errorList) { string mapIdName = img.Name.Substring(0, img.Name.Length - 4); node = MainPanel.DataTree.SelectedNode; WzFile wzFile = ((WzObject)node.Tag).WzFileParent; // Spawnpoint foothold and portal lists List <SpawnPoint.Spawnpoint> MSPs = new List <SpawnPoint.Spawnpoint>(); List <FootHold.Foothold> FHs = new List <FootHold.Foothold>(); List <Portals.Portal> Ps = new List <Portals.Portal>(); Size bmpSize; Point center; WzSubProperty miniMapSubProperty = ((WzSubProperty)img["miniMap"]); try { bmpSize = new Size(((WzIntProperty)miniMapSubProperty["width"]).Value, ((WzIntProperty)miniMapSubProperty["height"]).Value); center = new Point(((WzIntProperty)miniMapSubProperty["centerX"]).Value, ((WzIntProperty)miniMapSubProperty["centerY"]).Value); } catch (Exception exp) { if (exp is KeyNotFoundException || exp is NullReferenceException) { try { WzSubProperty infoSubProperty = ((WzSubProperty)img["info"]); bmpSize = new Size(((WzIntProperty)infoSubProperty["VRRight"]).Value - ((WzIntProperty)infoSubProperty["VRLeft"]).Value, ((WzIntProperty)infoSubProperty["VRBottom"]).Value - ((WzIntProperty)infoSubProperty["VRTop"]).Value); center = new Point(((WzIntProperty)infoSubProperty["VRRight"]).Value, ((WzIntProperty)infoSubProperty["VRBottom"]).Value); } catch { errorList.Add("Missing map info WzSubProperty. Path: " + mapIdName + ".img/info/VRRight; VRLeft; VRBottom; VRTop\r\n OR info/miniMap/width ; height; centerX; centerY"); return(false); } } else { return(false); } } // Render minimap Bitmap minimapRender = RenderMinimap(bmpSize, wzFile, img, mapIdName, miniMapSubProperty); // Render map Bitmap mapRender = new Bitmap(bmpSize.Width, bmpSize.Height); using (Graphics drawBuf = Graphics.FromImage(mapRender)) { WzSubProperty ps = (WzSubProperty)img["portal"]; foreach (WzSubProperty p in ps.WzProperties) { //WzSubProperty p = (WzSubProperty)p10.ExtendedProperty; int x = ((WzIntProperty)p["x"]).Value + center.X; int y = ((WzIntProperty)p["y"]).Value + center.Y; int pt = ((WzIntProperty)p["pt"]).Value; string pn = ((WzStringProperty)p["pn"]).ReadString(string.Empty); int tm = ((WzIntProperty)p["tm"]).ReadValue(999999999); Color pColor = Color.Red; if (pt == 0) { pColor = Color.Orange; } else if (pt == 2 || pt == 7)//Normal { pColor = Color.Blue; } else if (pt == 3)//Auto-enter { pColor = Color.Magenta; } else if (pt == 1 || pt == 8) { pColor = Color.BlueViolet; } else { pColor = Color.IndianRed; } // Draw portal preview image bool drewPortalImg = false; if (pn != string.Empty || pt == 2) { string portalEditorImage = wzFile.WzDirectory.Name + "/MapHelper.img/portal/editor/" + (pt == 2 ? "pv" : pn); WzCanvasProperty portalEditorCanvas = (WzCanvasProperty)wzFile.GetObjectFromPath(portalEditorImage); if (portalEditorCanvas != null) { drewPortalImg = true; PointF canvasOriginPosition = portalEditorCanvas.GetCanvasVectorPosition(); drawBuf.DrawImage(portalEditorCanvas.GetLinkedWzCanvasBitmap(), x - canvasOriginPosition.X, y - canvasOriginPosition.Y); } } if (!drewPortalImg) { drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, pColor.R, pColor.G, pColor.B)), x - 20, y - 20, 40, 40); drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x - 20, y - 20, 40, 40); } // Draw portal name drawBuf.DrawString("Portal: " + p.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x - 8, y - 7.7F); Portals.Portal portal = new Portals.Portal(); portal.Shape = new Rectangle(x - 20, y - 20, 40, 40); portal.Data = p; Ps.Add(portal); } WzSubProperty SPs = (WzSubProperty)img["life"]; foreach (WzSubProperty sp in SPs.WzProperties) { Color MSPColor = Color.ForestGreen; string type = ((WzStringProperty)sp["type"]).Value; switch (type) { case "n": // NPC case "m": // monster { bool isNPC = type == "n"; int lifeId = int.Parse(((WzStringProperty)sp["id"]).GetString()); int x = ((WzIntProperty)sp["x"]).Value + center.X; int y = ((WzIntProperty)sp["y"]).Value + center.Y; int x_text = x - 15; int y_text = y - 15; bool facingLeft = ((WzIntProperty)sp["f"]).ReadValue(0) == 0; // This value is optional. If its not stated in the WZ, its assumed to be 0 SpawnPoint.Spawnpoint MSP = new SpawnPoint.Spawnpoint(); MSP.Shape = new Rectangle(x_text, y_text, 30, 30); MSP.Data = sp; MSPs.Add(MSP); // Render monster image string lifeStrId = lifeId.ToString().PadLeft(7, '0'); string mobWzPath; string mobLinkWzPath; string mobNamePath; if (!isNPC) { mobWzPath = string.Format("Mob.wz/{0}.img/info/link", lifeStrId); mobNamePath = string.Format("String.wz/Mob.img/{0}/name", lifeId); } else { mobWzPath = string.Format("Npc.wz/{0}.img/info/link", lifeStrId); mobNamePath = string.Format("String.wz/Npc.img/{0}/name", lifeId); } WzStringProperty linkInfo = (WzStringProperty)WzFile.GetObjectFromMultipleWzFilePath(mobWzPath, Program.WzMan.WzFileListReadOnly); if (linkInfo != null) { lifeId = int.Parse(linkInfo.GetString()); lifeStrId = lifeId.ToString().PadLeft(7, '0'); } if (!isNPC) { mobLinkWzPath = string.Format("Mob.wz/{0}.img/stand/0", lifeStrId); } else { mobLinkWzPath = string.Format("Npc.wz/{0}.img/stand/0", lifeStrId); } WzCanvasProperty lifeImg = (WzCanvasProperty)WzFile.GetObjectFromMultipleWzFilePath(mobLinkWzPath, Program.WzMan.WzFileListReadOnly); if (lifeImg != null) { PointF canvasOriginPosition = lifeImg.GetCanvasVectorPosition(); PointF renderXY = new PointF(x - canvasOriginPosition.X, y - canvasOriginPosition.Y); Bitmap renderMobbitmap = lifeImg.GetLinkedWzCanvasBitmap(); if (!facingLeft) { renderMobbitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); } drawBuf.DrawImage(renderMobbitmap, renderXY); } else { //drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, MSPColor.R, MSPColor.G, MSPColor.B)), x_text, y_text, 30, 30); //drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x_text, y_text, 30, 30); errorList.Add("Missing monster/npc object. Path: " + mobWzPath + "\r\n" + mobLinkWzPath); } // Get monster name WzStringProperty stringName = (WzStringProperty)WzFile.GetObjectFromMultipleWzFilePath(mobNamePath, Program.WzMan.WzFileListReadOnly); if (stringName != null) { drawBuf.DrawString(string.Format("SP: {0}, Name: {1}, ID: {2}", sp.Name, stringName.GetString(), lifeId), FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x_text + 7, y_text + 7.3F); } else { errorList.Add("Missing monster/npc string object. Path: " + mobNamePath); } break; } default: { break; } } } WzSubProperty fhs = (WzSubProperty)img["foothold"]; foreach (WzImageProperty fhspl0 in fhs.WzProperties) { foreach (WzImageProperty fhspl1 in fhspl0.WzProperties) { Color c = Color.FromArgb(95, Color.FromArgb(GetPseudoRandomColor(fhspl1.Name))); foreach (WzSubProperty fh in fhspl1.WzProperties) { int x = ((WzIntProperty)fh["x1"]).Value + center.X; int y = ((WzIntProperty)fh["y1"]).Value + center.Y; int width = ((((WzIntProperty)fh["x2"]).Value + center.X) - x); int height = ((((WzIntProperty)fh["y2"]).Value + center.Y) - y); if (width < 0) { x += width;// *2; width = -width; } if (height < 0) { y += height;// *2; height = -height; } if (width == 0 || width < 15) { width = 15; } height += 10; FootHold.Foothold nFH = new FootHold.Foothold(); nFH.Shape = new Rectangle(x, y, width, height); nFH.Data = fh; FHs.Add(nFH); //drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, Color.Gray.R, Color.Gray.G, Color.Gray.B)), x, y, width, height); drawBuf.FillRectangle(new SolidBrush(c), x, y, width, height); drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x, y, width, height); drawBuf.DrawString(fh.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), new PointF(x + (width / 2) - 8, y + (height / 2) - 7.7F)); } } } } mapRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_footholdRender.bmp"); Bitmap backgroundRender = new Bitmap(bmpSize.Width, bmpSize.Height); using (Graphics tileBuf = Graphics.FromImage(backgroundRender)) { WzSubProperty backImg = (WzSubProperty)img["back"]; if (backImg != null) { foreach (WzSubProperty bgItem in backImg.WzProperties) { string bS = ((WzStringProperty)bgItem["bS"]).Value; int front = ((WzIntProperty)bgItem["front"]).Value; int ani = ((WzIntProperty)bgItem["ani"]).Value; int no = ((WzIntProperty)bgItem["no"]).Value; int x = ((WzIntProperty)bgItem["x"]).Value; int y = ((WzIntProperty)bgItem["y"]).Value; int rx = ((WzIntProperty)bgItem["rx"]).Value; int ry = ((WzIntProperty)bgItem["ry"]).Value; int type = ((WzIntProperty)bgItem["type"]).Value; int cx = ((WzIntProperty)bgItem["cx"]).Value; int cy = ((WzIntProperty)bgItem["cy"]).Value; int a = ((WzIntProperty)bgItem["a"]).Value; bool facingLeft = ((WzIntProperty)bgItem["f"]).ReadValue(0) == 0; if (bS == string.Empty) { continue; } string bgObjImagePath = "Map.wz/Back/" + bS + ".img/Back/" + no; WzCanvasProperty wzBgCanvas = (WzCanvasProperty)WzFile.GetObjectFromMultipleWzFilePath(bgObjImagePath, Program.WzMan.WzFileListReadOnly); if (wzBgCanvas != null) { PointF canvasOriginPosition = wzBgCanvas.GetCanvasVectorPosition(); PointF renderXY = new PointF(x + canvasOriginPosition.X + center.X, y + canvasOriginPosition.X + center.Y); Bitmap drawImage = wzBgCanvas.GetLinkedWzCanvasBitmap(); if (!facingLeft) { drawImage.RotateFlip(RotateFlipType.RotateNoneFlipX); } tileBuf.DrawImage(drawImage, renderXY); } else { errorList.Add("Missing Map BG object. Path: " + bgObjImagePath); } } } } backgroundRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_backgroundRender.bmp"); // Render tooltip WzSubProperty tooltipProperty = (WzSubProperty)img["ToolTip"]; Bitmap toolTip = null; if (tooltipProperty != null) { toolTip = new Bitmap(bmpSize.Width, bmpSize.Height); using (Graphics toolTipBuf = Graphics.FromImage(toolTip)) { string stringTooltipPath = "String.wz/ToolTipHelp.img/Mapobject/" + mapIdName; WzSubProperty wzToolTip = (WzSubProperty)WzFile.GetObjectFromMultipleWzFilePath(stringTooltipPath, Program.WzMan.WzFileListReadOnly); if (wzToolTip == null) { errorList.Add("Map tooltip object is missing. Path: " + stringTooltipPath); } for (int i = 0; i < 99; i++) // starts from 0 { WzSubProperty toolTipItem = (WzSubProperty)tooltipProperty[i.ToString()]; if (toolTipItem == null) { break; } int x1 = toolTipItem["x1"].ReadValue(); int x2 = toolTipItem["x2"].ReadValue(); int y1 = toolTipItem["y1"].ReadValue(); int y2 = toolTipItem["y2"].ReadValue(); // Check String.wz WzSubProperty wzToolTipForI = (WzSubProperty)wzToolTip[i.ToString()]; if (wzToolTipForI == null) { errorList.Add("Map tooltip is missing. Path: " + stringTooltipPath + "/" + i); } string title = wzToolTipForI["Title"].ReadString(null); string desc = wzToolTipForI["Desc"].ReadString(null); if (title == null) { errorList.Add("Map tooltip is missing. Path: " + stringTooltipPath + "/" + i + "/Title"); } toolTipBuf.DrawString(string.Format("{0}\n{1}", title, desc == null ? string.Empty : desc), FONT_GAME_TOOLTIP, new SolidBrush(Color.Black), new PointF(x1 + center.X, y1 + center.Y)); } } toolTip.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_tooltip.bmp"); } // Render Tiles Bitmap tileRender = new Bitmap(bmpSize.Width, bmpSize.Height); using (Graphics tileBuf = Graphics.FromImage(tileRender)) { for (int i = 0; i < 7; i++) { // The below code was commented out because it was creating problems when loading certain maps. When debugging it would throw an exception at line 469. // Objects first WzSubProperty iProperty = (WzSubProperty)img[i.ToString()]; WzSubProperty objProperties = ((WzSubProperty)iProperty["obj"]); WzSubProperty infoProperties = ((WzSubProperty)iProperty["info"]); WzSubProperty tileProperties = ((WzSubProperty)iProperty["tile"]); if (objProperties.WzProperties.Count > 0) { foreach (WzSubProperty obj in objProperties.WzProperties) { //WzSubProperty obj = (WzSubProperty)oe.ExtendedProperty; string imgName = ((WzStringProperty)obj["oS"]).Value + ".img"; string l0 = ((WzStringProperty)obj["l0"]).Value; string l1 = ((WzStringProperty)obj["l1"]).Value; string l2 = ((WzStringProperty)obj["l2"]).Value; int x = ((WzIntProperty)obj["x"]).Value + center.X; int y = ((WzIntProperty)obj["y"]).Value + center.Y; PointF origin; WzCanvasProperty png; string imgObjPath = string.Format("{0}/Obj/{1}/{2}/{3}/{4}/0", wzFile.WzDirectory.Name, imgName, l0, l1, l2); WzImageProperty objData = (WzImageProperty)WzFile.GetObjectFromMultipleWzFilePath(imgObjPath, Program.WzMan.WzFileListReadOnly); tryagain: if (objData is WzCanvasProperty) { png = ((WzCanvasProperty)objData); origin = ((WzCanvasProperty)objData).GetCanvasVectorPosition(); } else if (objData is WzUOLProperty) { WzObject currProp = objData.Parent; foreach (string directive in ((WzUOLProperty)objData).Value.Split("/".ToCharArray())) { if (directive == "..") { currProp = currProp.Parent; } else { if (currProp.GetType() == typeof(WzSubProperty)) { currProp = ((WzSubProperty)currProp)[directive]; } else if (currProp.GetType() == typeof(WzCanvasProperty)) { currProp = ((WzCanvasProperty)currProp)[directive]; } else if (currProp.GetType() == typeof(WzImage)) { currProp = ((WzImage)currProp)[directive]; } else if (currProp.GetType() == typeof(WzConvexProperty)) { currProp = ((WzConvexProperty)currProp)[directive]; } else { errorList.Add("UOL error at map renderer"); return(false); } } } objData = (WzImageProperty)currProp; goto tryagain; } else { errorList.Add("Unknown Wz type at map renderer"); return(false); } //WzVectorProperty origin = (WzVectorProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0"); //WzPngProperty png = (WzPngProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0/PNG"); tileBuf.DrawImage(png.GetLinkedWzCanvasBitmap(), x - origin.X, y - origin.Y); } } if (infoProperties.WzProperties.Count == 0) { continue; } if (tileProperties.WzProperties.Count == 0) { continue; } // Ok, we have some tiles and a tileset string tileSetName = ((WzStringProperty)infoProperties["tS"]).Value; // Browse to the tileset string tilePath = wzFile.WzDirectory.Name + "/Tile/" + tileSetName + ".img"; WzImage tileSet = (WzImage)WzFile.GetObjectFromMultipleWzFilePath(tilePath, Program.WzMan.WzFileListReadOnly); if (!tileSet.Parsed) { tileSet.ParseImage(); } foreach (WzSubProperty tile in tileProperties.WzProperties) { //WzSubProperty tile = (WzSubProperty)te.ExtendedProperty; int x = ((WzIntProperty)tile["x"]).Value + center.X; int y = ((WzIntProperty)tile["y"]).Value + center.Y; string tilePackName = ((WzStringProperty)tile["u"]).Value; string tileID = ((WzIntProperty)tile["no"]).Value.ToString(); WzSubProperty tilePack = ((WzSubProperty)tileSet[tilePackName]); WzCanvasProperty tileCanvas = (WzCanvasProperty)tilePack[tileID]; if (tileCanvas == null) { errorList.Add(string.Format("Tile {0}, ID: {1} is not found.", tilePackName, tileID)); } PointF tileVector = tileCanvas.GetCanvasVectorPosition(); tileBuf.DrawImage(tileCanvas.GetBitmap(), x - tileVector.X, y - tileVector.Y); } } } tileRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_tileRender.bmp"); // Render nodeInfo Bitmap nodeInfoRender = null; WzSubProperty nodeInfoProperty = (WzSubProperty)img["nodeInfo"]; if (nodeInfoProperty != null) { nodeInfoRender = new Bitmap(bmpSize.Width, bmpSize.Height); using (Graphics nodeInfoBuffer = Graphics.FromImage(nodeInfoRender)) { int start = 0; int end = 0; foreach (WzImageProperty nodeInfoImg in nodeInfoProperty.WzProperties) { switch (nodeInfoImg.Name) { case "edgeInfo": { break; } case "end": { end = ((WzIntProperty)nodeInfoImg).ReadValue(); break; } case "start": { start = ((WzIntProperty)nodeInfoImg).ReadValue(); break; } default: { int nodeInfoImgFileName = -1; if (int.TryParse(nodeInfoImg.Name, out nodeInfoImgFileName)) { int attr = ((WzIntProperty)nodeInfoImg["attr"]).ReadValue(); int key = ((WzIntProperty)nodeInfoImg["key"]).ReadValue(); int x = ((WzIntProperty)nodeInfoImg["x"]).ReadValue() + center.X; int y = ((WzIntProperty)nodeInfoImg["y"]).ReadValue() + center.Y; List <int> edges = new List <int>(); foreach (WzImageProperty edge in nodeInfoImg["edge"].WzProperties) { edges.Add(edge.ReadValue()); } const int width = 200; const int height = 20; nodeInfoBuffer.FillRectangle(new SolidBrush(Color.Wheat), x, y, width, height); nodeInfoBuffer.DrawRectangle(new Pen(Color.Black, 1F), x, y, width, height); nodeInfoBuffer.DrawString( string.Format("Key: {0}, x: {1}, y: {1}", key, x, y), FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Black), new PointF(x + (width / 2) - 8, y + (height / 2) - 7.7F)); } break; } } } } nodeInfoRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_nodeInfoRender.bmp"); } // Render everything combined Bitmap fullBmp = new Bitmap(bmpSize.Width, bmpSize.Height + 10); using (Graphics fullBuf = Graphics.FromImage(fullBmp)) { fullBuf.FillRectangle(new SolidBrush(Color.CornflowerBlue), 0, 0, bmpSize.Width, bmpSize.Height + 10); fullBuf.DrawImage(backgroundRender, 0, 0); fullBuf.DrawImage(tileRender, 0, 0); fullBuf.DrawImage(mapRender, 0, 0); if (toolTip != null) { fullBuf.DrawImage(toolTip, 0, 0); } if (nodeInfoRender != null) { fullBuf.DrawImage(nodeInfoRender, 0, 0); } fullBuf.DrawImage(minimapRender, 0, 0); } //pbx_Foothold_Render.Image = fullBmp; fullBmp.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_fullRender.bmp"); // Cleanup resources backgroundRender.Dispose(); tileRender.Dispose(); mapRender.Dispose(); toolTip?.Dispose(); minimapRender.Dispose(); if (errorList.Count() > 0) { return(false); } // Display render map DisplayMap showMap = new DisplayMap(); showMap.map = fullBmp; showMap.Footholds = FHs; showMap.thePortals = Ps; showMap.settings = settings; showMap.MobSpawnPoints = MSPs; showMap.FormClosed += new FormClosedEventHandler(DisplayMapClosed); try { showMap.scale = zoom; showMap.Show(); return(true); } catch (FormatException) { MessageBox.Show("You must set the render scale to a valid number.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } }
private void LoadWzData(WzMapleVersion mapleVersion, string mapleDirectory) { int selectedRoot = TabControlMain.SelectedIndex; switch (TabControlMain.SelectedTab.Controls[0]) { case DataViewer view: { // contains just the grid table view.GridView.Rows.Clear(); break; } case TabControl ctrl: { // contains sub-categories if (ctrl.SelectedTab.Controls[0] is DataViewer view) { view.GridView.Rows.Clear(); } break; } } ((DataViewer)EquipTab.SelectedTab.Controls[0]).GridView.Rows.Clear(); switch (selectedRoot) { default: Debug.WriteLine($"Unable to load WZ data unhandled selected index: {TabControlMain.SelectedIndex}"); break; case 0: // Equips { if (!LoadWzFileIfAbsent(ref CharacterWz, mapleDirectory + "/Character", mapleVersion)) { return; } List <WzImage> children = CharacterWz.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); for (int i = 0; i < CharacterWz.WzDirectory.CountImages(); i++) { WzImage image = children[i]; string name = Path.GetFileNameWithoutExtension(image.Name); if (int.TryParse(name, out int equipId)) { int selectedTab = EquipTab.SelectedIndex; int bodyPart = equipId / 10000; switch (bodyPart) { default: if (selectedTab == 2 && bodyPart >= 130 && bodyPart <= 170) { AddGridRow(EquipWeaponsView.GridView, image); } else if (selectedTab == 1 && (bodyPart == 2 || bodyPart == 5)) { AddFaceRow(image); } else if (selectedTab == 0 && (bodyPart == 3 || bodyPart == 4)) { AddHairRow(image); } break; case 100: // Caps if (selectedTab == 4) { AddGridRow(EquipCapsView.GridView, image); } break; case 101: case 102: case 103: case 112: case 113: case 114: // Accessory if (selectedTab == 3) { AddGridRow(EquipAccessoryView.GridView, image); } break; case 110: // Cape if (selectedTab == 9) { AddGridRow(EquipCapesView.GridView, image); } break; case 104: // Coat if (selectedTab == 6) { AddGridRow(EquipTopsView.GridView, image); } break; case 108: // Glove if (selectedTab == 10) { AddGridRow(EquipGlovesView.GridView, image); } break; case 105: // Longcoat if (selectedTab == 5) { AddGridRow(EquipsOverallsView.GridView, image); } break; case 106: // Pants if (selectedTab == 7) { AddGridRow(EquipPantsView.GridView, image); } break; case 180: case 181: case 182: case 183: // Pet Equips // image.ParseImage(); break; case 111: // Rings if (selectedTab == 11) { AddGridRow(EquipRingsView.GridView, image); } break; case 109: // Shield if (selectedTab == 12) { AddGridRow(EquipShieldsView.GridView, image); } break; case 107: // Shoes if (selectedTab == 8) { AddGridRow(EquipShoesView.GridView, image); } break; case 190: case 191: case 193: // Taming Mob if (selectedTab == 13) { AddGridRow(EquipMountsView.GridView, image); } break; } } } break; } case 1: // Use case 2: // Setup case 3: // Etc case 4: // Cash case 9: // Pets { if (!LoadWzFileIfAbsent(ref ItemWz, mapleDirectory + "/Item", mapleVersion)) { return; } List <WzImage> children = ItemWz.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); for (int i = 0; i < ItemWz.WzDirectory.CountImages(); i++) { WzImage image = children[i]; string name = Path.GetFileNameWithoutExtension(image.Name); if (int.TryParse(name, out int itemId)) { switch (itemId) { default: image.ParseImage(); if (selectedRoot == 9 && ItemConstants.IsPet(itemId)) // pet { AddGridRow(PetsView.GridView, image); } if (selectedRoot == 3 && ItemConstants.IsEtc(itemId)) // etc { image.WzProperties.ForEach(img => AddGridRow(EtcView.GridView, img)); } if (selectedRoot == 4 && ItemConstants.IsCash(itemId)) // cash { image.WzProperties.ForEach(img => AddGridRow(CashView.GridView, img)); } if (selectedRoot == 1 && ItemConstants.IsConsume(itemId)) // consume { image.WzProperties.ForEach(img => AddGridRow(UseConsumeView.GridView, img)); } break; case 204: // scrolls if (selectedRoot == 1) { image.WzProperties.ForEach(img => AddGridRow(UseScrollsView.GridView, img)); } break; case 206: case 207: case 233: // projectiles if (selectedRoot == 1) { image.WzProperties.ForEach(img => AddGridRow(UseProjectileView.GridView, img)); } break; case 301: // chairs case 399: // x-mas characters if (selectedRoot == 2) { image.WzProperties.ForEach(img => AddGridRow((itemId == 301 ? SetupChairsView : SetupOthersView).GridView, img)); } break; } } } break; } case 5: // Map { if (!LoadWzFileIfAbsent(ref MapWz, mapleDirectory + "/Map", mapleVersion)) { return; } List <WzImage> children = MapWz.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); for (int i = 0; i < MapWz.WzDirectory.CountImages(); i++) { WzImage image = children[i]; string sMapId = Path.GetFileNameWithoutExtension(image.Name); if (int.TryParse(sMapId, out int mapId)) { image.ParseImage(); string properties = BuildProperties(image); WzCanvasProperty icon = (WzCanvasProperty)image.GetFromPath("miniMap/canvas"); string name = StringUtility.GetFieldFullName(mapId); MapsView.GridView.Rows.Add(mapId, icon?.GetBitmap(), name, properties); } } break; } case 6: // Mob { if (!LoadWzFileIfAbsent(ref MobWz, mapleDirectory + "/Mob", mapleVersion)) { return; } MobsView.GridView.Rows.Clear(); List <WzImage> children = MobWz.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); for (int i = 0; i < MobWz.WzDirectory.CountImages(); i++) { WzImage image = children[i]; AddGridRow(MobsView.GridView, image); } break; } case 7: // Skills { if (!LoadWzFileIfAbsent(ref SkillWz, mapleDirectory + "/Skill", mapleVersion)) { return; } SkillsView.GridView.Rows.Clear(); SkillWz.WzDirectory.ParseImages(); List <WzImage> children = SkillWz.WzDirectory.GetChildImages(); for (int i = 0; i < SkillWz.WzDirectory.CountImages(); i++) { WzImage image = children[i]; string name = Path.GetFileNameWithoutExtension(image.Name); if (int.TryParse(name, out _)) { WzImageProperty tree = image.GetFromPath("skill"); if (tree is WzSubProperty) { List <WzImageProperty> skills = tree.WzProperties; skills.ForEach(s => AddSkillRow(s)); } } } break; } case 8: // NPCs { if (!LoadWzFileIfAbsent(ref NpcWz, mapleDirectory + "/Npc", mapleVersion)) { return; } NPCView.GridView.Rows.Clear(); List <WzImage> children = NpcWz.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); for (int i = 0; i < NpcWz.WzDirectory.CountImages(); i++) { WzImage image = children[i]; AddGridRow(NPCView.GridView, image); } break; } case 10: // Reactors { if (!LoadWzFileIfAbsent(ref ReactorWz, mapleDirectory + "/Reactor", mapleVersion)) { return; } ReactorView.GridView.Rows.Clear(); List <WzImage> children = ReactorWz.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); for (int i = 0; i < ReactorWz.WzDirectory.CountImages(); i++) { WzImage image = children[i]; AddGridRow(ReactorView.GridView, image); } break; } } }
private void LoadWzData(int selectedRoot, WzMapleVersion encryption, string directory) { if (selectedRoot == -1) { var result = MessageBox.Show("You have opted to load data for every tab. Are you sure you want to do this?", "Warning", MessageBoxButtons.YesNo); if (result != DialogResult.Yes) { return; } loadAll = true; for (int i = 0; i <= 10; i++) { TabControlMain.SelectedIndex = i; LoadWzData(i, encryption, directory); BtnSave_Click(null, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); } return; } switch (selectedRoot) { case 0: // Equips { var file = Wz.Character.LoadFile($@"{directory}\Character", encryption, false); List <WzImage> children = file.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (var img in children) { string sId = Path.GetFileNameWithoutExtension(img.Name); if (int.TryParse(sId, out int itemId)) { var name = StringWz.GetEqp(itemId); var properties = GetAllProperties(img); var icon = img.GetFromPath("info/icon")?.GetBitmap(); DataViewer dv; int bodyPart = itemId / 10000; switch (bodyPart) { default: continue; case int n when(n >= 130 && n <= 170): dv = EquipWeaponsView; break; case int n when(n == 2 || n == 5): icon = img.GetFromPath("blink/0/face")?.GetBitmap(); dv = EquipFacesView; break; case int n when(n == 3 || n == 4): { icon = (img.GetFromPath("default/hairOverHead") ?? img.GetFromPath("default/hair"))?.GetBitmap(); var hairBelowBody = (img.GetFromPath("default/hairBelowBody") as WzCanvasProperty)?.GetBitmap(); if (icon != null && hairBelowBody != null) { var merge = new Bitmap(Math.Max(icon.Width, hairBelowBody.Width), Math.Max(icon.Height, hairBelowBody.Height)); using (var g = Graphics.FromImage(merge)) { g.DrawImage(hairBelowBody, Point.Empty); g.DrawImage(icon, Point.Empty); } icon = merge; } dv = EquipHairsView; break; } case int n when((n >= 101 && n <= 103) || (n >= 112 && n <= 114)): dv = EquipAccessoryView; break; case 100: dv = EquipCapsView; break; case 105: dv = EquipsOverallsView; break; case 104: dv = EquipTopsView; break; case 106: dv = EquipPantsView; break; case 107: dv = EquipShoesView; break; case 110: dv = EquipCapesView; break; case 108: dv = EquipGlovesView; break; case 111: dv = EquipRingsView; break; case 109: dv = EquipShieldsView; break; case int n when(n == 190 || n == 191 || n == 193): dv = EquipMountsView; break; } ((List <BinData>)dv.Tag).Add(new BinData(itemId, icon, name, properties)); dv.GridView.Rows.Add(itemId, icon, name, properties); } } Wz.Character.Dispose(); break; } case 1: // Use case 2: // Setup case 3: // Etc case 4: // Cash case 9: // Pets { var file = Wz.Item.LoadFile($@"{directory}\Item", encryption, false); var children = file.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); void AddRow(WzImage wz, DataViewer dv) => wz.WzProperties.ForEach(imgs => AddGridRow(dv.GridView, imgs)); foreach (var img in children) { string name = Path.GetFileNameWithoutExtension(img.Name); if (int.TryParse(name, out int itemId)) { switch (selectedRoot) { case 1: switch (itemId) { default: if (ItemConstants.IsConsume(itemId)) { AddRow(img, UseConsumeView); } break; case 204: AddRow(img, UseScrollsView); break; case 206: case 207: case 233: AddRow(img, UseProjectileView); break; } break; case 2 when itemId == 301 || itemId == 399: AddRow(img, (itemId == 301 ? SetupChairsView : SetupOthersView)); break; case 3 when ItemConstants.IsEtc(itemId): AddRow(img, EtcView); break; case 4 when ItemConstants.IsCash(itemId): AddRow(img, CashView); break; case 9 when ItemConstants.IsPet(itemId): AddGridRow(PetsView.GridView, img); break; } } } Wz.Item.Dispose(); break; } case 5: { // Map var file = Wz.Map.LoadFile($@"{directory}\Map", encryption, false); var children = file.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (var img in children) { string sMapId = Path.GetFileNameWithoutExtension(img.Name); if (!int.TryParse(sMapId, out int mapId)) { continue; } img.ParseImage(); string properties = GetAllProperties(img); WzCanvasProperty icon = (WzCanvasProperty)img.GetFromPath("miniMap/canvas"); string name = StringWz.GetFieldFullName(mapId); MapsView.GridView.Rows.Add(mapId, icon?.GetBitmap(), name, properties); } Wz.Map.Dispose(); break; } case 6: { // Mob var file = Wz.Mob.LoadFile($@"{directory}\Mob", encryption, false); var children = file.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (var img in children) { AddGridRow(MobsView.GridView, img); } Wz.Mob.Dispose(); break; } case 7: { // Skills var file = Wz.Skill.LoadFile($@"{directory}\Skill", encryption, false); var children = file.WzDirectory.GetChildImages(); foreach (var img in children) { string name = Path.GetFileNameWithoutExtension(img.Name); if (!int.TryParse(name, out _)) { continue; } WzImageProperty tree = img.GetFromPath("skill"); if (!(tree is WzSubProperty)) { continue; } List <WzImageProperty> skills = tree.WzProperties; skills.ForEach(s => AddSkillRow(s)); } Wz.Skill.Dispose(); break; } case 8: { // NPCs var file = Wz.Npc.LoadFile($@"{directory}\Npc", encryption, false); var children = file.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (var img in children) { AddGridRow(NPCView.GridView, img); } Wz.Npc.Dispose(); break; } case 10: { // Reactors var file = Wz.Reactor.LoadFile($@"{directory}\Reactor", encryption, false); var children = file.WzDirectory.GetChildImages(); children.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (var img in children) { AddGridRow(ReactorView.GridView, img); } Wz.Reactor.Dispose(); break; } } }
private void AddGridRow(DataGridView grid, object wzObject) { int id; string properties = BuildProperties(wzObject); string name = null; WzCanvasProperty icon = null; if (wzObject is WzImage image) { image.ParseImage(); string imgName = Path.GetFileNameWithoutExtension(image.Name); properties = BuildProperties(image) ?? ""; id = int.Parse(imgName); WzImageProperty entityIcon = image.GetFromPath("stand/0"); WzImageProperty linkProperty = image.GetFromPath("info/link"); if (linkProperty != null) { string linkName = ((WzStringProperty)linkProperty).Value; image = ((WzDirectory)image.Parent).GetChildImages().Find(p => p.Name.Equals(linkName + ".img")); if (image == null) { return; } } if (image.WzFileParent.Name.StartsWith("Npc")) // icon path like: '{ID}/stand/0' // and also sometimes contains a link STRING property instead of using UOL { name = StringUtility.GetNPC(id); } else if (image.WzFileParent.Name.StartsWith("Mob")) { // icon path like: '{ID}/(move|stand|fly)/0' name = StringUtility.GetMob(id); // attempt to get image of the monster entityIcon = image.GetFromPath("fly/0") ?? image.GetFromPath("move/0"); } else if (image.WzFileParent.Name.StartsWith("Reactor")) { name = image.GetFromPath("action")?.WzValue.ToString(); entityIcon = image.GetFromPath("0/0"); } else // for breadcrumb like: '{ID}.img/info/icon' { if (ItemConstants.IsEquip(id)) { name = StringUtility.GetEqp(id); } else if (ItemConstants.IsPet(id)) { name = StringUtility.GetPet(id); } icon = (WzCanvasProperty)image.GetFromPath("info/icon"); } if (icon == null) { if (entityIcon is WzUOLProperty uol) { icon = (WzCanvasProperty)uol.LinkValue; } else { icon = (WzCanvasProperty)entityIcon; } } } else if (wzObject is WzSubProperty subProperty) { if (subProperty.WzFileParent.Name.StartsWith("Skill")) { id = int.Parse(subProperty.Name); name = StringUtility.GetSkill(subProperty.Name); icon = (WzCanvasProperty)subProperty.GetFromPath("icon"); } else // for breadcrumb like: 'category.img/{ID}/info/icon' (etc.wz) { string imgName = subProperty.Name; id = int.Parse(imgName); if (ItemConstants.IsEtc(id)) { name = StringUtility.GetEtc(id); } else if (ItemConstants.IsCash(id)) { name = StringUtility.GetCash(id); } else if (ItemConstants.IsChair(id)) { name = StringUtility.GetChair(id); } else if (ItemConstants.IsConsume(id)) { name = StringUtility.GetConsume(id); } WzImageProperty imgIcon = subProperty.GetFromPath("info/icon"); if (imgIcon is WzUOLProperty ufo) { imgIcon = (WzCanvasProperty)ufo.LinkValue; } else if (imgIcon is WzCanvasProperty canvas) { imgIcon = canvas; } if (imgIcon != null) { icon = (WzCanvasProperty)imgIcon; } } } else { return; } Bitmap bitmap = null; try { bitmap = icon?.GetBitmap(); } catch (Exception) { } grid.Rows.Add(id, bitmap, name, properties); }
public void SaveMap(WzImage img, double zoom) { node = MainPanel.DataTree.SelectedNode; WzFile wzFile = (WzFile)((WzObject)node.Tag).WzFileParent; // Spawnpoint foothold and portal lists List <SpawnPoint.Spawnpoint> MSPs = new List <SpawnPoint.Spawnpoint>(); List <FootHold.Foothold> FHs = new List <FootHold.Foothold>(); List <Portals.Portal> Ps = new List <Portals.Portal>(); Size bmpSize; Point center; WzSubProperty miniMapSubProperty = ((WzSubProperty)img["miniMap"]); try { bmpSize = new Size(((WzIntProperty)miniMapSubProperty["width"]).Value, ((WzIntProperty)miniMapSubProperty["height"]).Value); center = new Point(((WzIntProperty)miniMapSubProperty["centerX"]).Value, ((WzIntProperty)miniMapSubProperty["centerY"]).Value); } catch (Exception exp) { if (exp is KeyNotFoundException || exp is NullReferenceException) { try { WzSubProperty infoSubProperty = ((WzSubProperty)img["info"]); bmpSize = new Size(((WzIntProperty)infoSubProperty["VRRight"]).Value - ((WzIntProperty)infoSubProperty["VRLeft"]).Value, ((WzIntProperty)infoSubProperty["VRBottom"]).Value - ((WzIntProperty)infoSubProperty["VRTop"]).Value); center = new Point(((WzIntProperty)infoSubProperty["VRRight"]).Value, ((WzIntProperty)infoSubProperty["VRBottom"]).Value); } catch { return; } } else { return; } } Bitmap mapRender = new Bitmap(bmpSize.Width, bmpSize.Height + 10); using (Graphics drawBuf = Graphics.FromImage(mapRender)) { //drawBuf.FillRectangle(new SolidBrush(Color.CornflowerBlue), 0, 0, bmpSize.Width, bmpSize.Height); drawBuf.DrawString("Map " + img.Name.Substring(0, img.Name.Length - 4), FONT_DISPLAY_MAPID, new SolidBrush(Color.Black), new PointF(10, 10)); if (miniMapSubProperty != null) { drawBuf.DrawImage(((WzCanvasProperty)miniMapSubProperty["canvas"]).PngProperty.GetPNG(false), 10, 45); } else { drawBuf.DrawString("Minimap not availible", FONT_DISPLAY_MINIMAP_NOT_AVAILABLE, new SolidBrush(Color.Black), new PointF(10, 45)); } WzSubProperty ps = (WzSubProperty)img["portal"]; foreach (WzSubProperty p in ps.WzProperties) { //WzSubProperty p = (WzSubProperty)p10.ExtendedProperty; int x = ((WzIntProperty)p["x"]).Value + center.X; int y = ((WzIntProperty)p["y"]).Value + center.Y; int type = ((WzIntProperty)p["pt"]).Value; Color pColor = Color.Red; if (type == 0) { pColor = Color.Orange; } else if (type == 2 || type == 7)//Normal { pColor = Color.Blue; } else if (type == 3)//Auto-enter { pColor = Color.Magenta; } else if (type == 1 || type == 8) { pColor = Color.BlueViolet; } else { pColor = Color.IndianRed; } drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, pColor.R, pColor.G, pColor.B)), x - 20, y - 20, 40, 40); drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x - 20, y - 20, 40, 40); drawBuf.DrawString(p.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x - 8, y - 7.7F); Portals.Portal portal = new Portals.Portal(); portal.Shape = new Rectangle(x - 20, y - 20, 40, 40); portal.Data = p; Ps.Add(portal); } try { WzSubProperty SPs = (WzSubProperty)img["life"]; foreach (WzSubProperty sp in SPs.WzProperties) { Color MSPColor = Color.ForestGreen; switch (((WzStringProperty)sp["type"]).Value) { case "m": // monster { int monsterId = int.Parse(((WzStringProperty)sp["id"]).GetString()); int x = ((WzIntProperty)sp["x"]).Value + center.X; int y = ((WzIntProperty)sp["y"]).Value + center.Y; int x_text = x - 15; int y_text = y - 15; SpawnPoint.Spawnpoint MSP = new SpawnPoint.Spawnpoint(); MSP.Shape = new Rectangle(x_text, y_text, 30, 30); MSP.Data = sp; MSPs.Add(MSP); // Render monster image string monsterStrId = monsterId < 1000000 ? ("0" + monsterId) : monsterId.ToString(); WzStringProperty linkInfo = (WzStringProperty)WzFile.GetObjectFromMultipleWzFilePath(string.Format("Mob.wz/{0}.img/info/link", monsterStrId), Program.WzMan.WzFileListReadOnly); if (linkInfo != null) { monsterId = int.Parse(linkInfo.GetString()); monsterStrId = monsterId < 1000000 ? ("0" + monsterId) : monsterId.ToString(); } WzCanvasProperty mobImage = (WzCanvasProperty)WzFile.GetObjectFromMultipleWzFilePath(string.Format("Mob.wz/{0}.img/stand/0", monsterStrId), Program.WzMan.WzFileListReadOnly); if (mobImage != null) { WzVectorProperty originXY = (WzVectorProperty)mobImage["origin"]; PointF renderXY; if (originXY != null) { renderXY = new PointF(x - originXY.Pos.X, y - originXY.Pos.Y); } else { renderXY = new PointF(x, y); } WzImageProperty linkedCanvas = mobImage.GetLinkedWzCanvasProperty(); if (linkedCanvas != null) { drawBuf.DrawImage(linkedCanvas.GetBitmap(), renderXY); } else { drawBuf.DrawImage(mobImage.GetBitmap(), renderXY); } } else { drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, MSPColor.R, MSPColor.G, MSPColor.B)), x_text, y_text, 30, 30); drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x_text, y_text, 30, 30); } // Get monster name WzStringProperty stringName = (WzStringProperty)WzFile.GetObjectFromMultipleWzFilePath(string.Format("String.wz/Mob.img/{0}/name", monsterId), Program.WzMan.WzFileListReadOnly); drawBuf.DrawString(string.Format("SP: {0}, Name: {1}, ID: {2}", sp.Name, stringName != null ? stringName.GetString() : string.Empty, monsterId), FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), x_text + 7, y_text + 7.3F); break; } case "n": // NPC { break; } } } } catch (Exception exp) { Debug.WriteLine(exp.ToString()); } WzSubProperty fhs = (WzSubProperty)img["foothold"]; foreach (WzImageProperty fhspl0 in fhs.WzProperties) { foreach (WzImageProperty fhspl1 in fhspl0.WzProperties) { Color c = Color.FromArgb(95, Color.FromArgb(GetPseudoRandomColor(fhspl1.Name))); foreach (WzSubProperty fh in fhspl1.WzProperties) { int x = ((WzIntProperty)fh["x1"]).Value + center.X; int y = ((WzIntProperty)fh["y1"]).Value + center.Y; int width = ((((WzIntProperty)fh["x2"]).Value + center.X) - x); int height = ((((WzIntProperty)fh["y2"]).Value + center.Y) - y); if (width < 0) { x += width;// *2; width = -width; } if (height < 0) { y += height;// *2; height = -height; } if (width == 0 || width < 15) { width = 15; } height += 10; FootHold.Foothold nFH = new FootHold.Foothold(); nFH.Shape = new Rectangle(x, y, width, height); nFH.Data = fh; FHs.Add(nFH); //drawBuf.FillRectangle(new SolidBrush(Color.FromArgb(95, Color.Gray.R, Color.Gray.G, Color.Gray.B)), x, y, width, height); drawBuf.FillRectangle(new SolidBrush(c), x, y, width, height); drawBuf.DrawRectangle(new Pen(Color.Black, 1F), x, y, width, height); drawBuf.DrawString(fh.Name, FONT_DISPLAY_PORTAL_LFIE_FOOTHOLD, new SolidBrush(Color.Red), new PointF(x + (width / 2) - 8, y + (height / 2) - 7.7F)); } } } } mapRender.Save("Renders\\" + img.Name.Substring(0, img.Name.Length - 4) + "\\" + img.Name.Substring(0, img.Name.Length - 4) + "_footholdRender.bmp"); Bitmap tileRender = new Bitmap(bmpSize.Width, bmpSize.Height); using (Graphics tileBuf = Graphics.FromImage(tileRender)) { for (int i = 0; i < 7; i++) { // The below code was commented out because it was creating problems when loading certain maps. When debugging it would throw an exception at line 469. // Objects first if (((WzSubProperty)((WzSubProperty)img[i.ToString()])["obj"]).WzProperties.Count > 0) { foreach (WzSubProperty obj in ((WzSubProperty)((WzSubProperty)img[i.ToString()])["obj"]).WzProperties) { //WzSubProperty obj = (WzSubProperty)oe.ExtendedProperty; string imgName = ((WzStringProperty)obj["oS"]).Value + ".img"; string l0 = ((WzStringProperty)obj["l0"]).Value; string l1 = ((WzStringProperty)obj["l1"]).Value; string l2 = ((WzStringProperty)obj["l2"]).Value; int x = ((WzIntProperty)obj["x"]).Value + center.X; int y = ((WzIntProperty)obj["y"]).Value + center.Y; WzVectorProperty origin; WzPngProperty png; string imgObjPath = wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0"; WzImageProperty objData = (WzImageProperty)WzFile.GetObjectFromMultipleWzFilePath(imgObjPath, Program.WzMan.WzFileListReadOnly); tryagain: if (objData is WzCanvasProperty) { png = ((WzCanvasProperty)objData).PngProperty; origin = (WzVectorProperty)((WzCanvasProperty)objData)["origin"]; } else if (objData is WzUOLProperty) { WzObject currProp = objData.Parent; foreach (string directive in ((WzUOLProperty)objData).Value.Split("/".ToCharArray())) { if (directive == "..") { currProp = currProp.Parent; } else { if (currProp.GetType() == typeof(WzSubProperty)) { currProp = ((WzSubProperty)currProp)[directive]; } else if (currProp.GetType() == typeof(WzCanvasProperty)) { currProp = ((WzCanvasProperty)currProp)[directive]; } else if (currProp.GetType() == typeof(WzImage)) { currProp = ((WzImage)currProp)[directive]; } else if (currProp.GetType() == typeof(WzConvexProperty)) { currProp = ((WzConvexProperty)currProp)[directive]; } else { throw new Exception("UOL error at map renderer"); } } } objData = (WzImageProperty)currProp; goto tryagain; } else { throw new Exception("unknown type at map renderer"); } //WzVectorProperty origin = (WzVectorProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0"); //WzPngProperty png = (WzPngProperty)wzFile.GetObjectFromPath(wzFile.WzDirectory.Name + "/Obj/" + imgName + "/" + l0 + "/" + l1 + "/" + l2 + "/0/PNG"); tileBuf.DrawImage(png.GetPNG(false), x - origin.X.Value, y - origin.Y.Value); } } if (((WzSubProperty)((WzSubProperty)img[i.ToString()])["info"]).WzProperties.Count == 0) { continue; } if (((WzSubProperty)((WzSubProperty)img[i.ToString()])["tile"]).WzProperties.Count == 0) { continue; } // Ok, we have some tiles and a tileset string tileSetName = ((WzStringProperty)((WzSubProperty)((WzSubProperty)img[i.ToString()])["info"])["tS"]).Value; // Browse to the tileset string tilePath = wzFile.WzDirectory.Name + "/Tile/" + tileSetName + ".img"; WzImage tileSet = (WzImage)WzFile.GetObjectFromMultipleWzFilePath(tilePath, Program.WzMan.WzFileListReadOnly); if (!tileSet.Parsed) { tileSet.ParseImage(); } foreach (WzSubProperty tile in ((WzSubProperty)((WzSubProperty)img[i.ToString()])["tile"]).WzProperties) { //WzSubProperty tile = (WzSubProperty)te.ExtendedProperty; int x = ((WzIntProperty)tile["x"]).Value + center.X; int y = ((WzIntProperty)tile["y"]).Value + center.Y; string tilePackName = ((WzStringProperty)tile["u"]).Value; string tileID = ((WzIntProperty)tile["no"]).Value.ToString(); Point origin = new Point(((WzVectorProperty)((WzCanvasProperty)((WzSubProperty)tileSet[tilePackName])[tileID])["origin"]).X.Value, ((WzVectorProperty)((WzCanvasProperty)((WzSubProperty)tileSet[tilePackName])[tileID])["origin"]).Y.Value); tileBuf.DrawImage(((WzCanvasProperty)((WzSubProperty)tileSet[tilePackName])[tileID]).PngProperty.GetPNG(false), x - origin.X, y - origin.Y); } } } tileRender.Save("Renders\\" + img.Name.Substring(0, img.Name.Length - 4) + "\\" + img.Name.Substring(0, img.Name.Length - 4) + "_tileRender.bmp"); Bitmap fullBmp = new Bitmap(bmpSize.Width, bmpSize.Height + 10); using (Graphics fullBuf = Graphics.FromImage(fullBmp)) { fullBuf.FillRectangle(new SolidBrush(Color.CornflowerBlue), 0, 0, bmpSize.Width, bmpSize.Height + 10); fullBuf.DrawImage(tileRender, 0, 0); fullBuf.DrawImage(mapRender, 0, 0); } //pbx_Foothold_Render.Image = fullBmp; fullBmp.Save("Renders\\" + img.Name.Substring(0, img.Name.Length - 4) + "\\" + img.Name.Substring(0, img.Name.Length - 4) + "_fullRender.bmp"); DisplayMap showMap = new DisplayMap(); showMap.map = fullBmp; showMap.Footholds = FHs; showMap.thePortals = Ps; showMap.settings = settings; showMap.MobSpawnPoints = MSPs; showMap.FormClosed += new FormClosedEventHandler(DisplayMapClosed); try { showMap.scale = zoom; showMap.Show(); } catch (FormatException) { MessageBox.Show("You must set the render scale to a valid number.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }