tweak
This commit is contained in:
+25
-1
@@ -426,6 +426,7 @@
|
||||
type: 'select',
|
||||
options: { '': 'None', V: 'V', A: 'A', M: 'M' },
|
||||
value: metadata.injector || '',
|
||||
description: 'Selecting an injector adds gender.male to required actor tags. You can remove that tag afterward.',
|
||||
condition: fieldCondition,
|
||||
};
|
||||
form[`${base}_injects_into`] = {
|
||||
@@ -486,6 +487,25 @@
|
||||
});
|
||||
}
|
||||
|
||||
function createInjectorGenderDefaultHandler(form) {
|
||||
const roles = new Map(Object.entries(form).filter(([key]) => key.endsWith('_injector'))
|
||||
.map(([key, field]) => [key, field.value || '']));
|
||||
return (dialog, result) => {
|
||||
const updates = {};
|
||||
for (const [key, previous] of roles) {
|
||||
if (!result || !(key in result)) continue;
|
||||
const role = result[key];
|
||||
roles.set(key, role);
|
||||
if (role === previous || !['V', 'A', 'M'].includes(role)) continue;
|
||||
const tagsKey = key.replace(/_injector$/, '_actor_tags');
|
||||
const tags = uniqueTrimmedStrings(parseCommaSeparatedStrings(result[tagsKey]));
|
||||
if (tags.includes('gender.male')) continue;
|
||||
result[tagsKey] = updates[tagsKey] = [...tags, 'gender.male'].join(', ');
|
||||
}
|
||||
if (Object.keys(updates).length) dialog.form.setValues(updates, false);
|
||||
};
|
||||
}
|
||||
|
||||
function validateActorAnimdefMetadata(metadata, actorLabel) {
|
||||
for (const entityType of metadata.entity_types || []) {
|
||||
if (!RESOURCE_ID_PATTERN.test(entityType)) {
|
||||
@@ -1650,6 +1670,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
const updateInjectorGenderDefault = createInjectorGenderDefaultHandler(form);
|
||||
const dialog = new Dialog({
|
||||
id: 'edit_actor_preferences',
|
||||
title: 'Actor Preferences',
|
||||
@@ -1658,9 +1679,10 @@
|
||||
buttons: ['Cancel', 'Save & Apply'],
|
||||
cancelIndex: 0,
|
||||
confirmIndex: 1,
|
||||
onFormChange: (result) => {
|
||||
onFormChange(result) {
|
||||
showBoneTextureOverrides = !!result?.show_bone_texture_overrides;
|
||||
showAnimdefMetadata = !!result?.show_animdef_metadata;
|
||||
updateInjectorGenderDefault(this, result);
|
||||
},
|
||||
onConfirm: (result) => {
|
||||
let editing = false;
|
||||
@@ -4088,11 +4110,13 @@
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const updateInjectorGenderDefault = createInjectorGenderDefaultHandler(form);
|
||||
const dialog = new Dialog({
|
||||
id: 'create_afw_animation_definition_review',
|
||||
title: `Animation Definition: ${group.id}`,
|
||||
width: 760,
|
||||
form,
|
||||
onFormChange(result) { updateInjectorGenderDefault(this, result); },
|
||||
buttons: ['Cancel', 'Save', 'Create Animdef'],
|
||||
cancelIndex: 0,
|
||||
confirmIndex: 2,
|
||||
|
||||
Reference in New Issue
Block a user