Exemplo n.º 1
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "Sonic 1/Sonic 2 Background files (Backgrounds.bin)|Backgrounds.bin|Sonic CD Background files (Backgrounds.bin)|Backgrounds.bin|Sonic Nexus Background files (Backgrounds.bin)|Backgrounds.bin|Retro-Sonic Background files (ZoneBG.map)|ZoneBG.map";

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                switch (dlg.FilterIndex - 1)
                {
                case 0:
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    break;

                case 1:
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    break;

                case 2:
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    break;
                }
                Background = dlg.FileName;
                background.ExportTo(engineType, Background);
            }
        }
Exemplo n.º 2
0
 void CheckDimensions(Retro_Formats.EngineType RSDKver, ushort[][] OldTiles, ushort[][] NewTiles, int OLDwidth, int OLDheight)
 {
     if (RSDKver == Retro_Formats.EngineType.RSDKvRS)
     {
         if (background.Layers[curlayer].width != OLDwidth || background.Layers[curlayer].height != OLDheight)
         {
             Console.WriteLine("Different");
             background.Layers[curlayer].MapLayout = UpdateMapDimensions(OldTiles, NewTiles, (ushort)OLDwidth, (ushort)OLDheight, (ushort)background.Layers[curlayer].width, (ushort)background.Layers[curlayer].height, RSDKver);
         }
     }
     if (RSDKver == Retro_Formats.EngineType.RSDKv1)
     {
         if (background.Layers[_mapViewer.curlayer].width != OLDwidth || background.Layers[_mapViewer.curlayer].height != OLDheight)
         {
             Console.WriteLine("Different");
             background.Layers[curlayer].MapLayout = UpdateMapDimensions(OldTiles, NewTiles, (ushort)OLDwidth, (ushort)OLDheight, (ushort)background.Layers[_mapViewer.curlayer].width, (ushort)background.Layers[_mapViewer.curlayer].height, RSDKver);
         }
     }
     if (RSDKver == Retro_Formats.EngineType.RSDKv2)
     {
         if (background.Layers[curlayer].width != OLDwidth || background.Layers[curlayer].height != OLDheight)
         {
             Console.WriteLine("Different");
             background.Layers[curlayer].MapLayout = UpdateMapDimensions(OldTiles, NewTiles, (ushort)OLDwidth, (ushort)OLDheight, (ushort)background.Layers[curlayer].width, (ushort)background.Layers[curlayer].height, RSDKver);
         }
     }
     if (RSDKver == Retro_Formats.EngineType.RSDKvB)
     {
         if (background.Layers[curlayer].width != OLDwidth || background.Layers[curlayer].height != OLDheight)
         {
             Console.WriteLine("Different");
             background.Layers[curlayer].MapLayout = UpdateMapDimensions(OldTiles, NewTiles, (ushort)OLDwidth, (ushort)OLDheight, (ushort)background.Layers[curlayer].width, (ushort)background.Layers[curlayer].height, RSDKver);
         }
     }
 }
Exemplo n.º 3
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.DefaultExt = ".bin";
            dlg.Filter     = "RSDKvB Chunk Mappings|128x128Tiles.bin|RSDKv2 Chunk Mappings|128x128Tiles.bin|RSDKv1 Chunk Mappings|128x128Tiles.bin|Retro-Sonic Chunk Mappings|Zone.til";

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                filename = dlg.FileName;
                string RSDK = "RSDKvB";
                switch (dlg.FilterIndex - 1)
                {
                case 0:
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    RSDK       = "RSDKvB";
                    break;

                case 1:
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    RSDK       = "RSDKv2";
                    break;

                case 2:
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    RSDK       = "RSDKv1";
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    RSDK       = "RSDKvRS";
                    break;
                }

                string        dispname = "";
                string        folder   = Path.GetDirectoryName(filename);
                DirectoryInfo di       = new DirectoryInfo(folder);
                folder = di.Name;
                string file = Path.GetFileName(filename);

                if (filename != null)
                {
                    RetroED.MainForm.Instance.CurrentTabText = folder + "/" + file;
                    dispname = folder + "/" + file;
                }
                else
                {
                    RetroED.MainForm.Instance.CurrentTabText = "New Chunk Mappings - RSDK Chunk Mappings Editor";
                    dispname = "New Chunk Mappings - RSDK Chunk Mappings Editor";
                }

                RetroED.MainForm.Instance.rp.state   = "RetroED - " + this.Text;
                RetroED.MainForm.Instance.rp.details = "Editing: " + dispname + " (" + RSDK + ")";
                SharpPresence.Discord.RunCallbacks();
                SharpPresence.Discord.UpdatePresence(RetroED.MainForm.Instance.rp);

                Chunks.ExportTo(engineType, filename);
            }
        }
