ui: various MA Parameters UI adjustments (#984)

* chore: use ON/OFF for parameters default field

* ui: MA Parameters UI adjustments
This commit is contained in:
bd_ 2024-08-11 18:09:20 -07:00 committed by GitHub
parent 5a7e02d591
commit d49f87e754
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 63 additions and 18 deletions

View File

@ -12,6 +12,9 @@ namespace nadena.dev.modular_avatar.core.editor
{
}
private const string V_True = "ON";
private const string V_False = "OFF";
private readonly TextField _visibleField;
private readonly FloatField _defaultValueField;
private readonly DropdownField _boolField;
@ -25,8 +28,8 @@ namespace nadena.dev.modular_avatar.core.editor
_boolField = new DropdownField();
_boolField.choices.Add("");
_boolField.choices.Add("True");
_boolField.choices.Add("False");
_boolField.choices.Add(V_True);
_boolField.choices.Add(V_False);
_defaultValueField.RegisterValueChangedCallback(
evt => UpdateVisibleField(evt.newValue, _hasExplicitDefaultSetField.value));
@ -58,7 +61,7 @@ namespace nadena.dev.modular_avatar.core.editor
_boolField.RegisterValueChangedCallback(evt =>
{
if (evt.newValue == "True")
if (evt.newValue == V_True)
_defaultValueField.value = 1;
else
_defaultValueField.value = 0;
@ -95,9 +98,9 @@ namespace nadena.dev.modular_avatar.core.editor
if (!hasExplicitValue)
boolStr = "";
else if (value > 0.5)
boolStr = "True";
boolStr = V_True;
else
boolStr = "False";
boolStr = V_False;
_boolField.SetValueWithoutNotify(boolStr);
}

View File

@ -20,14 +20,14 @@ namespace nadena.dev.modular_avatar.core.editor.Parameters
Localization.UI.Localize(root);
root.styleSheets.Add(uss);
// Prototype UI
var proot = root.Q<VisualElement>("Root");
var type_field = proot.Q<DropdownField>("f-type");
var f_sync_type = proot.Q<VisualElement>("f-sync-type");
SetupPairedDropdownField(
proot,
type_field,
proot.Q<VisualElement>("f-sync-type"),
f_sync_type,
proot.Q<VisualElement>("f-is-prefix"),
("Bool", "False", "params.syncmode.Bool"),
("Float", "False", "params.syncmode.Float"),
@ -36,6 +36,24 @@ namespace nadena.dev.modular_avatar.core.editor.Parameters
(null, "True", "params.syncmode.PhysBonesPrefix")
);
f_sync_type.Q<DropdownField>().RegisterValueChangedCallback(evt =>
{
var is_anim_only = evt.newValue == "Not Synced";
if (is_anim_only)
proot.AddToClassList("st-anim-only");
else
proot.RemoveFromClassList("st-anim-only");
});
var f_synced = proot.Q<Toggle>("f-synced");
var f_local_only = proot.Q<Toggle>("f-local-only");
// Invert f_local_only and f_synced
f_local_only.RegisterValueChangedCallback(evt => { f_synced.SetValueWithoutNotify(!evt.newValue); });
f_synced.RegisterValueChangedCallback(evt => { f_local_only.value = !evt.newValue; });
var internalParamAccessor = proot.Q<Toggle>("f-internal-parameter");
internalParamAccessor.RegisterValueChangedCallback(evt =>
{

View File

@ -24,18 +24,23 @@
<ui:Label name="f-default-param" text="test test test"/>
</ui:VisualElement>
<ui:VisualElement class="horizontal small-label st-pb-prefix__hide">
<ui:VisualElement class="horizontal small-label st-pb-prefix__hide ">
<ui:VisualElement class="horizontal">
<ui:Label text="merge_parameter.ui.defaultValue" class="ndmf-tr no-left-margin"/>
<ma:DefaultValueField/>
</ui:VisualElement>
<ui:VisualElement class="v-separator">
<ui:VisualElement/>
<ui:VisualElement class="horizontal st-anim-only__hide">
<ui:VisualElement class="v-separator">
<ui:VisualElement/>
</ui:VisualElement>
<ui:Toggle binding-path="saved" text="merge_parameter.ui.saved"
class="ndmf-tr st-pb-prefix__first-retained"/>
<ui:Toggle binding-path="localOnly" text="merge_parameter.ui.localOnly" class="ndmf-tr"
name="f-local-only"/>
<ui:Toggle text="merge_parameter.ui.synced" class="ndmf-tr" name="f-synced"/>
<ui:Toggle binding-path="m_overrideAnimatorDefaults" text="merge_parameter.ui.overrideAnimatorDefaults"
class="ndmf-tr"/>
</ui:VisualElement>
<ui:Toggle binding-path="saved" text="merge_parameter.ui.saved" class="ndmf-tr"/>
<ui:Toggle binding-path="localOnly" text="merge_parameter.ui.localOnly" class="ndmf-tr"/>
<ui:Toggle binding-path="m_overrideAnimatorDefaults" text="merge_parameter.ui.overrideAnimatorDefaults"
class="ndmf-tr"/>
</ui:VisualElement>
</ui:VisualElement>

View File

@ -56,6 +56,7 @@
.horizontal {
flex-direction: row;
align-content: center;
margin-top: 1px;
}
.horizontal > * {
@ -121,10 +122,26 @@ DefaultValueField DropdownField {
display: none;
}
.st-anim-only .st-anim-only__hide {
display: none;
}
.st-anim-only .st-pb-prefix__first-retained {
margin-left: 0;
}
.st-anim-only .st-pb-prefix__first-retained Label.unity-label {
margin-left: 0;
}
#f-remap-to {
flex-grow: 1;
}
#f-local-only {
display: none;
}
/** Ghostly text for the renameTo text box **/
Label#f-default-param {
position: absolute;

View File

@ -18,6 +18,7 @@
"params.syncmode.Int": "Int",
"params.syncmode.Float": "Float",
"params.syncmode.Bool": "Bool",
"params.syncmode.PhysBonesPrefix": "PB Prefix",
"params.__comment__": "=== Unity 2019 only strings ===",
"params.autodetect_header": " Autodetected Parameters ",
"params.internal": "Internal",
@ -44,8 +45,8 @@
"merge_parameter.ui.internalParameter.tooltip": "If set, this parameter will be automatically renamed to avoid conflicts with other parameters",
"merge_parameter.ui.isPrefix": "Is PhysBone Prefix",
"merge_parameter.ui.syncType": "Parameter type",
"merge_parameter.ui.localOnly": "Local Only",
"merge_parameter.ui.localOnly.tooltip": "If set, this parameter will not be synced across the network",
"merge_parameter.ui.synced": "Synced",
"merge_parameter.ui.synced.tooltip": "If set, this parameter will be synced across the network",
"merge_parameter.ui.unregistered_foldout": "Unregistered Parameters",
"merge_parameter.ui.add_button": "Add",
"merge_parameter.ui.details": "Parameter Configuration",

View File

@ -16,6 +16,7 @@
"params.syncmode.Int": "Int",
"params.syncmode.Float": "Float",
"params.syncmode.Bool": "Bool",
"params.syncmode.PhysBonesPrefix": "PB Prefix",
"params.autodetect_header": " 自動検出されたパラメーター ",
"params.internal": "内部値",
"params.pb_prefix": "PhysBones接頭辞",
@ -40,8 +41,8 @@
"merge_parameter.ui.internalParameter.tooltip": "有効にすると、名前かぶりを回避するために自動的に名前を変更します",
"merge_parameter.ui.isPrefix": "PhysBone 接頭辞",
"merge_parameter.ui.syncType": "パラメーター型",
"merge_parameter.ui.localOnly": "ローカルのみ",
"merge_parameter.ui.localOnly.tooltip": "有効にすると、ネットワーク上同期されなくなります",
"merge_parameter.ui.synced": "同期する",
"merge_parameter.ui.synced.tooltip": "有効にすると、ネットワーク上同期されます",
"merge_parameter.ui.unregistered_foldout": "未登録パラメーター",
"merge_parameter.ui.add_button": "追加",
"merge_parameter.ui.details": "パラメーターの詳細設定",