예제 #1
0
 public NSMBPath(NSMBPath path)
 {
     this.id = path.id;
     NSMBPathPoint newpt;
     foreach (NSMBPathPoint pt in path.points) {
         newpt = new NSMBPathPoint(pt);
         newpt.parent = this;
         this.points.Add(newpt);
     }
 }
예제 #2
0
 public NSMBPathPoint(NSMBPathPoint p)
 {
     X = p.X;
     Y = p.Y;
     parent = p.parent;
     Unknown1 = p.Unknown1;
     Unknown2 = p.Unknown2;
     Unknown3 = p.Unknown3;
     Unknown4 = p.Unknown4;
     Unknown5 = p.Unknown5;
     Unknown6 = p.Unknown6;
 }
예제 #3
0
 public NSMBPathPoint(NSMBPathPoint p)
 {
     X        = p.X;
     Y        = p.Y;
     parent   = p.parent;
     Unknown1 = p.Unknown1;
     Unknown2 = p.Unknown2;
     Unknown3 = p.Unknown3;
     Unknown4 = p.Unknown4;
     Unknown5 = p.Unknown5;
     Unknown6 = p.Unknown6;
 }
예제 #4
0
        public NSMBPath(NSMBPath path)
        {
            this.id = path.id;
            NSMBPathPoint newpt;

            foreach (NSMBPathPoint pt in path.points)
            {
                newpt        = new NSMBPathPoint(pt);
                newpt.parent = this;
                this.points.Add(newpt);
            }
        }
예제 #5
0
        public int RemoveZIndex(LevelItem obj)
        {
            int idx = -1;

            if (obj is NSMBObject)
            {
                idx = Objects.IndexOf(obj as NSMBObject);
                Objects.Remove(obj as NSMBObject);
            }
            if (obj is NSMBSprite)
            {
                idx = Sprites.IndexOf(obj as NSMBSprite);
                Sprites.Remove(obj as NSMBSprite);
            }
            if (obj is NSMBEntrance)
            {
                idx = Entrances.IndexOf(obj as NSMBEntrance);
                Entrances.Remove(obj as NSMBEntrance);
            }
            if (obj is NSMBView)
            {
                NSMBView v = obj as NSMBView;
                if (v.isZone)
                {
                    idx = Zones.IndexOf(v);
                    Zones.Remove(v);
                }
                else
                {
                    idx = Views.IndexOf(v);
                    Views.Remove(v);
                }
            }
            if (obj is NSMBPathPoint)
            {
                NSMBPathPoint pp = obj as NSMBPathPoint;
                idx = pp.parent.points.IndexOf(pp);
                pp.parent.points.Remove(pp);
                if (pp.parent.points.Count == 0)
                {
                    if (pp.parent.isProgressPath)
                    {
                        ProgressPaths.Remove(pp.parent);
                    }
                    else
                    {
                        Paths.Remove(pp.parent);
                    }
                }
            }
            return(idx == -1 ? 0 : idx);
        }
예제 #6
0
        public static NSMBPathPoint read(ByteArrayInputStream inp, NSMBPath parent)
        {
            NSMBPathPoint p = new NSMBPathPoint(parent);

            p.X        = inp.readUShort();
            p.Y        = inp.readUShort();
            p.Unknown1 = inp.readUShort();
            p.Unknown2 = inp.readUShort();
            p.Unknown3 = inp.readUShort();
            p.Unknown4 = inp.readUShort();
            p.Unknown5 = inp.readUShort();
            p.Unknown6 = inp.readUShort();
            return(p);
        }
예제 #7
0
        public static NSMBPathPoint FromString(string[] strs, ref int idx, NSMBPath p)
        {
            NSMBPathPoint pt = new NSMBPathPoint(p);

            pt.X        = int.Parse(strs[1 + idx]);
            pt.Y        = int.Parse(strs[2 + idx]);
            pt.Unknown1 = ushort.Parse(strs[3 + idx]);
            pt.Unknown2 = ushort.Parse(strs[4 + idx]);
            pt.Unknown3 = ushort.Parse(strs[5 + idx]);
            pt.Unknown4 = ushort.Parse(strs[6 + idx]);
            pt.Unknown5 = ushort.Parse(strs[7 + idx]);
            pt.Unknown6 = ushort.Parse(strs[8 + idx]);
            idx        += 9;
            return(pt);
        }
