public static List <CheatInfo> Load(string filepath, string gameName, string gameCrc)
 {
     try {
         XmlDocument xml = new XmlDocument();
         xml.Load(filepath);
         return(NestopiaCheatLoader.Load(xml, gameName, gameCrc, filepath));
     } catch {
         //Invalid xml file
         MesenMsgBox.Show("InvalidXmlFile", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, Path.GetFileName(filepath));
         return(null);
     }
 }
 public static List <CheatInfo> Load(Stream cheatFile, string gameName, string gameCrc)
 {
     try {
         XmlDocument xml = new XmlDocument();
         xml.Load(cheatFile);
         return(NestopiaCheatLoader.Load(xml, gameName, gameCrc, ""));
     } catch {
         //Invalid xml file
         MesenMsgBox.Show("InvalidXmlFile", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, string.Empty);
         return(null);
     }
 }
Пример #3
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            _cheats = NestopiaCheatLoader.Load(ResourceManager.GetZippedResource("MesenCheatDb.xml"), "", "");

            _gamesByCrc = new Dictionary <string, GameInfo>();
            foreach (CheatInfo cheat in _cheats)
            {
                if (_gamesByCrc.ContainsKey(cheat.GameName))
                {
                    _gamesByCrc[cheat.GameCrc].CheatCount++;
                }
                else
                {
                    _gamesByCrc[cheat.GameCrc] = new GameInfo()
                    {
                        Name = cheat.GameName, Crc = cheat.GameCrc, CheatCount = 1
                    };
                }
            }

            lblCheatCount.Text = ResourceHelper.GetMessage("CheatsFound", _gamesByCrc.Count.ToString(), _cheats.Count.ToString());
            lstGames.Sorted    = true;

            txtSearch.Focus();
            UpdateList();

            RomInfo info = InteropEmu.GetRomInfo();

            if (!string.IsNullOrWhiteSpace(info.GetRomName()))
            {
                string loadedGameCrc = info.GetPrgCrcString();
                for (int i = 0, len = lstGames.Items.Count; i < len; i++)
                {
                    if (((GameInfo)lstGames.Items[i]).Crc == loadedGameCrc)
                    {
                        lstGames.TopIndex      = Math.Max(0, i - 10);
                        lstGames.SelectedIndex = i;
                        break;
                    }
                }
            }
        }
Пример #4
0
        private void btnBrowseCheat_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = ResourceHelper.GetMessage("FilterCheat");
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _cheatFile        = ofd.FileName;
                _isMesenCheatFile = NestopiaCheatLoader.IsMesenCheatFile(_cheatFile);
                if (_isMesenCheatFile)
                {
                    txtGameName.Text = "";
                    _gameName        = "";
                    _gameCrc         = "";
                }
                txtCheatFile.Text = Path.GetFileName(_cheatFile);
                UpdateImportButton();
            }
        }
Пример #5
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (File.Exists(_cheatFile))
            {
                switch (Path.GetExtension(_cheatFile).ToLowerInvariant().Substring(1))
                {
                default:
                case "xml":
                    ImportedCheats = NestopiaCheatLoader.Load(_cheatFile, _gameName, _gameCrc);
                    break;

                case "cht":
                    ImportedCheats = FceuxCheatLoader.Load(_cheatFile, _gameName, _gameCrc);
                    break;
                }
            }

            if (ImportedCheats != null)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }