public void Display(object data, bool isRowOdd)
        {
            SetupControls();

            float maxLabelWidth = width - 120;

            m_building  = data as BuildingItem;
            m_name.text = m_building.displayName;
            if (m_building.prefab == null)
            {
                m_name.text += " (Not Loaded)";
            }
            m_name.label.textColor     = m_building.GetStatusColor();
            m_name.label.isInteractive = false;
            m_name.isChecked           = m_building.included;

            m_level.text = m_building.level == 0 ? null : "L" + m_building.level;
            m_size.text  = m_building.sizeAsString;

            if (m_building.category != Category.None)
            {
                m_category.atlas      = UIUtils.GetAtlas(CategoryIcons.atlases[(int)m_building.category]);
                m_category.spriteName = CategoryIcons.spriteNames[(int)m_building.category];
                m_category.tooltip    = CategoryIcons.tooltips[(int)m_building.category];
                m_category.isVisible  = true;
            }
            else
            {
                m_category.isVisible = false;
            }

            if (m_building.steamID != null)
            {
                m_steamIcon.tooltip   = m_building.steamID;
                m_steamIcon.isVisible = true;

                maxLabelWidth -= 30;

                m_name.label.relativePosition = new Vector3(52, 2);
            }
            else
            {
                m_steamIcon.isVisible = false;

                m_name.label.relativePosition = new Vector3(22, 2);
            }

            if (isRowOdd)
            {
                background.backgroundSprite = "UnlockingItemBackground";
                background.color            = new Color32(0, 0, 0, 128);
            }
            else
            {
                background.backgroundSprite = null;
            }


            UIUtils.TruncateLabel(m_name.label, maxLabelWidth);
        }
示例#2
0
        public void Display(object data, bool isRowOdd)
        {
            if (m_name == null)
            {
                m_name                  = AddUIComponent <UILabel>();
                m_name.textScale        = 0.9f;
                m_name.relativePosition = new Vector3(5, 13);
            }

            m_theme     = data as Configuration.Theme;
            m_name.text = m_theme.name;
            UIUtils.TruncateLabel(m_name, parent.width - 30);

            string validityError = UIThemeManager.instance.ThemeValidityError(m_theme);

            m_name.textColor = (validityError == null) ? new Color32(255, 255, 255, 255) : new Color32(255, 255, 0, 255);;
            tooltip          = validityError;

            if (isRowOdd)
            {
                background.backgroundSprite = "UnlockingItemBackground";
                background.color            = new Color32(0, 0, 0, 128);
            }
            else
            {
                background.backgroundSprite = null;
            }
        }
        public void Display(object data, bool isRowOdd)
        {
            SetupControls();

            m_building  = data as BuildingItem;
            m_name.text = m_building.displayName;

            UIUtils.TruncateLabel(m_name, width - 40);
            m_size.text = m_building.sizeAsString;

            backgroundSprite = null;
        }
示例#4
0
        public void Show(BuildingItem item)
        {
            if (m_item == item)
            {
                return;
            }

            m_item         = item;
            m_renderPrefab = (m_item == null) ? null : m_item.prefab;

            // Preview
            if (m_renderPrefab != null && m_renderPrefab.m_mesh != null)
            {
                m_previewRenderer.cameraRotation = 210f;
                m_previewRenderer.zoom           = 4f;
                m_previewRenderer.mesh           = m_renderPrefab.m_mesh;
                m_previewRenderer.material       = m_renderPrefab.m_material;

                RenderPreview();

                m_preview.texture = m_previewRenderer.texture;

                m_noPreview.isVisible = false;
            }
            else
            {
                m_preview.texture     = null;
                m_noPreview.isVisible = true;
            }

            m_buildingName.isVisible = false;
            m_categoryIcon.isVisible = false;
            m_level.isVisible        = false;
            m_size.isVisible         = false;

            if (item == null)
            {
                return;
            }

            // Name
            m_buildingName.isVisible = true;
            m_buildingName.text      = m_item.displayName;
            UIUtils.TruncateLabel(m_buildingName, width - 45);
            m_buildingName.autoHeight = true;

            // Category icon
            Category category = m_item.category;

            if (category != Category.None)
            {
                m_categoryIcon.atlas      = UIUtils.GetAtlas(CategoryIcons.atlases[(int)category]);
                m_categoryIcon.spriteName = CategoryIcons.spriteNames[(int)category];
                m_categoryIcon.tooltip    = CategoryIcons.tooltips[(int)category];
                m_categoryIcon.isVisible  = true;
            }

            // Level
            if (m_item.level != 0)
            {
                m_level.text      = "Level " + m_item.level;
                m_level.isVisible = true;
            }

            // Size
            if (m_item.size != Vector2.zero)
            {
                m_size.text      = m_item.sizeAsString;
                m_size.isVisible = true;

                m_size.autoSize         = true;
                m_size.relativePosition = new Vector3(width - m_size.width - 7, height - 20);
            }
        }