Ejemplo n.º 1
0
        public PublishedFileDetails GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
        {
            var pubFileRequest = new CPublishedFile_GetDetails_Request()
            {
                appid = appId
            };

            pubFileRequest.publishedfileids.Add(pubFile);

            bool completed = false;
            PublishedFileDetails details = null;

            Action <SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
            {
                completed = true;
                if (callback.Result == EResult.OK)
                {
                    var response = callback.GetDeserializedResponse <CPublishedFile_GetDetails_Response>();
                    details = response.publishedfiledetails.FirstOrDefault();
                }
                else
                {
                    throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfile {pubFile}.");
                }
            };

            WaitUntilCallback(() =>
            {
                callbacks.Subscribe(steamPublishedFile.SendMessage(api => api.GetDetails(pubFileRequest)), cbMethod);
            }, () => { return(completed); });

            return(details);
        }
Ejemplo n.º 2
0
        public bool LookupUGCName(ulong pubFile, out string name)
        {
            name = null;

            UGCCacheEntry cacheEntry;

            if (ugcCache.TryGetValue(pubFile, out cacheEntry))
            {
                name = cacheEntry.Name;

                // we had the name cached in memory, no need to touch disk
                return(true);
            }

            // otherwise, need to see if we have it on disk

            PublishedFileDetails fileDetails = GetDetailsFromDisk(pubFile);

            if (fileDetails == null)
            {
                // couldn't load details from disk cache, lets try requesting info from steam
                RequestUGC(pubFile, res => { });

                return(false);
            }

            name = fileDetails.title;

            ugcCache[pubFile] = new UGCCacheEntry
            {
                PubFileID = pubFile,
                AppID     = fileDetails.consumer_appid,

                Name = name,
                Tags = fileDetails.tags
            };

            return(true);
        }
Ejemplo n.º 3
0
        void OnUGC(UGCHandler.UGCJobResult result)
        {
            var req = GetRequest(r => r.JobID == result.ID);

            if (req == null)
            {
                return;
            }

            if (result.TimedOut)
            {
                IRC.Instance.Send(req.Channel, "{0}: Unable to request published file info: request timed out", req.Requester.Nickname);
                return;
            }

            if (result.Result != EResult.OK)
            {
                IRC.Instance.Send(req.Channel, "{0}: Unable to request published file info: {1}", req.Requester.Nickname, result.Result);
                return;
            }

            PublishedFileDetails details = result.Details;

            var displayDict = new DisplayDictionary();

            displayDict.Add("Title", details.title, true);
            displayDict.Add("URL", details.url);
            displayDict.Add("Creator", details.creator);
            displayDict.Add("Creator App", Steam.Instance.GetAppName(details.creator_appid));
            displayDict.Add("Consumer App", Steam.Instance.GetAppName(details.consumer_appid));

            if (details.shortcutid != 0)
            {
                displayDict.Add("Creator Game", details.shortcutname);
                displayDict.Add("Consumer Game", details.consumer_shortcutid);
            }

            if (details.hcontent_file != 0)
            {
                displayDict.Add("File UGC", details.hcontent_file);
            }

            if (details.hcontent_preview != 0)
            {
                displayDict.Add("Preview UGC", details.hcontent_preview);
            }

            displayDict.Add("Desc.", details.short_description, true);
            displayDict.Add("Creation", Utils.DateTimeFromUnixTime(details.time_created));
            displayDict.Add("Vis.", ( EPublishedFileVisibility )details.visibility);
            displayDict.Add("File", details.file_url);

            if (details.banned)
            {
                displayDict.Add("Ban Reason", details.ban_reason, true);
                displayDict.Add("Banner", details.banner);
            }

            if (details.incompatible)
            {
                displayDict.Add("Incompatible", "True");
            }

            if (details.num_reports > 0)
            {
                displayDict.Add("# Reports", details.num_reports.ToString());
            }

            if (details.vote_data != null)
            {
                displayDict.Add("Votes", string.Format("{0} up, {1} down", details.vote_data.votes_up, details.vote_data.votes_down));
                displayDict.Add("Score", string.Format("{0:N4}", details.vote_data.score));
            }

            if (details.for_sale_data != null)
            {
                if (details.for_sale_data.is_for_sale)
                {
                    displayDict.Add("For Sale", "True");
                }

                displayDict.Add("Sale Status", details.for_sale_data.estatus);
            }

            if (details.kvtags.Count > 0)
            {
                string kvTagsString = string.Join(", ", details.kvtags.Select(kv => string.Format("{0}={1}", kv.key, kv.value)));
                displayDict.Add("KVTags", kvTagsString);
            }

            if (details.tags.Count > 0)
            {
                string tagString = string.Join(", ", details.tags.Select(tag =>
                {
                    if (tag.adminonly)
                    {
                        return(string.Format("{0} (admin)", tag.tag));
                    }

                    return(tag.tag);
                }));

                displayDict.Add("Tags", tagString);
            }

            IRC.Instance.Send(req.Channel, "{0}: {1}: {2}", req.Requester.Nickname, req.PubFileID, displayDict);
        }