Example #1
0
 public ResourceToDisplay(string path, LibraryGUIEntryType type)
 {
     this.path = path;
     this.type = type;
 }
        /// <summary>
        /// Constructs a new resource tile entry.
        /// </summary>
        /// <param name="owner">Content area this entry is part of.</param>
        /// <param name="parent">Parent layout to add this entry's GUI elements to.</param>
        /// <param name="path">Path to the project library entry to display data for.</param>
        /// <param name="index">Sequential index of the entry in the conent area.</param>
        /// <param name="width">Width of the GUI entry.</param>
        /// <param name="height">Maximum allowed height for the label.</param>"
        /// <param name="type">Type of the entry, which controls its style and/or behaviour.</param>
        public LibraryGUIEntry(LibraryGUIContent owner, GUILayout parent, string path, int index, int width, int height,
                               LibraryGUIEntryType type)
        {
            GUILayout entryLayout;

            if (owner.GridLayout)
            {
                entryLayout = parent.AddLayoutY();
            }
            else
            {
                entryLayout = parent.AddLayoutX();
            }

            SpriteTexture iconTexture = GetIcon(path, owner.TileSize);

            icon = new GUITexture(iconTexture, GUITextureScaleMode.ScaleToFit,
                                  true, GUIOption.FixedHeight(owner.TileSize), GUIOption.FixedWidth(owner.TileSize));

            label = null;

            string name = PathEx.GetTail(path);

            if (owner.GridLayout)
            {
                int labelHeight = height - owner.TileSize;

                label = new GUILabel(name, EditorStyles.MultiLineLabelCentered,
                                     GUIOption.FixedWidth(width), GUIOption.FixedHeight(labelHeight));

                switch (type)
                {
                case LibraryGUIEntryType.Single:
                    break;

                case LibraryGUIEntryType.MultiFirst:
                    groupUnderlay = new GUITexture(null, LibraryEntryFirstBg);
                    break;

                case LibraryGUIEntryType.MultiElement:
                    groupUnderlay = new GUITexture(null, LibraryEntryBg);
                    break;

                case LibraryGUIEntryType.MultiLast:
                    groupUnderlay = new GUITexture(null, LibraryEntryLastBg);
                    break;
                }
            }
            else
            {
                label = new GUILabel(name, GUIOption.FixedWidth(width - owner.TileSize), GUIOption.FixedHeight(height));

                switch (type)
                {
                case LibraryGUIEntryType.Single:
                    break;

                case LibraryGUIEntryType.MultiFirst:
                    groupUnderlay = new GUITexture(null, LibraryEntryVertFirstBg);
                    break;

                case LibraryGUIEntryType.MultiElement:
                    groupUnderlay = new GUITexture(null, LibraryEntryVertBg);
                    break;

                case LibraryGUIEntryType.MultiLast:
                    groupUnderlay = new GUITexture(null, LibraryEntryVertLastBg);
                    break;
                }
            }

            entryLayout.AddElement(icon);
            entryLayout.AddElement(label);

            if (groupUnderlay != null)
            {
                owner.DeepUnderlay.AddElement(groupUnderlay);
            }

            this.owner    = owner;
            this.index    = index;
            this.path     = path;
            this.bounds   = new Rect2I();
            this.underlay = null;
            this.type     = type;
            this.width    = width;
            this.height   = height;
        }
Example #3
0
 public ResourceToDisplay(string path, LibraryGUIEntryType type)
 {
     this.path = path;
     this.type = type;
 }
Example #4
0
        /// <summary>
        /// Constructs a new resource tile entry.
        /// </summary>
        /// <param name="owner">Content area this entry is part of.</param>
        /// <param name="parent">Parent layout to add this entry's GUI elements to.</param>
        /// <param name="path">Path to the project library entry to display data for.</param>
        /// <param name="index">Sequential index of the entry in the conent area.</param>
        /// <param name="width">Width of the GUI entry.</param>
        /// <param name="height">Maximum allowed height for the label.</param>"
        /// <param name="type">Type of the entry, which controls its style and/or behaviour.</param>
        public LibraryGUIEntry(LibraryGUIContent owner, GUILayout parent, string path, int index, int width, int height,
            LibraryGUIEntryType type)
        {
            GUILayout entryLayout;

            if (owner.GridLayout)
                entryLayout = parent.AddLayoutY();
            else
                entryLayout = parent.AddLayoutX();

            SpriteTexture iconTexture = GetIcon(path, owner.TileSize);

            icon = new GUITexture(iconTexture, GUIImageScaleMode.ScaleToFit,
                true, GUIOption.FixedHeight(owner.TileSize), GUIOption.FixedWidth(owner.TileSize));

            label = null;

            string name = PathEx.GetTail(path);
            if (owner.GridLayout)
            {
                int labelHeight = height - owner.TileSize;

                label = new GUILabel(name, EditorStyles.MultiLineLabelCentered,
                    GUIOption.FixedWidth(width), GUIOption.FixedHeight(labelHeight));

                switch (type)
                {
                    case LibraryGUIEntryType.Single:
                        break;
                    case LibraryGUIEntryType.MultiFirst:
                        groupUnderlay = new GUITexture(null, LibraryEntryFirstBg);
                        break;
                    case LibraryGUIEntryType.MultiElement:
                        groupUnderlay = new GUITexture(null, LibraryEntryBg);
                        break;
                    case LibraryGUIEntryType.MultiLast:
                        groupUnderlay = new GUITexture(null, LibraryEntryLastBg);
                        break;
                }
            }
            else
            {
                label = new GUILabel(name, GUIOption.FixedWidth(width - owner.TileSize), GUIOption.FixedHeight(height));

                switch (type)
                {
                    case LibraryGUIEntryType.Single:
                        break;
                    case LibraryGUIEntryType.MultiFirst:
                        groupUnderlay = new GUITexture(null, LibraryEntryVertFirstBg);
                        break;
                    case LibraryGUIEntryType.MultiElement:
                        groupUnderlay = new GUITexture(null, LibraryEntryVertBg);
                        break;
                    case LibraryGUIEntryType.MultiLast:
                        groupUnderlay = new GUITexture(null, LibraryEntryVertLastBg);
                        break;
                }
            }

            entryLayout.AddElement(icon);
            entryLayout.AddElement(label);

            if (groupUnderlay != null)
                owner.DeepUnderlay.AddElement(groupUnderlay);

            this.owner = owner;
            this.index = index;
            this.path = path;
            this.bounds = new Rect2I();
            this.underlay = null;
            this.type = type;
            this.width = width;
            this.height = height;
        }