Exemplo n.º 4
0
        private void SelectFolderButton_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            SelectRSDKForm selectRSDKForm = new SelectRSDKForm();

            selectRSDKForm.usingRSDKv5 = true;
            selectRSDKForm.RSDKVerBox.Items.Clear();
            selectRSDKForm.RSDKVerBox.Items.Add("RSDKvRS");
            selectRSDKForm.RSDKVerBox.Items.Add("RSDKv1");
            selectRSDKForm.RSDKVerBox.Items.Add("RSDKv2");
            selectRSDKForm.RSDKVerBox.Items.Add("RSDKvB");
            selectRSDKForm.RSDKVerBox.Items.Add("RSDKv5");

            if (selectRSDKForm.ShowDialog(this) == DialogResult.OK)
            {
                engineType = selectRSDKForm.engineType;
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    filename = dlg.SelectedPath;
                    DataFolderLocation.Text = filename;

                    switch (engineType)
                    {
                    case Retro_Formats.EngineType.RSDKvRS:
                        BuildFromDataFolderVRS(dlg.SelectedPath);
                        break;

                    case Retro_Formats.EngineType.RSDKv1:
                        BuildFromDataFolderV1(dlg.SelectedPath);
                        break;

                    case Retro_Formats.EngineType.RSDKv2:
                        BuildFromDataFolderV2(dlg.SelectedPath);
                        break;

                    case Retro_Formats.EngineType.RSDKvB:
                        BuildFromDataFolderVB(dlg.SelectedPath);
                        break;

                    case Retro_Formats.EngineType.RSDKv5:
                        BuildFromDataFolderV5(dlg.SelectedPath);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void RSDKVerBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!usingRSDKv5)
            {
                switch (RSDKVerBox.SelectedIndex)
                {
                case 0:
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    break;

                case 1:
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    break;

                case 2:
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    break;
                }
            }
            else
            {
                switch (RSDKVerBox.SelectedIndex)
                {
                case 4:
                    engineType = Retro_Formats.EngineType.RSDKv5;
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    break;

                case 2:
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    break;

                case 1:
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    break;

                case 0:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    break;
                }
            }
        }
Exemplo n.º 6
0
        private void FixStageButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "RSDKvRS Scenes|Act*.map|RSDKv1 Scenes|Act*.bin|RSDKv2 Scenes|Act*.bin|RSDKvB Scenes|Act*.bin";

            Retro_Formats.EngineType engineType = Retro_Formats.EngineType.RSDKv2;

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                switch (dlg.FilterIndex - 1)
                {
                case 0:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    break;

                case 1:
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    break;

                case 2:
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    break;
                }
                scene.ImportFrom(engineType, dlg.FileName);
                scene.ExportTo(engineType, dlg.FileName + ".bak"); //create a backup

                int diff = NewSize - OldSize;

                for (int i = 0; i < scene.objects.Count; i++)
                {
                    if (scene.objects[i].type > OldSize)
                    {
                        scene.objects[i].type += (byte)diff;
                    }
                }

                scene.ExportTo(engineType, dlg.FileName); //save our scene
            }
        }
Exemplo n.º 7
0
        public Bitmap RenderObject(Retro_Formats.EngineType RSDKver, string DataPath)
        {
            Bitmap b = RetroED.Properties.Resources.OBJ;

            if (!System.IO.File.Exists(DataPath + SpriteSheet))
            {
                b = RetroED.Properties.Resources.OBJ;
                return(b);
            }

            if (RSDKver == Retro_Formats.EngineType.RSDKvRS)
            {
                b = GFXHolder;
                b = CropImage(b, new Rectangle(X, Y, Width, Height));
                b.MakeTransparent(Color.FromArgb(255, 0, 0, 0));
            }
            else
            {
                b = new Bitmap(DataPath + SpriteSheet, false);
                b = CropImage(b, new Rectangle(X, Y, Width, Height));
                b.MakeTransparent(Color.FromArgb(255, 255, 0, 255));
            }
            return(b);
        }
