Exemplo n.º 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!CheckSave())
            {
                return;
            }

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            dialog.Filter           = "Madden files (*.ros;*.fra;*.db;*.rdb)|*.ros;*.fra;*.db;*.rdb|All Files (*.*)|*.*";
            dialog.FilterIndex      = 1;
            dialog.Multiselect      = false;
            dialog.ShowDialog();

            if (dialog.FileNames.Length > 0)
            {
                // If they saved above, then reverting does nothing.
                // If not, then reverting is what they wanted.

                CloseModel();

                string filename = dialog.FileNames[0];
                fb = new FB();
                db = new BEDB();

                fb.Extract(filename);
                if (fb.FB_Type != Frostbyte_type.NA)
                {
                    if (fb.FB_Type == Frostbyte_type.Franchise)
                    {
                        MessageBox.Show("Madden 19 Save Files Not Supported !", "Wrong Type", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (fb.FB_Type == Frostbyte_type.Draft)
                    {
                        MessageBox.Show("Please Load a valid Madden 19 Roster First !", "Draft Class", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (fb.FB_Type == Frostbyte_type.Roster)
                    {
                        Mad19    = true;
                        filename = fb.database;
                    }
                    manager.config.Madden19Serial = fb.Serial;
                    manager.config.Madden19UserSettingsFilename = manager.UserSettings.ReadUserSettings(manager.config.Madden19UserSettingsFilename);
                }
                else
                {
                    bigendian = db.Read(filename);
                    if (!db.isdb)
                    {
                        MessageBox.Show("Not a valid Madden Database !", "Unsupported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                filePathToLoad = filename;
                // Insert code here to process the files.
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    CleanUI();
                    statusStrip.Visible = true;
                    rosterFileLoaderThread.RunWorkerAsync();
                    //Now the model is opened.
                }
                catch (ApplicationException err)
                {
                    MessageBox.Show(err.ToString(), "Error opening file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }