Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();
            _screens = new List<ScreenBase>();
            _currScreenIdx = -1;
            _core = new TheGhostCore();

            this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);

            loadConfiguration(_core.Project.Defaults);
            this.Visible = false;

            ProjectForm frm = new ProjectForm();
            frm.Construct(_core);
            frm.ShowDialog();
            _projectFilename = frm.Project;

            if (frm.DialogResult == DialogResult.Cancel)
            {
                frm.Close();
                _core.Project.Filename = string.Empty;
                _exitApp = true;
            }
            else
            {
                frm.Close();
                _core.Project.Filename = _projectFilename;
                _core.Project.StoreProjectFiles = frm.StoreProjectFiles;
                this.Visible = true;
                _exitApp = false;
            }

            projectScreen.ScreenBusy += new ScreenBusyEventHandler(screen_ScreenBusy);
        }
Exemplo n.º 2
0
        public Project(TheGhostCore core)
        {
            _audioExport = null;
            _audioImport = null;
            _fileCopy = null;
            _audioImportInfo = null;
            _audioExportInfo = null;
            _fileCopyInfo = null;

            _songs = null;
            _tiers = null;

            _backgroundAudio = new List<ProjectBackgroundAudio>();

            _fileManager = null;
            _core = core;

            _theGhostInfo = null;

            _defaults = new ProjectDefaults();

            _storeProjectFiles = false;

            _projectSettings = new ProjectSettings(this);
            _projectSettingsGameMods = new ProjectSettingsGameMods(this);
        }
