Beispiel #1
0
        private static void AddGameFromXmlNode(XmlNode node, Profile profile, int profileVersion)
        {
            int id;

            if (XmlUtil.TryGetIntFromNode(node[XmlName_Game_Id], out id))
            {
                GameListingSource source = XmlUtil.GetEnumFromNode(node[XmlName_Game_Source], GameListingSource.Unknown);

                if ((source < GameListingSource.Manual) && profile.IgnoreList.Contains(id))
                {
                    return;
                }

                string   name = XmlUtil.GetStringFromNode(node[XmlName_Game_Name], null);
                GameInfo game = new GameInfo(id, name, profile.GameData);
                game.Source = source;
                profile.GameData.Games.Add(id, game);

                game.Hidden     = XmlUtil.GetBoolFromNode(node[XmlName_Game_Hidden], false);
                game.Executable = XmlUtil.GetStringFromNode(node[XmlName_Game_Executable], null);
                game.LastPlayed = XmlUtil.GetIntFromNode(node[XmlName_Game_LastPlayed], 0);

                if (profileVersion < 1)
                {
                    string catName;
                    if (XmlUtil.TryGetStringFromNode(node[XmlName_Game_Category], out catName))
                    {
                        game.AddCategory(profile.GameData.GetCategory(catName));
                    }

                    if (node.SelectSingleNode(XmlName_Old_Game_Favorite) != null)
                    {
                        game.SetFavorite(true);
                    }
                }
                else
                {
                    XmlNode catListNode = node.SelectSingleNode(XmlName_Game_CategoryList);
                    if (catListNode != null)
                    {
                        XmlNodeList catNodes = catListNode.SelectNodes(XmlName_Game_Category);
                        foreach (XmlNode cNode in catNodes)
                        {
                            string cat;
                            if (XmlUtil.TryGetStringFromNode(cNode, out cat))
                            {
                                game.AddCategory(profile.GameData.GetCategory(cat));
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private static void AddGameFromNode(XmlNode node, Profile profile)
        {
            if (!XmlUtil.TryGetIntFromNode(node[XmlNameGameId], out int id))
            {
                return;
            }

            GameListingSource source = XmlUtil.GetEnumFromNode(node[XmlNameGameSource], GameListingSource.Unknown);

            if (source < GameListingSource.Manual && profile.IgnoreList.Contains(id))
            {
                return;
            }

            string   name = XmlUtil.GetStringFromNode(node[XmlNameGameName], null);
            GameInfo game = new GameInfo(id, name, profile.GameData)
            {
                Source = source
            };

            profile.GameData.Games.Add(id, game);

            game.IsHidden    = XmlUtil.GetBoolFromNode(node[XmlNameGameHidden], false);
            game.Executable  = XmlUtil.GetStringFromNode(node[XmlNameGameExecutable], null);
            game.LastPlayed  = XmlUtil.GetIntFromNode(node[XmlNameGameLastPlayed], 0);
            game.HoursPlayed = XmlUtil.GetDoubleFromNode(node[XmlNameGameHoursPlayed], 0);

            XmlNode     catListNode = node.SelectSingleNode(XmlNameGameCategoryList);
            XmlNodeList catNodes    = catListNode?.SelectNodes(XmlNameGameCategory);

            if (catNodes == null)
            {
                return;
            }

            foreach (XmlNode cNode in catNodes)
            {
                if (XmlUtil.TryGetStringFromNode(cNode, out string cat))
                {
                    game.AddCategory(profile.GameData.GetCategory(cat));
                }
            }
        }
Beispiel #3
0
 public void ApplySource( GameListingSource src )
 {
     if( this.Source < src ) this.Source = src;
 }
Beispiel #4
0
        /// <summary>
        /// Adds a new game to the database, or updates an existing game with new information.
        /// </summary>
        /// <param name="appId">App ID to add or update</param>
        /// <param name="appName">Name of app to add, or update to</param>
        /// <param name="overwriteName">If true, will overwrite any existing games. If false, will fail if the game already exists.</param>
        /// <param name="ignore">Set of games to ignore. Can be null. If the game is in this list, no action will be taken.</param>
        /// <param name="forceInclude">If true, include the game even if it is of an ignored type.</param>
        /// <param name="src">The listing source that this request came from.</param>
        /// <param name="isNew">If true, a new game was added. If false, an existing game was updated, or the operation failed.</param>
        /// <returns>True if the game was integrated, false otherwise.</returns>
        private GameInfo IntegrateGame( int appId, string appName, bool overwriteName, SortedSet<int> ignore, AppTypes includedTypes, GameListingSource src, out bool isNew )
        {
            isNew = false;
            if( ( ignore != null && ignore.Contains( appId ) ) || !Program.GameDB.IncludeItemInGameList( appId, includedTypes ) ) {
                Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_SkippedIntegratingGame, appId, appName );
                return null;
            }

            GameInfo result = null;
            if( !Games.ContainsKey( appId ) ) {
                result = new GameInfo( appId, appName, this );
                Games.Add( appId, result );
                isNew = true;
            } else {
                result = Games[appId];
                if( overwriteName ) {
                    result.Name = appName;
                }
            }
            result.ApplySource( src );

            Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_IntegratedGameIntoGameList, appId, appName, isNew );
            return result;
        }