コード例 #1
0
        private void SetGameDirectoryInfoListRecursively(string root)
        {
            foreach (DirectoryInfo directory in new DirectoryInfo(root).GetDirectories())
            {
                DirectoryInfo[] directories = directory.GetDirectories();

                GameDirectoryInfo info = new GameDirectoryInfo();
                info.RootDirectory    = directory;
                info.CodeDirectory    = directories.SingleOrDefault(x => x.Name.ToLower() == "code");
                info.ContentDirectory = directories.SingleOrDefault(x => x.Name.ToLower() == "content");
                info.MetaDirectory    = directories.SingleOrDefault(x => x.Name.ToLower() == "meta");
                info.CosXml           = info.CodeDirectory == null ? null : new FileInfo($@"{info.CodeDirectory.FullName}\cos.xml");
                info.AppXml           = info.CodeDirectory == null ? null : new FileInfo($@"{info.CodeDirectory.FullName}\app.xml");
                info.MetaXml          = info.MetaDirectory == null ? null : new FileInfo($@"{info.MetaDirectory.FullName}\meta.xml");

                if (info.CodeDirectory != null && info.ContentDirectory != null && info.MetaDirectory != null)
                {
                    if (info.CosXml.Exists && info.AppXml.Exists && info.MetaXml.Exists)
                    {
                        GameDirectoryInfoList.Add(info);
                    }
                }
                else
                {
                    SetGameDirectoryInfoListRecursively(directory.FullName);
                }
            }
        }
コード例 #2
0
        private void SetGames(GameDirectoryInfo info)
        {
            try
            {
                string[] data = GetGameDataFromMetaXmlFile(info.MetaXml);

                Game game = new Game()
                {
                    Name          = data[0],
                    ProductID     = data[1],
                    CompanyCode   = data[2],
                    Publisher     = data[3],
                    GameDirectory = info.RootDirectory,
                    GameSize      = GetReadableDirectorySizeFromBytes(GetDirectorySizeInBytes(info.RootDirectory))
                };

                if (Games.Where(x => x.ProductID == game.ProductID && x.CompanyCode == game.CompanyCode).Count() == 0) //Don't add duplicate games
                {
                    string productID   = game.ProductID.Substring(game.ProductID.Length - 4);
                    string companyCode = game.CompanyCode.Substring(game.CompanyCode.Length - 2);

                    game.BoxArtURL = $"http://www.gametdb.com/WiiU/{productID}{companyCode}";

                    try
                    {
                        game.BannerImage = Paloma.TargaImage.LoadTargaImage($@"{info.MetaDirectory.FullName}\bootDrcTex.tga");
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine($"Get BannerImage error: {ex.Message}");
                    }

                    if (File.Exists(game.BoxArtFileName))
                    {
                        game.BoxArtImage = Image.FromFile(game.BoxArtFileName);
                    }
                    else
                    {
                        DownloadBoxArt(game);

                        if (File.Exists(game.BoxArtFileName))
                        {
                            game.BoxArtImage = Image.FromFile(game.BoxArtFileName);
                        }
                        else
                        {
                            game.BoxArtImage = null;
                        }
                    }

                    Games.Add(game);
                    if (OnGameAdded != null)
                    {
                        OnGameAdded(this, game);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }