Beispiel #1
0
 public void uMyGUI_TreeBrowser_InitNode(object p_data)
 {
     if (m_text != null)
     {
         if (p_data is SendMessageInitData)
         {
             SendMessageInitData data = (SendMessageInitData)p_data;
             // text
             m_text.text = data.m_text;
             // initial selection
             if (data.m_isSelected)
             {
                 ShowSelection();
             }
         }
         else
         {
             Debug.LogError("LE_TextPrefabNode: uMyGUI_TreeBrowser_InitNode: expected p_data to be a LE_TextPrefabNode.SendMessageInitData! p_data: " + p_data);
         }
     }
     else
     {
         Debug.LogError("LE_TextPrefabNode: uMyGUI_TreeBrowser_InitNode: m_text was not set via inspector!");
     }
 }
Beispiel #2
0
 public void uMyGUI_TreeBrowser_InitNode(object p_data)
 {
     if (m_text != null && m_image != null)
     {
         if (p_data is SendMessageInitData)
         {
             SendMessageInitData data = (SendMessageInitData)p_data;
             // image
             Texture2D iconTex = (Texture2D)Resources.Load(data.m_object.IconPath);
             if (iconTex != null)
             {
                 m_image.texture = iconTex;
             }
             else
             {
                 Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: object '" + data.m_object.name + "'" +
                                " has an invalid icon resource path! Path: '" + data.m_object.IconPath + "'");
             }
             // name
             m_text.text = UtilityStrings.InsertSpacesIntoCamelCase(data.m_object.name);
             // resize text due to indent
             Vector2 offsetMax = m_text.rectTransform.offsetMax;
             offsetMax.x -= data.m_indentLevel * 10f;
             m_text.rectTransform.offsetMax = offsetMax;
         }
         else if (p_data is LE_ObjectCategoryNode.SendMessageInitData)
         {
             LE_ObjectCategoryNode.SendMessageInitData data = (LE_ObjectCategoryNode.SendMessageInitData)p_data;
             Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: the category '" + data.m_categoryName + "' is empty and will not be shown correctly!");
             m_image.gameObject.SetActive(false);
             m_text.text = LE_ObjectCategoryNode.GetCleanCategoryName(data.m_categoryName);
         }
         else
         {
             Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: expected p_data to be a LE_ObjectPrefabNode.SendMessageInitData! p_data: " + p_data);
         }
     }
     else
     {
         Debug.LogError("LE_ObjectPrefabNode: uMyGUI_TreeBrowser_InitNode: m_text or m_image were not set via inspector!");
     }
 }
Beispiel #3
0
 public void uMyGUI_TreeBrowser_InitNode(object p_data)
 {
     if (m_text != null)
     {
         if (p_data is SendMessageInitData)
         {
             SendMessageInitData data = (SendMessageInitData)p_data;
             // text
             m_text.text = data.m_text;
             // try load icon
             StartCoroutine(LoadLevelIcon(data.m_iconPath));
             // delete button click handler
             if (m_deleteBtn != null)
             {
                 if (data.m_onDelete != null)
                 {
                     m_deleteBtn.onClick.AddListener(() => data.m_onDelete());
                 }
                 else
                 {
                     m_deleteBtn.transform.parent.gameObject.SetActive(false);
                 }
             }
             // initial selection
             if (data.m_isSelected)
             {
                 ShowSelection();
             }
         }
         else
         {
             Debug.LogError("LE_TextPrefabNode: uMyGUI_TreeBrowser_InitNode: expected p_data to be a LE_TextPrefabNode.SendMessageInitData! p_data: " + p_data);
         }
     }
     else
     {
         Debug.LogError("LE_TextPrefabNode: uMyGUI_TreeBrowser_InitNode: m_text was not set via inspector!");
     }
 }
        /// <summary>
        /// Called from the SteamLeaderboardsUI class to initialze the item UI.
        /// </summary>
        /// <param name="p_data">is of type SendMessageInitData. Contains the Steam data of the score entry.</param>
        public virtual void uMyGUI_TreeBrowser_InitNode(object p_data)
        {
            if (p_data is SendMessageInitData)
            {
                SendMessageInitData data = (SendMessageInitData)p_data;
                // avatar image
                if (m_image != null)
                {
                    StartCoroutine(LoadAvatarTexture(data.ScoreEntry));
                }
                // highlight if this is the score of the current player
                string textFormat = data.ScoreEntry.IsCurrentUserScore ? "<color=lime>{0}</color>" : "{0}";
                // user name, rank and score
                if (m_textUserName != null)
                {
                    m_textUserName.text = string.Format(textFormat, data.ScoreEntry.UserName);
                }
                if (m_textRank != null)
                {
                    m_textRank.text = string.Format(textFormat, data.ScoreEntry.GlobalRank);
                }
                if (m_textScore != null)
                {
                    m_textScore.text = string.Format(textFormat, data.ScoreEntry.ScoreString);
                }

                // invoke event
                if (SteamLeaderboardsUI.Instance != null)
                {
                    SteamLeaderboardsUI.Instance.InvokeOnEntryDataSet(data.ScoreEntry, this);
                }
            }
            else
            {
                Debug.LogError("SteamLeaderboardsScoreEntryNode: uMyGUI_TreeBrowser_InitNode: expected p_data to be a SteamLeaderboardsScoreEntryNode.SendMessageInitData! p_data: " + p_data);
            }
        }
 public void uMyGUI_TreeBrowser_InitNode(object p_data)
 {
     if (m_text != null)
     {
         if (p_data is SendMessageInitData)
         {
             SendMessageInitData data = (SendMessageInitData)p_data;
             // category name text
             m_text.text = GetCleanCategoryName(data.m_categoryName);
             // resize text due to indent
             Vector2 offsetMax = m_text.rectTransform.offsetMax;
             offsetMax.x -= data.m_indentLevel * 10f;
             m_text.rectTransform.offsetMax = offsetMax;
         }
         else
         {
             Debug.LogError("LE_ObjectCategoryNode: uMyGUI_TreeBrowser_InitNode: expected p_data to be a string! p_data: " + p_data);
         }
     }
     else
     {
         Debug.LogError("LE_ObjectCategoryNode: uMyGUI_TreeBrowser_InitNode: m_text was not set via inspector!");
     }
 }
