Esempio n. 1
0
        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;
                }
            }
        }
Esempio n. 2
0
        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();
                }
            }
        }
Esempio n. 3
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();
                }
            }
        }
Esempio n. 4
0
        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();
            }

        }
Esempio n. 5
0
 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();
         }
     }
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
        public static void SwapInt(IMGEntry e1, IMGEntry e2)
        {
            int temp = e1.GetInt();
            e1.SetInt(e2.GetInt());
            e2.SetInt(temp);

        }