Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        private void LoadLevel(byte[] eLevelFile, byte[] eBGFile, NSMBGraphics GFX)
        {
            this.GFX = GFX;

            int FilePos;

            for (int x = 0; x < 512; x++)
            {
                for (int y = 0; y < 256; y++)
                {
                    levelTilemap[x, y] = (x + y) % 512;
                }
            }

            // Level loading time yay.
            // Since I don't know the format for every block, I will just load them raw.
            Blocks = new byte[][] { null, null, null, null, null, null, null, null, null, null, null, null, null, null };

            FilePos = 0;
            for (int BlockIdx = 0; BlockIdx < 14; BlockIdx++)
            {
                int BlockOffset = eLevelFile[FilePos] | (eLevelFile[FilePos + 1] << 8) | (eLevelFile[FilePos + 2] << 16) | eLevelFile[FilePos + 3] << 24;
                FilePos += 4;
                int BlockSize = eLevelFile[FilePos] | (eLevelFile[FilePos + 1] << 8) | (eLevelFile[FilePos + 2] << 16) | eLevelFile[FilePos + 3] << 24;
                FilePos += 4;

                Blocks[BlockIdx] = new byte[BlockSize];
                Array.Copy(eLevelFile, BlockOffset, Blocks[BlockIdx], 0, BlockSize);
            }

            // Now objects.

            int ObjectCount = eBGFile.Length / 10;

            Objects = new List <NSMBObject>(ObjectCount);
            FilePos = 0;
            for (int ObjectIdx = 0; ObjectIdx < ObjectCount; ObjectIdx++)
            {
                int ObjID     = eBGFile[FilePos] | (eBGFile[FilePos + 1] << 8);
                int ObjX      = eBGFile[FilePos + 2] | (eBGFile[FilePos + 3] << 8);
                int ObjY      = eBGFile[FilePos + 4] | (eBGFile[FilePos + 5] << 8);
                int ObjWidth  = eBGFile[FilePos + 6] | (eBGFile[FilePos + 7] << 8);
                int ObjHeight = eBGFile[FilePos + 8] | (eBGFile[FilePos + 9] << 8);
                Objects.Add(new NSMBObject(ObjID & 4095, (ObjID & 61440) >> 12, ObjX, ObjY, ObjWidth, ObjHeight, GFX));
                FilePos += 10;
            }

            /*
             * Sprite struct:
             * Offs Len Dat
             * 0x0   2   Sprite id
             * 0x2   2   X
             * 0x4   2   Y
             * 0x6   6   Dat
             * 0xD   end
             */

            // Sprites
            byte[] SpriteBlock = Blocks[6];
            int    SpriteCount = (SpriteBlock.Length - 2) / 12;

            Sprites = new List <NSMBSprite>(SpriteCount);
            FilePos = 0;
            for (int SpriteIdx = 0; SpriteIdx < SpriteCount; SpriteIdx++)
            {
                NSMBSprite Sprite = new NSMBSprite(this);
                Sprite.Type    = SpriteBlock[FilePos] | (SpriteBlock[FilePos + 1] << 8);
                Sprite.X       = SpriteBlock[FilePos + 2] | (SpriteBlock[FilePos + 3] << 8);
                Sprite.Y       = SpriteBlock[FilePos + 4] | (SpriteBlock[FilePos + 5] << 8);
                Sprite.Data    = new byte[6];
                FilePos       += 6;
                Sprite.Data[0] = SpriteBlock[FilePos + 1];
                Sprite.Data[1] = SpriteBlock[FilePos + 0];
                Sprite.Data[2] = SpriteBlock[FilePos + 5];
                Sprite.Data[3] = SpriteBlock[FilePos + 4];
                Sprite.Data[4] = SpriteBlock[FilePos + 3];
                Sprite.Data[5] = SpriteBlock[FilePos + 2];
//                Array.Copy(SpriteBlock, FilePos + 6, Sprite.Data, 0, 6);
                Sprites.Add(Sprite);
                FilePos += 6;
            }

            // Entrances.
            byte[] EntranceBlock = Blocks[5];
            int    EntranceCount = EntranceBlock.Length / 20;

            Entrances = new List <NSMBEntrance>(EntranceCount);
            FilePos   = 0;
            for (int EntIdx = 0; EntIdx < EntranceCount; EntIdx++)
            {
                NSMBEntrance Entrance = new NSMBEntrance();
                Entrance.X               = EntranceBlock[FilePos] | (EntranceBlock[FilePos + 1] << 8);
                Entrance.Y               = EntranceBlock[FilePos + 2] | (EntranceBlock[FilePos + 3] << 8);
                Entrance.CameraX         = EntranceBlock[FilePos + 4] | (EntranceBlock[FilePos + 5] << 8);
                Entrance.CameraY         = EntranceBlock[FilePos + 6] | (EntranceBlock[FilePos + 7] << 8);
                Entrance.Number          = EntranceBlock[FilePos + 8];
                Entrance.DestArea        = EntranceBlock[FilePos + 9];
                Entrance.ConnectedPipeID = EntranceBlock[FilePos + 10];
                Entrance.DestEntrance    = EntranceBlock[FilePos + 12];
                Entrance.Type            = EntranceBlock[FilePos + 14];
                Entrance.Settings        = EntranceBlock[FilePos + 15];
                Entrance.Unknown1        = EntranceBlock[FilePos + 16];
                Entrance.EntryView       = EntranceBlock[FilePos + 18];
                Entrance.Unknown2        = EntranceBlock[FilePos + 19];
                //Array.Copy(EntranceBlock, FilePos, Entrance.Data, 0, 20);
                Entrances.Add(Entrance);
                FilePos += 20;
            }

            // Views
            ByteArrayInputStream ViewBlock = new ByteArrayInputStream(Blocks[7]);
            ByteArrayInputStream CamBlock  = new ByteArrayInputStream(Blocks[1]);

            Views = new List <NSMBView>();
            while (ViewBlock.lengthAvailable(16))
            {
                Views.Add(NSMBView.read(ViewBlock, CamBlock));
            }

            // Zones
            ByteArrayInputStream ZoneBlock = new ByteArrayInputStream(Blocks[8]);

            Zones = new List <NSMBView>();
            while (ZoneBlock.lengthAvailable(12))
            {
                Zones.Add(NSMBView.readZone(ZoneBlock));
            }

            // Paths

            ByteArrayInputStream PathBlock     = new ByteArrayInputStream(Blocks[10]);
            ByteArrayInputStream PathNodeBlock = new ByteArrayInputStream(Blocks[12]);

            Paths = new List <NSMBPath>();
            while (!PathBlock.end())
            {
                Paths.Add(NSMBPath.read(PathBlock, PathNodeBlock, false));
            }

            PathBlock     = new ByteArrayInputStream(Blocks[9]);
            PathNodeBlock = new ByteArrayInputStream(Blocks[11]);

            ProgressPaths = new List <NSMBPath>();
            while (!PathBlock.end())
            {
                ProgressPaths.Add(NSMBPath.read(PathBlock, PathNodeBlock, true));
            }


            CalculateSpriteModifiers();
            repaintAllTilemap();
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 public NSMBPathPoint(NSMBPath p)
 {
     parent = p;
 }
Ejemplo n.º 14
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;
 }
Ejemplo n.º 15
0
 public NSMBPathPoint(NSMBPath p)
 {
     parent = p;
 }
Ejemplo n.º 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;
 }