public string GetString(string name) { IMGEntry e = GetChild(name); if (e == null) { return(""); } return(e.GetString()); }
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 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(); } } }