VFX Category Label Generation
This commit is contained in:
@@ -7409,12 +7409,150 @@ func TestApplyAutogenConsumersAugmentsHeadVisualeffectsFromLocalOverride(t *test
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyAutogenConsumersUsesFolderDrivenSlashHeadVisualeffectsNames(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
overrideRoot := filepath.Join(root, "autogen-assets")
|
||||
mkdirAll(t, filepath.Join(overrideRoot, "vfxs", "headfeature", "sinfar", "ears_plt"))
|
||||
writeFile(t, filepath.Join(overrideRoot, "vfxs", "headfeature", "sinfar", "ears_plt", "hfx_Ear_EL_L.mdl"), "mdl\n")
|
||||
|
||||
p := testProject(root)
|
||||
p.Config.Autogen.Consumers = []project.AutogenConsumerConfig{
|
||||
{
|
||||
ID: "head_visualeffects",
|
||||
Producer: "head_visualeffects",
|
||||
Dataset: "visualeffects",
|
||||
Mode: "head_visualeffects",
|
||||
Root: "vfxs",
|
||||
Include: []string{"headfeature/**/*.mdl"},
|
||||
Derive: project.AutogenDeriveConfig{Kind: "model_stem", GroupFrom: "first_path_segment"},
|
||||
Manifest: project.AutogenManifestConfig{ReleaseTag: "head-vfx-manifest-current", AssetName: "sow-head-vfx-manifest.json", CacheName: "sow-head-vfx-manifest.json"},
|
||||
LocalOverrideRoot: "autogen-assets",
|
||||
HeadVisualeffects: project.HeadVisualeffectsConfig{
|
||||
Groups: map[string]project.HeadVisualeffectGroupConfig{
|
||||
"headfeature": {
|
||||
ModelColumns: []string{"Imp_HeadCon_Node", "Imp_Root_H_Node"},
|
||||
},
|
||||
},
|
||||
GroupTokenSource: "folder_name",
|
||||
CategoryFrom: "immediate_parent",
|
||||
Delimiter: "/",
|
||||
Case: "preserve",
|
||||
StripModelPrefixes: []string{"hfx_"},
|
||||
KeyFormat: "{dataset}:{group}{delimiter}{category_segment}{stem}",
|
||||
LabelFormat: "{group}{delimiter}{category_segment}{stem}",
|
||||
LegacyKeyFormat: "{dataset}:{group}_{stem}",
|
||||
RowDefaults: map[string]string{
|
||||
"Type_FD": "D",
|
||||
"OrientWithGround": "0",
|
||||
"OrientWithObject": "1",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
collected := []nativeCollectedDataset{
|
||||
{
|
||||
Dataset: nativeDataset{Name: "visualeffects", Kind: nativeDatasetBase},
|
||||
Columns: []string{"Label", "Type_FD", "OrientWithGround", "Imp_HeadCon_Node", "Imp_Root_H_Node", "OrientWithObject"},
|
||||
Rows: nil,
|
||||
LockData: map[string]int{
|
||||
"visualeffects:headfeature_Ear_EL_L": 11030,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
got, err := applyAutogenConsumers(p, collected, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("applyAutogenConsumers failed: %v", err)
|
||||
}
|
||||
if len(got) != 1 || len(got[0].Rows) != 1 {
|
||||
t.Fatalf("expected one autogenerated visualeffects row, got %#v", got)
|
||||
}
|
||||
row := got[0].Rows[0]
|
||||
if row["key"] != "visualeffects:headfeature/ears_plt/Ear_EL_L" {
|
||||
t.Fatalf("expected folder-driven key, got %#v", row)
|
||||
}
|
||||
if row["id"] != 11030 {
|
||||
t.Fatalf("expected legacy lock id to be preserved, got %#v", row)
|
||||
}
|
||||
if row["Label"] != "headfeature/ears_plt/Ear_EL_L" {
|
||||
t.Fatalf("expected preserve-case slash label, got %#v", row)
|
||||
}
|
||||
if row["Imp_HeadCon_Node"] != "hfx_Ear_EL_L" || row["Imp_Root_H_Node"] != "hfx_Ear_EL_L" {
|
||||
t.Fatalf("expected configured model columns, got %#v", row)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHeadVisualeffectsConsumerMapsLegacyManifestGroupsToFolderDrivenNames(t *testing.T) {
|
||||
collected := []nativeCollectedDataset{
|
||||
{
|
||||
Dataset: nativeDataset{Name: "visualeffects", Kind: nativeDatasetBase},
|
||||
Columns: []string{"Label", "Type_FD", "OrientWithGround", "Imp_HeadCon_Node", "Imp_Root_H_Node", "OrientWithObject"},
|
||||
Rows: nil,
|
||||
LockData: map[string]int{
|
||||
"visualeffects:headfeature_ear_el_l": 11030,
|
||||
},
|
||||
},
|
||||
}
|
||||
entries := []autogenManifestEntry{
|
||||
{
|
||||
Group: "head_features",
|
||||
Source: "head_features/sinfar/ears_plt/hfx_ear_el_l.mdl",
|
||||
ModelStem: "hfx_ear_el_l",
|
||||
},
|
||||
}
|
||||
consumer := project.AutogenConsumerConfig{
|
||||
Dataset: "visualeffects",
|
||||
HeadVisualeffects: project.HeadVisualeffectsConfig{
|
||||
Groups: map[string]project.HeadVisualeffectGroupConfig{
|
||||
"headfeature": {
|
||||
ModelColumns: []string{"Imp_HeadCon_Node", "Imp_Root_H_Node"},
|
||||
},
|
||||
},
|
||||
GroupTokenSource: "folder_name",
|
||||
CategoryFrom: "immediate_parent",
|
||||
Delimiter: "/",
|
||||
Case: "preserve",
|
||||
StripModelPrefixes: []string{
|
||||
"hfx_",
|
||||
},
|
||||
KeyFormat: "{dataset}:{group}{delimiter}{category_segment}{stem}",
|
||||
LabelFormat: "{group}{delimiter}{category_segment}{stem}",
|
||||
LegacyGroups: map[string]string{"head_features": "headfeature"},
|
||||
LegacyKeyFormat: "{dataset}:{group}_{stem}",
|
||||
RowDefaults: map[string]string{
|
||||
"Type_FD": "D",
|
||||
"OrientWithGround": "0",
|
||||
"OrientWithObject": "1",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
got, err := augmentWithAutogeneratedHeadVisualeffects(collected, entries, consumer, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("augmentWithAutogeneratedHeadVisualeffects failed: %v", err)
|
||||
}
|
||||
if len(got) != 1 || len(got[0].Rows) != 1 {
|
||||
t.Fatalf("expected one autogenerated row, got %#v", got)
|
||||
}
|
||||
row := got[0].Rows[0]
|
||||
if row["key"] != "visualeffects:headfeature/ears_plt/ear_el_l" || row["id"] != 11030 {
|
||||
t.Fatalf("expected migrated slash key with preserved ID, got %#v", row)
|
||||
}
|
||||
if _, exists := got[0].LockData["visualeffects:headfeature/ears_plt/ear_el_l"]; !exists {
|
||||
t.Fatalf("expected new slash key in lock data, got %#v", got[0].LockData)
|
||||
}
|
||||
if _, exists := got[0].LockData["visualeffects:headfeature_ear_el_l"]; exists {
|
||||
t.Fatalf("expected legacy key to be removed from active lock data, got %#v", got[0].LockData)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNativeUsesConfiguredHeadVisualeffectsGroups(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mkdirAll(t, filepath.Join(root, "src"))
|
||||
mkdirAll(t, filepath.Join(root, "build"))
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "visualeffects"))
|
||||
mkdirAll(t, filepath.Join(root, "autogen-assets", "vfxs", "chest_accessories"))
|
||||
mkdirAll(t, filepath.Join(root, "autogen-assets", "vfxs", "chestaccessory"))
|
||||
mkdirAll(t, filepath.Join(root, "autogen-assets", "vfxs", "head_jewels"))
|
||||
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "visualeffects", "base.json"), `{
|
||||
@@ -7422,7 +7560,7 @@ func TestBuildNativeUsesConfiguredHeadVisualeffectsGroups(t *testing.T) {
|
||||
"columns": ["Label", "Type_FD", "OrientWithGround", "Imp_HeadCon_Node", "Imp_Root_S_Node", "Imp_Root_M_Node", "Imp_Root_L_Node", "Imp_Root_H_Node", "OrientWithObject"],
|
||||
"rows": []
|
||||
}`+"\n")
|
||||
writeFile(t, filepath.Join(root, "autogen-assets", "vfxs", "chest_accessories", "tfx_sash.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "autogen-assets", "vfxs", "chestaccessory", "tfx_sash.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "autogen-assets", "vfxs", "head_jewels", "hfx_circlet.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "nwn-tool.yaml"), `
|
||||
module:
|
||||
@@ -7442,7 +7580,7 @@ autogen:
|
||||
mode: head_visualeffects
|
||||
root: vfxs
|
||||
include:
|
||||
- chest_accessories/**/*.mdl
|
||||
- chestaccessory/**/*.mdl
|
||||
- head_jewels/**/*.mdl
|
||||
derive:
|
||||
kind: model_stem
|
||||
@@ -7454,7 +7592,7 @@ autogen:
|
||||
local_override_root: autogen-assets
|
||||
head_visualeffects:
|
||||
groups:
|
||||
chest_accessories:
|
||||
chestaccessory:
|
||||
prefix: chestaccessory
|
||||
model_columns:
|
||||
- Imp_Root_S_Node
|
||||
@@ -7499,16 +7637,16 @@ autogen:
|
||||
|
||||
func TestBuildGenerated2DAAssetsAppendsCachedModelsFromHeadVisualeffects(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "chest_accessories"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "head_accessories"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "head_decorations"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "head_features", "hair"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "chestaccessory"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "headaccessory"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "headdecoration"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "headfeature", "hair"))
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "cachedmodels"))
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "chest_accessories", "tfx_sash.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "head_accessories", "hfx_bandana.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "head_accessories", "hfx_existing.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "head_decorations", "hfx_laurel.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "head_features", "hair", "hfx_hair_bangs.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "chestaccessory", "tfx_sash.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "headaccessory", "hfx_bandana.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "headaccessory", "hfx_existing.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "headdecoration", "hfx_laurel.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "headfeature", "hair", "hfx_hair_bangs.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "cachedmodels", "base.json"), `{
|
||||
"columns": ["Model"],
|
||||
"rows": [
|
||||
@@ -7530,7 +7668,7 @@ func TestBuildGenerated2DAAssetsAppendsCachedModelsFromHeadVisualeffects(t *test
|
||||
ID: "cachedmodels",
|
||||
Mode: "cachedmodels_rows",
|
||||
Root: "vfxs",
|
||||
Include: []string{"chest_accessories/**/*.mdl", "head_accessories/**/*.mdl", "head_decorations/**/*.mdl", "head_features/**/*.mdl"},
|
||||
Include: []string{"chestaccessory/**/*.mdl", "headaccessory/**/*.mdl", "headdecoration/**/*.mdl", "headfeature/**/*.mdl"},
|
||||
Derive: project.AutogenDeriveConfig{Kind: "model_stem", GroupFrom: "first_path_segment"},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user