コード例 #1
0
        }         //GEN-LAST:event_btnClearActionPerformed

        private void btnImportCheatDBActionPerformed([email protected] evt)
        {         //GEN-FIRST:event_btnImportCheatDBActionPerformed
            File cheatDBFile = new File("cheat.db");

            if (cheatDBFile.canRead())
            {
                try
                {
                    System.IO.StreamReader reader = new System.IO.StreamReader(cheatDBFile);
                    bool insideApplicationid      = false;
                    while (reader.ready())
                    {
                        string line = reader.ReadLine();
                        if (string.ReferenceEquals(line, null))
                        {
                            // end of file
                            break;
                        }
                        line = line.Trim();
                        if (line.StartsWith("_S ", StringComparison.Ordinal))
                        {
                            string applicationId = line.Substring(2).Trim().Replace("-", "");
                            insideApplicationid = applicationId.Equals(State.discId, StringComparison.OrdinalIgnoreCase);
                        }
                        if (insideApplicationid)
                        {
                            // Add the line to the cheat codes
                            addCheatLine(line);
                        }
                    }
                    reader.Close();
                }
                catch (IOException e)
                {
                    Emulator.Console.WriteLine("Import from cheat.db", e);
                }
            }
            else
            {
                JpcspDialogManager.showInformation(this, java.util.ResourceBundle.getBundle("pspsharp/languages/pspsharp").getString("CheatsGUI.strReadFromDB.text"));
            }
        }         //GEN-LAST:event_btnImportCheatDBActionPerformed