예제 #8
0
 public void Add(LevelItem obj)
 {
     if (obj is NSMBObject)
     {
         Objects.Add(obj as NSMBObject);
     }
     if (obj is NSMBSprite)
     {
         Sprites.Add(obj as NSMBSprite);
     }
     if (obj is NSMBEntrance)
     {
         Entrances.Add(obj as NSMBEntrance);
     }
     if (obj is NSMBView)
     {
         NSMBView v = obj as NSMBView;
         if (v.isZone)
         {
             Zones.Add(v);
         }
         else
         {
             Views.Add(v);
         }
     }
     if (obj is NSMBPathPoint)
     {
         NSMBPathPoint pp = obj as NSMBPathPoint;
         pp.parent.points.Add(pp);
         if (pp.parent.isProgressPath)
         {
             if (!ProgressPaths.Contains(pp.parent))
             {
                 ProgressPaths.Add(pp.parent);
             }
         }
         else
         {
             if (!Paths.Contains(pp.parent))
             {
                 Paths.Add(pp.parent);
             }
         }
     }
 }
예제 #9
0
        private void Write(NSMBPathPoint p, ushort value)
        {
            switch (PropNum)
            {
            case 0: p.Unknown1 = value; break;

            case 1: p.Unknown2 = value; break;

            case 2: p.Unknown3 = value; break;

            case 3: p.Unknown4 = value; break;

            case 4: p.Unknown5 = value; break;

            case 5: p.Unknown6 = value; break;
            }
        }
예제 #10
0
        private ushort Read(NSMBPathPoint p)
        {
            switch (PropNum)
            {
            case 0: return(p.Unknown1);

            case 1: return(p.Unknown2);

            case 2: return(p.Unknown3);

            case 3: return(p.Unknown4);

            case 4: return(p.Unknown5);

            case 5: return(p.Unknown6);
            }
            return(0);
        }
예제 #11
0
 public void Remove(LevelItem obj)
 {
     if (obj is NSMBObject)
     {
         Objects.Remove(obj as NSMBObject);
     }
     if (obj is NSMBSprite)
     {
         Sprites.Remove(obj as NSMBSprite);
     }
     if (obj is NSMBEntrance)
     {
         Entrances.Remove(obj as NSMBEntrance);
     }
     if (obj is NSMBView)
     {
         NSMBView v = obj as NSMBView;
         if (v.isZone)
         {
             Zones.Remove(v);
         }
         else
         {
             Views.Remove(v);
         }
     }
     if (obj is NSMBPathPoint)
     {
         NSMBPathPoint pp = obj as NSMBPathPoint;
         pp.parent.points.Remove(pp);
         if (pp.parent.points.Count == 0)
         {
             if (pp.parent.isProgressPath)
             {
                 ProgressPaths.Remove(pp.parent);
             }
             else
             {
                 Paths.Remove(pp.parent);
             }
         }
     }
 }
예제 #12
0
        public void render(Graphics g, LevelEditorControl ed, bool selected)
        {
            if (points.Count == 0)
            {
                return;
            }

            bool first = true;
            int  lx    = 0;
            int  ly    = 0;

            foreach (NSMBPathPoint p in points)
            {
                if (!first)
                {
                    g.DrawLine(NSMBGraphics.PathPen, lx, ly, p.X + 8 + XOffs, p.Y + 8 + YOffs);
                }

                lx    = p.X + 8 + XOffs;
                ly    = p.Y + 8 + YOffs;
                first = false;
            }

            NSMBPathPoint fp  = points[0];
            NSMBPathPoint lp  = points[points.Count - 1];
            int           num = 0;

            foreach (NSMBPathPoint p in points)
            {
                Pen pe = null;
                if (p == fp)
                {
                    pe = Pens.Green;
                }
                if (p == lp)
                {
                    pe = Pens.Red;
                }

                p.render(g, ed);
                num++;
            }
        }
예제 #13
0
        public static NSMBPath read(ByteArrayInputStream inp, ByteArrayInputStream nodes, bool isProgressPath)
        {
            NSMBPath p = new NSMBPath();

            p.isProgressPath = isProgressPath;

            p.id = inp.readUShort();
            int row = inp.readUShort();
            int len = inp.readUShort();

            inp.skip(2); //unused values

            nodes.seek(row * 16);
            for (int i = 0; i < len; i++)
            {
                p.points.Add(NSMBPathPoint.read(nodes, p));
            }
            return(p);
        }
예제 #14
0
        private void addPath_Click(object sender, EventArgs e)
        {
            Rectangle va = EdControl.ViewableBlocks;
            NSMBPath  np = new NSMBPath();

            if (isProgress)
            {
                np.id = EdControl.Level.getFreePathNumber(lst, 1);
            }
            else
            {
                np.id = EdControl.Level.getFreePathNumber(lst, 0);
            }
            np.isProgressPath = isProgress;

            NSMBPathPoint npp = new NSMBPathPoint(np);

            npp.X = (va.X + va.Width / 2) * 16;
            npp.Y = (va.Y + va.Height / 2) * 16;
            EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(npp)));
            EdControl.mode.SelectObject(npp);
        }
예제 #15
0
        public void UpdateInfo()
        {
            UpdateList();

            if (SelectedObjects == null || SelectedObjects.Count == 0)
            {
                panel2.Visible     = false;
                deletePath.Enabled = false;
                return;
            }
            NSMBPathPoint pp = SelectedObjects[0] as NSMBPathPoint;

            panel2.Visible     = true;
            deletePath.Enabled = true;
            DataUpdateFlag     = true;
            List <NSMBPath> paths = new List <NSMBPath>();

            foreach (LevelItem obj in SelectedObjects)
            {
                NSMBPath p = (obj as NSMBPathPoint).parent;
                if (lst.Contains(p) && !paths.Contains(p))
                {
                    pathsList.SelectedIndices.Add(lst.IndexOf(p));
                    paths.Add(p);
                }
            }

            pathID.Value   = pp.parent.id;
            unk1.Value     = pp.Unknown1;
            unk2.Value     = pp.Unknown2;
            unk3.Value     = pp.Unknown3;
            unk4.Value     = pp.Unknown4;
            unk5.Value     = pp.Unknown5;
            unk6.Value     = pp.Unknown6;
            DataUpdateFlag = false;
        }
예제 #16
0
 public static NSMBPathPoint FromString(string[] strs, ref int idx, NSMBPath p) {
     NSMBPathPoint pt = new NSMBPathPoint(p);
     pt.X = int.Parse(strs[1 + idx]);
     pt.Y = int.Parse(strs[2 + idx]);
     pt.Unknown1 = ushort.Parse(strs[3 + idx]);
     pt.Unknown2 = ushort.Parse(strs[4 + idx]);
     pt.Unknown3 = ushort.Parse(strs[5 + idx]);
     pt.Unknown4 = ushort.Parse(strs[6 + idx]);
     pt.Unknown5 = ushort.Parse(strs[7 + idx]);
     pt.Unknown6 = ushort.Parse(strs[8 + idx]);
     idx += 9;
     return pt;
 }
