Example #1
0
        private void menuItem_ExpandIso_Click(object sender, EventArgs e)
        {
            bool isPsx = currentStream.Length % PatcherLib.Iso.IsoPatch.SectorSizes[PatcherLib.Iso.IsoPatch.IsoType.Mode2Form1] == 0;

            if (isPsx)
            {
                DialogResult result   = DialogResult.None;
                bool         expanded = AllSprites.DetectExpansionOfPsxIso(currentStream);
                if (!expanded &&
                    (result = MyMessageBox.Show(this, "Are you sure you want to Expand this ISO?", "Expand ISO?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2))
                    == DialogResult.Yes)
                {
                    AllSprites.ExpandPsxIso(currentStream);

                    AllSprites s = AllSprites.FromIso(currentStream, true);
                    allSpritesEditor1.BindTo(s, currentStream);
                    tabControl1.Enabled    = true;
                    spriteMenuItem.Enabled = true;
                    sp2Menu.Enabled        = true;

                    AllOtherImages otherImages = AllOtherImages.FromIso(currentStream);
                    allOtherImagesEditor1.BindTo(otherImages, currentStream);
                }
            }
        }
Example #2
0
        public void BindTo(AllSprites allSprites, Stream iso)
        {
            if (allSprites == null)
            {
                throw new ArgumentNullException("allSprites");
            }
            if (iso == null)
            {
                throw new ArgumentNullException("iso");
            }
            if (!iso.CanRead || !iso.CanWrite || !iso.CanSeek)
            {
                throw new InvalidOperationException("iso doesn't support reading, writing, and seeking");
            }

            this.Sprites = allSprites;
            this.iso     = iso;
            Enabled      = true;
            comboBox1.BeginUpdate();
            comboBox1.Items.Clear();
            for (int i = 0; i < allSprites.Count; i++)
            {
                comboBox1.Items.Add(Sprites[i]);
            }
            comboBox1.SelectedIndex = 0;
            comboBox1.EndUpdate();
        }
Example #3
0
        public void BindTo(AllSprites allSprites, Stream iso)
        {
            if (allSprites == null)
                throw new ArgumentNullException("allSprites");
            if (iso == null)
                throw new ArgumentNullException("iso");
            if (!iso.CanRead || !iso.CanWrite || !iso.CanSeek)
                throw new InvalidOperationException("iso doesn't support reading, writing, and seeking");

            this.Sprites = allSprites;
            this.iso = iso;
            Enabled = true;
            comboBox1.BeginUpdate();
            comboBox1.Items.Clear();
            for (int i = 0; i < allSprites.Count; i++)
            {
                comboBox1.Items.Add(Sprites[i]);
            }
            comboBox1.SelectedIndex = 0;
            comboBox1.EndUpdate();
        }
Example #4
0
        private void openIsoMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter   = "ISO files (*.bin, *.iso, *.img)|*.bin;*.iso;*.img";
            openFileDialog.FileName = string.Empty;
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                Stream openedStream = File.Open(openFileDialog.FileName, FileMode.Open, FileAccess.ReadWrite);
                if (openedStream != null)
                {
                    bool psx = openedStream.Length % PatcherLib.Iso.IsoPatch.SectorSizes[PatcherLib.Iso.IsoPatch.IsoType.Mode2Form1] == 0;
                    bool psp = openedStream.Length % PatcherLib.Iso.IsoPatch.SectorSizes[PatcherLib.Iso.IsoPatch.IsoType.Mode1] == 0;
                    if (psp || psx)
                    {
                        bool expanded = psx && AllSprites.DetectExpansionOfPsxIso(openedStream);

                        if (currentStream != null)
                        {
                            currentStream.Flush();
                            currentStream.Close();
                            currentStream.Dispose();
                        }
                        currentStream = openedStream;

                        AllSprites s = AllSprites.FromIso(currentStream, false);
                        allSpritesEditor1.BindTo(s, currentStream);
                        tabControl1.Enabled        = true;
                        spriteMenuItem.Enabled     = true;
                        sp2Menu.Enabled            = true;
                        menuItem_ExpandIso.Enabled = psx && !expanded;

                        AllOtherImages otherImages = AllOtherImages.FromIso(currentStream);
                        allOtherImagesEditor1.BindTo(otherImages, currentStream);

                        Text = string.Format(titleFormatString, Path.GetFileName(openFileDialog.FileName));
                    }
                }
            }
        }