예제 #1
0
        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();
                    }

                }

            }
        }
예제 #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();
                }
            }
        }
예제 #3
0
        private void openMapLoginimgToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (load())
            {
                if (Map.Instance != null)
                {
                    OnMapUnload();

                }
                Map map;
                lock(UILock)
                    map = new Map(ui.Directory.GetIMG("MapLogin.img"));

                map.map.ToSave = true;

                UpdateIMGsList(true);

                MapID = "MapLogin.img";

                EditBack.Enabled = true;

                ZoomLevel = 0;
                Zoom = 1;

                SetMapSize((int)(map.Width * Zoom), (int)(map.Height * Zoom));

                GraphicPanel.Render();
            }
        }
예제 #4
0
        private void Open_Click(object sender, EventArgs e)
        {
            if (load())
            {
                MapSelect select = new MapSelect();
                select.ShowDialog();

                if (select.Result == "")
                {
                    return;
                }
                if (Map.Instance != null)
                {
                    OnMapUnload();
                }

                MapID = select.Result.Substring(9, 9);
                Map map;
                lock(MapLock)
                    map = new Map(file.Directory.GetIMG(select.Result));

                map.map.ToSave = true;

                UpdateIMGsList(true);

                ZoomLevel = 0;
                Zoom = 1;

                SetMapSize((int)(map.Width * Zoom), (int)(map.Height * Zoom));

                GraphicPanel.Render();
            }
        }
