mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-31 02:32:53 +08:00
review:
- Rebased to 1.10.0-rc.4 because the inspector of SubMenu of source Expressions Menu were broken in the base commit this branch initially started with, which was preventing testing some aspects raised during review. - When this is being rendered as part of an SubMenu of source Expressions Menu, don't use any of the label logic, as menu items within such an Expressions Menu are not backed by any GameObject. - Rename _isTryingRichLabel to _useLabel. - Since switching to unlinked always overwrites the label field with the current ObjectName, and switching to linked always empties the label field, the state of _useLabel while the Inspector is open is implied by the value of the label field, or the previous state of the _useLabel field itself when the label field is being emptied out. - In addition, use the |= operator. - When the name is linked, and the user begins typing the "<" character, set the label field, and do not apply the name. This will automatically switch to linked mode as the inspector will be reevaluated a second time. - If the original object name already contains a "<" character (i.e. it comes from a previous version of Modular Avatar), there will be no automatic conversion happening as long as the object name still contains the "<" character. - Changed the localization keys to discard the rich text toggle aspect. - Not addressed: When multiple Menu Item components are selected, the behaviour of the inspector currently edits the GameObject name, with no link button, and no automatic conversion when typing "<", regardless of the contents of the label field.
This commit is contained in:
parent
776f08be3f
commit
c5e787045a
@ -59,6 +59,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
internal class MenuItemCoreGUI
|
||||
{
|
||||
private const string ImpliesRichText = "<";
|
||||
|
||||
private static readonly ObjectIDGenerator IdGenerator = new ObjectIDGenerator();
|
||||
private readonly GameObject _parameterReference;
|
||||
private readonly Action _redraw;
|
||||
@ -99,7 +101,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
private readonly Dictionary<string, ProvidedParameter> _knownParameters = new();
|
||||
private bool _parameterSourceNotDetermined;
|
||||
private bool _isTryingRichLabel;
|
||||
private bool _useLabel;
|
||||
|
||||
public MenuItemCoreGUI(SerializedObject obj, Action redraw)
|
||||
{
|
||||
@ -262,8 +264,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
var needsRichLabel = (!string.IsNullOrEmpty(_prop_label.stringValue) || _isTryingRichLabel);
|
||||
if (!needsRichLabel)
|
||||
|
||||
if (_parameterReference == null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(_name, G("menuitem.prop.name"));
|
||||
@ -274,26 +276,42 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(_prop_label, G("menuitem.prop.name"));
|
||||
}
|
||||
var linkIcon = EditorGUIUtility.IconContent(needsRichLabel ? "UnLinked" : "Linked").image;
|
||||
var guiIcon = new GUIContent(linkIcon, S(needsRichLabel ? "menuitem.rich_text.toggle_off.tooltip" : "menuitem.rich_text.toggle_on.tooltip"));
|
||||
if (GUILayout.Button(guiIcon, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.Width(25)))
|
||||
_useLabel |= !string.IsNullOrEmpty(_prop_label.stringValue);
|
||||
|
||||
if (!_useLabel)
|
||||
{
|
||||
if (!needsRichLabel)
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var previousName = _name.stringValue;
|
||||
EditorGUILayout.PropertyField(_name, G("menuitem.prop.name"));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (!previousName.Contains(ImpliesRichText) && _name.stringValue.Contains(ImpliesRichText))
|
||||
{
|
||||
_isTryingRichLabel = true;
|
||||
_prop_label.stringValue = _name.stringValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isTryingRichLabel = false;
|
||||
_prop_label.stringValue = "";
|
||||
_name.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(_prop_label, G("menuitem.prop.name"));
|
||||
}
|
||||
|
||||
var linkIcon = EditorGUIUtility.IconContent(_useLabel ? "UnLinked" : "Linked").image;
|
||||
var guiIcon = new GUIContent(linkIcon, S(_useLabel ? "menuitem.label.gameobject_name.tooltip" : "menuitem.label.long_name.tooltip"));
|
||||
if (GUILayout.Button(guiIcon, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.Width(25)))
|
||||
{
|
||||
_prop_label.stringValue = !_useLabel ? _name.stringValue : "";
|
||||
_useLabel = !_useLabel;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (needsRichLabel && _prop_label.stringValue.Contains("<"))
|
||||
if (_useLabel && _prop_label.stringValue.Contains(ImpliesRichText))
|
||||
{
|
||||
var style = new GUIStyle(EditorStyles.textField);
|
||||
style.richText = true;
|
||||
|
@ -282,6 +282,6 @@
|
||||
"ro_sim.effect_group.rule_inverted.tooltip": "This rule will be applied when one of its conditions is NOT met",
|
||||
"ro_sim.effect_group.conditions": "Conditions",
|
||||
|
||||
"menuitem.rich_text.toggle_on.tooltip": "Use a long name which may contain rich text and line breaks.",
|
||||
"menuitem.rich_text.toggle_off.tooltip": "Use the GameObject name."
|
||||
"menuitem.label.long_name.tooltip": "Use a long name which may contain rich text and line breaks.",
|
||||
"menuitem.label.gameobject_name.tooltip": "Use the GameObject name."
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user