Ejemplo n.º 1
0
        public void Display(ItemData data, int index)
        {
            try
            {
                if (data == null)
                {
                    Debugging.Message("Data null");
                }

                if (component == null || data?.name == null)
                {
                    return;
                }

                currentData = data;

                component.Unfocus();
                component.name = data.name;
                component.gameObject.GetComponent <TutorialUITag>().tutorialTag = data.name;

                PrefabInfo prefab = data.asset.prefab;
                if (prefab == null)
                {
                    Debugging.Message("Couldn't display item. Prefab is null");
                    return;
                }

                ImageUtils.FixThumbnails(prefab, null, data.asset);

                component.atlas             = prefab.m_Atlas;
                component.verticalAlignment = UIVerticalAlignment.Middle;

                component.normalFgSprite   = prefab.m_Thumbnail;
                component.hoveredFgSprite  = prefab.m_Thumbnail + "Hovered";
                component.pressedFgSprite  = prefab.m_Thumbnail + "Pressed";
                component.disabledFgSprite = prefab.m_Thumbnail + "Disabled";
                component.focusedFgSprite  = null;

                bool rico = false;

                if (FindIt.isRicoEnabled)
                {
                    string name = Asset.GetName(prefab);
                    if (AssetTagList.instance.assets.ContainsKey(name))
                    {
                        rico = AssetTagList.instance.assets[name].assetType == Asset.AssetType.Rico;
                    }
                }

                component.isEnabled      = rico || Settings.unlockAll || ToolsModifierControl.IsUnlocked(prefab.GetUnlockMilestone());
                component.tooltip        = data.tooltip;
                component.tooltipBox     = data.tooltipBox;
                component.objectUserData = data.asset.prefab;
                component.forceZOrder    = index;

                if (component.containsMouse)
                {
                    component.RefreshTooltip();

                    if (m_tooltipBox != null && m_tooltipBox.isVisible && m_tooltipBox != data.tooltipBox)
                    {
                        m_tooltipBox.Hide();
                        data.tooltipBox.Show(true);
                        data.tooltipBox.opacity          = 1f;
                        data.tooltipBox.relativePosition = m_tooltipBox.relativePosition + new Vector3(0, m_tooltipBox.height - data.tooltipBox.height);
                    }

                    m_tooltipBox = data.tooltipBox;

                    RefreshTooltipAltas(component);
                }

                if (m_tagSprite != null)
                {
                    m_tagSprite.atlas = FindIt.atlas;

                    m_tagSprite.isVisible = currentData.asset != null && AssetTagList.instance.assets.ContainsValue(currentData.asset) && (component.containsMouse || currentData.asset.tagsCustom.Count > 0);
                }


                // batch action check box
                if (m_batchCheckBox != null && data.asset != null && UIFilterTag.instance?.batchAssetSet != null)
                {
                    if (UIFilterTag.instance.batchAssetSet.Contains(data.asset))
                    {
                        m_batchCheckBox.isChecked = true;
                    }
                    else
                    {
                        m_batchCheckBox.isChecked = false;
                    }

                    m_batchCheckBox.isVisible = UISearchBox.instance.tagPanel.isBatchActionsEnabled;
                }
                else if (m_batchCheckBox != null)
                {
                    m_batchCheckBox.isVisible = false;
                }

                if (m_instanceCountLabel != null && data.asset?.prefab != null)
                {
                    if (Settings.showInstancesCounter)
                    {
                        m_instanceCountLabel.isVisible = true;

                        uint count = 0;
                        if (AssetTagList.instance.prefabInstanceCountDictionary.ContainsKey(data.asset.prefab))
                        {
                            count = AssetTagList.instance.prefabInstanceCountDictionary[data.asset.prefab];
                        }

                        if (data.asset.prefab is NetInfo)
                        {
                            m_instanceCountLabel.text = (count == 0) ? Translations.Translate("FIF_UIS_UN") : Translations.Translate("FIF_UIS_IN");
                        }
                        else
                        {
                            if (data.asset.prefab is TreeInfo)
                            {
                                m_instanceCountLabel.text = (count == 0) ? Translations.Translate("FIF_UIS_UN") : count.ToString();
                            }
                            else
                            {
                                if (Settings.includePOinstances && FindIt.isPOEnabled)
                                {
                                    uint poCount = 0;
                                    poCount = ProceduralObjectsTool.GetPrefabPOInstanceCount(data.asset.prefab);
                                    m_instanceCountLabel.text = "";
                                    if (count == 0 && poCount == 0)
                                    {
                                        m_instanceCountLabel.text = Translations.Translate("FIF_UIS_UN");
                                    }
                                    if (count != 0)
                                    {
                                        m_instanceCountLabel.text += (count.ToString());
                                        if (poCount != 0)
                                        {
                                            m_instanceCountLabel.text += (" + ");
                                        }
                                    }
                                    if (poCount != 0)
                                    {
                                        m_instanceCountLabel.text += (poCount.ToString() + " PO");
                                    }
                                }
                                else
                                {
                                    m_instanceCountLabel.text = (count == 0) ? Translations.Translate("FIF_UIS_UN") : count.ToString();
                                }
                            }
                        }
                    }
                    else
                    {
                        m_instanceCountLabel.isVisible = false;
                    }
                }

                if (m_dlcSprite != null)
                {
                    m_dlcSprite.tooltip   = null;
                    m_dlcSprite.isVisible = false;
                    m_dlcSprite.opacity   = 0.8f;

                    if (data.asset != null)
                    {
                        if (FindIt.isNext2Enabled && AssetTagList.instance.next2Assets.Contains(data.asset))
                        {
                            m_dlcSprite.isVisible  = true;
                            m_dlcSprite.spriteName = "UIFilterWorkshopItemsFocusedHovered";
                            m_dlcSprite.tooltip    = "Network Extension 2 Mod";
                        }
                        else if (FindIt.isETSTEnabled && AssetTagList.instance.etstAssets.Contains(data.asset))
                        {
                            m_dlcSprite.isVisible  = true;
                            m_dlcSprite.spriteName = "UIFilterWorkshopItemsFocusedHovered";
                            m_dlcSprite.tooltip    = "Extra Train Station Tracks Mod";
                        }
                        else if (FindIt.isOWTTEnabled && AssetTagList.instance.owttAssets.Contains(data.asset))
                        {
                            m_dlcSprite.isVisible  = true;
                            m_dlcSprite.spriteName = "UIFilterWorkshopItemsFocusedHovered";
                            m_dlcSprite.tooltip    = "One-Way Train Tracks Mod";
                        }
                        else if (!data.asset.prefab.m_isCustomContent)
                        {
                            SetDLCSprite(m_dlcSprite, data.asset.prefab.m_dlcRequired);
                        }
                        else
                        {
                            if (!data.asset.author.IsNullOrWhiteSpace() && (data.asset.steamID != 0))
                            {
                                m_dlcSprite.opacity    = 0.45f;
                                m_dlcSprite.isVisible  = true;
                                m_dlcSprite.spriteName = "UIFilterWorkshopItems";
                                m_dlcSprite.tooltip    = "By " + data.asset.author + "\n" + Translations.Translate("FIF_UIS_WS");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (data != null)
                {
                    Debugging.Message("Display failed : " + data.name);
                }
                else
                {
                    Debugging.Message("Display failed");
                }
                Debugging.LogException(e);
            }
        }
Ejemplo n.º 2
0
        public void Display(ItemData data, int index)
        {
            try
            {
                if (data == null)
                {
                    Debugging.Message("Data null");
                }

                if (component == null || data == null)
                {
                    return;
                }

                currentData = data;

                component.Unfocus();
                component.name = data.name;
                component.gameObject.GetComponent <TutorialUITag>().tutorialTag = data.name;

                PrefabInfo prefab = data.asset.prefab;
                if (prefab == null)
                {
                    Debugging.Message("Couldn't display item. Prefab is null");
                    return;
                }

                ImageUtils.FixThumbnails(prefab, null);

                component.atlas             = prefab.m_Atlas;
                component.verticalAlignment = UIVerticalAlignment.Middle;

                component.normalFgSprite   = prefab.m_Thumbnail;
                component.hoveredFgSprite  = prefab.m_Thumbnail + "Hovered";
                component.pressedFgSprite  = prefab.m_Thumbnail + "Pressed";
                component.disabledFgSprite = prefab.m_Thumbnail + "Disabled";
                component.focusedFgSprite  = null;

                bool rico = false;
                if (FindIt.isRicoEnabled)
                {
                    string name = Asset.GetName(prefab);
                    if (AssetTagList.instance.assets.ContainsKey(name))
                    {
                        rico = AssetTagList.instance.assets[name].assetType == Asset.AssetType.Rico;
                    }
                }

                component.isEnabled      = rico || FindIt.unlockAll.value || ToolsModifierControl.IsUnlocked(prefab.GetUnlockMilestone());
                component.tooltip        = data.tooltip;
                component.tooltipBox     = data.tooltipBox;
                component.objectUserData = data.asset.prefab;
                component.forceZOrder    = index;

                if (component.containsMouse)
                {
                    component.RefreshTooltip();

                    if (m_tooltipBox != null && m_tooltipBox.isVisible && m_tooltipBox != data.tooltipBox)
                    {
                        m_tooltipBox.Hide();
                        data.tooltipBox.Show(true);
                        data.tooltipBox.opacity          = 1f;
                        data.tooltipBox.relativePosition = m_tooltipBox.relativePosition + new Vector3(0, m_tooltipBox.height - data.tooltipBox.height);
                    }

                    m_tooltipBox = data.tooltipBox;

                    RefreshTooltipAltas(component);
                }

                if (m_tagSprite != null)
                {
                    m_tagSprite.atlas = FindIt.atlas;

                    m_tagSprite.isVisible = currentData.asset != null && AssetTagList.instance.assets.ContainsValue(currentData.asset) && (component.containsMouse || currentData.asset.tagsCustom.Count > 0);
                }

                if (m_steamSprite != null)
                {
                    m_steamSprite.tooltip = null;

                    if (data.asset != null)
                    {
                        m_steamSprite.isVisible = data.asset.steamID != 0;
                        if (!data.asset.author.IsNullOrWhiteSpace())
                        {
                            m_steamSprite.tooltip = "By " + data.asset.author;
                        }
                    }

                    if (m_steamSprite.containsMouse)
                    {
                        m_steamSprite.tooltipBox.isVisible = m_steamSprite.tooltip != null;
                    }

                    m_steamSprite.isVisible = m_steamSprite.tooltip != null;

                    if (m_steamSprite.containsMouse)
                    {
                        m_steamSprite.RefreshTooltip();
                        m_steamSprite.tooltipBox.isVisible = m_steamSprite.tooltip != null;
                    }
                }
            }
            catch (Exception e)
            {
                if (data != null)
                {
                    Debugging.Message("Display failed : " + data.name);
                }
                else
                {
                    Debugging.Message("Display failed");
                }
                Debugging.LogException(e);
            }
        }