static void Main(string[] args) { bool terminate; LoadConfig(out terminate); if (terminate) { return; } LoadDBConfig(out terminate); if (terminate) { return; } if (args.Length == 0) { // For our application-idle task queue Application.Idle += new EventHandler(Application_Idle); // Called before RomDB.LoadDBs so if there is an error, the error window looks pretty. Yes, really. Application.EnableVisualStyles(); // Load and parse all DBs RomDB.LoadDBs(); Application.Run(new HashForm()); } SaveConfig(); // Database config is save when (and only when) user re-configured DBs }
private ClrMameProParser(DBConfig.Database info, string document, IList <Platforms> platform) { this.info = info; this.reader = new CmpReader(document); this.document = document; result = new RomDB(platform, info.Name); }
/// <summary> /// Gets friendly display string for DB version /// </summary> /// <param name="db"></param> /// <returns></returns> private static string GetDbVersionString(RomDB db) { if (string.IsNullOrEmpty(db.Version)) { return("(" + db.Name + " version unknown)"); } return("(" + db.Name + " version " + db.Version + ")"); }
private static void AddDbMatches(RomData data, List <DBMatch> matches, RomDB db) { var dbmatches = db.FindMatches(data.Hashes); for (int i = 0; i < dbmatches.Count; i++) { matches.Add(new DBMatch(db, dbmatches[i])); } }
/// <summary> /// Displays a database config dialog to the users, and re-loads databases when the dialog is dismissed. /// </summary> internal static void ConfigureDatabases() { (new frmDBConfig()).ShowDialog(); RomDB.UnloadDbs(); Program.SaveConfig(); SaveDBConfig(); RomDB.LoadDBs(); }
/// <summary> /// Creates a DBMatch object /// </summary> /// <param name="database">The ROM database this match corresponds to.</param> /// <param name="entry">The matched entry.</param> /// <exception cref="NullReferenceException">Thrown if any arguments are null.</exception> public DBMatch(RomDB database, RomDB.Entry entry) : this() { this.Database = database; this.Entry = entry; if (this.Database == null || this.Entry == null) { throw new ArgumentNullException(); } }
private static byte parsebyte(string s, int index) { int result = 0; if (index + 2 > s.Length) { throw new ArgumentException("String is not a valid hex number"); } char c = s[index]; if (c >= '0' & c <= '9') { result = c - '0'; } else if (c >= 'a' & c <= 'f') { result = c - 'a' + 10; } else if (c >= 'A' & c <= 'F') { result = c - 'A' + 10; } else { throw new ArgumentException("String is not a valid hex number"); } // Move nibble to high result <<= 4; c = s[index + 1]; if (c >= '0' & c <= '9') { result |= c - '0'; } else if (c >= 'a' & c <= 'f') { result |= c - 'a' + 10; } else if (c >= 'A' & c <= 'F') { result |= c - 'A' + 10; } else { throw new ArgumentException("String is not a valid hex number"); } return((byte)result); }
/// <summary> /// Finds ROM database matches for a given RomData object, and populates the RomData object with those matches. /// </summary> /// <param name="data">A RomData object that has its hash list populated but not its db match list</param> private static void FindDbMatches(RomData data) { List <DBMatch> matches = new List <DBMatch>(); if (data.Platform != null) { List <RomDB> processedDbs = new List <RomDB>(); // Recognized systems foreach (var db in RomDB.GetDBs(data.Platform.ID)) { AddDbMatches(data, matches, db); processedDbs.Add(db); } if (!string.IsNullOrEmpty(data.MiscPlatform)) { // Unrecognized system foreach (var db in RomDB.GetAllDBs()) { // Don't process same DB twice bool platformMatch = false; foreach (var platform in db.MiscPlatforms) { if (platform.Equals(data.MiscPlatform, StringComparison.OrdinalIgnoreCase)) { platformMatch = true; } } if (platformMatch) { AddDbMatches(data, matches, db); processedDbs.Add(db); } } } } data.DatabaseMatches = matches.AsReadOnly(); }