예제 #17
0
        private MouseAction getActionAtPos(int x, int y)
        {
            MouseAction act = new MouseAction();

            for (int l = SelectedObjects.Count - 1; l > -1; l--)
            {
                LevelItem o = SelectedObjects[l];
                // For clicking the plus buttons on selected nodes
                if (o is NSMBPathPoint)
                {
                    NSMBPathPoint pp = o as NSMBPathPoint;
                    if (x >= pp.x + 16 && x < pp.x + 32 && y >= pp.y && y < pp.y + 16)
                    {
                        act.nodeType = CreateNode.After;
                        act.node     = pp;
                        return(act);
                    }
                    if (x >= pp.x - 16 && x < pp.x && y >= pp.y && y < pp.y + 16)
                    {
                        act.nodeType = CreateNode.Before;
                        act.node     = pp;
                        return(act);
                    }
                }
                if (o.isResizable && resizeHandles)
                {
                    act.drag = true;

                    if (x >= o.x - 8 && x <= o.x + 4)
                    {
                        act.hor = ResizeType.ResizeBegin;
                    }
                    else if (x >= o.x + o.width - 4 && x <= o.x + o.width + 8)
                    {
                        act.hor = ResizeType.ResizeEnd;
                    }
                    else if (x >= o.x && x <= o.x + o.width)
                    {
                        act.hor = ResizeType.ResizeNone;
                    }
                    else
                    {
                        act.drag = false;
                    }

                    if (y >= o.y - 8 && y <= o.y + 4)
                    {
                        act.vert = ResizeType.ResizeBegin;
                    }
                    else if (y >= o.y + o.height - 4 && y <= o.y + o.height + 8)
                    {
                        act.vert = ResizeType.ResizeEnd;
                    }
                    else if (y >= o.y && y <= o.y + o.height)
                    {
                        act.vert = ResizeType.ResizeNone;
                    }
                    else
                    {
                        act.drag = false;
                    }
                    //Only display move cursor on views if cursor is over text
                    if (act.vert == ResizeType.ResizeNone && act.hor == ResizeType.ResizeNone && o is NSMBView && !GetViewTextRect(o).Contains(x, y))
                    {
                        act.drag = false;
                    }
                }
                else
                {
                    act.hor  = ResizeType.ResizeNone;
                    act.vert = ResizeType.ResizeNone;

                    act.drag = false;

                    if (x >= o.x && x < o.x + o.width && y >= o.y && y < o.y + o.height)
                    {
                        act.drag = true;
                    }
                }

                if (act.drag)
                {
                    return(act);
                }
            }
            return(act);
        }
예제 #18
0
        public override void MouseDown(int x, int y, MouseButtons buttons)
        {
            //Right clicking creates a new object
            if (buttons == MouseButtons.Right)
            {
                dx        = x / 16;
                dy        = y / 16;
                lx        = x;
                ly        = y;
                CreateObj = true;
                if (tabs.SelectedTab == 2) //The sprite tab
                {
                    NSMBSprite newSprite = new NSMBSprite(Level);
                    newSprite.Type = tabs.sprites.getSelectedType();
                    if (newSprite.Type == -1)
                    {
                        return;
                    }
                    newSprite.Data = new byte[6];
                    newSprite.x    = x;
                    newSprite.y    = y;
                    EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(newSprite)));
                    SelectObject(newSprite);
                    return;
                }
                newObj = new NSMBObject(tabs.objects.getObjectType(), tabs.objects.getTilesetNum(), dx, dy, 1, 1, Level.GFX);
                EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(newObj)));
                SelectObject(newObj);
                return;
            }
            lx = x;
            ly = y;
            dx = x;
            dy = y;

            mouseAct = getActionAtPos(x, y);
            // Resize with the shift key
            if (mouseAct.nodeType != CreateNode.None)
            {
                NSMBPathPoint pp     = new NSMBPathPoint(mouseAct.node);
                int           zIndex = pp.parent.points.IndexOf(mouseAct.node);
                if (mouseAct.nodeType == CreateNode.After)
                {
                    pp.x += 16;
                    zIndex++;
                }
                else
                {
                    pp.x -= 16;
                }
                EdControl.UndoManager.Do(new AddPathNodeAction(UndoManager.ObjToList(pp), zIndex));
                SelectObject(pp);
            }
            else
            {
                if (Control.ModifierKeys == Keys.Shift && mouseAct.drag && mouseAct.vert == ResizeType.ResizeNone && mouseAct.hor == ResizeType.ResizeNone)
                {
                    mouseAct.vert = ResizeType.ResizeEnd;
                    mouseAct.hor  = ResizeType.ResizeEnd;
                }
                if (!mouseAct.drag)
                {
                    // Select an object
                    findSelectedObjects(x, y, x, y, true, true);
                    SelectMode = SelectedObjects.Count == 0;
                }
                else if (mouseAct.vert == ResizeType.ResizeNone && mouseAct.hor == ResizeType.ResizeNone)
                {
                    List <LevelItem> selectedObjectsBack = new List <LevelItem>();
                    selectedObjectsBack.AddRange(SelectedObjects);

                    // Select an object
                    findSelectedObjects(x, y, x, y, true, true);

                    if (SelectedObjects.Count == 0)
                    {
                        SelectMode = true;
                    }
                    else
                    {
                        if (selectedObjectsBack.Contains(SelectedObjects[0]))
                        {
                            SelectedObjects = selectedObjectsBack;
                        }
                    }
                    UpdateSelectionBounds();
                    EdControl.repaint();
                }

                if (!SelectMode)
                {
                    CloneMode = Control.ModifierKeys == Keys.Control;
                    lx       -= selectionSnap / 2;
                    ly       -= selectionSnap / 2;
                }
            }
            EdControl.repaint();

            tabs.SelectObjects(SelectedObjects);
            UpdatePanel();
        }
