Пример #1
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));
                }
            }
        }