private void mportFromFileToolStripMenuItem_Click(object sender, EventArgs e) { if (load()) { OpenFileDialog open = new OpenFileDialog(); open.Filter = ".img File|*.img"; if (open.ShowDialog() != DialogResult.Cancel) { ImportMap imp = new ImportMap(System.IO.Path.GetFileNameWithoutExtension(open.FileName)); imp.ShowDialog(); if (!imp.Canceled) { File f = new File(open.FileName); IMGFile img = new IMGFile(imp.MapID.Text.PadLeft(9, '0') + ".img", f); WZDirectory dir = file.Directory.GetDirectory("Map/Map" + img.Name[0]); dir.IMGs.Add(img.Name, img); img.Directory = dir; IMGEntry sname = new IMGEntry(int.Parse(imp.MapID.Text).ToString()); sname.SetString("streetName", imp.StreetName.Text); sname.SetString("mapName", imp.MapName.Text); lock (StringLock) { MapEditor.stringf.Directory.GetIMG("Map.img").ToSave = true; MapEditor.stringf.Directory.GetIMG("Map.img").GetChild((string)imp.MapGroup.SelectedItem).Add(sname); } if (Map.Instance != null) { OnMapUnload(); } Map map; lock (MapLock) map = new Map(img); map.map.ToSave = true; UpdateIMGsList(true); this.MapID = img.Name.Substring(0, 9); ZoomLevel = 0; Zoom = 1; SetMapSize((int)(map.Width * Zoom), (int)(map.Height * Zoom)); GraphicPanel.Render(); } } } }
private void New_Click(object sender, EventArgs e) { if (load()) { NewMapWizard wizard = new NewMapWizard(); wizard.ShowDialog(); if (!wizard.Cancel) { int MapID = int.Parse(wizard.MapID.Text); int width = int.Parse(wizard.MapWidth.Text); int height = int.Parse(wizard.MapHeight.Text); int cy = Math.Min(height / 2, 300); int cx = width / 2; IMGFile img = new IMGFile(MapID.ToString().PadLeft(9, '0') + ".img"); IMGEntry info = new IMGEntry("info"); info.SetInt("version", 10); info.SetInt("cloud", 0); info.SetInt("town", wizard.IsTown.Checked ? 1 : 0); info.SetInt("version", wizard.IsTown.Checked ? 1 : 0); info.SetInt("returnMap", wizard.IsReturnMap.Checked ? int.Parse(wizard.ReturnMap.Text) : 999999999); info.SetFloat("mobRate", 1); info.SetString("bgm", ((string)wizard.BGMsList.SelectedItem).Replace(".img", "")); info.SetString("mapDesc", ""); info.SetInt("hideMinimap", 0); info.SetInt("forcedReturn", 999999999); info.SetInt("moveLimit", 0); info.SetString("mapMark", wizard.selectedMark); info.SetInt("fieldLimit", 0); info.SetInt("VRTop", cy - height); info.SetInt("VRLeft", cx - width); info.SetInt("VRBottom", cy); info.SetInt("VRRight", cx); info.SetInt("swim", wizard.IsSwim.Checked ? 1 : 0); img.Add(info); img.Add(MapBackground.Object.GetChild("back").Clone() as IMGEntry); img.Add(new IMGEntry("life")); for (int i = 0; i < 8; i++) { IMGEntry entry = new IMGEntry(i.ToString()); entry.Add(new IMGEntry("info")); entry.Add(new IMGEntry("tile")); entry.Add(new IMGEntry("obj")); img.Add(entry); } img.Add(new IMGEntry("reactor")); img.Add(new IMGEntry("foothold")); if (wizard.IsMiniMap.Checked) { IMGEntry minimap = new IMGEntry("miniMap"); minimap.SetCanvas("canvas", new WZCanvas()); minimap.SetInt("width", width + 100); minimap.SetInt("height", height + 100); minimap.SetInt("centerX", (width - cx) + 50); minimap.SetInt("centerY", (height - cy) + 50); minimap.SetInt("mag", 4); img.Add(minimap); } img.Add(new IMGEntry("portal")); WZDirectory dir = file.Directory.GetDirectory("Map/Map" + img.Name[0]); dir.IMGs.Add(img.Name, img); img.Directory = dir; IMGEntry sname = new IMGEntry(MapID.ToString()); sname.SetString("streetName", wizard.StreetName.Text); sname.SetString("mapName", wizard.MapName.Text); lock (StringLock) { MapEditor.stringf.Directory.GetIMG("Map.img").ToSave = true; MapEditor.stringf.Directory.GetIMG("Map.img").GetChild((string)wizard.MapGroup.SelectedItem).Add(sname); } if (Map.Instance != null) { OnMapUnload(); } Map map; lock(MapLock) map = new Map(img); img.ToSave = true; UpdateIMGsList(true); this.MapID = img.Name.Substring(0, 9); ZoomLevel = 0; Zoom = 1; SetMapSize((int)(map.Width * Zoom), (int)(map.Height * Zoom)); GraphicPanel.Render(); } } }
private void ItemsList_DoubleClick(object sender, EventArgs e) { if (EditMode.Checked && !LinkToFH.Checked) { Point pos = new Point((int)(ShiftX / Zoom), (int)(ShiftY / Zoom)); pos.X += Math.Min(splitContainer1.SplitterDistance, GraphicPanel.Width)/2 - Map.Instance.CenterX; pos.Y += Math.Min(splitContainer1.Height, GraphicPanel.Height) / 2 - Map.Instance.CenterY; if (EditLife.Checked) { string type = (string)IMGsList.SelectedItem; lock ((type == "Npc.wz") ? NpcLock : MobLock) { string id = ((string)ItemsList.SelectedItem).Substring(0, 11); IMGEntry entry = new IMGEntry(); entry.SetString("type", type == "Mob.wz" ? "m" : "n"); entry.SetString("id", id.Substring(0, id.IndexOf(".")).PadLeft(7, '0')); entry.SetInt("x", pos.X); entry.SetInt("y", pos.Y); if (type == "Mob.wz") entry.SetInt("mobTime", 0); entry.SetInt("f", 0); entry.SetInt("hide", 0); entry.SetInt("fh", 0); entry.SetInt("cy", pos.Y); entry.SetInt("rx0", pos.X - 50); entry.SetInt("rx1", pos.X + 50); MapLife l; if (type == "Npc.wz") { l = new MapNPC(); } else { l = new MapMob(); } l.Object = entry; if (l is MapNPC) { IMGFile npc = MapEditor.npc.Directory.GetIMG(l.Object.GetString("id") + ".img"); if (npc.GetChild("info/link") != null) { npc = MapEditor.npc.Directory.GetIMG(npc.GetString("info/link") + ".img"); } l.Image = npc.GetChild("stand/0"); } else { IMGFile mob = MapEditor.mob.Directory.GetIMG(l.Object.GetString("id") + ".img"); if (mob.GetChild("info/link") != null) { mob = MapEditor.mob.Directory.GetIMG(mob.GetString("info/link") + ".img"); } l.Image = mob.GetChild("stand/0"); if (l.Image == null) l.Image = mob.GetChild("fly/0"); } l.Image = Map.GetRealImage(l.Image); Map.Instance.Add(l); undo.Push(new ActionAdd(l)); redo.Clear(); } } else if (EditReactor.Checked) { lock (ReactorLock) { string type = (string)IMGsList.SelectedItem; string id = ((string)ItemsList.SelectedItem).Substring(0, 11); IMGEntry entry = new IMGEntry(); entry.SetString("id", id.Substring(0, id.IndexOf(".")).PadLeft(7, '0')); entry.SetInt("x", pos.X); entry.SetInt("y", pos.Y); entry.SetInt("reactorTime", 0); entry.SetInt("f", 0); entry.SetString("name", ""); MapReactor r = new MapReactor(); r.Object = entry; IMGFile reactor = MapEditor.reactor.Directory.GetIMG(r.Object.GetString("id") + ".img"); if (reactor.GetChild("info/link") != null) { reactor = MapEditor.reactor.Directory.GetIMG(reactor.GetString("info/link") + ".img"); } r.Image = reactor.GetChild("0/0"); r.Image = Map.GetRealImage(r.Image); Map.Instance.Add(r); undo.Push(new ActionAdd(r)); redo.Clear(); } } GraphicPanel.Focus(); } }
private void AddLine_Click(object sender, EventArgs e) { Point pos = new Point((int)(ShiftX / Zoom), (int)(ShiftY / Zoom)); pos.X += Math.Min(splitContainer1.SplitterDistance, GraphicPanel.Width)/2 - Map.Instance.CenterX; pos.Y += Math.Min(splitContainer1.Height, GraphicPanel.Height) / 2 - Map.Instance.CenterY; if (EditFH.Checked) { IMGEntry gentry = new IMGEntry(); gentry.Name = Map.Instance.GenerateFootholdsGroupID().ToString(); IMGEntry entry = new IMGEntry(); entry.Name = Map.Instance.GenerateFootholdID().ToString(); entry.SetInt("x1", pos.X); entry.SetInt("y1", pos.Y); entry.SetInt("x2", pos.X + 20); entry.SetInt("y2", pos.Y); entry.SetInt("prev", 0); entry.SetInt("next", 0); gentry.Add(entry); IMGEntry layer = Map.Instance.map.GetChild("foothold/" + (int)Layer.Value); if(layer == null) { layer = new IMGEntry(); layer.Name = ((int)Layer.Value).ToString(); Map.Instance.map.GetChild("foothold").Add(layer); } layer.Add(gentry); MapFootholds group = new MapFootholds(int.Parse(gentry.Name)); group.Object = gentry; MapFoothold fh = new MapFoothold(int.Parse(entry.Name)); fh.Object = entry; fh.s1 = new MapFootholdSide(); fh.s2 = new MapFootholdSide(); fh.s1.ID = 1; fh.s2.ID = 2; fh.s1.Object = entry; fh.s2.Object = entry; fh.s1.Foothold = fh; fh.s2.Foothold = fh; fh.Group = group; group.footholds.Add(fh.ID, fh); group.ToFix = true; Map.Instance.layers[(int)Layer.Value].footholdGroups.Add(group.ID, group); } if (EditLR.Checked) { IMGEntry entry = new IMGEntry(); entry.SetInt("l", 1); entry.SetInt("uf", 1); entry.SetInt("x", pos.X); entry.SetInt("y1", pos.Y); entry.SetInt("y2", pos.Y + 20); entry.SetInt("page", (int)Layer.Value); MapLR lr = new MapLR(); lr.Object = entry; lr.s1 = new MapLRSide(); lr.s2 = new MapLRSide(); lr.s1.ID = 1; lr.s2.ID = 2; lr.s1.Object = entry; lr.s2.Object = entry; lr.s1.LR = lr; lr.s2.LR = lr; Map.Instance.Add(lr); } else if (EditSeat.Checked) { IMGEntry entry = new IMGEntry(); entry.SetVector(new WZVector(pos.X, pos.Y)); MapSeat seat = new MapSeat(); seat.Object = entry; Map.Instance.Add(seat); undo.Push(new ActionAdd(seat)); redo.Clear(); } else if (EditPortal.Checked) { IMGEntry entry = new IMGEntry(); entry.SetString("pn", "sp"); entry.SetInt("pt", 0); entry.SetInt("x", pos.X); entry.SetInt("y", pos.Y); entry.SetInt("tm", 999999999); entry.SetString("tn", ""); MapPortal portal = new MapPortal(); portal.Object = entry; Map.Instance.Add(portal); undo.Push(new ActionAdd(portal)); redo.Clear(); } else if (EditToolTip.Checked) { IMGEntry entry = new IMGEntry(); entry.SetInt("x1", pos.X); entry.SetInt("y1", pos.Y); entry.SetInt("x2", pos.X + 40); entry.SetInt("y2", pos.Y + 20); MapToolTip tt = new MapToolTip(); tt.Object = entry; tt.c1 = new MapToolTipCorner(); tt.c1.Object = entry; tt.c1.type = MapToolTipCornerType.TopLeft; tt.c1.ToolTip = tt; tt.c2 = new MapToolTipCorner(); tt.c2.Object = entry; tt.c2.type = MapToolTipCornerType.TopRight; tt.c2.ToolTip = tt; tt.c3 = new MapToolTipCorner(); tt.c3.Object = entry; tt.c3.type = MapToolTipCornerType.BottomLeft; tt.c3.ToolTip = tt; tt.c4 = new MapToolTipCorner(); tt.c4.Object = entry; tt.c4.type = MapToolTipCornerType.BottomRight; tt.c4.ToolTip = tt; Map.Instance.Add(tt); lock (StringLock) { IMGEntry ToolTipsStrings = stringf.Directory.GetIMG("ToolTipHelp.img").GetChild("Mapobject").GetChild(int.Parse(MapEditor.Instance.MapID).ToString()); if (ToolTipsStrings == null) { ToolTipsStrings = new IMGEntry(); ToolTipsStrings.Name = int.Parse(MapID).ToString(); stringf.Directory.GetIMG("ToolTipHelp.img").GetChild("Mapobject").Add(ToolTipsStrings); } IMGEntry strings = new IMGEntry(tt.Object.Name); strings.SetString("Title", "Title"); strings.SetString("Desc", "Desc"); ToolTipsStrings.Add(strings); stringf.Directory.GetIMG("ToolTipHelp.img").ToSave = true; tt.Image = strings; } } else if (EditClock.Checked) { if (Map.Instance.clock == null) { IMGEntry entry = new IMGEntry(); entry.SetInt("x", pos.X - 100); entry.SetInt("y", pos.Y - 100); entry.SetInt("width", 200); entry.SetInt("height", 200); MapClock clock = new MapClock(); clock.Object = entry; lock(MapLock) Map.Instance.Add(clock); undo.Push(new ActionAdd(clock)); redo.Clear(); } } }
private void ImageViewer_MouseDoubleClick(object sender, MouseEventArgs e) { lock (MapLock) { if (EditMode.Checked) { Point pos = new Point((int)(ShiftX / Zoom), (int)(ShiftY / Zoom)); pos.X += Math.Min(splitContainer1.SplitterDistance, GraphicPanel.Width) / 2 - Map.Instance.CenterX; pos.Y += Math.Min(splitContainer1.Height, GraphicPanel.Height) / 2 - Map.Instance.CenterY; if (EditTile.Checked) { IMGEntry entry = new IMGEntry(); string tile = m_ActiveImageViewer.Name; IMGFile img = MapEditor.file.Directory.GetIMG("Tile/" + Map.Instance.layers[(int)Layer.Value].info.GetString("tS") + ".img"); if (RandomTiles.Checked) { tile += "/" + random.Next(img.GetChild(tile).childs.Count).ToString(); } entry.SetInt("x", pos.X); entry.SetInt("y", pos.Y); entry.SetString("u", tile.Substring(0, tile.IndexOf("/"))); entry.SetInt("no", int.Parse(tile.Substring(tile.IndexOf("/") + 1))); entry.SetInt("zM", 0); MapTile t = new MapTile(); t.Object = entry; t.Image = img.GetChild(tile); t.CreateFootholdDesignList(); t.SetDesign(entry.GetString("u")); Map.Instance.layers[(int)Layer.Value].Add(t); undo.Push(new ActionAdd(t, (int)Layer.Value)); redo.Clear(); Deselect(); selected.Add(t); t.Selected = true; Map.Instance.layers[(int)Layer.Value].OrderTiles(); } else if (EditObj.Checked) { IMGEntry entry = new IMGEntry(); string img = (string)ObjectsFolders.SelectedItem; string obj = m_ActiveImageViewer.Name; entry.SetString("oS", img.Substring(0, img.IndexOf("."))); entry.SetString("l0", obj.Substring(0, obj.IndexOf("/"))); int f1 = obj.IndexOf("/") + 1; entry.SetString("l1", obj.Substring(f1, obj.IndexOf("/", f1) - f1)); int f2 = obj.IndexOf("/", f1) + 1; entry.SetString("l2", obj.Substring(f2)); entry.SetInt("x", pos.X); entry.SetInt("y", pos.Y); entry.SetInt("z", 0); entry.SetInt("f", 0); entry.SetInt("zM", 0); MapObject o = new MapObject(); o.Object = entry; o.Image = Map.GetRealImage(MapEditor.file.Directory.GetIMG("Obj/" + img).GetChild(obj + "/0")); o.CreateFootholdDesignList(); Map.Instance.layers[(int)Layer.Value].Add(o); undo.Push(new ActionAdd(o, (int)Layer.Value)); redo.Clear(); Deselect(); selected.Add(o); o.Selected = true; } GraphicPanel.Focus(); } } }