예제 #19
0
 private void Write(NSMBPathPoint p, ushort value)
 {
     switch (PropNum) {
         case 0: p.Unknown1 = value; break;
         case 1: p.Unknown2 = value; break;
         case 2: p.Unknown3 = value; break;
         case 3: p.Unknown4 = value; break;
         case 4: p.Unknown5 = value; break;
         case 5: p.Unknown6 = value; break;
     }
 }
예제 #20
0
 private ushort Read(NSMBPathPoint p)
 {
     switch (PropNum) {
         case 0: return p.Unknown1;
         case 1: return p.Unknown2;
         case 2: return p.Unknown3;
         case 3: return p.Unknown4;
         case 4: return p.Unknown5;
         case 5: return p.Unknown6;
     }
     return 0;
 }
예제 #21
0
 public static NSMBPathPoint read(ByteArrayInputStream inp, NSMBPath parent)
 {
     NSMBPathPoint p = new NSMBPathPoint(parent);
     p.X = inp.readUShort();
     p.Y = inp.readUShort();
     p.Unknown1 = inp.readUShort();
     p.Unknown2 = inp.readUShort();
     p.Unknown3 = inp.readUShort();
     p.Unknown4 = inp.readUShort();
     p.Unknown5 = inp.readUShort();
     p.Unknown6 = inp.readUShort();
     return p;
 }
예제 #22
0
        public void SelectObjects(List <LevelItem> objs, LevelItem selectedTabType)
        {
            if (objs.Contains(selectedTabType))
            {
                objs.Remove(selectedTabType);
                objs.Insert(0, selectedTabType);
            }
            SelectedObjs = objs;
            ClearTabs();
            int tabIndex = -1;

            foreach (LevelItem obj in objs)
            {
                if (obj is NSMBObject)
                {
                    AddTab(objects);
                }
                if (obj is NSMBSprite)
                {
                    AddTab(sprites);
                }
                if (obj is NSMBEntrance)
                {
                    AddTab(entrances);
                }
                if (obj is NSMBView)
                {
                    NSMBView v = obj as NSMBView;
                    if (v.isZone)
                    {
                        AddTab(zones);
                    }
                    else
                    {
                        AddTab(views);
                    }
                }
                if (obj is NSMBPathPoint)
                {
                    NSMBPathPoint pp = obj as NSMBPathPoint;
                    if (pp.parent.isProgressPath)
                    {
                        AddTab(progresspaths);
                    }
                    else
                    {
                        AddTab(paths);
                    }
                }

                if (selectedTabType != null && obj.GetType() == selectedTabType.GetType() && tabIndex == -1)
                {
                    tabIndex = tabControl1.TabCount - 1;
                }
            }
            if (tabControl1.TabCount == 0)
            {
                SelectNone();
            }
            if (tabIndex > -1)
            {
                tabControl1.SelectedIndex = tabIndex;
            }
            EdControl.Focus();
        }
