Example #1
0
        private void WorkshopAdPanelOnQueryCompleted(UGCDetails result, bool ioError)
        {
            try
            {
                var workshopAdPanel = GameObject.Find("WorkshopAdPanel").GetComponent <WorkshopAdPanel>();

                if (result.result == Result.OK)
                {
                    UIComponent uIComponent = Util.GetPrivate <UIScrollablePanel>(workshopAdPanel, "m_ScrollContainer").AttachUIComponent
                                                  (UITemplateManager.GetAsGameObject("WorkshopAdTemplate"));

                    string price = String.Format(CultureInfo.CurrentCulture, "{0:C}", 0.99f);
                    if (UnityEngine.Random.Range(0, 2) == 0)
                    {
                        price = String.Format(CultureInfo.CurrentCulture, "{0:C}", 2.49f);
                    }
                    else if (UnityEngine.Random.Range(0, 7) == 0)
                    {
                        price = String.Format(CultureInfo.CurrentCulture, "{0:C}", 4.99f);
                    }
                    else if (UnityEngine.Random.Range(0, 25) == 0)
                    {
                        price = String.Format(CultureInfo.CurrentCulture, "{0:C}", 8.49f);
                    }

                    uIComponent.Find <UILabel>("Title").text = String.Format("{0} - {1}\n{2}", result.title, price, result.tags);

                    if (result.image != null)
                    {
                        result.image.wrapMode = TextureWrapMode.Clamp;
                    }
                    uIComponent.Find <UITextureSprite>("Image").texture = result.image;
                    UIProgressBar uIProgressBar = uIComponent.Find <UIProgressBar>("Rating");
                    uIProgressBar.isVisible = (result.score >= 0f);
                    uIProgressBar.value     = result.score;
                    uIComponent.Find <UIButton>("ClickableArea").eventClick += delegate(UIComponent c, UIMouseEventParameter p)
                    {
                        if (Steam.IsOverlayEnabled())
                        {
                            Steam.ActivateGameOverlayToWorkshopItem(result.publishedFileId);
                        }
                    };
                }
                else
                {
                    CODebugBase <LogChannel> .Warn(LogChannel.Core, string.Concat(new object[]
                    {
                        "Workshop item: ",
                        result.publishedFileId,
                        " error: ",
                        result.result
                    }));
                }
            }
            catch (Exception ex)
            {
                CODebugBase <LogChannel> .Error(LogChannel.Core, ex.ToString());
            }
        }
Example #2
0
 public void Execute()
 {
     ModLogger.Debug("Executing ShowWorkshopAssetInfo command for workshopid '{0}'", _workshopAssetRowData.WorkshopId);
     if (Steam.IsOverlayEnabled() && _workshopAssetRowData.WorkshopId > 0)
     {
         Steam.ActivateGameOverlayToWorkshopItem(new PublishedFileId(_workshopAssetRowData.WorkshopId));
     }
     else
     {
         ConfirmPanel.ShowModal(UITexts.WorkshopAssetInfoOpenInBrowserTitle, UITexts.WorkshopAssetInfoOpenInBrowserMessage, AskInfoModalCallback);
     }
 }
Example #3
0
        private void SetupControls()
        {
            if (m_name != null)
            {
                return;
            }

            isVisible     = true;
            canFocus      = true;
            isInteractive = true;
            width         = parent.width;
            height        = 40;

            m_name                  = UIUtils.CreateCheckBox(this);
            m_name.width            = 20;
            m_name.clipChildren     = false;
            m_name.relativePosition = new Vector3(5, 13);

            m_name.eventCheckChanged += (c, state) =>
            {
                if (m_building != null)
                {
                    UIThemeManager.instance.ChangeBuildingStatus(m_building, state);
                }
            };

            m_steamIcon                  = m_name.AddUIComponent <UISprite>();
            m_steamIcon.spriteName       = "SteamWorkshop";
            m_steamIcon.isVisible        = false;
            m_steamIcon.relativePosition = new Vector3(22, 0);

            UIUtils.ResizeIcon(m_steamIcon, new Vector2(25, 25));

            if (Steam.IsOverlayEnabled())
            {
                m_steamIcon.eventClick += (c, p) =>
                {
                    p.Use();
                    Steam.ActivateGameOverlayToWorkshopItem(new PublishedFileId(ulong.Parse(m_building.steamID)));
                };
            }

            m_size               = AddUIComponent <UILabel>();
            m_size.width         = 30;
            m_size.textAlignment = UIHorizontalAlignment.Center;

            m_level               = AddUIComponent <UILabel>();
            m_level.width         = 30;
            m_level.textAlignment = UIHorizontalAlignment.Center;

            m_category      = AddUIComponent <UISprite>();
            m_category.size = new Vector2(20, 20);
        }
Example #4
0
 private void TopLabel_eventClicked(UIComponent component, UIMouseEventParameter eventParam)
 {
     Steam.ActivateGameOverlayToWorkshopItem(new PublishedFileId(549792340));
 }