public MultiSystem(DatabaseGame gameObject) { this.gameObject = gameObject; }
internal DatabaseGame(DatabaseGame game) { this.RomName = game.RomName; this.Description = game.Description; this.Genre = game.Genre; this.Year = game.Year; this.name = game.name; this.Rating = game.Rating; this.Enabled = game.Enabled; this.CloneOf = game.CloneOf; this.Index = game.Index; this.Image = game.Image; this.Manufacturer = game.Manufacturer; this.Crc = game.Crc; }
/// <summary> /// Get Game values for given favorite /// </summary> /// <param name="romName"></param> /// <param name="system"></param> internal void QueryFavorite(string romName, string system) { string mainMenuXml = Path.Combine(dbPath, system + "\\" + system + ".xml"); XDocument xdoc = null; DatabaseGame g = new DatabaseGame(); if (system == "Future Pinball") { Console.WriteLine(""); } using (XmlReader xr = XmlReader.Create(mainMenuXml)) { try { xdoc = XDocument.Load(xr); } catch (XmlException e) { MessageBox.Show(e.Message); } } try { var gameVars = from item in xdoc.Descendants("game") where (item.Attribute("name").Value.Contains(romName) && (item.Element("cloneof").Value == "")) select new { RomName = item.Attribute("name").Value, Enabled = 1, Description = item.Element("description").Value, CloneOf = item.Element("cloneof").Value, CRC = item.Element("crc").Value, Manufacturer = item.Element("manufacturer").Value, Genre = item.Element("genre").Value, Year = Convert.ToInt32(item.Element("year").Value), Rating = item.Element("rating").Value, System = system }; try { foreach (var item in gameVars) { if (item != null) { FavesOutList.Add(new DatabaseGame(item.RomName, "", "", item.Description, item.CloneOf, item.CRC, item.Manufacturer, item.Year, item.Genre, item.Rating, item.Enabled, system)); } } } catch (NullReferenceException e) { } } catch (Exception) { } }
/// <summary> /// Return the full path to selected cell /// </summary> /// <param name="columnHeader"></param> /// <param name="game_click"></param> /// <param name="hsPath"></param> /// <returns></returns> public string getFullPath(string columnHeader, DatabaseGame game_click, string hsPath) { //SystemName = systemName; switch (columnHeader) { case "Name": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Wheel\\"; IsHyperspin = true; break; case "Description": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Wheel\\"; IsHyperspin = true; break; case "Manufacturer": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Wheel\\"; IsHyperspin = true; break; case "Artwork1": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Artwork1\\"; IsHyperspin = true; break; case "Artwork2": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Artwork2\\"; IsHyperspin = true; break; case "Artwork3": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Artwork3\\"; IsHyperspin = true; break; case "Artwork4": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Artwork4\\"; IsHyperspin = true; break; case "Theme": IsHyperspin = true; FullPath = hsPath + "\\Media\\" + SystemName + "\\Themes\\"; break; case "Video": FullPath = hsPath + "\\Media\\" + SystemName + "\\Video\\"; IsHyperspin = true; break; case "Background": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Backgrounds\\"; IsHyperspin = true; break; case "Wheel": FullPath = hsPath + "\\Media\\" + SystemName + "\\Images\\Wheel\\"; IsHyperspin = true; break; case "Letters": FullPath = hsPath + "\\Media\\" + game_click.RomName + "\\Images\\Letters\\"; IsHyperspin = true; break; case "Special": FullPath = hsPath + "\\Media\\" + game_click.RomName + "\\Images\\Special\\"; IsHyperspin = true; break; case "GenreBG": FullPath = hsPath + "\\Media\\" + game_click.RomName + "\\Images\\Genre\\Backgrounds\\"; IsHyperspin = true; break; case "GenreWheel": FullPath = hsPath + "\\Media\\" + game_click.RomName + "\\Images\\Genre\\Wheel\\"; IsHyperspin = true; break; case "Pointer": FullPath = hsPath + "\\Media\\" + game_click.RomName + "\\Images\\Other\\"; IsHyperspin = true; break; case "Snds-Wheel": FullPath = hsPath + "\\Media\\" + game_click.RomName + "\\Sound\\Wheel Sounds\\"; IsHyperspin = true; break; case "BG-Music": FullPath = hsPath + "\\Media\\" + SystemName + "\\Sound\\Background Music\\"; IsHyperspin = true; break; //RocketLaunch Folders case "Artwork": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Backgrounds": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Bezels": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Cards": FullPath = setRLMediaPath("Bezels", game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Controller": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Fade": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Guides": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Manuals": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "MultiGame": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Music": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Saves": FullPath = setRLMediaPath("Saved Games", game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; case "Videos": FullPath = setRLMediaPath(columnHeader, game_click.RomName, SystemName, hsPath); IsHyperspin = false; break; default: break; } return FullPath; }
/// <summary> /// Returns the 4 values from the ini for the game sent to this /// times played, last time played , average, total time /// </summary> /// <param name="systemName"></param> /// <param name="romName"></param> /// <returns></returns> public void GetSingleGameStats(DatabaseGame game) { IniFile ini = new IniFile(); ini.Load(RLPath + "\\Data\\Statistics\\" + SystemName + ".ini"); var i = ini.GetSection(RomName); if (i == null) return; try { TimesPlayed = Convert.ToInt32(ini.GetKeyValue(RomName, "Number_of_Times_Played")); } catch (Exception) { } try { LastTimePlayed = Convert.ToDateTime(ini.GetKeyValue(RomName, "Last_Time_Played")); } catch (Exception) { } try { var avgTime = TimeSpan.Parse(ini.GetKeyValue(RomName, "Average_Time_Played")).Days; AvgTimePlayed = new TimeSpan(0, 0, avgTime); } catch (Exception) { } try { var TotalTime = TimeSpan.Parse(ini.GetKeyValue(RomName, "Total_Time_Played")).Days; TotalTimePlayed = new TimeSpan(0, 0, TotalTime); TotalOverallTime = TotalOverallTime + TotalTimePlayed; } catch (Exception) { } }
public virtual void UpdateGameBools(string column, string fullPath,DatabaseGame game = null) { FullPath = fullPath; switch (column) { case "Wheel": if (FileManagement.CheckForFile(fullPath + game.RomName + ".png")) game.HaveWheel = true; else game.HaveWheel = false; break; case "Background": if (FileManagement.CheckForFile(fullPath + game.RomName + ".png")) game.HaveBackgroundsHS = true; else game.HaveBackgroundsHS = false; break; case "Artwork1": if (FileManagement.CheckForFile(fullPath + game.RomName + ".png")) game.HaveArt1 = true; else game.HaveArt1 = false; break; case "Artwork2": if (FileManagement.CheckForFile(fullPath + game.RomName + ".png")) game.HaveArt2 = true; else game.HaveArt2 = false; break; case "Artwork3": if (FileManagement.CheckForFile(fullPath + game.RomName + ".png")) game.HaveArt3 = true; else game.HaveArt3 = false; break; case "Artwork4": if (FileManagement.CheckForFile(fullPath + game.RomName + ".png")) game.HaveArt4 = true; else game.HaveArt4 = false; break; case "Theme": if (FileManagement.CheckForFile(fullPath + game.RomName + ".zip")) game.HaveTheme = true; else game.HaveTheme = false; break; case "Video": if (FileManagement.CheckForFile(fullPath + game.RomName + ".mp4")) game.HaveVideo = true; else if (FileManagement.CheckForFile(fullPath + game.RomName + ".flv")) game.HaveVideo = true; else if (FileManagement.CheckForFile(fullPath + game.RomName + ".png")) game.HaveVideo = true; else game.HaveVideo = false; break; case "Letters": FullPath = HSPath + "\\Media\\" + SystemName + "\\Images\\Letters\\"; // DisplaySelectedImage(game_click); break; case "Special": FullPath = HSPath + "\\Media\\" + SystemName + "\\Images\\Special"; // DisplaySelectedImage(game_click); break; case "GenreBG": FullPath = HSPath + "\\Media\\" + SystemName + "\\Images\\Genre\\Backgrounds\\"; // DisplaySelectedImage(game_click); break; case "GenreWheel": FullPath = HSPath + "\\Media\\" + SystemName + "\\Images\\Genre\\Wheel"; // DisplaySelectedImage(game_click); break; case "Pointer": FullPath = HSPath + "\\Media\\" + SystemName + "\\Images\\Other"; break; default: break; } }
/// <summary> /// /// </summary> /// <param name="game"></param> /// <param name="systemName"></param> /// <returns></returns> public static Uri YoutubeSearch(DatabaseGame game, string systemName) { if (game == null) return new Uri(""); string GameName = game.Description; string YoutubeSearchLink = "https://www.google.co.uk/search?q=site:youtube.com" + "+" + GameName; YoutubeSearchLink = "https://www.google.co.uk/search?q=site:youtube.com" + "+" + GameName + "+" + systemName; return GetUriForYoutube(YoutubeSearchLink); }
/// <summary> /// Build game variables from the database /// </summary> /// <returns></returns> public static DatabaseGame GetAttributesFromGame() { DatabaseGame game = new DatabaseGame(); return game; }
public virtual void DroppedFile(string[] filelist, DatabaseGame game, string selectedColumn) { }
private void wheel_drop(string file, string filenamenoExt, DatabaseGame game, string selectedColumn) { string ext = Path.GetExtension(file); string path = Path.GetDirectoryName(file); string endPath = string.Empty; //try { File.Copy(file, file + "_temp"); } //catch { } try { if (ext == ".bmp" || ext == ".gif") endPath = Path.Combine(path, game.RomName + ".png"); else endPath = Path.Combine(path, game.RomName + ext); if (File.Exists(endPath)) { FileManagement.SendToTrash("Hyperspin", new FileInfo(endPath), systemName, selectedColumn, game.RomName); } if (ext == ".bmp" || ext == ".gif") path = FullPath + game.RomName + ext; if (file.EndsWith(".jpg") || file.EndsWith(".gif") || file.EndsWith(".jpeg") || file.EndsWith(".JPG") || file.EndsWith(".bmp")) { using (System.Drawing.Image im = System.Drawing.Image.FromFile(file)) { im.Save(Path.Combine(path, game.RomName + ".png"), ImageFormat.Png); //UpdateGameBools(game); } return; } else if (file.EndsWith(".PNG") || file.EndsWith(".png") || file.EndsWith(".mp4")) { if (!Directory.Exists(path)) Directory.CreateDirectory(path); System.IO.File.Copy(file, endPath); //File.Delete(file + "_temp"); } } catch (Exception) { } //UpdateGameBools(game); }
private void theme_drop(string file, string filenamenoExt, DatabaseGame game, string selectedColumn) { string ext = Path.GetExtension(file); string path; // if extension is a zip just rename & copy over for now if (ext == ".zip") { path = FullPath + game.RomName + ext; if (File.Exists(path)) { FileManagement.SendToTrash("Hyperspin", new FileInfo(path), systemName, selectedColumn, game.RomName); } if (!Directory.Exists(FullPath)) Directory.CreateDirectory(FullPath); System.IO.File.Copy(file, path); game.HaveTheme = true; return; } // Quick theme file creator // // If image format is dragged into theme folder then create a basic theme with image // renamed to Background.png, info.txt & Theme.xml // romname + ".zip" using (System.Drawing.Image im = System.Drawing.Image.FromFile(file)) { System.Drawing.Image im2 = System.Drawing.Image.FromFile(file); im2 = ImageEdits.ResizeImageEdit(im, new System.Drawing.Size(1024, 768)); im2.Save("Background.png", ImageFormat.Png); } try { if (!File.Exists("Theme.xml")) return; using (ZipFile zip = new ZipFile()) { zip.CompressionLevel = Ionic.Zlib.CompressionLevel.None; zip.AddFile("Background.png"); zip.AddFile("Theme.xml"); zip.AddFile("Info.txt"); zip.Save(FullPath + "\\" + game.RomName + ".zip"); System.IO.File.Delete("Background.png"); } } catch (Exception) { } }
private void audio_drop(string file, string filenamenoExt, DatabaseGame game, string selectedColumn) { string ext = Path.GetExtension(file); string path; FullPath = Path.GetDirectoryName(file); // if extension is a zip just rename & copy over for now if (ext == ".mp3") { path = FullPath + "\\" + game.RomName + ext; if (File.Exists(path)) { FileManagement.SendToTrash("Hyperspin", new FileInfo(path), systemName, selectedColumn, game.RomName); } if (!Directory.Exists(Path.GetDirectoryName(path))) Directory.CreateDirectory(FullPath); System.IO.File.Copy(file, path); game.HaveBGMusic = true; return; } }
public override void DroppedFile(string[] filelist, DatabaseGame game, string selectedColumn) { int i; string Filename, ext, filename3; for (i = 0; i < filelist.Length; i++) { Filename = System.IO.Path.GetFileName(filelist[i]); ext = System.IO.Path.GetExtension(filelist[i]); filename3 = System.IO.Path.GetFileNameWithoutExtension(filelist[i]); if (selectedColumn == "Wheel" || selectedColumn == "Artwork1" || selectedColumn == "Artwork2" || selectedColumn == "Artwork3" || selectedColumn == "Artwork4" || selectedColumn == "Video" || selectedColumn == "Background") { wheel_drop(filelist[i], filename3, game, selectedColumn); } else if (selectedColumn == "Theme") { theme_drop(filelist[i], filename3, game, selectedColumn); } else if (selectedColumn =="BG-Music") { audio_drop(filelist[i], filename3, game, selectedColumn); } } }