示例#1
0
        // Opening ROM
        private void Open(string filename)
        {
            if (AppControl.WriteToROMAndCloseWindows())
            {
                MessageBox.Show("All of the editor's windows must be closed before loading a new ROM.",
                                "Lazy Shell", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            bool ret;

            if (filename == null)             // Load the rom
            {
                ret = AppControl.OpenRomFile();
            }
            else
            {
                ret = AppControl.OpenRomFile(filename);
            }
            if (ret && !AppControl.Locked())             // Verify it is a SMRPG rom of the correct version
            {
                if (AppControl.GameCode() != "ARWE")
                {
                    if (MessageBox.Show("The game code for this ROM is invalid. There will likely be problems editing the ROM.\n\nLoad anyways?",
                                        "Lazy Shell", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        return;
                    }
                }
                toolStrip2.Enabled = true;
                foreach (ToolStripItem item in toolStrip4.Items)
                {
                    if (item != recentFiles && item != openSettings)
                    {
                        item.Enabled = true;
                    }
                }
                this.saveROM.Enabled         = true;
                this.saveROMAs.Enabled       = true;
                this.restoreElements.Enabled = true;
                AppControl.CreateNewMd5Checksum();                 // Create a new checksum for a new rom
                UpdateRomInfo();
            }
            else if (ret)
            {
                if (AppControl.Locked())
                {
                    this.saveROM.Enabled         = true;
                    this.saveROMAs.Enabled       = true;
                    this.restoreElements.Enabled = true;
                    UpdateRomInfo();
                }
                toolStrip2.Enabled = false;
                foreach (ToolStripItem item in toolStrip4.Items)
                {
                    if (item != recentFiles && item != openSettings)
                    {
                        item.Enabled = false;
                    }
                }
            }
            if (ret)
            {
                mruManager.Add(AppControl.GetPathWithoutFileName() + AppControl.GetFileNameWithoutPath());
                settings.Save();
            }
            if (toolStrip2.Enabled && settings.LoadAllData)
            {
                AppControl.LoadAll();
            }
        }