Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
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();
                }
            }
        }
Exemplo n.º 5
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();
                }
            }
        }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
        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;            
        }