Exemplo n.º 8
0
        private void tsmiFileOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Sonic 1/Sonic 2 Background files (Backgrounds.bin)|Backgrounds.bin|Sonic CD Background files (Backgrounds.bin)|Backgrounds.bin|Sonic Nexus Background files (Backgrounds.bin)|Backgrounds.bin|Retro-Sonic Background files (ZoneBG.map)|ZoneBG.map";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                switch (ofd.FilterIndex - 1)
                {
                case 0:
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    break;

                case 1:
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    break;

                case 2:
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    break;
                }

                if (engineType == Retro_Formats.EngineType.RSDKvRS)
                {
                    tiles      = Path.Combine(Path.GetDirectoryName(ofd.FileName), "Zone.gfx");
                    mappings   = Path.Combine(Path.GetDirectoryName(ofd.FileName), "Zone.til");
                    Background = ofd.FileName;
                    if (File.Exists(tiles) && File.Exists(mappings) && File.Exists(Background))
                    {
                        LoadLevel(ofd.FileName);
                    }
                    else
                    {
                        MessageBox.Show("Tiles and Mappings need to exist in the same folder as act data, just like the game.");
                    }
                }

                if (engineType != Retro_Formats.EngineType.RSDKvRS)
                {
                    tiles      = Path.Combine(Path.GetDirectoryName(ofd.FileName), "16x16Tiles.gif");
                    mappings   = Path.Combine(Path.GetDirectoryName(ofd.FileName), "128x128Tiles.bin");
                    Background = ofd.FileName;
                    if (File.Exists(tiles) && File.Exists(mappings) && File.Exists(Background))
                    {
                        LoadLevel(ofd.FileName);
                    }
                    else
                    {
                        MessageBox.Show("Tiles and Mappings need to exist in the same folder as act data, just like the game.");
                    }
                }

                string filename = Path.GetFileName(ofd.FileName);

                string dispname = "";

                if (filename != null)
                {
                    string        dir = "";
                    string        pth = Path.GetFileName(ofd.FileName);
                    string        tmp = ofd.FileName.Replace(pth, "");
                    DirectoryInfo di  = new DirectoryInfo(tmp);
                    dir = di.Name;
                    RetroED.MainForm.Instance.CurrentTabText = dir + "/" + pth;
                    dispname = dir + "/" + pth;
                }
                else
                {
                    RetroED.MainForm.Instance.CurrentTabText = "New Scene - RSDK Background Editor";
                    dispname = "New Scene - RSDK Background Editor";
                }

                RetroED.MainForm.Instance.rp.state = "RetroED - " + this.Text;
                switch (engineType)
                {
                case Retro_Formats.EngineType.RSDKvB:
                    RetroED.MainForm.Instance.rp.details = "Editing: " + dispname + " (RSDKvB)";
                    break;

                case Retro_Formats.EngineType.RSDKv2:
                    RetroED.MainForm.Instance.rp.details = "Editing: " + dispname + " (RSDKv2)";
                    break;

                case Retro_Formats.EngineType.RSDKv1:
                    RetroED.MainForm.Instance.rp.details = "Editing: " + dispname + " (RSDKv1)";
                    break;

                case Retro_Formats.EngineType.RSDKvRS:
                    RetroED.MainForm.Instance.rp.details = "Editing: " + dispname + " (RSDKvRS)";
                    break;
                }
                SharpPresence.Discord.RunCallbacks();
                SharpPresence.Discord.UpdatePresence(RetroED.MainForm.Instance.rp);
            }
        }