예제 #23
0
        public override void MouseDown(int x, int y, MouseButtons buttons)
        {
            //Right clicking creates a new object
            if (buttons == MouseButtons.Right) {
                dx = x / 16;
                dy = y / 16;
                lx = x;
                ly = y;
                CreateObj = true;
                if (tabs.SelectedTab == 2) //The sprite tab
                {
                    NSMBSprite newSprite = new NSMBSprite(Level);
                    newSprite.Type = tabs.sprites.getSelectedType();
                    if (newSprite.Type == -1)
                        return;
                    newSprite.Data = new byte[6];
                    newSprite.x = x;
                    newSprite.y = y;
                    EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(newSprite)));
                    SelectObject(newSprite);
                    return;
                }
                newObj = new NSMBObject(tabs.objects.getObjectType(), tabs.objects.getTilesetNum(), dx, dy, 1, 1, Level.GFX);
                EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(newObj)));
                SelectObject(newObj);
                return;
            }
            lx = x;
            ly = y;
            dx = x;
            dy = y;

            mouseAct = getActionAtPos(x, y);
            // Resize with the shift key
            if (mouseAct.nodeType != CreateNode.None)
            {
                NSMBPathPoint pp = new NSMBPathPoint(mouseAct.node);
                int zIndex = pp.parent.points.IndexOf(mouseAct.node);
                if (mouseAct.nodeType == CreateNode.After)
                {
                    pp.x += 16;
                    zIndex++;
                }
                else
                    pp.x -= 16;
                EdControl.UndoManager.Do(new AddPathNodeAction(UndoManager.ObjToList(pp), zIndex));
                SelectObject(pp);
            }
            else
            {
                if (Control.ModifierKeys == Keys.Shift && mouseAct.drag && mouseAct.vert == ResizeType.ResizeNone && mouseAct.hor == ResizeType.ResizeNone)
                {
                    mouseAct.vert = ResizeType.ResizeEnd;
                    mouseAct.hor = ResizeType.ResizeEnd;
                }
                if (!mouseAct.drag)
                {
                    // Select an object
                    if (Control.ModifierKeys != Keys.Shift)
                        SelectedObjects.Clear();
                    findSelectedObjects(x, y, x, y, true, true);
                    SelectMode = CurSelectedObjs.Count == 0;
                    if (!SelectMode)
                        SelectedObjects.Add(CurSelectedObjs[0]);
                }
                else if (mouseAct.vert == ResizeType.ResizeNone && mouseAct.hor == ResizeType.ResizeNone)
                {
                    List<LevelItem> selectedObjectsBack = new List<LevelItem>();
                    selectedObjectsBack.AddRange(SelectedObjects);

                    // Select an object
                    findSelectedObjects(x, y, x, y, true, true);

                    if (SelectedObjects.Count == 0)
                        SelectMode = true;
                    else
                    {
                        if (selectedObjectsBack.Contains(SelectedObjects[0]))
                            SelectedObjects = selectedObjectsBack;
                    }
                    UpdateSelectionBounds();
                    EdControl.repaint();
                }

                if (!SelectMode)
                {
                    CloneMode = Control.ModifierKeys == Keys.Control;
                    lx -= selectionSnap / 2;
                    ly -= selectionSnap / 2;
                }
            }
            EdControl.repaint();

            tabs.SelectObjects(SelectedObjects);
            UpdatePanel();
        }
예제 #24
0
        private void addPath_Click(object sender, EventArgs e)
        {
            Rectangle va = EdControl.ViewableBlocks;
            NSMBPath np = new NSMBPath();
            if (isProgress)
                np.id = EdControl.Level.getFreePathNumber(lst, 1);
            else
                np.id = EdControl.Level.getFreePathNumber(lst, 0);
            np.isProgressPath = isProgress;

            NSMBPathPoint npp = new NSMBPathPoint(np);
            npp.X = (va.X + va.Width / 2) * 16;
            npp.Y = (va.Y + va.Height / 2) * 16;
            EdControl.UndoManager.Do(new AddLvlItemAction(UndoManager.ObjToList(npp)));
            EdControl.mode.SelectObject(npp);
        }