예제 #5
0
파일: Map.cs 프로젝트: smolson4/wzmapeditor
        public Map(IMGEntry map)
        {
            Instance = this;

            MapEditor.Instance.EditBack.Enabled = false;

            this.map = map;

            IMGEntry Info = map.GetChild("info");
            IMGEntry MiniMap = map.GetChild("miniMap");
            if (Info.GetChild("VRTop") != null)
            {
                VRLeft = Info.GetInt("VRLeft");
                VRTop = Info.GetInt("VRTop");
                VRRight = Info.GetInt("VRRight");
                VRBottom = Info.GetInt("VRBottom");
            }
            if (MiniMap == null)
            {
                if (VRTop == 0) throw new Exception("Unhandled Map");
                CenterX = -VRLeft + 50;
                CenterY = -VRTop + 50;
                Width = VRRight + CenterX + 100;
                Height = VRBottom + CenterY + 100;
            }
            else
            {
                CenterX = MiniMap.GetInt("centerX");
                CenterY = MiniMap.GetInt("centerY");
                Width = MiniMap.GetInt("width");
                Height = MiniMap.GetInt("height");
                if (VRTop == 0)
                {
                    VRLeft = -CenterX + 69;
                    VRTop = -CenterY + 86;
                    VRRight = Width - CenterX - 69;
                    VRBottom = Height - CenterY - 86;
                }
            }

            fly = Info.GetBool("swim") ? -1 : 1;

            int maxX = Int32.MinValue;
            int maxY = Int32.MinValue;
            int minX = Int32.MaxValue;
            int minY = Int32.MaxValue;

            for (int i = 0; i < 8; i++)
            {
                MapLayer layer = new MapLayer();

                IMGEntry layerEntry = map.GetChild(i.ToString());

                layer.layer = layerEntry;
                layer.info = layerEntry.GetChild("info");
                layer.ID = i;

                IMGEntry objects = layerEntry.GetChild("obj");
                foreach (IMGEntry o in objects.childs.Values)
                {
                    MapObject mo = new MapObject();

                    mo.Object = o;
                    mo.Image = GetRealImage(MapEditor.file.Directory.GetIMG("Obj/" + o.GetString("oS") + ".img").GetChild(o.GetString("l0") + "/" + o.GetString("l1") + "/" + o.GetString("l2") + "/0"));
                    mo.ID = int.Parse(o.Name);

                    mo.CreateFootholdDesignList();

                    footholdsGroups.Add(o.GetInt("zM"));

                    layer.objects.Add(mo);
                }

                layer.objects.Sort(CompareItems);

                layer.OrderObjects();

                IMGEntry tiles = layerEntry.GetChild("tile");
                foreach (IMGEntry t in tiles.childs.Values)
                {
                    MapTile mt = new MapTile();

                    mt.Object = t;
                    mt.Image = MapEditor.file.Directory.GetIMG("Tile/" + layer.info.GetString("tS") + ".img").GetChild(t.GetString("u") + "/" + t.GetInt("no").ToString());
                    //mt.Image = MapEditor.file.Directory.GetIMG("Tile/blackTile.img").GetChild(t.GetString("u") + "/0");
                    mt.ID = int.Parse(t.Name);

                    mt.SetDesign(t.GetString("u"));

                    mt.CreateFootholdDesignList();

                    footholdsGroups.Add(t.GetInt("zM"));

                    layer.tiles.Add(mt);
                }

                layer.tiles.Sort(CompareItems);

                layer.OrderTiles();

                IMGEntry footholds = map.GetChild("foothold/" + i.ToString());
                if (footholds != null)
                {
                    foreach (IMGEntry group in footholds.childs.Values)
                    {
                        //if (group.Name != "3") continue;
                        MapFootholds f = new MapFootholds(int.Parse(group.Name));

                        f.Object = group;

                        layer.footholdGroups.Add(f.ID, f);

                        foreach (IMGEntry fhe in group.childs.Values)
                        {
                            MapFoothold fh = new MapFoothold(int.Parse(fhe.Name));

                            fh.Object = fhe;
                            fh.Group = f;
                            fh.s1 = new MapFootholdSide();
                            fh.s2 = new MapFootholdSide();
                            fh.s1.Object = fhe;
                            fh.s2.Object = fhe;
                            fh.s1.ID = 1;
                            fh.s2.ID = 2;
                            fh.s1.Foothold = fh;
                            fh.s2.Foothold = fh;

                            if (fhe.GetInt("x1") < minX) minX = fhe.GetInt("x1");
                            if (fhe.GetInt("y1") < minY) minY = fhe.GetInt("y1");
                            if (fhe.GetInt("x2") < minX) minX = fhe.GetInt("x2");
                            if (fhe.GetInt("y2") < minY) minY = fhe.GetInt("y2");
                            if (fhe.GetInt("x1") > maxX) maxX = fhe.GetInt("x1");
                            if (fhe.GetInt("y1") > maxY) maxY = fhe.GetInt("y1");
                            if (fhe.GetInt("x2") > maxX) maxX = fhe.GetInt("x2");
                            if (fhe.GetInt("y2") > maxY) maxY = fhe.GetInt("y2");

                            f.footholds.Add(fh.ID, fh);
                        }
                    }

                }


                layers.Add(layer);
            }
            /*if (VRTop == 0)
            {
                if (maxX != Int32.MinValue)
                {
                    VRLeft = minX + 30;
                    VRRight = maxX - 30;
                    VRTop = minY - 300;
                    VRBottom = maxY + 10;
                }
            }*/
            left = minX + 30;
            right = maxX - 30;
            top = minY - 300;
            bottom = maxY + 10;
            if (Info.GetChild("VRLeft") != null)
            {
                if (left < Info.GetInt("VRLeft") + 20) left = Info.GetInt("VRLeft") + 20;
                if (right > Info.GetInt("VRRight")) right = Info.GetInt("VRRight");
                if (top < Info.GetInt("VRTop") + 65) top = Info.GetInt("VRTop") + 65;
                if (bottom > Info.GetInt("VRBottom")) bottom = Info.GetInt("VRBottom");
            }
            left -= 10;
            right += 10;
            top -= 10;
            bottom += 10;

            IMGEntry back = map.GetChild("back");
            foreach (IMGEntry b in back.childs.Values)
            {
                if (b.GetString("bS") != "")
                {
                    MapBack mb = new MapBack();

                    mb.Object = b;
                    if (b.GetInt("ani") == 0) mb.Image = MapEditor.file.Directory.GetIMG("Back/" + b.GetString("bS") + ".img").GetChild("back/" + b.GetInt("no").ToString());
                    else mb.Image = MapEditor.file.Directory.GetIMG("Back/" + b.GetString("bS") + ".img").GetChild("ani/" + b.GetInt("no").ToString() + "/0");
                    mb.ID = int.Parse(b.Name);

                    if (b.GetInt("ani") == 1) mb.GenerateFrames();

                    backs.Add(mb);
                }
            }

            backs = backs.OrderBy(o => o.ID).ToList<MapBack>();

            IMGEntry elr = map.GetChild("ladderRope");
            if (elr != null)
            {
                foreach (IMGEntry lr in elr.childs.Values)
                {
                    MapLR mlr = new MapLR();

                    mlr.Object = lr;
                    mlr.ID = int.Parse(lr.Name);
                    mlr.s1 = new MapLRSide();
                    mlr.s2 = new MapLRSide();
                    mlr.s1.Object = lr;
                    mlr.s2.Object = lr;
                    mlr.s1.ID = 1;
                    mlr.s2.ID = 2;
                    mlr.s1.LR = mlr;
                    mlr.s2.LR = mlr;

                    lrs.Add(mlr);
                }
            }

            lrs = lrs.OrderBy(l => l.ID).ToList<MapLR>();

            IMGEntry eseats = map.GetChild("seat");
            if (eseats != null)
            {
                foreach (IMGEntry s in eseats.childs.Values)
                {
                    MapSeat ms = new MapSeat();

                    ms.Object = s;
                    ms.ID = int.Parse(s.Name);

                    seats.Add(ms);
                }
            }

            seats = seats.OrderBy(l => l.ID).ToList<MapSeat>();


            IMGEntry eLifes = map.GetChild("life");
            if (eLifes != null)
            {
                foreach (IMGEntry l in eLifes.childs.Values)
                {
                    MapLife ml;
                    if (l.GetString("type") == "n")
                    {
                        ml = new MapNPC();
                    }
                    else
                    {
                        ml = new MapMob();
                    }

                    ml.Object = l;

                    if (ml is MapNPC)
                    {
                        IMGFile npc = MapEditor.npc.Directory.GetIMG(l.GetString("id") + ".img");
                        if (npc.GetChild("info/link") != null)
                        {
                            npc = MapEditor.npc.Directory.GetIMG(npc.GetString("info/link") + ".img");
                        }
                        ml.Image = npc.GetChild("stand/0");

                    }
                    else
                    {
                        IMGFile mob = MapEditor.mob.Directory.GetIMG(l.GetString("id") + ".img");
                        if (mob.GetChild("info/link") != null)
                        {
                            mob = MapEditor.mob.Directory.GetIMG(mob.GetString("info/link") + ".img");
                        }
                        ml.Image = mob.GetChild("stand/0");
                        if (ml.Image == null) ml.Image = mob.GetChild("fly/0");
                    }
                    ml.Image = GetRealImage(ml.Image);
                    ml.ID = int.Parse(l.Name);

                    lifes.Add(ml);
                }
            }

            lifes = lifes.OrderBy(l => l.ID).ToList<MapLife>();

            IMGEntry eReactors = map.GetChild("reactor");
            if (eReactors != null)
            {
                foreach (IMGEntry r in eReactors.childs.Values)
                {
                    MapReactor mr = new MapReactor();
                    mr.Object = r;

                    IMGFile reactor = MapEditor.reactor.Directory.GetIMG(r.GetString("id") + ".img");
                    if (reactor.GetChild("info/link") != null)
                    {
                        reactor = MapEditor.reactor.Directory.GetIMG(reactor.GetString("info/link") + ".img");
                    }
                    mr.Image = reactor.GetChild("0/0");
                    mr.Image = GetRealImage(mr.Image);
                    mr.ID = int.Parse(r.Name);

                    reactors.Add(mr);
                }
            }

            lifes = lifes.OrderBy(l => l.ID).ToList<MapLife>();

            IMGEntry pImage = MapEditor.file.Directory.GetIMG("MapHelper.img").GetChild("portal/game/pv/0");

            IMGEntry ePortals = map.GetChild("portal");
            if (ePortals != null)
            {
                foreach (IMGEntry p in ePortals.childs.Values)
                {
                    MapPortal mp = new MapPortal();

                    mp.Object = p;
                    mp.ID = int.Parse(p.Name);
                    mp.Image = pImage;

                    portals.Add(mp);
                }
            }

            seats = seats.OrderBy(l => l.ID).ToList<MapSeat>();

            IMGEntry tooltipsE = map.GetChild("ToolTip");
            if (tooltipsE != null)
            {
                foreach (IMGEntry tte in tooltipsE.childs.Values)
                {
                    if (tte.Name.Contains("char")) continue;
                    MapToolTip tt = new MapToolTip();

                    tt.Object = tte;
                    tt.ID = int.Parse(tte.Name);
                    tt.Image = MapEditor.stringf.Directory.GetIMG("ToolTipHelp.img").GetChild("Mapobject").GetChild(int.Parse(MapEditor.Instance.MapID).ToString()).GetChild(tte.Name);
                    tt.c1 = new MapToolTipCorner();
                    tt.c1.Object = tte;
                    tt.c1.type = MapToolTipCornerType.TopLeft;
                    tt.c1.ToolTip = tt;
                    tt.c2 = new MapToolTipCorner();
                    tt.c2.Object = tte;
                    tt.c2.type = MapToolTipCornerType.TopRight;
                    tt.c2.ToolTip = tt;
                    tt.c3 = new MapToolTipCorner();
                    tt.c3.Object = tte;
                    tt.c3.type = MapToolTipCornerType.BottomLeft;
                    tt.c3.ToolTip = tt;
                    tt.c4 = new MapToolTipCorner();
                    tt.c4.Object = tte;
                    tt.c4.type = MapToolTipCornerType.BottomRight;
                    tt.c4.ToolTip = tt;

                    tooltips.Add(tt);
                }
            }
            IMGEntry clockEntry = map.GetChild("clock");
            if (clockEntry != null)
            {
                clock = new MapClock();

                clock.Object = clockEntry;
                clock.Image = MapEditor.file.Directory.GetIMG("Obj/etc.img").GetChild("clock/fontTime");
            }

        }