Exemplo n.º 9
0
        ushort[][] UpdateMapDimensions(ushort[][] OldTiles, ushort[][] NewTiles, ushort oldWidth, ushort oldHeight, ushort NewWidth, ushort NewHeight, Retro_Formats.EngineType RSDKver)
        {
            //Yeah, I "borrowed" this from Maniac

            // fill the extended tile arrays with "empty" values
            Array.Resize(ref NewTiles, NewHeight);

            // if we're actaully getting shorter, do nothing!
            for (ushort i = oldHeight; i < NewHeight; i++)
            {
                // first create arrays child arrays to the old width
                // a little inefficient, but at least they'll all be equal sized
                NewTiles[i] = new ushort[oldWidth];
                for (int j = 0; j < oldWidth; ++j)
                {
                    NewTiles[i][j] = 0; // fill the new ones with blanks
                }
            }

            for (ushort i = 0; i < NewHeight; i++)
            {
                // now resize all child arrays to the new width
                Array.Resize(ref NewTiles[i], NewWidth);
                for (ushort j = oldWidth; j < NewWidth; j++)
                {
                    NewTiles[i][j] = 0; // and fill with blanks if wider
                }
            }
            return(NewTiles);
        }
Exemplo n.º 10
0
 public RSN_LayerPropertiesForm(Retro_Formats.EngineType RSDKver)
 {
     InitializeComponent();
     engineType = RSDKver;
 }
Exemplo n.º 11
0
        private void SelectDataFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "RSDKvRS Data files|Data*.bin|RSDKv1 Data files|Data*.bin|RSDKv2 Data files|Data*.rsdk|RSDKvB Data files|Data*.rsdk|RSDKv5 Data files|*.rsdk";

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                switch (dlg.FilterIndex - 1)
                {
                case 0:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    break;

                case 1:
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    break;

                case 2:
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    break;

                case 4:
                    engineType = Retro_Formats.EngineType.RSDKv5;
                    break;
                }
                filename = dlg.FileName;
                DataFileLocation.Text = filename;

                this.Text = "Data File Manager - Loading Datafile";
                //RetroED.MainForm.Instance.CurrentTabText = "Data File Manager - Loading Datafile";

                switch (engineType)
                {
                case Retro_Formats.EngineType.RSDKvRS:
                    DatavRS = new RSDKvRS.DataFile(filename);
                    SetFileListRS();
                    break;

                case Retro_Formats.EngineType.RSDKv1:
                    Datav1 = new RSDKv1.DataFile(filename);
                    SetFileListv1();
                    break;

                case Retro_Formats.EngineType.RSDKv2:
                    Datav2 = new RSDKv2.DataFile(filename);
                    SetFileListv2();
                    break;

                case Retro_Formats.EngineType.RSDKvB:
                    if (FileList == null || FileList.Count <= 0)
                    {
                        if (File.Exists("Data/DataFileUnpacker/RSDKvBFileList.txt"))
                        {
                            StreamReader reader = new StreamReader(File.OpenRead("Data/DataFileUnpacker/RSDKvBFileList.txt"));
                            while (!reader.EndOfStream)
                            {
                                FileList.Add(reader.ReadLine());
                            }
                            reader.Close();
                        }
                    }
                    if (FileList != null && FileList.Count > 0)
                    {
                        DatavB = new RSDKvB.DataFile(filename, FileList);
                        SetFileListvB();
                    }
                    break;

                case Retro_Formats.EngineType.RSDKv5:
                    if (FileList == null || FileList.Count <= 0)
                    {
                        if (File.Exists("Data/DataFileUnpacker/RSDKv5FileList.txt"))
                        {
                            StreamReader reader = new StreamReader(File.OpenRead("Data/DataFileUnpacker/RSDKv5FileList.txt"));
                            while (!reader.EndOfStream)
                            {
                                string[] info = reader.ReadLine().Split(',');
                                FileList.Add(info[0]);
                                if (info.Length > 2)
                                {
                                    KeyList.Add(info[1].ToUpper(), info[2].ToUpper());
                                }
                            }
                            reader.Close();
                        }
                        //Scan Object list and create hashes
                        if (File.Exists("Data/DataFileUnpacker/RSDKv5Objects.txt"))
                        {
                            StreamReader reader = new StreamReader(File.OpenRead("Data/DataFileUnpacker/RSDKv5Objects.txt"));
                            StreamWriter writer = new StreamWriter(File.OpenWrite("StaticObjects.txt"));
                            while (!reader.EndOfStream)
                            {
                                string rawhash;
                                string hash = "";
                                string name = reader.ReadLine();
                                rawhash = GetMd5HashString(name);

                                for (int c = 0; c < rawhash.Length; c += 2)
                                {
                                    char c1 = ' ';
                                    char c2 = ' ';
                                    c1 = rawhash[c];
                                    c2 = rawhash[c + 1];

                                    hash += c2;
                                    hash += c1;
                                }

                                string path = "Data/Objects/Static/" + hash.ToUpper() + ".bin";
                                writer.WriteLine(name + " (" + hash.ToUpper() + ")");

                                FileList.Add(path);
                            }
                            writer.Close();
                            reader.Close();
                        }
                    }
                    if (FileList != null && FileList.Count > 0)
                    {
                        Datav5 = new RSDKv5.DataFile(filename, FileList, KeyList);
                        SetFileListv5();
                    }
                    break;

                default:
                    break;
                }

                this.Text = "Data File Manager";
                //RetroED.MainForm.Instance.CurrentTabText = "Data File Manager";
            }
        }
