private bool ToggleItemEnabled(GUITickBox tickBox)
 {
     Facepunch.Steamworks.Workshop.Item item = tickBox.UserData as Facepunch.Steamworks.Workshop.Item;
     if (tickBox.Selected)
     {
         tickBox.Selected = SteamManager.EnableWorkShopItem(item, false);
     }
     else
     {
         tickBox.Selected = !SteamManager.DisableWorkShopItem(item);
     }
     return(true);
 }
Beispiel #2
0
        public bool LoadItem(Facepunch.Steamworks.Workshop.Item item)
        {
            Logging.Assert(item.Id != 0);
            if (item.Id <= 0)
            {
                return(false);
            }
            FileName    = item.Id.ToString() + ".vpk";
            FileSize    = (long)item.FileSize;
            PublishedId = item.Id;
            ImageURL    = item.PreviewImageUrl;
            //Author = item.OwnerName;//some problem here, author is not included in firend list, need refine it with RequestUserStats
            if (true) //need decoding
            {
                Title       = item.Title;
                Description = item.Description;
                Tags        = item.Tags;
            }
            else // from URL : takes a long time
            {
                string url = WebHelper.GetWebClient(item.Url);
                url = url.Substring(0, url.IndexOf(@"<link"));
                Match match = Regex.Match(url, @"<meta.*content=""([\s\S]*)"">[\s\S]*<title>(.+)</title>", RegexOptions.Multiline);
                Logging.Assert(match.Success, url);

                if (match.Groups.Count < 3)
                {
                    return(false);
                }
                if (!match.Groups[1].Value.Contains(':'))
                {
                    return(false);
                }
                if (!match.Groups[2].Value.Contains("::"))
                {
                    return(false);
                }
                Description = match.Groups[1].Value.Substring(match.Groups[1].Value.IndexOf(':') + 1);
                Title       = match.Groups[2].Value.Substring(match.Groups[2].Value.IndexOf("::") + 1);
            }
            HandleTags();
            return(true);
        }
        private void ShowItemPreview(Facepunch.Steamworks.Workshop.Item item)
        {
            itemPreviewFrame.ClearChildren();

            if (item == null)
            {
                return;
            }

            var content = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), itemPreviewFrame.RectTransform, Anchor.Center))
            {
                RelativeSpacing = 0.02f
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), item.Title, font: GUI.LargeFont);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), item.Description, wrap: true);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), "Score: " + item.Score);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), "Upvotes: " + item.VotesUp);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), "Downvotes: " + item.VotesDown);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), "Creator: " + item.OwnerName);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), "Created: " + item.Created);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), "Modified: " + item.Modified);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), "Url: " + item.Url);
        }
Beispiel #4
0
 public L4D2Mod(Facepunch.Steamworks.Workshop.Item item)
 {
     DoInitialize();
     LoadItem(item);
 }