mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 05:55:15 +08:00
feat: track official versions and import resources
Persist official version-state, extend CAS/ResourceRepository import classification, and add offline catalog and failure regression fixtures. Fixes #13 Fixes #12 Fixes #8
This commit is contained in:
@@ -187,12 +187,32 @@ impl AddressablesCatalogDriver {
|
||||
}
|
||||
|
||||
fn resource_type_for_path(path: &str) -> ResourceType {
|
||||
if path.contains("TableBundles/") || path.ends_with(".bytes") {
|
||||
ResourceType::TableBundle
|
||||
} else if path.ends_with(".bundle") {
|
||||
ResourceType::AssetBundle
|
||||
} else if path.contains("catalog") {
|
||||
let normalized = path.replace('\\', "/").to_ascii_lowercase();
|
||||
if normalized.contains("catalog") || normalized.ends_with(".hash") {
|
||||
ResourceType::Manifest
|
||||
} else if normalized.contains("tablebundles/") {
|
||||
ResourceType::TableBundle
|
||||
} else if normalized.contains("mediaresources/")
|
||||
|| normalized.contains("mediaresources-")
|
||||
|| matches!(
|
||||
normalized.rsplit('.').next(),
|
||||
Some(
|
||||
"mp3" | "mp4" | "ogg" | "wav" | "png" | "jpg" | "jpeg" | "webp" | "acb" | "awb"
|
||||
)
|
||||
)
|
||||
{
|
||||
ResourceType::Media
|
||||
} else if normalized.ends_with(".bundle") {
|
||||
ResourceType::AssetBundle
|
||||
} else if normalized.contains("textassets/")
|
||||
|| matches!(
|
||||
normalized.rsplit('.').next(),
|
||||
Some("txt" | "csv" | "xml" | "yaml" | "yml")
|
||||
)
|
||||
{
|
||||
ResourceType::TextAsset
|
||||
} else if normalized.ends_with(".bytes") {
|
||||
ResourceType::TableBundle
|
||||
} else {
|
||||
ResourceType::Other
|
||||
}
|
||||
@@ -210,6 +230,16 @@ impl AddressablesCatalogDriver {
|
||||
return ResourceType::Manifest;
|
||||
}
|
||||
|
||||
if resource_type_name.is_some_and(|name| name.contains("TextAsset")) {
|
||||
return ResourceType::TextAsset;
|
||||
}
|
||||
|
||||
if resource_type_name.is_some_and(|name| {
|
||||
name.contains("AudioClip") || name.contains("VideoClip") || name.contains("Texture2D")
|
||||
}) {
|
||||
return ResourceType::Media;
|
||||
}
|
||||
|
||||
Self::resource_type_for_path(path)
|
||||
}
|
||||
|
||||
@@ -1017,4 +1047,24 @@ mod tests {
|
||||
ResourceType::TableBundle
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_parse_text_and_media_resource_types() {
|
||||
let driver = AddressablesCatalogDriver::new();
|
||||
|
||||
let catalog_json = r#"{
|
||||
"m_LocatorId": "AddressablesMainContentCatalog",
|
||||
"m_Entries": [
|
||||
{"internal_id": "TextAssets/dialogue.csv"},
|
||||
{"internal_id": "MediaResources-Windows/voice/academy.acb"},
|
||||
{"internal_id": "MediaResources-Windows/movie/opening.mp4"}
|
||||
]
|
||||
}"#;
|
||||
|
||||
let manifest = driver.parse(catalog_json.as_bytes()).await.unwrap();
|
||||
|
||||
assert_eq!(manifest.resources[0].resource_type, ResourceType::TextAsset);
|
||||
assert_eq!(manifest.resources[1].resource_type, ResourceType::Media);
|
||||
assert_eq!(manifest.resources[2].resource_type, ResourceType::Media);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user