/// <summary> /// Name back all [system].cfg files in the mednafen directory /// </summary> public static void SystemConfigsOn() { // get a list of systems var systems = from s in GSystem.GetSystems() select s.systemCode.ToLower(); // check the mednafen directory exists before proceeding if (Paths.isMednafenPathValid() == false) { return; } string medpath = Paths.GetPaths().mednafenExe; // iterate through each system name foreach (string sys in systems) { // check for system.cfgBackup if (File.Exists(medpath + "\\" + sys + ".cfgBackup")) { // does an original file already exist? if (File.Exists(medpath + "\\" + sys + ".cfg")) { // do nothing return; } // rename system.cfg File.Move(medpath + "\\" + sys + ".cfgBackup", medpath + "\\" + sys + ".cfg"); } } }
public static List <GSystem> GetSystems() { List <GSystem> systems = new List <GSystem>(); using (var sysCon = new MyDbContext()) { var sys = GSystem.GetSystems(); foreach (GSystem g in sys) { systems.Add(g); } return(systems); } }
public static void GetInfo(int gameID, Label sysLabel, TextBlock sysDesc, Image sysImage)//, Image gameImage) { // gets game and system info from the database and populates the right information panel // get system info first using (var context = new MyDbContext()) { var gameInfo = (from g in context.Game where g.gameId == gameID select g).FirstOrDefault(); List <GSystem> si = GSystem.GetSystems(); var sysInfo = (from s in si where s.systemId == gameInfo.systemId select new { s.systemName, s.systemDescription, s.systemId }).FirstOrDefault(); // image handling string image = @"Graphics\Icons\na.png"; if (sysInfo != null) { if (sysInfo.systemId == 10) { // master system image = @"Graphics\Systems\snes.jpg"; } else { image = @"Graphics\Icons\na.png"; } } // set system image BitmapImage b = new BitmapImage(); b.BeginInit(); b.UriSource = new Uri(image, UriKind.Relative); b.EndInit(); // ... Get Image reference from sender. //var image = sender as Image; // ... Assign Source. sysImage.Source = b; //sysImage.Source = new BitmapImage(new Uri(image, UriKind.Relative)); // set system label sysLabel.Content = sysInfo.systemName; // set system description sysDesc.Text = sysInfo.systemDescription; } }
public bool DoesParamContainSystemCode(string param) { // convert list of systemcodes to hashset var s = (from z in GSystem.GetSystems() select z.systemCode); bool itDoes = false; foreach (string code in s) { if (param.Contains(code)) { itDoes = true; break; } } return(itDoes); }
public void ImportAll(ProgressDialogController controller) { if (controller != null) { controller.SetMessage("Importing Mednafen Configs from disk\nPlease wait....."); } // import mednafen-09x.cfg into relevant config files ImportBaseConfigFromDisk(null); // get any system specific .cfg files List <GSystem> systems = GSystem.GetSystems(); foreach (GSystem sys in systems) { ImportSystemConfigFromDisk(null, sys); } // now save to database SaveToDatabase(); }
public static List <TruRipObject> Go() { // Import data for each system List <GSystem> systems = GSystem.GetSystems().ToList(); List <TruRipObject> l = new List <TruRipObject>(); foreach (var sys in systems) { // get a list of strings containing all data info for this system List <string> dats = LoadDATs(sys.systemId); // iterate through each data and parse the information into a new object foreach (string s in dats) { List <TruRipObject> list = Parse(s, sys.systemId); l.AddRange(list); } } l.Distinct(); return(l); }
public static void CheckGamesExist(MediaType mediaType) { List <GSystem> sys = new List <GSystem>(); if (mediaType == MediaType.DISC) { sys = GSystem.GetSystems().Where(a => a.systemId == 8 || a.systemId == 9 || a.systemId == 13 || a.systemId == 18).ToList(); } else if (mediaType == MediaType.ROM) { sys = GSystem.GetSystems().Where(a => a.systemId != 8 && a.systemId != 9 && a.systemId != 13 && a.systemId != 18).ToList(); } foreach (var s in sys) { } }
public static HashSet <string> GetAllowedFileExtensions(int systemId) { var exts = (from g in GSystem.GetSystems() where g.systemId == systemId select g).SingleOrDefault(); string archive = exts.supportedArchiveExtensions; string nonArchive = exts.supportedFileExtensions; HashSet <string> supported = new HashSet <string>(); char c = ','; string[] aSplit = archive.Split(c); string[] nSplit = nonArchive.Split(c); foreach (string s in aSplit) { supported.Add(s); } foreach (string s in nSplit) { supported.Add(s); } return(supported); }
// constructor public GameScanner() { // load master dat from disk string filePath = AppDomain.CurrentDomain.BaseDirectory + @"Data\System\DATMaster.json"; DAT = JsonConvert.DeserializeObject <IEnumerable <DATMerge> >(File.ReadAllText(filePath)); db = new MyDbContext(); Games = (from g in db.Game select g).ToList(); Paths = (from p in db.Paths where p.pathId == 1 select p).ToList().SingleOrDefault(); Systems = GSystem.GetSystems(); RomSystems = new List <GSystem>(); DiskSystems = new List <GSystem>(); // populate RomSystems and DiskSystems foreach (GSystem gs in Systems) { // exlude non-path systems if (gs.systemId == 16 || gs.systemId == 17) { continue; } // populate disksystems if (gs.systemId == 18 || // pcecd gs.systemId == 8 || // pcfx gs.systemId == 9 || // psx gs.systemId == 13) // Saturn { DiskSystems.Add(gs); } else { RomSystems.Add(gs); } } RomSystemsWithPaths = new List <GSystem>(); DiskSystemsWithPaths = new List <GSystem>(); // populate RomSystemsWithPaths with only entries that only have Rom paths set (and are not non-path systems like snes_faust and pce_fast) and where ROM directories are valid foreach (var sys in RomSystems) { if (GetPath(sys.systemId) == null || GetPath(sys.systemId) == "" || !Directory.Exists(GetPath(sys.systemId))) { continue; } RomSystemsWithPaths.Add(sys); } /* * for (int i = 1; RomSystems.Count >= i; i++) * { * if (GetPath(i) == null || GetPath(i) == "") * continue; * * MessageBoxResult result2 = MessageBox.Show(RomSystems[i - 1].systemName); * RomSystemsWithPaths.Add(RomSystems[i - 1]); * } */ // populate DiskSystemsWithPaths with only entries that only have Disk paths set (and are not non-path systems like snes_faust and pce_fast) foreach (var sys in DiskSystems) { if (GetPath(sys.systemId) == null || GetPath(sys.systemId) == "") { continue; } DiskSystemsWithPaths.Add(sys); } // per system lists GamesGB = (from g in Games where g.systemId == 1 select g).ToList(); GamesGBA = (from g in Games where g.systemId == 2 select g).ToList(); GamesLYNX = (from g in Games where g.systemId == 3 select g).ToList(); GamesMD = (from g in Games where g.systemId == 4 select g).ToList(); GamesGG = (from g in Games where g.systemId == 5 select g).ToList(); GamesNGP = (from g in Games where g.systemId == 6 select g).ToList(); GamesPCE = (from g in Games where g.systemId == 7 select g).ToList(); GamesPCFX = (from g in Games where g.systemId == 8 select g).ToList(); GamesPSX = (from g in Games where g.systemId == 9 select g).ToList(); GamesSMS = (from g in Games where g.systemId == 10 select g).ToList(); GamesNES = (from g in Games where g.systemId == 11 select g).ToList(); GamesSNES = (from g in Games where g.systemId == 12 select g).ToList(); GamesSS = (from g in Games where g.systemId == 13 select g).ToList(); GamesVB = (from g in Games where g.systemId == 14 select g).ToList(); GamesWSWAN = (from g in Games where g.systemId == 15 select g).ToList(); GamesPCECD = (from g in Games where g.systemId == 18 select g).ToList(); RomsToUpdate = new List <Game>(); RomsToAdd = new List <Game>(); DisksToUpdate = new List <Game>(); DisksToAdd = new List <Game>(); AddedStats = 0; HiddenStats = 0; UpdatedStats = 0; UntouchedStats = 0; }
public static string SelectGameFile() { // get all game system allowed file extensions var systems = GSystem.GetSystems(); List <string> exts = new List <string>(); foreach (var s in systems) { string sup = s.supportedFileExtensions; string[] spl = sup.Split(','); if (spl.Length > 0) { foreach (string e in spl) { exts.Add(e); } } } // remove duplicates exts.Distinct(); // add ZIP extension exts.Add(".zip"); // convert allowed types to filter string string filter = ""; string fStart = "Allowed Types ("; string fEnd = ""; foreach (string i in exts) { if (i == "") { continue; } fStart += "*" + i + ","; fEnd += "*" + i + ";"; } char comma = ','; char semi = ';'; filter = (fStart.TrimEnd(comma)) + ")|" + (fEnd.TrimEnd(semi)); //MessageBox.Show(filter); // open the file dialog showing only allowed file types - multi-select disabled OpenFileDialog filePath = new OpenFileDialog(); filePath.Multiselect = false; filePath.Filter = filter; filePath.Title = "Select a single ROM, Disc or playlist file to run with Mednafen"; filePath.ShowDialog(); if (filePath.FileName.Length > 0) { // file has been selected string file = filePath.FileName; return(file); } else { // no files selected - return empty string return(null); } }
public static List <MobyPlatformGame> GamesListScrape(ProgressDialogController controller) { string BaseUrl = "http://www.mobygames.com/browse/games/"; // get all platforms List <GSystem> systems = GSystem.GetSystems(); List <MobyPlatformGame> allGames = new List <MobyPlatformGame>(); // iterate through each system foreach (GSystem s in systems) { if (s.systemId == 16 || s.systemId == 17) { break; } foreach (string sys in s.MobyPlatformName) { if (controller != null) { controller.SetMessage("Scraping basic list of all " + sys + " games"); if (controller.IsCanceled) { return(null); } } // build initial query string to get the search page string param = sys + "/list-games"; string initialPage = ReturnWebpage(BaseUrl, param, 10000); /* Get the total number of games available for this system */ // split the html to list via line breaks List <string> html = initialPage.Split('\n').ToList(); // get only the line that contains the number of games string hLine = html.Where(a => a.Contains(" games)")).FirstOrDefault(); // get only the substring "xxx games" string resultString = Regex.Match(hLine, @"(?<=\().+?(?=\))").Value; // split by whitespace string[] gArr = resultString.Split(' '); // get int number of games int totalGames = Convert.ToInt32(gArr[0]); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(initialPage); // build a list of page URLs double numberofpages = Convert.ToDouble(totalGames) / 25; int numberOfPages = Convert.ToInt32(Math.Ceiling(numberofpages)); // connect to every page and import all the game information for (int i = 0; i < numberOfPages; i++) { if (controller != null) { if (controller.IsCanceled) { return(null); } } int offset = i * 25; string p = sys + "/offset," + offset + "/so,0a/list-games"; HtmlDocument hDoc = new HtmlDocument(); if (i == 0) { hDoc = doc; } else { string htmlRes = ReturnWebpage(BaseUrl, p, 10000); hDoc.LoadHtml(htmlRes); } // get just the data table we are interested in HtmlNode objectTable = hDoc.GetElementbyId("mof_object_list"); // iterate through each row and scrape the game information int cGame = 1; foreach (HtmlNode row in objectTable.SelectNodes("tbody/tr")) { int currentGameNumber = offset + cGame; if (controller != null) { if (controller.IsCanceled) { return(null); } controller.SetMessage("Scraping basic list of all " + sys + " games\nGame: (" + currentGameNumber + " of " + totalGames + ")\nPage: (" + (i + 1) + " of " + numberOfPages + ")"); controller.Minimum = 1; controller.Maximum = totalGames; controller.SetProgress(Convert.ToDouble(currentGameNumber)); } HtmlNode[] cells = (from a in row.SelectNodes("td") select a).ToArray(); string Title = cells[0].InnerText.Trim(); //var allLi = row.SelectSingleNode("//a[@href]"); string URLstring = cells[0].InnerHtml.Trim(); Regex regex = new Regex("href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase); Match match; string URL = ""; for (match = regex.Match(URLstring); match.Success; match = match.NextMatch()) { URL = match.Groups[1].ToString(); } MobyPlatformGame game = new MobyPlatformGame(); game.SystemId = s.systemId; game.PlatformName = sys; game.Title = WebUtility.HtmlDecode(Title); game.UrlName = WebUtility.HtmlDecode(URL.Split('/').LastOrDefault()); // add game to main list allGames.Add(game); cGame++; } } } } return(allGames); }
public static void InitialSeed() { // check whether initial seed needs to continue bool doSeed = false; using (var db = new MyDbContext()) { var se = db.GlobalSettings.FirstOrDefault(); if (se == null || se.databaseGenerated == false) { doSeed = true; } } if (doSeed == true) { /* * // Create systems * List<GameSystem> gSystems = GameSystem.GetGameSystemDefaults(); * using (var context = new MyDbContext()) * { * var gameData = context.GameSystem.AsNoTracking().ToList(); * foreach (var newEntry in gSystems) * { * var idLookup = (from e in gameData * where e.systemId == newEntry.systemId * select e).FirstOrDefault(); * * if (idLookup == null) * { * // entry doesnt exist - insert * context.GameSystem.Add(newEntry); * } * else * { * // entry exists - update * context.GameSystem.Update(newEntry); * } * } * context.SaveChanges(); * } */ // populate Versions table Versions version = Versions.GetVersionDefaults(); using (var context = new MyDbContext()) { context.Versions.Add(version); context.SaveChanges(); } // default netplay settings ConfigNetplaySettings npSettings = ConfigNetplaySettings.GetNetplayDefaults(); using (var context = new MyDbContext()) { context.ConfigNetplaySettings.Add(npSettings); context.SaveChanges(); } // default ConfigBaseSettings population ConfigBaseSettings cfbs = ConfigBaseSettings.GetConfigDefaults(); cfbs.ConfigId = 2000000000; // base configuration using (var context = new MyDbContext()) { context.ConfigBaseSettings.Add(cfbs); context.SaveChanges(); } // create system specific configs (set to disabled by default) List <GSystem> gamesystems = GSystem.GetSystems(); using (var gsContext = new MyDbContext()) { // iterate through each system and create a default config for them - setting them to disabled, setting their ID to 2000000000 + SystemID // and setting their systemident to systemid foreach (GSystem System in gamesystems) { int def = 2000000000; ConfigBaseSettings c = ConfigBaseSettings.GetConfigDefaults(); c.ConfigId = def + System.systemId; c.systemIdent = System.systemId; c.isEnabled = false; // add to databsae gsContext.ConfigBaseSettings.Add(c); gsContext.SaveChanges(); } } // Populate Servers List <ConfigServerSettings> servers = ConfigServerSettings.GetServerDefaults(); using (var context = new MyDbContext()) { context.ConfigServerSettings.AddRange(servers); context.SaveChanges(); } // Create General Settings Entry GlobalSettings gs = GlobalSettings.GetGlobalDefaults(); using (var context = new MyDbContext()) { context.GlobalSettings.Add(gs); context.SaveChanges(); } // create Paths entry Paths paths = new Paths { pathId = 1 }; using (var context = new MyDbContext()) { context.Paths.Add(paths); context.SaveChanges(); } //add test rom data /* * List<Game> roms = new List<Game> * { * new Game { gameName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8), gamePath = ".\\", systemId = 3, hidden = false, isFavorite = true }, * new Game { gameName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8), gamePath = ".\\", systemId = 10, hidden = false, isFavorite = false } * }; * using (var context = new MyDbContext()) * { * * context.Game.AddRange(roms); * context.SaveChanges(); * } */ // initial seeding complete. mark GeneralSettings table so that regeneration does not occur GlobalSettings set; using (var context = new MyDbContext()) { set = (from a in context.GlobalSettings where a.settingsId == 1 select a).FirstOrDefault <GlobalSettings>(); } if (set != null) { set.databaseGenerated = true; } using (var dbCtx = new MyDbContext()) { dbCtx.Entry(set).State = EntityState.Modified; dbCtx.SaveChanges(); } } }
public static void HideControls(WrapPanel wp, int configId) { // get a class object with all child controls UIHandler ui = UIHandler.GetChildren(wp); ConfigsVisualHandler cv = new ConfigsVisualHandler(); //Border b = (Border)cv.MWindow.FindName("brdNONDYNAMICvfilters"); // get a list of system codes List <string> codes = (from a in GSystem.GetSystems() select a.systemCode.ToString().ToLower()).ToList(); // iterate through each ui element and collapse the ones that are not needed for system specific settings if (configId != 2000000000) { //b.Visibility = Visibility.Collapsed; foreach (Button x in ui.Buttons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (CheckBox x in ui.CheckBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (ComboBox x in ui.ComboBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (NumericUpDown x in ui.NumericUpDowns) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (RadioButton x in ui.RadioButtons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (Slider x in ui.Sliders) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Collapsed; } } foreach (TextBox x in ui.TextBoxes) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("tb_Generic__")) { x.Visibility = Visibility.Collapsed; } } foreach (Label x in ui.Labels) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("lbl_cfg___") || x.Name.StartsWith("lbl_Generic__")) { x.Visibility = Visibility.Collapsed; } } } else { GlobalSettings gs = GlobalSettings.GetGlobals(); if (gs.showAllBaseSettings == true) { //b.Visibility = Visibility.Collapsed; } else { //b.Visibility = Visibility.Visible; foreach (Button x in ui.Buttons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (CheckBox x in ui.CheckBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (ComboBox x in ui.ComboBoxes) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (NumericUpDown x in ui.NumericUpDowns) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (RadioButton x in ui.RadioButtons) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (Slider x in ui.Sliders) { if (x.Name.StartsWith("cfg___")) { x.Visibility = Visibility.Visible; } } foreach (TextBox x in ui.TextBoxes) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("tb_Generic__")) { x.Visibility = Visibility.Visible; } } foreach (Label x in ui.Labels) { if (x.Name.StartsWith("cfg___") || x.Name.StartsWith("lbl_cfg___") || x.Name.StartsWith("lbl_Generic__")) { x.Visibility = Visibility.Visible; } } } } }
public static void InitialSeed() { // check whether initial seed needs to continue bool doSeed = false; using (var db = new MyDbContext()) { var se = db.GlobalSettings.FirstOrDefault(); if (se == null || se.databaseGenerated == false) { doSeed = true; } } if (doSeed == true) { // populate Versions table Versions version = Versions.GetVersionDefaults(); using (var context = new MyDbContext()) { context.Versions.Add(version); context.SaveChanges(); } // default netplay settings ConfigNetplaySettings npSettings = ConfigNetplaySettings.GetNetplayDefaults(); using (var context = new MyDbContext()) { context.ConfigNetplaySettings.Add(npSettings); context.SaveChanges(); } // default ConfigBaseSettings population ConfigBaseSettings cfbs = ConfigBaseSettings.GetConfigDefaults(); cfbs.ConfigId = 2000000000; // base configuration using (var context = new MyDbContext()) { context.ConfigBaseSettings.Add(cfbs); context.SaveChanges(); } // create system specific configs (set to disabled by default) List <GSystem> gamesystems = GSystem.GetSystems(); using (var gsContext = new MyDbContext()) { // iterate through each system and create a default config for them - setting them to disabled, setting their ID to 2000000000 + SystemID // and setting their systemident to systemid foreach (GSystem System in gamesystems) { int def = 2000000000; ConfigBaseSettings c = ConfigBaseSettings.GetConfigDefaults(); c.ConfigId = def + System.systemId; c.systemIdent = System.systemId; c.isEnabled = false; // add to databsae gsContext.ConfigBaseSettings.Add(c); gsContext.SaveChanges(); } } // Populate Servers List <ConfigServerSettings> servers = ConfigServerSettings.GetServerDefaults(); using (var context = new MyDbContext()) { context.ConfigServerSettings.AddRange(servers); context.SaveChanges(); } // Create General Settings Entry GlobalSettings gs = GlobalSettings.GetGlobalDefaults(); using (var context = new MyDbContext()) { context.GlobalSettings.Add(gs); context.SaveChanges(); } // create mednanet general entry MednaNetSettings ms = MednaNetSettings.GetMednaNetDefaults(); using (var context = new MyDbContext()) { context.MednaNetSettings.Add(ms); context.SaveChanges(); } // create Paths entry Paths paths = new Paths { pathId = 1 }; using (var context = new MyDbContext()) { context.Paths.Add(paths); context.SaveChanges(); } // initial seeding complete. mark GeneralSettings table so that regeneration does not occur GlobalSettings set; using (var context = new MyDbContext()) { set = (from a in context.GlobalSettings where a.settingsId == 1 select a).FirstOrDefault <GlobalSettings>(); } if (set != null) { set.databaseGenerated = true; } using (var dbCtx = new MyDbContext()) { dbCtx.Entry(set).State = EntityState.Modified; dbCtx.SaveChanges(); } } }
// Constructor public GameLauncher(int gameId) { db = new MyDbContext(); GameId = gameId; // get Game object Game game = (from g in db.Game where g.gameId == gameId select g).SingleOrDefault(); ConfigId = game.configId; RomPath = game.gamePath; RomName = game.gameName; // get globals Global = (from g in db.GlobalSettings where g.settingsId == 1 select g).SingleOrDefault(); SystemId = game.systemId; // do PSX sbi check and check whether game file actually exists (as it might have been renamed) if (SystemId == 9 && File.Exists(game.gamePath)) { // get all implied files from othe cue/m3u that is in the database string cuePath = game.gamePath; // this is never relative with disc-based games DiscGameFile originalCue = new DiscGameFile(cuePath, 9); List <DiscGameFile> imageFiles = new List <DiscGameFile>(); // DiscScan.ParseTrackSheetForImageFiles(new DiscGameFile(cuePath, 9), 9); // check whether m3u if (originalCue.Extension.ToLower() == ".m3u") { // get all cue files var allc = DiscScan.ParseTrackSheet(originalCue, CueType.m3u, SystemId); foreach (var g in allc) { imageFiles.Add(g); } } else { // standard cue file imageFiles.Add(originalCue); } // iterate through each image and check for serial number for (int i = 0; i < imageFiles.Count; i++) { string serial = MedDiscUtils.GetPSXSerial(imageFiles[i].FullPath); if (serial == null || serial == "") { continue; } // add serial to imageFiles imageFiles[i].ExtraInfo = serial; } // if imageFile has only one entry, then this matches originalCue if (imageFiles.Count == 1) { if (PsxSBI.IsSbiAvailable(imageFiles.First().ExtraInfo) == true) { // sbi is available - check whether sbi already exists string sbipath = imageFiles.First().FullPath.Replace(imageFiles.First().Extension, ".sbi"); //if (!File.Exists(imageFiles.First().FolderPath + "\\" + imageFiles.First().FileName.Replace(imageFiles.First().Extension, "") + ".sbi")) if (!File.Exists(sbipath)) { var result = MessagePopper.ShowMessageDialog("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", "SBI Patch Needed - " + imageFiles.First().FileName, MessagePopper.DialogButtonOptions.YESNO); //MessageBoxResult result = MessageBox.Show("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", // "SBI Patch Needed - " + imageFiles.First().FileName, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessagePopper.ReturnResult.Affirmative) { // copy sbi file to folder (named the same as the cue file) originalCue.ExtraInfo = imageFiles.First().ExtraInfo; //PsxSBI.InstallSBIFile(originalCue); PsxSBI.InstallSBIFile(imageFiles.First()); } } } } // if imageFiles has multiple entries - it will have come from an m3u file if (imageFiles.Count > 1) { // create an array of m3u cue files string[] cues = File.ReadAllLines(originalCue.FullPath); // loop through for (int image = 0; image < imageFiles.Count; image++) { if (PsxSBI.IsSbiAvailable(imageFiles[image].ExtraInfo) == true) { // sbi is available - prompt user if (!File.Exists(imageFiles[image].FolderPath + "\\" + imageFiles[image].FileName.Replace(imageFiles[image].Extension, "") + ".sbi")) { var result = MessagePopper.ShowMessageDialog("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", "SBI Patch Needed - " + imageFiles.First().FileName, MessagePopper.DialogButtonOptions.YESNO); //MessageBoxResult result = MessageBox.Show("MedLaunch has determined that you need an available SBI patch file to play this game properly.\n\nDo you wish to copy this file to your disc directory?\n", //"SBI Patch Needed - " + imageFiles[image].FileName + imageFiles[image].Extension, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessagePopper.ReturnResult.Affirmative) { // copy sbi file to folder (named the same as the cue file) DiscGameFile d = new DiscGameFile(cues[image], 9); d.ExtraInfo = imageFiles[image].ExtraInfo; PsxSBI.InstallSBIFile(d); } } } } } } // logic for faust & fast if (game.systemId == 12) { if (Global.enableSnes_faust == true) { SystemId = 16; //MessageBoxResult result = MessageBox.Show("FAUST DETECTED"); } else { SystemId = game.systemId; } } if (game.systemId == 7 || game.systemId == 18) { if (Global.enablePce_fast == true) { SystemId = 17; } else { SystemId = 7; } } gSystem = GSystem.GetSystems().Where(a => a.systemId == SystemId).Single(); SystemCode = gSystem.systemCode; RomFolder = GetRomFolder(SystemId, db); MednafenFolder = (from m in db.Paths select m.mednafenExe).SingleOrDefault(); // set the config id int actualConfigId = SystemId + 2000000000; // take general settings from base config (2000000000) and system specific settings from actual config ConfigBaseSettings _config = (from c in db.ConfigBaseSettings where (c.ConfigId == actualConfigId) select c).SingleOrDefault(); List <ConfigObject> sysConfigObject = ListFromType(_config).Where(a => !a.Key.StartsWith("__")).ToList(); SysConfigObject = new List <ConfigObject>(); foreach (var x in sysConfigObject) { var systems = GSystem.GetSystems().Where(a => a.systemCode != SystemCode); bool isValid = true; foreach (var sc in systems) { if (x.Key.StartsWith(sc.systemCode + "__")) { isValid = false; break; } } if (isValid == true) { SysConfigObject.Add(x); } } // if option is enabled save system specific config for this system if (Global.saveSystemConfigs == true) { if (SystemCode == "pcecd") { SystemCode = "pce"; } SaveSystemConfigToDisk(SystemCode, SysConfigObject); } // build actual config list //ConfObject = new List<ConfigObject>(); //ConfObject.AddRange(GenConfigObject); //ConfObject.AddRange(SysConfigObject); /* * if (_config.isEnabled == true) * { * Config = _config; * } * else * { * Config = (from c in db.ConfigBaseSettings * where c.ConfigId == 2000000000 * select c).SingleOrDefault(); * } */ // get netplay Netplay = (from n in db.ConfigNetplaySettings where n.ConfigNPId == 1 select n).SingleOrDefault(); // get server Server = (from s in db.ConfigServerSettings where s.ConfigServerId == Global.serverSelected select s).SingleOrDefault(); // get overide server settings (password and gamekey from custom ServerOveride = (from s in db.ConfigServerSettings where s.ConfigServerId == 100 select s).SingleOrDefault(); }
public static void ScrapeBasicGamesList(ProgressDialogController controller) { List <GDBPlatformGame> gs = new List <GDBPlatformGame>(); int count = 0; int sysCount = GSystem.GetSystems().Count - 3; if (controller != null) { controller.Minimum = 0; controller.Maximum = sysCount; } foreach (GSystem sys in GSystem.GetSystems()) { if (controller.IsCanceled) { controller.CloseAsync(); return; } // skip systems that are not needed if (sys.systemId == 16 || sys.systemId == 17 || sys.systemId == 18) { continue; } count++; List <GDBNETGameSearchResult> merged = new List <GDBNETGameSearchResult>(); if (controller != null) { controller.SetProgress(Convert.ToDouble(count)); controller.SetMessage("Retrieving Game List for Platform: " + sys.systemName); //controller.SetIndeterminate(); } // perform lookups foreach (int gid in sys.theGamesDBPlatformId) { if (controller.IsCanceled) { controller.CloseAsync(); return; } List <GDBNETGameSearchResult> result = GDBNETGamesDB.GetPlatformGames(gid).ToList(); if (result.Count == 0) { // nothing returned if (controller != null) { controller.SetMessage("No results returned.\n Maybe an issue connecting to thegamesdb.net..."); Task.Delay(2000); } } foreach (var r in result) { if (controller.IsCanceled) { controller.CloseAsync(); return; } GDBPlatformGame gsingle = new GDBPlatformGame(); gsingle.id = r.ID; gsingle.SystemId = sys.systemId; gsingle.GameTitle = r.Title; gsingle.GDBPlatformName = GSystem.ReturnGamesDBPlatformName(gid); gsingle.ReleaseDate = r.ReleaseDate; gs.Add(gsingle); } } // remove duplicates gs.Distinct(); // now we have a complete list of games for our platforms from thegamesdb.net - update the local json file if (controller != null) { controller.SetMessage("Saving to file..."); } if (controller.IsCanceled) { return; } string filePath = @"..\..\Data\System\TheGamesDB.json"; string json = JsonConvert.SerializeObject(gs, Formatting.Indented); File.WriteAllText(filePath, json); } }
// Constructor public GameLauncher(int gameId) { db = new MyDbContext(); GameId = gameId; // get Game object Game game = (from g in db.Game where g.gameId == gameId select g).SingleOrDefault(); ConfigId = game.configId; RomPath = game.gamePath; RomName = game.gameName; // get globals Global = (from g in db.GlobalSettings where g.settingsId == 1 select g).SingleOrDefault(); SystemId = game.systemId; // logic for faust & fast if (game.systemId == 12) { if (Global.enableSnes_faust == true) { SystemId = 16; //MessageBoxResult result = MessageBox.Show("FAUST DETECTED"); } else { SystemId = game.systemId; } } if (game.systemId == 7 || game.systemId == 18) { if (Global.enablePce_fast == true) { SystemId = 17; } else { SystemId = 7; } } gSystem = GSystem.GetSystems().Where(a => a.systemId == SystemId).Single(); SystemCode = gSystem.systemCode; RomFolder = GetRomFolder(SystemId, db); MednafenFolder = (from m in db.Paths select m.mednafenExe).SingleOrDefault(); // set the config id int actualConfigId = SystemId + 2000000000; // take general settings from base config (2000000000) and system specific settings from actual config ConfigBaseSettings _config = (from c in db.ConfigBaseSettings where (c.ConfigId == actualConfigId) select c).SingleOrDefault(); List <ConfigObject> sysConfigObject = ListFromType(_config).Where(a => !a.Key.StartsWith("__")).ToList(); SysConfigObject = new List <ConfigObject>(); foreach (var x in sysConfigObject) { var systems = GSystem.GetSystems().Where(a => a.systemCode != SystemCode); bool isValid = true; foreach (var sc in systems) { if (x.Key.StartsWith(sc.systemCode + "__")) { isValid = false; break; } } if (isValid == true) { SysConfigObject.Add(x); } } // if option is enabled save system specific config for this system if (Global.saveSystemConfigs == true) { if (SystemCode == "pcecd") { SystemCode = "pce"; } SaveSystemConfigToDisk(SystemCode, SysConfigObject); } // build actual config list //ConfObject = new List<ConfigObject>(); //ConfObject.AddRange(GenConfigObject); //ConfObject.AddRange(SysConfigObject); /* * if (_config.isEnabled == true) * { * Config = _config; * } * else * { * Config = (from c in db.ConfigBaseSettings * where c.ConfigId == 2000000000 * select c).SingleOrDefault(); * } */ // get netplay Netplay = (from n in db.ConfigNetplaySettings where n.ConfigNPId == 1 select n).SingleOrDefault(); // get server Server = (from s in db.ConfigServerSettings where s.ConfigServerId == Global.serverSelected select s).SingleOrDefault(); // get overide server settings (password and gamekey from custom ServerOveride = (from s in db.ConfigServerSettings where s.ConfigServerId == 100 select s).SingleOrDefault(); }
public static void ScrapeBasicDocsList(ProgressDialogController controller) { List <ReplacementDocs> rdlist = new List <ReplacementDocs>(); // iterate through mednafen systems var systems = GSystem.GetSystems(); foreach (var sys in systems) { controller.SetMessage("Getting manual links for: " + sys.systemName + "\n"); if (sys.systemId == 16 || sys.systemId == 17 || sys.systemId == 18) { continue; } List <int> rdsystems = ConvertSystemId2RDSystemId(sys.systemId); // iterate through replacementdocs systems foreach (int s in rdsystems) { // get the whole page for this system WebOps wo = new WebOps(); wo.BaseUrl = "http://www.replacementdocs.com/download.php?"; wo.Params = "1.list." + s.ToString() + ".1000.download_name.ASC"; wo.Timeout = 20000; string result = wo.ApiCall(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(result); HtmlNode table = doc.DocumentNode.SelectSingleNode("//table[contains(@class, 'fborder')]"); // iterate through each table row foreach (HtmlNode row in table.ChildNodes) { if (row.ChildNodes.Count > 0) { HtmlNode[] cells = (from a in row.SelectNodes("td") select a).ToArray(); if (cells[0].InnerHtml.Contains("download.php?view.")) { // this is a data cell string title = cells[0].InnerText.Replace("\t", "").Trim(); string url = cells[0].InnerHtml.Replace("\t", "").Trim().Replace("<a href='download.php?view.", ""); string[] urlArr = url.Split('\''); string fileId = urlArr[0]; var recordcheck = (from a in rdlist where a.GameName == title && a.TGBSystemName == ConvertRDSystemId2TGBPlatformName(s) select a).ToList(); if (recordcheck.Count > 0) { ReplacementDocs r = recordcheck.FirstOrDefault(); r.Urls.Add("http://www.replacementdocs.com/request.php?" + fileId); r.Urls.Distinct(); rdlist.Add(r); } else { ReplacementDocs r = new ReplacementDocs(); r.GameName = title; r.TGBSystemName = ConvertRDSystemId2TGBPlatformName(s); r.Urls.Add("http://www.replacementdocs.com/request.php?" + fileId); r.Urls.Distinct(); rdlist.Add(r); } rdlist.Distinct(); } } } } } // save rdlist to json string json = JsonConvert.SerializeObject(rdlist, Formatting.Indented); File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Data\System\replacementdocs-manuals.json", json); }
// Update database with all platform games public static List <GDBPlatformGame> DatabasePlatformGamesImport(ProgressDialogController controller) { // create a new object for database import List <GDBPlatformGame> gs = new List <GDBPlatformGame>(); int count = 0; int sysCount = GSystem.GetSystems().Count - 3; controller.Minimum = 0; controller.Maximum = sysCount; foreach (GSystem sys in GSystem.GetSystems()) { // skip systems that are not needed if (sys.systemId == 16 || sys.systemId == 17 || sys.systemId == 18) { continue; } count++; List <GameSearchResult> merged = new List <GameSearchResult>(); controller.SetProgress(Convert.ToDouble(count)); controller.SetMessage("Retrieving Game List for Platform: " + sys.systemName); //controller.SetIndeterminate(); // perform lookups foreach (int gid in sys.theGamesDBPlatformId) { List <GameSearchResult> result = TheGamesDBAPI.GamesDB.GetPlatformGames(gid).ToList(); if (result.Count == 0) { // nothing returned controller.SetMessage("No results returned.\n Maybe an issue connecting to thegamesdb.net..."); Task.Delay(2000); } merged.AddRange(result); } // remove duplicates List <GameSearchResult> nodupe = merged.Distinct().ToList(); // convert to GDBPlatformGame format and add to top list foreach (var n in nodupe) { GDBPlatformGame gsingle = new GDBPlatformGame(); gsingle.id = n.ID; gsingle.SystemId = sys.systemId; gsingle.GameTitle = n.Title; gsingle.ReleaseDate = n.ReleaseDate; gs.Add(gsingle); } } // now we have a complete list of games for our platforms from thegamesdb.net - add or update the database controller.SetMessage("Saving to Database..."); return(gs); // first get the current data //List<GDBPlatformGame> current = GDBPlatformGame.GetGames(); }