diff --git a/Assets/GAME/Script/Editor/Database/AshwildDatabase.uss b/Assets/GAME/Script/Editor/Database/AshwildDatabase.uss index 225f5b01..1f5843f8 100644 --- a/Assets/GAME/Script/Editor/Database/AshwildDatabase.uss +++ b/Assets/GAME/Script/Editor/Database/AshwildDatabase.uss @@ -204,6 +204,19 @@ flex-grow: 1; } +.ash-namerow { + flex-direction: row; + align-items: center; +} + +.ash-namerow__pencil { + width: 13px; + height: 13px; + margin-right: 6px; + margin-bottom: 6px; + opacity: 0.55; +} + .ash-hero__name { margin-bottom: 6px; } diff --git a/Assets/GAME/Script/Editor/Database/AshwildUI.cs b/Assets/GAME/Script/Editor/Database/AshwildUI.cs index c26b45dd..923ddd0c 100644 --- a/Assets/GAME/Script/Editor/Database/AshwildUI.cs +++ b/Assets/GAME/Script/Editor/Database/AshwildUI.cs @@ -1,3 +1,4 @@ +using UnityEditor; using UnityEngine; using UnityEngine.UIElements; using Ashwild.Inventory; @@ -60,6 +61,29 @@ namespace Ashwild.EditorTools 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 } } diff --git a/Assets/GAME/Script/Editor/Database/ItemEditorView.cs b/Assets/GAME/Script/Editor/Database/ItemEditorView.cs index 822b9dd6..fad8c5ad 100644 --- a/Assets/GAME/Script/Editor/Database/ItemEditorView.cs +++ b/Assets/GAME/Script/Editor/Database/ItemEditorView.cs @@ -114,7 +114,7 @@ namespace Ashwild.EditorTools nameField.AddToClassList("ash-hero__name"); nameField.BindProperty(so.FindProperty("itemName")); nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke()); - info.Add(nameField); + info.Add(AshwildUI.EditableNameRow(nameField)); VisualElement typeRow = new VisualElement(); typeRow.AddToClassList("ash-hero__typerow"); diff --git a/Assets/GAME/Script/Editor/Database/RecipeEditorView.cs b/Assets/GAME/Script/Editor/Database/RecipeEditorView.cs index 44b63b86..2983bfe1 100644 --- a/Assets/GAME/Script/Editor/Database/RecipeEditorView.cs +++ b/Assets/GAME/Script/Editor/Database/RecipeEditorView.cs @@ -68,10 +68,12 @@ namespace Ashwild.EditorTools { TextField nameField = new TextField(); nameField.AddToClassList("ash-hero__name"); - nameField.AddToClassList("ash-recipe-name"); nameField.BindProperty(so.FindProperty("recipeName")); nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke()); - return nameField; + + VisualElement row = AshwildUI.EditableNameRow(nameField); + row.AddToClassList("ash-recipe-name"); + return row; } #endregion