/*private void browseBtn_Click(object sender, EventArgs e) { FolderBrowserDialog fldrBrowse = new FolderBrowserDialog(); fldrBrowse.Description = "Browse to your MapleStory folder"; if (fldrBrowse.ShowDialog() != DialogResult.OK) return; textDir.Text = fldrBrowse.SelectedPath + "\\EdittedWZ"; }*/ private void saveButton_Click(object sender, EventArgs e) { if (Program.WzManager.getWzPath() != "ERROR") { Form msgbx = new GUI.YesNoBox("Save confirmation", "Are you sure you want to save Map.wz?", "Yes", "No"); //DialogResult msgbx = MessageBox.Show("Are you sure you want to save Map.wz?", "Save confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); //if (msgbx == DialogResult.Yes) if (msgbx.DialogResult == DialogResult.Yes) { progressBar1.Enabled = true; progressBar1.PerformStep(); //10% progressBar1.Refresh(); if (MapEditor.Saver.WriteToMap(multiBoard.SelectedBoard) == "cancel") { progressBar1.Value = progressBar1.Minimum; progressBar1.Refresh(); progressBar1.Update(); return; } if (!Directory.Exists(Program.WzManager.getWzPath() + "\\EdittedWZ")) { DirectoryInfo di = Directory.CreateDirectory(Program.WzManager.getWzPath() + "\\EdittedWZ"); } Program.WzManager.SaveMap(Program.WzManager.getWzPath() + "\\EdittedWZ", multiBoard.SelectedBoard.MapInfo.mapImage, progressBar1); //MessageBox.Show("Save completed!", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); new GUI.InfoMsgBox("Completed", "Save completed!"); } } /*else { MessageBox.Show("Some shiz went down!" ,"FFFFFFFFFFFUUUUUUUUUUUUUU-", MessageBoxButtons.OK, MessageBoxIcon.Error); }*/ }
private void Tabs_PageClosing(TabPages.TabPage page, ref bool cancel) { Form msgbx = new GUI.YesNoBox("Close", "Are you sure you want to close this map?"); // MessageBox.Show("Are you sure you want to close this map?", "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question) if (msgbx.DialogResult != DialogResult.Yes) cancel = true; }
private void layersComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (multiBoard.SelectedBoard == null) return; int oldLayer; if (multiBoard.SelectedBoard.SelectedItems.Count > 0 && LayeredItemsSelected(out oldLayer)) { Form msgbx = new GUI.YesNoBox("Cross-Layer Operation", "Are you sure you want to move these items from layer " + oldLayer.ToString() + " to " + layersComboBox.SelectedIndex.ToString() + "?\r\n"); // MessageBox.Show("Are you sure you want to move these items from layer " + oldLayer.ToString() + " to " + layersComboBox.SelectedIndex.ToString() + "?\r\n", "Cross-Layer Operation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) if (UserSettings.suppressWarnings || msgbx.DialogResult != System.Windows.Forms.DialogResult.Yes) { InputHandler.ClearSelectedItems(multiBoard.SelectedBoard); SetLayer(); return; } Layer targetLayer = multiBoard.SelectedBoard.Layers[layersComboBox.SelectedIndex]; if (!LayerCapableOfHoldingSelectedItems(targetLayer)) { //MessageBox.Show("Error: Target layer cannot hold the selected items because they contain tiles with a tS different from the layer's", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); new GUI.ErrorBox("Target layer cannot hold the selected items because they contain tiles with a tile source different from the layer's."); return; } List<IContainsLayerInfo> items = new List<IContainsLayerInfo>(); foreach (BoardItem item in multiBoard.SelectedBoard.SelectedItems) { if (!(item is IContainsLayerInfo)) continue; ((IContainsLayerInfo)item).LayerNumber = targetLayer.LayerNumber; items.Add((IContainsLayerInfo)item); } if (items.Count > 0) multiBoard.SelectedBoard.UndoRedoMan.AddUndoBatch(new List<UndoRedoAction>() { UndoRedoManager.ItemsLayerChanged(items, oldLayer, targetLayer.LayerNumber) }); multiBoard.SelectedBoard.Layers[oldLayer].RecheckTileSet(); targetLayer.RecheckTileSet(); } SetLayer(); multiBoard.RenderFrame(); }
private void Editor_FormClosing(object sender, FormClosingEventArgs e) { Form msgbox = new GUI.YesNoBox("Quit", "Are you sure you want to quit?"); //if (MessageBox.Show("Are you sure you want to quit?", "Quit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (msgbox.DialogResult == DialogResult.Yes) { if (multiBoard.SelectedBoard.Mouse.State != MouseState.Selection) { ApplicationSettings.visibleTypes = prevVisibleTypes; ApplicationSettings.editedTypes = prevEditedTypes; } ApplicationSettings.lastDefaultLayer = multiBoard.SelectedBoard.SelectedLayerIndex; FormClosing -= Editor_FormClosing; Application.Exit(); } else e.Cancel = true; }
/// <summary> /// Overwrites the .img being edited, based on the Map open inside the Board /// </summary> /// <param name="mapBoard">Board containing everything about the map</param> public static string WriteToMap(Board mapBoard) { #region Info if (mapBoard.MapInfo.mapImage["info"] != null) mapBoard.MapInfo.mapImage["info"].Remove(); WzSubProperty info = new WzSubProperty("info"); info.AddProperty(new WzStringProperty("bgm", mapBoard.MapInfo.bgm)); if (mapBoard.MapInfo.MapMark != null) info.AddProperty(new WzStringProperty("mapMark", mapBoard.MapInfo.MapMark)); else info.AddProperty(new WzStringProperty("mapMark", "None")); info.AddProperty(new WzCompressedIntProperty("cloud", (MapleBool)mapBoard.MapInfo.cloud)); info.AddProperty(new WzCompressedIntProperty("version", 10)); info.AddProperty(new WzCompressedIntProperty("town", (MapleBool)mapBoard.MapInfo.town)); info.AddProperty(new WzCompressedIntProperty("returnMap", mapBoard.MapInfo.returnMap)); try { info.AddProperty(new WzByteFloatProperty("mobRate", mapBoard.MapInfo.mobRate)); } catch { info.AddProperty(new WzByteFloatProperty("mobRate", 1.5f)); } info.AddProperty(new WzCompressedIntProperty("swim", (MapleBool)mapBoard.MapInfo.swim)); info.AddProperty(new WzCompressedIntProperty("hideMinimap", (MapleBool)mapBoard.MapInfo.hideMinimap)); try { info.AddProperty(new WzCompressedIntProperty("fieldLimit", Convert.ToInt32(mapBoard.MapInfo.fieldLimit))); } catch { info.AddProperty(new WzCompressedIntProperty("fieldLimit", 0)); } try { info.AddProperty(new WzCompressedIntProperty("forcedReturn", mapBoard.MapInfo.forcedReturn)); } catch { info.AddProperty(new WzCompressedIntProperty("forcedReturn", 999999999)); } info.AddProperty(new WzCompressedIntProperty("VRTop", mapBoard.MapInfo.VR.Value.Y)); info.AddProperty(new WzCompressedIntProperty("VRLeft", mapBoard.MapInfo.VR.Value.X)); info.AddProperty(new WzCompressedIntProperty("VRBottom", mapBoard.MapInfo.VR.Value.Height + mapBoard.MapInfo.VR.Value.Y)); info.AddProperty(new WzCompressedIntProperty("VRRight", mapBoard.MapInfo.VR.Value.Width + mapBoard.MapInfo.VR.Value.X)); mapBoard.MapInfo.mapImage.AddProperty(info); #endregion #region Back if (mapBoard.MapInfo.mapImage["back"] != null) mapBoard.MapInfo.mapImage["back"].Remove(); WzSubProperty back = new WzSubProperty("back"); int backcount = 0; foreach (BackgroundInstance backInst in mapBoard.BoardItems.BackBackgrounds) { WzSubProperty backParent = new WzSubProperty(Convert.ToString(backcount)); backParent.AddProperty(new WzCompressedIntProperty("a", backInst.a)); backParent.AddProperty(new WzCompressedIntProperty("ani", (MapleBool)((BackgroundInfo)backInst.BaseInfo).ani)); backParent.AddProperty(new WzStringProperty("bS", ((BackgroundInfo)backInst.BaseInfo).bS)); backParent.AddProperty(new WzCompressedIntProperty("cx", backInst.cx)); backParent.AddProperty(new WzCompressedIntProperty("cy", backInst.cy)); backParent.AddProperty(new WzCompressedIntProperty("f", (MapleBool)backInst.Flip)); backParent.AddProperty(new WzCompressedIntProperty("front", (MapleBool)backInst.front)); backParent.AddProperty(new WzCompressedIntProperty("no", Convert.ToInt32(((BackgroundInfo)backInst.BaseInfo).no))); backParent.AddProperty(new WzCompressedIntProperty("rx", backInst.rx)); backParent.AddProperty(new WzCompressedIntProperty("ry", backInst.ry)); backParent.AddProperty(new WzCompressedIntProperty("type", Convert.ToInt32(backInst.type))); backParent.AddProperty(new WzCompressedIntProperty("x", backInst.X)); backParent.AddProperty(new WzCompressedIntProperty("y", backInst.Y)); backcount++; back.AddProperty(backParent); } foreach (BackgroundInstance backInst in mapBoard.BoardItems.FrontBackgrounds) { WzSubProperty backParent = new WzSubProperty(Convert.ToString(backcount)); backParent.AddProperty(new WzCompressedIntProperty("a", backInst.a)); backParent.AddProperty(new WzCompressedIntProperty("ani", (MapleBool)((BackgroundInfo)backInst.BaseInfo).ani)); backParent.AddProperty(new WzStringProperty("bS", ((BackgroundInfo)backInst.BaseInfo).bS)); backParent.AddProperty(new WzCompressedIntProperty("cx", backInst.cx)); backParent.AddProperty(new WzCompressedIntProperty("cy", backInst.cy)); backParent.AddProperty(new WzCompressedIntProperty("f", (MapleBool)backInst.Flip)); backParent.AddProperty(new WzCompressedIntProperty("front", (MapleBool)backInst.front)); backParent.AddProperty(new WzCompressedIntProperty("no", Convert.ToInt32(((BackgroundInfo)backInst.BaseInfo).no))); backParent.AddProperty(new WzCompressedIntProperty("rx", backInst.rx)); backParent.AddProperty(new WzCompressedIntProperty("ry", backInst.ry)); backParent.AddProperty(new WzCompressedIntProperty("type", Convert.ToInt32(backInst.type))); backParent.AddProperty(new WzCompressedIntProperty("x", backInst.X)); backParent.AddProperty(new WzCompressedIntProperty("y", backInst.Y)); backcount++; back.AddProperty(backParent); } mapBoard.MapInfo.mapImage.AddProperty(back); #endregion #region Minimap if (mapBoard.MapInfo.mapImage["miniMap"] != null) mapBoard.MapInfo.mapImage["miniMap"].Remove(); WzSubProperty mmSub = new WzSubProperty("miniMap"); WzCanvasProperty canvas = new WzCanvasProperty("canvas"); canvas.PngProperty = new WzPngProperty(); canvas.PngProperty.SetPNG(mapBoard.MiniMap); mmSub.AddProperty(canvas); mmSub.AddProperty(new WzCompressedIntProperty("centerX", mapBoard.CenterPoint.X)); mmSub.AddProperty(new WzCompressedIntProperty("centerY", mapBoard.CenterPoint.Y)); mmSub.AddProperty(new WzCompressedIntProperty("height", mapBoard.MapSize.Y)); mmSub.AddProperty(new WzCompressedIntProperty("width", mapBoard.MapSize.X)); mmSub.AddProperty(new WzCompressedIntProperty("mag", 4)); mapBoard.MapInfo.mapImage.AddProperty(mmSub); #endregion #region ladderRope if (mapBoard.MapInfo.mapImage["ladderRope"] != null) mapBoard.MapInfo.mapImage["ladderRope"].Remove(); WzSubProperty ladderRope = new WzSubProperty("ladderRope"); int ropeCounter = 1; foreach (Rope rope in mapBoard.BoardItems.Ropes) { WzSubProperty ropeParent = new WzSubProperty(Convert.ToString(ropeCounter)); ropeParent.AddProperty(new WzCompressedIntProperty("l", (MapleBool)rope.ladder)); ropeParent.AddProperty(new WzCompressedIntProperty("uf", 1)); ropeParent.AddProperty(new WzCompressedIntProperty("x", rope.FirstAnchor.X)); if (rope.FirstAnchor.Y < rope.SecondAnchor.Y) { ropeParent.AddProperty(new WzCompressedIntProperty("y1", rope.FirstAnchor.Y)); ropeParent.AddProperty(new WzCompressedIntProperty("y2", rope.SecondAnchor.Y)); } else { ropeParent.AddProperty(new WzCompressedIntProperty("y1", rope.SecondAnchor.Y)); ropeParent.AddProperty(new WzCompressedIntProperty("y2", rope.FirstAnchor.Y)); } ropeParent.AddProperty(new WzCompressedIntProperty("page", rope.page)); ropeCounter++; ladderRope.AddProperty(ropeParent); } mapBoard.MapInfo.mapImage.AddProperty(ladderRope); #endregion #region Remove/Re-add obj/tile removeLayerProps(mapBoard.MapInfo.mapImage); #endregion #region TileObj foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs) { IWzImageProperty curTileObj = mapBoard.MapInfo.mapImage[tileObj.LayerNumber.ToString()]; if (objNums[tileObj.LayerNumber] == null) objNums[tileObj.LayerNumber] = 0; if (tileNums[tileObj.LayerNumber] == null) tileNums[tileObj.LayerNumber] = 0; #region Object if (tileObj is ObjectInstance) { String objName = objNums[tileObj.LayerNumber].ToString(); IWzImageProperty curObj = curTileObj["obj"]; AddMapObj((WzSubProperty)curObj, objName, tileObj); objNums[tileObj.LayerNumber] = Convert.ToInt32(objNums[tileObj.LayerNumber]) + 1; } #endregion #region Tile else if (tileObj is TileInstance) { String tileName = tileNums[tileObj.LayerNumber].ToString(); IWzImageProperty curTile = curTileObj["tile"]; AddMapTile((WzSubProperty)curTile, tileName, tileObj); tileNums[tileObj.LayerNumber] = Convert.ToInt32(tileNums[tileObj.LayerNumber]) + 1; } #endregion } #endregion #region Vars if (mapBoard.MapInfo.mapImage["portal"] != null) mapBoard.MapInfo.mapImage["portal"].Remove(); WzSubProperty portal = new WzSubProperty("portal"); int portalCount = 0; if (mapBoard.MapInfo.mapImage["seat"] != null) mapBoard.MapInfo.mapImage["seat"].Remove(); WzSubProperty seatParent = new WzSubProperty("seat"); int seatCounter = 0; if (mapBoard.MapInfo.mapImage["life"] != null) mapBoard.MapInfo.mapImage["life"].Remove(); WzSubProperty lifeParent = new WzSubProperty("life"); int lifeCounter = 0; if (mapBoard.MapInfo.mapImage["reactor"] != null) mapBoard.MapInfo.mapImage["reactor"].Remove(); WzSubProperty reactorParent = new WzSubProperty("reactor"); int reactorCounter = 0; #endregion #region Portal foreach (PortalInstance portall in mapBoard.BoardItems.Portals) { WzSubProperty portalX = new WzSubProperty(Convert.ToString(portalCount)); portalX.AddProperty(new WzStringProperty("pn", portall.pn)); portalX.AddProperty(new WzCompressedIntProperty("pt", Convert.ToInt32(portall.pt))); portalX.AddProperty(new WzCompressedIntProperty("tm", portall.tm)); portalX.AddProperty(new WzStringProperty("tn", portall.tn)); portalX.AddProperty(new WzCompressedIntProperty("x", portall.X)); portalX.AddProperty(new WzCompressedIntProperty("y", portall.Y)); if ((!String.IsNullOrEmpty(portall.script)) || (!String.IsNullOrWhiteSpace(portall.script))) portalX.AddProperty(new WzStringProperty("script", portall.script)); portal.AddProperty(portalX); portalCount++; } #endregion #region Life #region NPCs foreach (LifeInstance npcInst in mapBoard.BoardItems.NPCs) { WzSubProperty life = new WzSubProperty(Convert.ToString(lifeCounter)); life.AddProperty(new WzCompressedIntProperty("cy", npcInst.Y)); life.AddProperty(new WzCompressedIntProperty("y", npcInst.Y)); life.AddProperty(new WzCompressedIntProperty("x", npcInst.X)); /*if (((LifeInstance)obj.obj).baseVar is MobInfo && ((MobInfo)((LifeInstance)obj.obj).baseVar).flying) life.AddProperty(new WzCompressedIntProperty("fh", 0)); else {*/ FootholdLine fhBelow = FootholdLine.findBelow(new Point(npcInst.X, npcInst.Y), mapBoard); if (fhBelow == null) { Form msgBox = new YesNoBox("No foothold detected", "Auto foothold detection error: No foothold found for the NPC (Name: " + ((NpcInfo)npcInst.BaseInfo).Name + ", ID: " + ((NpcInfo)npcInst.BaseInfo).ID + ") at point " + (npcInst.X).ToString() + "," + (npcInst.Y).ToString() + " (Center-related).\r\nPlease make sure that all Life objects (NPCs/Mobs) are right above a foothold!\r\nClick \"Continue\" if you wish to ignore this problem and continue (could cause map to crash)\r\nClick \"Cancel\" if you would like to cancel saving.", "Continue", "Cancel"); if (msgBox.DialogResult != DialogResult.Yes) return "cancel"; } else { life.AddProperty(new WzCompressedIntProperty("fh", fhBelow.num)); } //} /*if (((LifeInstance)obj.obj).baseVar is MobInfo) { life.AddProperty(new WzCompressedIntProperty("mobTime", Convert.ToInt32(((LifeInstance)npcInst.BaseInfo).MobTime))); life.AddProperty(new WzStringProperty("type", "m")); life.AddProperty(new WzStringProperty("id", ((MobInfo)((LifeInstance)obj.obj).baseVar).ID)); } else {*/ life.AddProperty(new WzStringProperty("type", "n")); life.AddProperty(new WzStringProperty("id", ((NpcInfo)npcInst.BaseInfo).ID)); //} life.AddProperty(new WzCompressedIntProperty("rx0", npcInst.rx0)); life.AddProperty(new WzCompressedIntProperty("rx1", npcInst.rx1)); lifeCounter++; lifeParent.AddProperty(life); } #endregion #region Mobs foreach (LifeInstance mobInst in mapBoard.BoardItems.Mobs) { WzSubProperty life = new WzSubProperty(Convert.ToString(lifeCounter)); life.AddProperty(new WzCompressedIntProperty("cy", mobInst.Y)); life.AddProperty(new WzCompressedIntProperty("y", mobInst.Y)); life.AddProperty(new WzCompressedIntProperty("x", mobInst.X)); //if (mobInst.BaseInfo is MobInfo && ((MobInfo)mobInst.BaseInfo)) // life.AddProperty(new WzCompressedIntProperty("fh", 0)); //else //{ FootholdLine fhBelow = FootholdLine.findBelow(new Point(mobInst.X, mobInst.Y), mapBoard); if (fhBelow == null) { Form msgBox = new YesNoBox("No foothold detected", "Auto foothold detection error: No foothold found for the Mob (Name: " + ((MobInfo)mobInst.BaseInfo).Name + ", ID: " + ((MobInfo)mobInst.BaseInfo).ID + ") at point " + (mobInst.X).ToString() + "," + (mobInst.Y).ToString() + " (Center-related).\r\nPlease make sure that all Life objects (NPCs/Mobs) are right above a foothold!\r\nClick \"Continue\" if you wish to ignore this problem and continue (could cause map to crash)\r\nClick \"Cancel\" if you would like to cancel saving.", "Continue", "Cancel"); if (msgBox.DialogResult != DialogResult.Yes) return "cancel"; } life.AddProperty(new WzCompressedIntProperty("fh", fhBelow.fh.num)); //} life.AddProperty(new WzCompressedIntProperty("mobTime", Convert.ToInt32(mobInst.MobTime))); life.AddProperty(new WzStringProperty("type", "m")); life.AddProperty(new WzStringProperty("id", ((MobInfo)mobInst.BaseInfo).ID)); life.AddProperty(new WzCompressedIntProperty("rx0", mobInst.rx0)); life.AddProperty(new WzCompressedIntProperty("rx1", mobInst.rx1)); lifeCounter++; lifeParent.AddProperty(life); } #endregion #endregion #region Reactor foreach (ReactorInstance reactorInst in mapBoard.BoardItems.Reactors) { WzSubProperty reactor = new WzSubProperty(Convert.ToString(reactorCounter)); reactor.AddProperty(new WzCompressedIntProperty("x", reactorInst.X)); reactor.AddProperty(new WzCompressedIntProperty("y", reactorInst.Y)); reactor.AddProperty(new WzCompressedIntProperty("f", 0)); reactor.AddProperty(new WzStringProperty("id", WzInfoTools.AddLeadingZeros(((ReactorInfo)reactorInst.BaseInfo).ID, 7))); reactor.AddProperty(new WzCompressedIntProperty("reactorTime", reactorInst.ReactorTime)); reactor.AddProperty(new WzStringProperty("name", reactorInst.Name)); reactorCounter++; reactorParent.AddProperty(reactor); } #endregion #region Seat/portal check #region Portal check if (portal.WzProperties.Count == 0) { Form msgbox = new GUI.YesNoBox("No portals", "No portals were detected in your map.\r\nMaking a map without at least one \"sp\" portal will cause the game to crash.\r\n\r\nClick \"Continue\" to continue building as-is\r\nClick \"Cancel\" to cancel and go back to the editor", "Continue", "Cancel"); if (msgbox.DialogResult != DialogResult.Yes) return "cancel"; } #endregion #region Seat foreach (Chair seat in mapBoard.BoardItems.Chairs) { seatParent.AddProperty(new WzVectorProperty(Convert.ToString(seatCounter), new WzCompressedIntProperty("X", seat.X), new WzCompressedIntProperty("Y", seat.Y))); seatCounter++; } #endregion #endregion #region Adding P/S/L/R mapBoard.MapInfo.mapImage.AddProperty(portal); mapBoard.MapInfo.mapImage.AddProperty(seatParent); mapBoard.MapInfo.mapImage.AddProperty(lifeParent); mapBoard.MapInfo.mapImage.AddProperty(reactorParent); #endregion #region FootHolds saveFootholds(mapBoard); #endregion return "fine"; }