示例#1
0
        public void CachePlatformGames(Platform platform)
        {
            if (launchboxFile == null)
            {
                GetLaunchBoxFile();
            }

            // Create a dictionary of existing Games to speed lookups
            Dictionary <long, LBGame> existingLBGameDict = R.Data.LBGames.ToDictionary(x => x.ID);

            // Create a Hashset of LBGames to store any new LBGames that we discover
            HashSet <LBGame> newLBGames = new HashSet <LBGame>();

            List <XElement> platformGameElements = gameElementLookupByPlatform[platform.LBPlatform.Title].ToList();
            int             gameCount            = platformGameElements.Count;

            Reporter.Report($"Found {gameCount} {platform.LBPlatform.Title} games in LaunchBox zip file.");
            int j = 0;

            foreach (XElement gameElement in platformGameElements)
            {
                // Reporting only
                if ((gameCount / 10) != 0 && ++j % (gameCount / 10) == 0)
                {
                    Reporter.Report("  Working " + j + " / " + gameCount + " " + platform.LBPlatform.Title + " games in the LaunchBox database.");
                }

                string title = gameElement.Element("Name")?.Value;

                // Don't create this game if the title or database ID is null
                if (string.IsNullOrEmpty(title) || !long.TryParse(gameElement.SafeGetA("DatabaseID"), out long id))
                {
                    continue;
                }

                // Check if the game alredy exists in the local cache before trying to add it
                if (!existingLBGameDict.TryGetValue(id, out LBGame lbGame))
                {
                    lbGame = new LBGame {
                        ID = id
                    };
                    newLBGames.Add(lbGame);
                    Debug.WriteLine("New game: " + lbGame.Title);
                }

                // If a game has changed platforms, catch it and zero out match
                if (lbGame.LBPlatform_ID != platform.LBPlatform.ID)
                {
                    lbGame.LBPlatform = platform.LBPlatform;
                    Release release = R.Data.Releases.FirstOrDefault(x => x.ID_LB == lbGame.ID);
                    if (release != null)
                    {
                        release.ID_LB = null;
                    }
                }

                // Set or overwrite game properties
                lbGame.Title = title;
                lbGame.Date  = DateTimeRoutines.SafeGetDateTime(gameElement.SafeGetA("ReleaseDate") ?? gameElement.SafeGetA("ReleaseYear") + @"-01-01 00:00:00");

                lbGame.Overview  = gameElement.Element("Overview")?.Value ?? lbGame.Overview;
                lbGame.Genres    = gameElement.Element("Genres")?.Value ?? lbGame.Genres;
                lbGame.Developer = gameElement.Element("Developer")?.Value ?? lbGame.Developer;
                lbGame.Publisher = gameElement.Element("Publisher")?.Value ?? lbGame.Publisher;
                lbGame.VideoURL  = gameElement.Element("VideoURL")?.Value ?? lbGame.VideoURL;
                lbGame.WikiURL   = gameElement.Element("WikipediaURL")?.Value ?? lbGame.WikiURL;
                lbGame.Players   = gameElement.Element("MaxPlayers")?.Value ?? lbGame.Players;
            }
            R.Data.LBGames.AddRange(newLBGames);
        }
