Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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();
                }
            }
        }