private static WZObject ComplexFromEntry(IMGEntry entry) { if (entry.value == null) { if (entry.childs.Count == 0) { return(PropertyFromEntry(entry)); } else { if (entry.childs.Contains("Convex0")) { return(ConvexFromEntry(entry)); } else { return(PropertyFromEntry(entry)); } } } else { switch (entry.value.type) { case WZObjectType.WZ_VECTOR: return(VectorFromEntry(entry)); case WZObjectType.WZ_CANVAS: return(CanvasFromEntry(entry)); case WZObjectType.WZ_SOUND: return(SoundFromEntry(entry)); case WZObjectType.WZ_UOL: return(UOLFromEntry(entry)); } } return(null); }
private static WZObject ObjectFromEntry(IMGEntry entry) { if (entry.value == null) { return(new WZComplex(entry.Name, ComplexFromEntry(entry))); } else { switch (entry.value.type) { case WZObjectType.WZ_EMPTY: return(EmptyFromEntry(entry)); case WZObjectType.WZ_SHORT: return(ShortFromEntry(entry)); case WZObjectType.WZ_INTEGER: return(IntegerFromEntry(entry)); case WZObjectType.WZ_FLOAT: return(FloatFromEntry(entry)); case WZObjectType.WZ_DOUBLE: return(DoubleFromEntry(entry)); case WZObjectType.WZ_STRING: return(StringFromEntry(entry)); case WZObjectType.WZ_VECTOR: case WZObjectType.WZ_CANVAS: case WZObjectType.WZ_SOUND: case WZObjectType.WZ_UOL: return(new WZComplex(entry.Name, ComplexFromEntry(entry))); } } return(null); }
public static void CreateEntry(IMGEntry parent, WZObject obj) { switch (obj.type) { case WZObject.WZObjectType.WZ_EMPTY: CreateEntry(parent, (WZEmpty)obj); break; case WZObject.WZObjectType.WZ_SHORT: CreateEntry(parent, (WZShort)obj); break; case WZObject.WZObjectType.WZ_INTEGER: CreateEntry(parent, (WZInteger)obj); break; case WZObject.WZObjectType.WZ_FLOAT: CreateEntry(parent, (WZFloat)obj); break; case WZObject.WZObjectType.WZ_DOUBLE: CreateEntry(parent, (WZDouble)obj); break; case WZObject.WZObjectType.WZ_STRING: CreateEntry(parent, (WZString)obj); break; case WZObject.WZObjectType.WZ_COMPLEX: CreateEntry(parent, (WZComplex)obj); break; case WZObject.WZObjectType.WZ_PROPERTY: CreateEntry(parent, (WZProperty)obj); break; case WZObject.WZObjectType.WZ_CONVEX: CreateEntry(parent, (WZConvex)obj); break; case WZObject.WZObjectType.WZ_VECTOR: CreateEntry(parent, (WZVector)obj); break; case WZObject.WZObjectType.WZ_CANVAS: CreateEntry(parent, (WZCanvas)obj); break; case WZObject.WZObjectType.WZ_UOL: CreateEntry(parent, (WZUOL)obj); break; case WZObject.WZObjectType.WZ_SOUND: CreateEntry(parent, (WZSound)obj); break; } }
public MaplePyhsics(IMGEntry physics, int x, int y) { this.physics = physics; this.x = x; this.y = y; new Thread(new ThreadStart(UpdateThread)).Start(); }
private static void CreateEntryChilds(IMGEntry parent, WZObjects obj) { foreach (WZObject o in obj.objects) { IMGEntry e = new IMGEntry(parent); CreateEntry(e, o); parent.Add(e); } }
private static WZProperty PropertyFromEntry(IMGEntry entry) { WZProperty obj = new WZProperty(); for (int i = 0; i < entry.childs.Count; i++) { obj.objects.Add(ObjectFromEntry(entry.childs[i])); } return(obj); }
// TODO Sound public short GetShort(string name) { IMGEntry e = GetChild(name); if (e == null) { return(0); } return(e.GetShort()); }
public double GetDouble(string name) { IMGEntry e = GetChild(name); if (e == null) { return(0); } return(e.GetDouble()); }
public int GetInt(string name) { IMGEntry e = GetChild(name); if (e == null) { return(0); } return(e.GetInt()); }
public string GetString(string name) { IMGEntry e = GetChild(name); if (e == null) { return(""); } return(e.GetString()); }
public float GetFloat(string name) { IMGEntry e = GetChild(name); if (e == null) { return(0); } return(e.GetFloat()); }
public WZCanvas GetCanvas(string name) { IMGEntry e = GetChild(name); if (e == null) { return(null); } return(e.GetCanvas()); }
public WZVector GetVector(string name) { IMGEntry e = GetChild(name); if (e == null) { return(null); } return(e.GetVector()); }
private static WZConvex ConvexFromEntry(IMGEntry entry) { WZConvex obj = new WZConvex(); for (int i = 0; i < entry.childs.Count; i++) { obj.objects.Add(ComplexFromEntry(entry.childs[i])); } return(obj); }
public bool GetBool(string name) { IMGEntry e = GetChild(name); if (e == null) { return(false); } return(e.GetBool()); }
public object Clone() { IMGEntry entry = new IMGEntry(Name, (value == null) ? null : value.Clone() as WZObject); foreach (IMGEntry subentry in childs.Values) { entry.Add(subentry.Clone() as IMGEntry); } return(entry); }
private static bool IsPadded(IMGEntry entry, int startID) { for (int i = startID; i < entry.childs.Count + startID; i++) { if (!entry.childs.Contains(i.ToString())) { return false; } } return true; }
private static WZCanvas CanvasFromEntry(IMGEntry entry) { WZCanvas c = (WZCanvas)entry.value; WZCanvas obj = new WZCanvas(c.file, c.width, c.height, c.size, c.offset, c.format); obj.SetBitmap(c.GetBitmap()); for (int i = 0; i < entry.childs.Count; i++) { obj.objects.Add(ObjectFromEntry(entry.childs[i])); } return(obj); }
private static void CreateEntry(IMGEntry parent, WZConvex obj) { int i = 0; foreach (WZObject o in obj.objects) { IMGEntry e = new IMGEntry(parent); CreateEntry(e, o); e.Name = "Convex" + (i++).ToString(); parent.Add(e); } }
public void SetFloat(string name, float set) { IMGEntry e = GetChild(name); if (e == null && name.IndexOf("/") == -1) { e = new IMGEntry(this); e.Name = name; e.value = new WZFloat(set); Add(e); } else if (e != null) { e.SetFloat(set); } }
public void SetCanvas(string name, WZCanvas set) { IMGEntry e = GetChild(name); if (e == null && name.IndexOf("/") == -1) { e = new IMGEntry(this); e.Name = name; e.value = set; Add(e); } else if (e != null) { e.SetCanvas(set); } }
public static void Pad(IMGEntry entry, MapItem[] items, int startID) { while (!IsPadded(entry, startID)) { foreach (IMGEntry e in entry.childs.Values) { int ID = int.Parse(e.Name); if (ID > startID) { if (!entry.childs.Contains((ID - 1).ToString())) { e.Rename((ID - 1).ToString()); break; } } } } UpdateMapItems(items); }
private static WZObject ObjectFromEntry(IMGEntry entry) { if (entry.value == null) { return new WZComplex(entry.Name, ComplexFromEntry(entry)); } else { switch (entry.value.type) { case WZObjectType.WZ_EMPTY: return EmptyFromEntry(entry); case WZObjectType.WZ_SHORT: return ShortFromEntry(entry); case WZObjectType.WZ_INTEGER: return IntegerFromEntry(entry); case WZObjectType.WZ_FLOAT: return FloatFromEntry(entry); case WZObjectType.WZ_DOUBLE: return DoubleFromEntry(entry); case WZObjectType.WZ_STRING: return StringFromEntry(entry); case WZObjectType.WZ_VECTOR: case WZObjectType.WZ_CANVAS: case WZObjectType.WZ_SOUND: case WZObjectType.WZ_UOL: return new WZComplex(entry.Name, ComplexFromEntry(entry)); } } return null; }
private static void CreateEntry(IMGEntry parent, WZComplex obj) { parent.Name = obj.name; CreateEntry(parent, obj.value); }
public IMGEntry(IMGEntry parent, string Name, WZObject value) { this.parent = parent; this.Name = Name; this.value = value; }
private static void CreateEntry(IMGEntry parent, WZEmpty obj) { parent.Name = obj.name; parent.value = new WZEmpty(); }
private static void CreateEntry(IMGEntry parent, WZDouble obj) { parent.Name = obj.name; parent.value = new WZDouble(obj.value); }
private void CreateSeat(MapSeatDesign seatd) { IMGEntry entry = new IMGEntry(); entry.SetVector(new WZVector(seatd.GetX() - Map.Instance.CenterX, seatd.GetY() - Map.Instance.CenterY)); MapSeat seat = new MapSeat(); seat.Object = entry; Map.Instance.Add(seat); }
private void CreateLRs(List<MapLRDesign> LRCreating) { if (LRCreating[0].GetY() > LRCreating[1].GetY()) { LRCreating.Reverse(); } IMGEntry entry = new IMGEntry(); entry.SetInt("l", LRCreating[0].ladder ? 1 : 0); entry.SetInt("uf", 1); entry.SetInt("x", LRCreating[0].GetX() - Map.Instance.CenterX); entry.SetInt("y1", LRCreating[0].GetY() - Map.Instance.CenterY); entry.SetInt("y2", LRCreating[1].GetY() - Map.Instance.CenterY); 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); }
private static WZString StringFromEntry(IMGEntry entry) { return new WZString(entry.Name, ((WZString)entry.value).value); }
public GetMapInfo(IMGEntry info) { InitializeComponent(); List<string> MusicNames = new List<string>(); lock (MapEditor.SoundLock) { foreach (IMGFile bgms in MapEditor.sound.Directory.IMGs.Values) { if (bgms.Name.Substring(0, 3) == "Bgm") { foreach (IMGEntry sound in bgms.childs.Values) { MusicNames.Add(bgms.Name + "/" + sound.Name); } } } } MusicNames.Sort(); BGMsList.Items.AddRange(MusicNames.ToArray()); BGMsList.SelectedItem = info.GetString("bgm").Replace("/", ".img/"); int returnMap = info.GetInt("returnMap"); if (returnMap == 999999999) { IsReturnMap.Checked = true; ReturnMap.Enabled = false; } else { IsReturnMap.Checked = false; ReturnMap.Enabled = true; } ReturnMap.Text = returnMap.ToString(); IsTown.Checked = info.GetInt("town") == 1; IsSwim.Checked = info.GetInt("swim") == 1; IsMiniMap.Checked = info.parent.GetChild("miniMap") != null; selectedMark = info.GetString("mapMark"); MarkPreview.Image = MapMarkSelect.GetMark(selectedMark); Bitmap background = new Bitmap(800, 600); using (Graphics g = Graphics.FromImage(background)) { foreach (MapBack b in Map.Instance.backs) { b.Draw(g); } } Bitmap thumb = new Bitmap(160, 120); using (Graphics g = Graphics.FromImage(thumb)) { g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(background, 0, 0, 160, 120); g.Dispose(); } BackgroundPreview.Image = thumb; }
private static WZUOL UOLFromEntry(IMGEntry entry) { WZUOL u = (WZUOL)entry.value; return new WZUOL(u.path); }
public static WZProperty FromEntry(IMGEntry entry) { return PropertyFromEntry(entry); }
private static WZSound SoundFromEntry(IMGEntry entry) { return new WZSound(); }
private static WZCanvas CanvasFromEntry(IMGEntry entry) { WZCanvas c = (WZCanvas)entry.value; WZCanvas obj = new WZCanvas(c.file, c.width, c.height, c.size, c.offset, c.format); obj.SetBitmap(c.GetBitmap()); for (int i = 0; i < entry.childs.Count; i++) { obj.objects.Add(ObjectFromEntry(entry.childs[i])); } return obj; }
private static WZVector VectorFromEntry(IMGEntry entry) { WZVector v = (WZVector)entry.value; return new WZVector(v.x, v.y); }
private static void CreateEntry(IMGEntry parent, WZCanvas obj) { parent.value = new WZCanvas(obj.file, obj.width, obj.height, obj.size, obj.offset, obj.format); CreateEntryChilds(parent, obj); }
private static WZObject ComplexFromEntry(IMGEntry entry) { if (entry.value == null) { if (entry.childs.Count == 0) { return PropertyFromEntry(entry); } else { if (entry.childs.Contains("Convex0")) { return ConvexFromEntry(entry); } else { return PropertyFromEntry(entry); } } } else { switch (entry.value.type) { case WZObjectType.WZ_VECTOR: return VectorFromEntry(entry); case WZObjectType.WZ_CANVAS: return CanvasFromEntry(entry); case WZObjectType.WZ_SOUND: return SoundFromEntry(entry); case WZObjectType.WZ_UOL: return UOLFromEntry(entry); } } return null; }
private static void CreateEntry(IMGEntry parent, WZSound obj) { parent.value = new WZSound(obj.file, obj.offset, obj.size, obj.bytesSize, obj.bytesSize); }
private static WZDouble DoubleFromEntry(IMGEntry entry) { return new WZDouble(entry.Name, ((WZDouble)entry.value).value); }
private static WZConvex ConvexFromEntry(IMGEntry entry) { WZConvex obj = new WZConvex(); for (int i = 0; i < entry.childs.Count; i++) { obj.objects.Add(ComplexFromEntry(entry.childs[i])); } return obj; }
private static WZFloat FloatFromEntry(IMGEntry entry) { return new WZFloat(entry.Name, ((WZFloat)entry.value).value); }
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(); } } }
private static WZInteger IntegerFromEntry(IMGEntry entry) { return new WZInteger(entry.Name, ((WZInteger)entry.value).value); }
private MapFootholds CreateFootholds(List<List<MapFootholdDesign>> footholdslist) { IMGEntry gentry = new IMGEntry(); gentry.Name = Map.Instance.GenerateFootholdsGroupID().ToString(); 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; Map.Instance.layers[(int)Layer.Value].footholdGroups.Add(group.ID, group); foreach (List<MapFootholdDesign> footholds in footholdslist) { List<IMGEntry> fhs = new List<IMGEntry>(); for (int i = 0; i < footholds.Count - 1; i++) { IMGEntry entry = new IMGEntry(); entry.Name = Map.Instance.GenerateFootholdID().ToString(); entry.SetInt("x1", footholds[i].GetX() - Map.Instance.CenterX); entry.SetInt("y1", footholds[i].GetY() - Map.Instance.CenterY); entry.SetInt("x2", footholds[i + 1].GetX() - Map.Instance.CenterX); entry.SetInt("y2", footholds[i + 1].GetY() - Map.Instance.CenterY); if (i == 0) { entry.SetInt("prev", 0); } else { entry.SetInt("prev", int.Parse(fhs[i - 1].Name)); fhs[i - 1].SetInt("next", int.Parse(entry.Name)); } entry.SetInt("next", 0); gentry.Add(entry); 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); fhs.Add(entry); } } return group; }
private static WZShort ShortFromEntry(IMGEntry entry) { return new WZShort(entry.Name, ((WZShort)entry.value).value); }
private static void CreateEntry(IMGEntry parent, WZInteger obj) { parent.Name = obj.name; parent.value = new WZInteger(obj.value); }
private static WZEmpty EmptyFromEntry(IMGEntry entry) { return new WZEmpty(entry.Name); }
private static void CreateEntry(IMGEntry parent, WZString obj) { parent.Name = obj.name; parent.value = new WZString(obj.value); }
private void GraphicPanel_OnMouseDoubleClick(object sender, MouseEventArgs e) { if (EditFH.Checked && !FootholdsCreator.Checked) { if (selected.Count == 1) { MapFootholdSide fh = (MapFootholdSide)selected[0]; IMGEntry entry = new IMGEntry(); entry.Name = Map.Instance.GenerateFootholdID().ToString(); if(fh.ID == 1) { entry.SetInt("x1", fh.Object.GetInt("x1") - 20); entry.SetInt("y1", fh.Object.GetInt("y1")); entry.SetInt("x2", fh.Object.GetInt("x1")); entry.SetInt("y2", fh.Object.GetInt("y1")); entry.SetInt("prev", 0); entry.SetInt("next", fh.Foothold.ID); } else if (fh.ID == 2) { entry.SetInt("x1", fh.Object.GetInt("x2")); entry.SetInt("y1", fh.Object.GetInt("y2")); entry.SetInt("x2", fh.Object.GetInt("x2") + 20); entry.SetInt("y2", fh.Object.GetInt("y2")); entry.SetInt("prev", fh.Foothold.ID); entry.SetInt("next", 0); } fh.Foothold.Group.Object.Add(entry); MapFoothold nFH = new MapFoothold(int.Parse(entry.Name)); nFH.Object = entry; nFH.s1 = new MapFootholdSide(); nFH.s2 = new MapFootholdSide(); nFH.s1.ID = 1; nFH.s2.ID = 2; nFH.s1.Object = entry; nFH.s2.Object = entry; nFH.s1.Foothold = nFH; nFH.s2.Foothold = nFH; nFH.Group = fh.Foothold.Group; fh.Foothold.Group.footholds.Add(nFH.ID, nFH); if (fh.ID == 1) { fh.Object.SetInt("prev", nFH.ID); selected.Add(nFH.s2); nFH.s2.Selected = true; } else { fh.Object.SetInt("next", nFH.ID); selected.Add(nFH.s1); nFH.s1.Selected = true; } } else if (selected.Count == 0) { MapFoothold fh = Map.Instance.layers[(int)Layer.Value].GetFootholdAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (fh != null) { MapFoothold next = (MapFoothold)fh.Group.footholds[fh.Object.GetInt("next")]; IMGEntry entry = new IMGEntry(); entry.Name = Map.Instance.GenerateFootholdID().ToString(); entry.SetInt("x1", e.X - Map.Instance.CenterX); entry.SetInt("y1", e.Y - Map.Instance.CenterY); entry.SetInt("x2", fh.Object.GetInt("x2")); entry.SetInt("y2", fh.Object.GetInt("y2")); entry.SetInt("prev", fh.ID); entry.SetInt("next", (next == null) ? 0 : next.ID); fh.Object.SetInt("x2", e.X - Map.Instance.CenterX); fh.Object.SetInt("y2", e.Y - Map.Instance.CenterY); fh.Object.SetInt("next", int.Parse(entry.Name)); if(next != null) next.Object.SetInt("prev", int.Parse(entry.Name)); fh.Group.Object.Add(entry); MapFoothold nFH = new MapFoothold(int.Parse(entry.Name)); nFH.Object = entry; nFH.s1 = new MapFootholdSide(); nFH.s2 = new MapFootholdSide(); nFH.s1.ID = 1; nFH.s2.ID = 2; nFH.s1.Object = entry; nFH.s2.Object = entry; nFH.s1.Foothold = nFH; nFH.s2.Foothold = nFH; nFH.Group = fh.Group; fh.Group.footholds.Add(nFH.ID, nFH); selected.Add(nFH.s1); selected.Add(fh.s2); nFH.s1.Selected = true; fh.s2.Selected = true; } } } else if (EditLife.Checked && selected.Count > 0) { int value = -1; foreach(MapLife life in selected) { if (life is MapMob) { int mobTime = life.Object.GetInt("mobTime"); if (value != -1 && value != mobTime) { value = -1; break; } if (value == -1) { value = mobTime; } } } if (value != -1) { GetRespawnTime t = new GetRespawnTime(value); t.ShowDialog(); value = int.Parse(t.RespawnTime.Text); foreach (MapLife life in selected) { if (life is MapMob) { life.Object.SetInt("mobTime", value); } } } } else if (EditReactor.Checked && selected.Count > 0) { MapReactor reactor = (MapReactor)Map.Instance.layers[(int)Layer.Value].GetItemAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (reactor != null) { GetReactorInfo t = new GetReactorInfo(reactor.Object.GetString("name"), reactor.Object.GetInt("reactorTime")); t.ShowDialog(); reactor.Object.SetString("name", t.RName.Text); reactor.Object.SetInt("reactorTime", int.Parse(t.RespawnTime.Text)); } } else if (EditLR.Checked && !FootholdsCreator.Checked) { MapLR lr = null; if (selected.Count > 0) { lr = ((MapLRSide)selected[0]).LR; } else { lr = Map.Instance.layers[(int)Layer.Value].GetLRAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); } if (lr != null) { GetLRType t = new GetLRType(lr.Object.GetInt("l")); t.ShowDialog(); lr.Object.SetInt("l", t.Type.SelectedIndex); } } else if (EditPortal.Checked) { MapPortal portal = Map.Instance.GetItemAt((int)(e.X / Zoom), (int)(e.Y / Zoom)) as MapPortal; if (portal != null) { GetPortalInfo t = new GetPortalInfo(portal.Object.GetInt("pt"), portal.Object.GetString("pn"), portal.Object.GetInt("tm"), portal.Object.GetString("tn")); t.ShowDialog(); int type = t.PortalType.SelectedIndex; switch (type) { case 4: type = 10; break; } portal.Object.SetInt("pt", type); if (type == 0) { portal.Object.SetString("pn", "sp"); portal.Object.SetInt("tm", 999999999); portal.Object.SetString("tn", ""); } else if (type == 1) { portal.Object.SetString("pn", t.PortalName.Text); if (t.IsTeleport.Checked) { if (t.ThisMap.Checked) { portal.Object.SetInt("tm", int.Parse(MapID)); } else { portal.Object.SetInt("tm", int.Parse(t.ToMap.Text)); } portal.Object.SetString("tn", t.ToName.Text); } else { portal.Object.SetInt("tm", 999999999); portal.Object.SetString("tn", ""); } } else if (type == 2) { portal.Object.SetString("pn", t.PortalName.Text); portal.Object.SetInt("tm", int.Parse(t.ToMap.Text)); portal.Object.SetString("tn", t.ToName.Text); } else if (type == 10 || type == 3) { portal.Object.SetString("pn", t.PortalName.Text); if (t.ThisMap.Checked) { portal.Object.SetInt("tm", int.Parse(MapID)); } else { portal.Object.SetInt("tm", int.Parse(t.ToMap.Text)); } portal.Object.SetString("tn", t.ToName.Text); } } } else if (EditToolTip.Checked) { MapItem item = Map.Instance.GetItemAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (item != null) { MapToolTip tt; if (item is MapToolTipCorner) { tt = (item as MapToolTipCorner).ToolTip; } else { tt = item as MapToolTip; } GetToolTipInfo info = new GetToolTipInfo(tt.Image.GetString("Title"), tt.Image.GetString("Desc")); info.ShowDialog(); tt.Image.SetString("Title", info.Title.Text); if (info.Desc.Text == "") { tt.Image.childs.Remove("Desc"); } else { tt.Image.SetString("Desc", info.Desc.Text); } tt.Image.parent.parent.parent.ToSave = true; } } }
private static void CreateEntry(IMGEntry parent, WZProperty obj) { CreateEntryChilds(parent, obj); }
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 static void CreateEntry(IMGEntry parent, WZVector obj) { parent.value = new WZVector(obj.x, obj.y); }
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 static void CreateEntry(IMGEntry parent, WZUOL obj) { parent.value = new WZUOL(obj.path); }
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 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 button1_Click(object sender, EventArgs e) { OpenFileDialog ofdOpen = new OpenFileDialog(); ofdOpen.Filter = "Mark|*.png"; if (ofdOpen.ShowDialog() != DialogResult.Cancel) { string FileName = ofdOpen.FileName; string ImageName = Path.GetFileNameWithoutExtension(FileName); foreach(ImageViewer iv in Panel.Controls) { if (iv.Name == ImageName) { Error.Text = "Error: There is already a mark with this name."; return; } } Image i = Bitmap.FromFile(FileName); if (i.Width > 38 || i.Height > 38) { Error.Text = "Error: The size of the image must not be larger than 38x38"; return; } IMGEntry marks = MapEditor.file.Directory.GetIMG("MapHelper.img").GetChild("mark"); IMGEntry entry = new IMGEntry(); WZCanvas c = new WZCanvas(); c.SetBitmap((Bitmap)i); c.format = WZCanvas.ImageFormat.FORMAT_4444; entry.SetCanvas(c); entry.Name = ImageName; marks.Add(entry); marks.parent.ToSave = true; Error.Text = ""; ImageViewer imageViewer = new ImageViewer(); imageViewer.Dock = DockStyle.Bottom; imageViewer.Image = c.GetBitmap(); imageViewer.Width = c.GetBitmap().Width + 6; imageViewer.Height = c.GetBitmap().Height + 6; imageViewer.Name = entry.Name; imageViewer.MouseClick += new MouseEventHandler(ImageViewer_MouseClick); imageViewer.MouseDoubleClick += new MouseEventHandler(ImageViewer_MouseDoubleClick); imageViewer.IsThumbnail = false; Panel.Controls.Add(imageViewer); } }
private static WZProperty PropertyFromEntry(IMGEntry entry) { WZProperty obj = new WZProperty(); for (int i = 0; i < entry.childs.Count; i++) { obj.objects.Add(ObjectFromEntry(entry.childs[i])); } return obj; }