示例#2
0
        //public List<Art> LBArt { get; set; }

        //public List<Art> GDBArt { get; set; }

        //public List<Art> GBArt { get; set; }

        //public List<Art> OVGArt { get; set; }


        public ArtWindowViewModel(Release release)
        {
            Release = release;
            //LBArt = new List<Art>();

            Launchbox launchbox = new();

            //R.Data.Releases.Include(x => x.LBRelease).Load();

            //if (LBRelease != null)
            //{
            //	if (!String.IsNullOrEmpty(LBRelease.BoxFrontPath))
            //	{
            //		LBArt.Add(new Art("Banner", LBRelease.BoxFrontUrl, LBRelease.BoxFrontPath));
            //	}
            //	if (!String.IsNullOrEmpty(LBRelease.BoxBackPath))
            //	{
            //		LBArt.Add(new Art("Banner", LBRelease.BoxBackUrl, LBRelease.BoxBackPath));
            //	}
            //	if (!String.IsNullOrEmpty(LBRelease.BannerUrl))
            //	{
            //		LBArt.Add(new Art("Banner", LBRelease.BannerUrl, LBRelease.BannerPath));
            //	}

            //	if (!String.IsNullOrEmpty(LBRelease.Box3DURL))
            //	{
            //		LBArt.Add(new Art("Banner", LBRelease.Box3DURL, LBRelease.Box3DPath));
            //	}

            //	if (!String.IsNullOrEmpty(LBRelease.Cart3DURL))
            //	{
            //		LBArt.Add(new Art("Banner", LBRelease.Cart3DURL, LBRelease.Cart3DPath));
            //	}

            //	if (!String.IsNullOrEmpty(LBRelease.CartBackURL))
            //	{
            //		LBArt.Add(new Art("Cartridge Back", LBRelease.CartBackURL, LBRelease.CartBackPath));
            //	}

            //	if (!String.IsNullOrEmpty(LBRelease.ControlPanelURL))
            //	{
            //		LBArt.Add(new Art("Control Panel", LBRelease.ControlPanelURL, LBRelease.ControlPanelPath));
            //	}

            //	if (!String.IsNullOrEmpty(LBRelease.LogoUrl))
            //	{
            //		LBArt.Add(new Art("Clear Logo", LBRelease.LogoUrl, LBRelease.LogoPath));
            //	}

            //	if (!String.IsNullOrEmpty(LBRelease.MarqueeURL))
            //	{
            //		LBArt.Add(new Art("Marquee", LBRelease.MarqueeURL, LBRelease.MarqueePath));
            //	}

            //}

            //if (GDBRelease != null)
            //{
            //	if (!String.IsNullOrEmpty(GDBRelease.BoxFrontPath))
            //	{
            //		GDBArt.Add(new Art("Banner", GDBRelease.BoxFrontUrl, GDBRelease.BoxFrontPath));
            //	}
            //	if (!String.IsNullOrEmpty(GDBRelease.BoxBackPath))
            //	{
            //		GDBArt.Add(new Art("Banner", GDBRelease.BoxBackUrl, GDBRelease.BoxBackPath));
            //	}
            //	if (!String.IsNullOrEmpty(GDBRelease.BannerUrl))
            //	{
            //		GDBArt.Add(new Art("Banner", GDBRelease.BannerUrl, GDBRelease.BannerPath));
            //	}

            //	if (!String.IsNullOrEmpty(GDBRelease.LogoUrl))
            //	{
            //		GDBArt.Add(new Art("Clear Logo", GDBRelease.LogoUrl, GDBRelease.LogoPath));
            //	}

            //	if (!String.IsNullOrEmpty(GDBRelease.))
            //	{
            //		GDBArt.Add(new Art("Marquee", GDBRelease.MarqueeURL, GDBRelease.MarqueePath));
            //	}

            //}
        }
示例#3
0
        public void ParseGood(string filename)
        {
            Release ROM = new Release();

            // Load static list of region codes and good codes
            //Regions Regions = new Regions();


            // Pull name file and folder from ROM file name
            var name = Path.GetFileNameWithoutExtension(filename);

            //file = Path.GetFileName(file_name);
            //folder = Path.GetDirectoryName(file_name);

            // Run over list of good codes and search name for each
            foreach (Good.GoodCode gc in Good.Codes)
            {
                // If good code is found in name
                if (name.IndexOf(gc.Goodcode) != -1)
                {
                    string code_letter = gc.Code;

                    try
                    {
                        // Set the standard code that was found in the current ROM
                        typeof(Release).GetProperty(code_letter).SetValue(ROM, true);
                    }

                    catch (NullReferenceException) { /*ignore*/ }
                }
            }

            // Run over list of region codes and search name for each
            foreach (Good.RegionCode rc in Good.Regions)
            {
                // If region code is found in name
                if (name.IndexOf(rc.Goodcode) != -1)
                {
                    //string code_letter = rc.code;
                    break;
                }
            }

            // Extract title from file name
            int name_length = name.IndexOf("(") - 1;

            if (name_length == -1)
            {
                name_length = name.IndexOf("[") - 1;
            }

            // Move "the" to front of name
            if (name_length > 3)
            {
                name = name.Substring(0, name_length);
            }

            if (name.Substring(name.Length - 3, 3).ToLower() == "the")
            {
                name = "The " + name.Substring(0, name.Length - 5);
            }

            //crc Crc = crc.Load(filename);
            //Title = name;
            ////this.File = file;
            ////Region = region;
            //CRC32 = Crc.CRC32;
        }