Exemplo n.º 3
0
        private void btnPrepIso_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtWorkingFolder.Text) || !File.Exists(txtIso.Text))
            {
                MessageBox.Show(this, "Input ISO or Working folder not found, drag and drop the ISO and Working Folder on to the text boxes above.", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            readDiscTitle();
            findMainPartition();

            if (!rdbGameGh3.Checked && !rdbGameGhA.Checked)
            {
                MessageBox.Show(this, "No Game selected.", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            //TODO enable message somewhere
            //if (_prepProps.EnableTierEditing == YesNo.Yes && (_prepProps.RemoveBossBattles == YesNo.Yes || _prepProps.TierSongsCount.Length != 0 ||  ))
            //{
            //    if (DialogResult.No == MessageBox.Show(this, "Adding more that 48 songs can stop the save file being restored (Tested on GH3)\r\n\r\nAre you sure you want to continue?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            //        return;
            //}

            //shortcuts to make code cleaner
            TheGhostCore core = new TheGhostCore();
            _project = core.Project;
            _plugins = core.PluginManager;

            //set up the project settings
            _project.WorkingPath = txtWorkingFolder.Text;
            _project.SourcePath = txtIso.Text;
            _project.GameId = (rdbGameGh3.Checked ? Game.GH3_Wii : Game.GHA_Wii);   //  or  GameInfo.GameStringToEnum("GH 3 (Wii)");

            _project.SetPlugins(_plugins.AudioImportPlugins["FFMpeg Plugin"],
                                _plugins.AudioExportPlugins["IMA ADPCM Plugin"],
                                _plugins.FileCopyPlugins["Wii Scrubber"]);  //no editor plugins

            _project.LanguageId = GameInfo.LanguageStringToId(cboLanguage.Text);

            bool failed = false;
            try
            {
                _project.FileManager.ImportPaks(null);
            }
            catch
            {
                failed = true;
            }
            if (failed || !_project.FileManager.PakFormat.PakFileExists)
            {
                MessageBox.Show(this, "The selected language does not exist in the ISO or file extraction failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int calcTierSongs = 0;
            int calcBonuSongs = 0;
            bool calcBossRemove = false;
            bool calcNonCareerMove = false;
            int calcSongsToAdd = 0;

            if (_prepProps.EnableTierEditing == YesNo.Yes)
            {

                if (_prepProps.Tiers != 0 && _prepProps.TierSongsTotalCount == 0)
                {
                    MessageBox.Show(this, "TierSongsCount must be set when setting TierSongs.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (_prepProps.TierSongsTotalCount != 0)
                {
                    foreach (int c in _prepProps.TierSongs)
                    {
                        if (c < 2)
                        {
                            MessageBox.Show(this, "Each Tier must contain at least 2 songs to function correctly with an encore.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                }

                bool calcTiersChanged;
                int bossSongCount = 0;
                int nonCareerOnlyCount = 0;
                int bonusSongCount = 0;
                int tierSongsCount = 0;
                bool ttfafExists = false; //does TTFAF exist in bonus, are we not editing the tier songs then inc tier counts, dec bonus counts
                bool kingQueenCredExists = false; //does kingsandqueencredits exist in bonus, are we not editing the tier songs then inc tier counts, dec bonus counts

                QbKey ttfafQk = QbKey.Create("thrufireandflames");
                QbKey kingQueenCred = QbKey.Create("kingsandqueenscredits");
                foreach (ProjectTierSong pts in _project.Songs.Values)
                {
                    switch (pts.Tier.Type)
                    {
                        case TierType.Career:
                            if (pts.SongQb.IsBoss)
                                bossSongCount++;
                            tierSongsCount++;
                            break;
                        case TierType.Bonus:
                            if (pts.SongQb.Id.Crc == ttfafQk.Crc)
                                ttfafExists = true;
                            if (pts.SongQb.Id.Crc == kingQueenCred.Crc)
                                kingQueenCredExists = true;
                            bonusSongCount++;
                            break;
                        case TierType.NonCareer:
                            nonCareerOnlyCount++;   //+1 for kingsandqueens in GHA +6 for non career songs
                            break;
                        case TierType.None:
                            break;
                        default:
                            break;
                    }
                }

                calcTierSongs = tierSongsCount; //will be the resulting value when editing the current tiers
                calcBonuSongs = bonusSongCount;

                calcBossRemove = (_prepProps.RemoveBossBattles == YesNo.Yes || _prepProps.TierSongsTotalCount != 0) && bossSongCount != 0;
                calcNonCareerMove = (_prepProps.AddNonCareerTracksToBonus == YesNo.Yes || _prepProps.TierSongsTotalCount != 0 || calcBossRemove) && nonCareerOnlyCount != 0;

                calcTiersChanged = (_prepProps.TierSongsTotalCount != 0 || calcBossRemove);

                if (calcTiersChanged) //if any change then force boss and non career move and copy career to other tier sets
                {
                    calcBossRemove = true;
                    calcNonCareerMove = true;
                }

                if (calcBossRemove)
                {
                    calcTierSongs -= bossSongCount;
                    if (ttfafExists)
                    {
                        calcTierSongs++;
                        calcBonuSongs--;
                    }
                    //if (!kingQueenCredExists && _project.GameInfo.Game == Game.GHA_Wii)
                    //    calcBonuSongs++;
                }

                if (calcNonCareerMove)
                {
                    calcBonuSongs += nonCareerOnlyCount; //+1 for kingsandqueens in GHA +6 for non career songs
                }

                calcSongsToAdd = 0;
                if (_prepProps.TierSongsTotalCount != 0)
                {
                    calcBonuSongs -= _prepProps.TierSongsTotalCount - calcTierSongs; //add or remove the difference from the bonus songs
                    calcTierSongs += _prepProps.TierSongsTotalCount - calcTierSongs;
                }

                if (calcBonuSongs < 1) //too many career songs. add more songs
                {
                    calcSongsToAdd += 1 - calcBonuSongs;
                    calcBonuSongs = 1;
                }

                if (_prepProps.BonusSongs != 0)
                {
                    calcSongsToAdd -= calcBonuSongs - _prepProps.BonusSongs;
                    calcBonuSongs = _prepProps.BonusSongs;
                }

                int existingCareerTiers = 0;
                foreach (ProjectTier t in _project.Tiers)
                {
                    if (t.Type == TierType.Career)
                        existingCareerTiers++;
                }

                if (DialogResult.OK != MessageBox.Show(this, string.Format(
            @"The following tier changes will be made to this ISO:

            {0} boss songs will be removed.{1}{2}
            {3} songs will be added to the bonus songs currently being Non Career/Bonus.{4}

            The career tiers will contain {5} songs{6}.
            The bonus tier will contain {7} songs{8}.

            The Game will contain {9} career tiers with {10} songs in total ({11} will be {12}).

            Remember that setting too many songs can cause the game to crash, read the FAQ for more information.

            Click OK to continue...",
                                           (calcBossRemove ? bossSongCount : 0).ToString(),
                                                   (calcTiersChanged) ? " (Tiers Changed)" : "",
                                                   (calcBossRemove && ttfafExists ? "\r\n    Through The Fire and Flames will be moved from the bonus tier to the career tiers.\r\n    This is because it can no longer be unlocked with out the Devil Battle" : ((calcNonCareerMove || calcBossRemove) && !kingQueenCredExists && _project.GameInfo.Game == Game.GHA_Wii ? "\r\n    Kings And Queen (End Credits Version) will be added as the last bonus song." : "")),
                                           (calcNonCareerMove ? nonCareerOnlyCount : 0).ToString(),
                                                   (calcTiersChanged) ? " (Tiers Changed)" : "",
                                           calcTierSongs.ToString(),
                                                   !calcTiersChanged ? " (no change)" : "",
                                           calcBonuSongs.ToString(),
                                                   (!calcTiersChanged && _prepProps.BonusSongs == 0) ? " (no change)" : "",
                                           _prepProps.Tiers != 0 ? _prepProps.Tiers.ToString() : existingCareerTiers.ToString(),
                                                   (calcTierSongs + calcBonuSongs).ToString(),
                                                   Math.Abs(calcSongsToAdd).ToString(),
                                                   (calcSongsToAdd < 0) ? "removed" : "added"
                   ), "ISO Songs", MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
                    return;

            }

            _shrinkPrgSize = 1;

            lblStatus.Text = "Replacing Audio";
            lblStatus.Update();

            btnPrepIso.Enabled = false;
            pgdPrep.Enabled = false;
            cboPresets.Enabled = false;
            cboLanguage.Enabled = false;
            btnPreset.Enabled = false;
            btnDiscIdSet.Enabled = false;
            btnTitleRead.Enabled = false;
            btnTitleWrite.Enabled = false;

            try
            {

                foreach (ProjectTierSong pts in _project.Songs.Values)
                {
                    pts.IsEditSong = false; //reset any edit flags
                    pts.Song = null;
                }

                if (_prepProps.EnableAudioBlanking != YesNo.Yes)
                {
                    prg.Visible = true;
                    prg.Minimum = 0;
                    _shrinkPrgSize = 1; //make the progress bar display better portions for scrubbing
                    prg.Maximum = 6;  //Extract files, build ISO, edit things, replace partition
                    prg.Value = 0;
                    Application.DoEvents();
                }
                else
                {

                    if (_prepProps.BlankTierSongs == YesNo.Yes || _prepProps.BlankBattles == YesNo.Yes)
                    {
                        foreach (ProjectTier pt in _project.Tiers)
                        {
                            if (pt.Type == TierType.Career)
                            {
                                foreach (ProjectTierSong pts in pt.Songs)
                                {
                                    if (((!pts.SongQb.IsBoss && _prepProps.BlankTierSongs == YesNo.Yes) || (pts.SongQb.IsBoss && _prepProps.BlankBattles == YesNo.Yes)) && !pts.IsAddedWithTheGhost)
                                        setEditSong(pts);
                                }
                            }
                        }
                    }

                    if (_prepProps.BlankBonus == YesNo.Yes || _prepProps.BlankBattles == YesNo.Yes)
                    {
                        foreach (ProjectTier pt in _project.Tiers)
                        {
                            if (pt.Type == TierType.Bonus)
                            {
                                foreach (ProjectTierSong pts in pt.Songs)
                                {
                                    if (((!pts.SongQb.IsBoss && _prepProps.BlankBonus == YesNo.Yes) || (pts.SongQb.IsBoss && _prepProps.BlankBattles == YesNo.Yes)) && !pts.IsAddedWithTheGhost)
                                        setEditSong(pts);
                                }
                            }
                        }
                    }

                    if (_prepProps.BlankAddedSongs == YesNo.Yes || _prepProps.BlankBattles == YesNo.Yes)
                    {
                        foreach (ProjectTier pt in _project.Tiers)
                        {
                            foreach (ProjectTierSong pts in pt.Songs)
                            {
                                if (pts.IsAddedWithTheGhost && ((!pts.SongQb.IsBoss && _prepProps.BlankAddedSongs == YesNo.Yes) || (pts.SongQb.IsBoss && _prepProps.BlankBattles == YesNo.Yes)))
                                    setEditSong(pts);
                            }
                        }
                    }

                    if (_prepProps.BlankNonCareerSongs == YesNo.Yes || _prepProps.BlankBattles == YesNo.Yes)
                    {
                        foreach (ProjectTier pt in _project.Tiers)
                        {
                            if (pt.Type == TierType.NonCareer)
                            {
                                foreach (ProjectTierSong pts in pt.Songs)
                                {
                                    if (((!pts.SongQb.IsBoss && _prepProps.BlankNonCareerSongs == YesNo.Yes) || (pts.SongQb.IsBoss && _prepProps.BlankBattles == YesNo.Yes)) && !pts.IsAddedWithTheGhost)
                                        setEditSong(pts);
                                }
                            }
                        }
                    }

                    prg.Visible = true;
                    prg.Minimum = 0;
                    _shrinkPrgSize = _project.EditSongs.Length; //make the progress bar display better portions for scrubbing
                    prg.Maximum = (_project.EditSongs.Length * 4) + (_shrinkPrgSize * 6); //*2=this loop and next, *4=File copy ImpNotesPAK, ExpNotesPAK, ExpDat, ExpWad +1 ExpQBPAK
                    prg.Value = 0;
                    Application.DoEvents();

                    replaceAudio();
                }

                replaceDataPartition(calcSongsToAdd, calcNonCareerMove, calcBossRemove, calcBonuSongs, _prepProps.TierSongs);

                lblStatus.Text = "Complete";

                MessageBox.Show(this, "Complete", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            finally
            {
                btnPrepIso.Enabled = true;
                pgdPrep.Enabled = true;
                cboPresets.Enabled = true;
                cboLanguage.Enabled = true;
                btnPreset.Enabled = true;
                btnDiscIdSet.Enabled = true;
                btnTitleRead.Enabled = true;
                btnTitleWrite.Enabled = true;
            }
        }