Beispiel #6
0
        /// <summary>
        /// Called from the SteamWorkshopUIBrowse class to initialze the item UI and everytime the item data is updated.
        /// </summary>
        /// <param name="p_data">is of type SendMessageInitData. Contains the Steam data of the item.</param>
        public virtual void uMyGUI_TreeBrowser_InitNode(object p_data)
        {
            if (p_data is SendMessageInitData)
            {
                SteamWorkshopMain.Instance.OnInstalled -= OnItemInstalled;                 // needed to prevent double registration
                SteamWorkshopMain.Instance.OnInstalled += OnItemInstalled;

                m_data = (SendMessageInitData)p_data;
                // preview image
                if (m_image != null && m_image.texture == null && m_pendingImageDownload == null)
                {
                    StartCoroutine(DownloadPreview(m_data.Item.PreviewImageURL));
                }
                // item name and stats
                if (m_textName != null)
                {
                    m_textName.text = m_data.Item.Name;
                }
                if (m_textDescription != null)
                {
                    m_textDescription.text = m_data.Item.Description;
                }
                if (m_textVotes != null)
                {
                    m_textVotes.text = m_data.Item.VotesUp + " / " + m_data.Item.VotesDown;
                }
                if (m_textFavorites != null)
                {
                    m_textFavorites.text = m_data.Item.Favorites.ToString();
                }
                if (m_textSubscriptions != null)
                {
                    m_textSubscriptions.text = m_data.Item.Subscriptions.ToString();
                }
                // icon states and callbacks
                if (m_btnFavorites != null && m_btnFavoritesActive != null)
                {
                    m_btnFavorites.gameObject.SetActive(!m_data.Item.IsFavorited);
                    m_btnFavoritesActive.gameObject.SetActive(m_data.Item.IsFavorited);
                }
                if (m_btnSubscriptions != null && m_btnSubscriptionsActive != null)
                {
                    m_btnSubscriptions.gameObject.SetActive(!m_data.Item.IsSubscribed);
                    m_btnSubscriptionsActive.gameObject.SetActive(m_data.Item.IsSubscribed);
                }
                if (m_btnVotesUp != null && m_btnVotesUpActive != null)
                {
                    m_btnVotesUp.gameObject.SetActive(!m_data.Item.IsVotedUp);
                    m_btnVotesUpActive.gameObject.SetActive(m_data.Item.IsVotedUp);
                }
                if (m_btnVotesDown != null && m_btnVotesDownActive != null)
                {
                    m_btnVotesDown.gameObject.SetActive(!m_data.Item.IsVotedDown);
                    m_btnVotesDownActive.gameObject.SetActive(m_data.Item.IsVotedDown);
                }
                // button states and callbacks
                if (m_btnDownload != null)
                {
                    m_btnDownload.gameObject.SetActive(!m_data.Item.IsInstalled && !m_data.Item.IsDownloading);
                }
                if (m_btnPlay != null)
                {
                    m_btnPlay.gameObject.SetActive(m_data.Item.IsInstalled && !m_data.Item.IsDownloading);
                }
                if (m_btnDelete != null)
                {
                    m_btnDelete.gameObject.SetActive(m_data.Item.IsSubscribed);
                }
                // improve button and icon navigation
                if (m_useExplicitNavigation)
                {
                    SetNavigationTargetsHorizontal(new Selectable[] { m_btnDelete, m_btnVotesUp, m_btnVotesUpActive, m_btnVotesDown, m_btnVotesDownActive, m_btnFavorites, m_btnFavoritesActive, m_btnSubscriptions, m_btnSubscriptionsActive, m_btnPlay, m_btnDownload });
                    StartCoroutine(SetNavigationTargetsVertical());
                }
                // download progress
                if (m_textDownloadProgress != null)
                {
                    m_textDownloadProgress.gameObject.SetActive(m_data.Item.IsDownloading);
                }
                if (m_data.Item.IsDownloading)
                {
                    StartCoroutine(ShowDownloadProgress());
                }

                // invoke event
                SteamWorkshopUIBrowse.Instance.InvokeOnItemDataSet(m_data.Item, this);
            }
            else
            {
                Debug.LogError("SteamWorkshopItemNode: uMyGUI_TreeBrowser_InitNode: expected p_data to be a SteamWorkshopItemNode.SendMessageInitData! p_data: " + p_data);
            }
        }