Exemplo n.º 12
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = ".bin";
            dlg.Filter     = "RSDKvB Chunk Mappings|128x128Tiles.bin|RSDKv2 Chunk Mappings|128x128Tiles.bin|RSDKv1 Chunk Mappings|128x128Tiles.bin|Retro-Sonic Chunk Mappings|Zone.til";
            string RSDK = "RSDKvB";

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                curChunk = 0;
                filename = dlg.FileName;
                switch (dlg.FilterIndex - 1) //What RSDK version was loaded?
                {
                case 0:
                    Tiles      = new Bitmap(dlg.FileName.Replace("128x128Tiles.bin", "16x16Tiles.gif")); //A Zone's Tileset should be in the same folder as its chunk mappings
                    engineType = Retro_Formats.EngineType.RSDKvB;
                    Chunks.ImportFrom(engineType, dlg.FileName);
                    RSDK = "RSDKvB";
                    break;

                case 1:
                    Tiles      = new Bitmap(dlg.FileName.Replace("128x128Tiles.bin", "16x16Tiles.gif")); //A Zone's Tileset should be in the same folder as its chunk mappings
                    engineType = Retro_Formats.EngineType.RSDKv2;
                    Chunks.ImportFrom(engineType, dlg.FileName);
                    RSDK = "RSDKv2";
                    break;

                case 2:
                    Tiles      = new Bitmap(dlg.FileName.Replace("128x128Tiles.bin", "16x16Tiles.gif")); //A Zone's Tileset should be in the same folder as its chunk mappings
                    engineType = Retro_Formats.EngineType.RSDKv1;
                    Chunks.ImportFrom(engineType, dlg.FileName);
                    RSDK = "RSDKv1";
                    break;

                case 3:
                    engineType = Retro_Formats.EngineType.RSDKvRS;
                    Chunks.ImportFrom(engineType, dlg.FileName);
                    RSDKvRS.gfx gfx = new RSDKvRS.gfx(dlg.FileName.Replace("Zone.til", "Zone.gfx"), false);     //A Zone's Tileset should be in the same folder as its chunk mappings
                    Tiles = new Bitmap(gfx.gfxImage);
                    RSDK  = "RSDKvRS";
                    break;
                }

                LoadTileSet(Tiles);
                LoadChunks(Tiles);
                GotoNUD.Maximum = Chunks.MaxChunks;
                RedrawChunk();

                string        dispname = "";
                string        folder   = Path.GetDirectoryName(filename);
                DirectoryInfo di       = new DirectoryInfo(folder);
                folder = di.Name;
                string file = Path.GetFileName(filename);

                if (filename != null)
                {
                    RetroED.MainForm.Instance.CurrentTabText = folder + "/" + file;
                    dispname = folder + "/" + file;
                }
                else
                {
                    RetroED.MainForm.Instance.CurrentTabText = "New Scene - RSDK Map Editor";
                    dispname = "New Scene - RSDK Map Editor";
                }



                RetroED.MainForm.Instance.rp.state   = "RetroED - " + this.Text;
                RetroED.MainForm.Instance.rp.details = "Editing: " + dispname + " (" + RSDK + ")";
                SharpPresence.Discord.RunCallbacks();
                SharpPresence.Discord.UpdatePresence(RetroED.MainForm.Instance.rp);
            }
        }