Exemple #1
0
        public static MapBlockInformation Load(string folderPath, string mapInx)
        {
            var mbi = new MapBlockInformation();

            var baseFilePath = folderPath + Path.DirectorySeparatorChar + mapInx;

            // Loads SHBD file if it exists and sets MapBlockInformation
            if (File.Exists(baseFilePath + ".shbd"))
            {
                mbi.HasSHBD = true;
                mbi.SHBD    = SHBD.Load(baseFilePath + ".shbd");
                var x = (uint)mbi.SHBD.XSize;
                var y = (uint)mbi.SHBD.YSize;

                mbi.BlockXSize            = 8 * x;
                mbi.BlockYSize            = y;
                mbi.MapXSize              = 5000 * x / 0x64;
                mbi.XByte                 = x;
                mbi.MapYSize              = 625 * mbi.BlockYSize / 0x64;
                mbi.UIRealOneSideDataSize = x;
                mbi.UIOneSideBlockCount   = y;
            }
            else
            {
                throw new Exception($"{baseFilePath}.shbd was not found!");
            }

            // Loads SHAB file if it exists
            if (File.Exists(baseFilePath + ".shab"))
            {
                mbi.HasSHAB = true;
                mbi.SHAB    = SHBD.Load(baseFilePath + ".shab");
            }

            // Loads MapDoorArray file if it exists
            if (File.Exists(baseFilePath + ".sbi"))
            {
                //TODO: Figure out what BlockYSize is, maybe actual in game size?
//				mbi.SBI = MapDoorArray.Load(baseFilePath + ".sbi", mbi.BlockYSize);
                mbi.SBI    = MapDoorArray.Load(baseFilePath + ".sbi");
                mbi.HasSBI = true;
            }

            if (File.Exists(baseFilePath + ".aid"))
            {
                mbi.HasAID = true;
                mbi.AID    = AID.Load(baseFilePath + ".aid");
            }

            if (File.Exists(baseFilePath + ".shmd"))
            {
                mbi.HasSHMD = true;
                mbi.SHMD    = SHMD.Load(baseFilePath + ".shmd");
            }

            return(mbi);
        }
Exemple #2
0
        public void Open()
        {
            EnableComponents(true);

            OpenedBmp  = false;
            OpenedSHBD = true;

            Selected = SHBD.Load(GetFullPath());
            Selected.SetBitmap();

            PictureBox.Image = Selected.Bitmap.Clone(new Rectangle(0, 0, Selected.Bitmap.Width, Selected.Bitmap.Height), PixelFormat.DontCare);
            ImageWidth       = PictureBox.Image.Width;
            ImageHeight      = PictureBox.Image.Height;

            Refresh();
        }
Exemple #3
0
        // ====================================Menu Items====================================
        private void OpenMenu_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter = @"SHBD File (*.shbd)|*.shbd|Bitmap File (*.bmp)|*.bmp",
            };

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Path   = System.IO.Path.GetDirectoryName(openFileDialog.FileName);
            MapInx = System.IO.Path.GetFileNameWithoutExtension(openFileDialog.FileName);
            EnableComponents(true);

            switch (openFileDialog.FilterIndex)
            {
            case 1:
                OpenedBmp  = false;
                OpenedSHBD = true;
                Selected   = SHBD.Load(GetFullPath());
                Selected.SetBitmap();
                break;

            case 2:
                OpenedBmp  = true;
                OpenedSHBD = false;
                var bitmap = ReadBitmapFromBytes(openFileDialog.FileName);
                Selected = SHBD.Load(bitmap.Width / 8, bitmap.Height, bitmap);
                break;
            }

            PictureBox.Image = Selected.Bitmap.Clone(new Rectangle(0, 0, Selected.Bitmap.Width, Selected.Bitmap.Height), PixelFormat.DontCare);
            ImageWidth       = PictureBox.Image.Width;
            ImageHeight      = PictureBox.Image.Height;

            Refresh();
        }