using UnityEditor; using UnityEngine; using UnityEngine.UIElements; using Ashwild.Inventory; namespace Ashwild.EditorTools { /// /// Small library of styled VisualElement builders shared by the Ashwild Database editor views /// (cards, type badges, accent colours). Centralised so the item and recipe editors stay visually /// consistent and free of inline-style duplication. /// public static class AshwildUI { #region Type Colours /// /// The accent colour identifying buildables (the construction family) across the list tag and /// the buildable editor badge — a cool blue that sets them apart from item-type accents. /// public static readonly Color BuildableColor = new Color(0.38f, 0.64f, 0.86f); /// /// The accent colour marking a recipe that is locked to a workstation, so the bench-only ones /// stand out from the plain (hand-craftable) rows at a glance. /// public static readonly Color StationColor = new Color(0.76f, 0.60f, 0.90f); /// /// The accent colour that identifies an item type across the list badges, hero and cards. /// public static Color TypeColor(ItemType type) { switch (type) { case ItemType.Tool: return new Color(0.93f, 0.58f, 0.22f); case ItemType.Weapon: return new Color(0.88f, 0.33f, 0.33f); case ItemType.Consumable: return new Color(0.42f, 0.76f, 0.47f); default: return new Color(0.47f, 0.57f, 0.69f); } } #endregion #region Builders /// /// Builds a titled card container; callers add their fields straight onto the returned element, /// below its heading. /// public static VisualElement Card(string title) { VisualElement card = new VisualElement(); card.AddToClassList("ash-card"); Label heading = new Label(title); heading.AddToClassList("ash-card__title"); card.Add(heading); return card; } /// /// Builds a small rounded badge tinted by a colour — used for item-type tags. The background is /// a translucent wash of the colour with the text in the solid colour for legibility on dark. /// public static VisualElement Badge(string text, Color color) { Label badge = new Label(text); badge.AddToClassList("ash-badge"); badge.style.color = color; badge.style.backgroundColor = new Color(color.r, color.g, color.b, 0.16f); return badge; } /// /// Wraps a name text field in a row prefixed by a small pencil icon, signalling that the title /// is editable. The field grows to fill the remaining width. /// public static VisualElement EditableNameRow(TextField nameField) { VisualElement row = new VisualElement(); row.AddToClassList("ash-namerow"); Texture pencil = EditorGUIUtility.IconContent("d_editicon.sml").image; if (pencil == null) pencil = EditorGUIUtility.IconContent("editicon.sml").image; if (pencil != null) { Image icon = new Image { image = pencil, scaleMode = ScaleMode.ScaleToFit }; icon.AddToClassList("ash-namerow__pencil"); row.Add(icon); } nameField.style.flexGrow = 1; row.Add(nameField); return row; } #endregion } }