From b0909b490b46ee84388cf0aff91466adeb50a930 Mon Sep 17 00:00:00 2001 From: emoose Date: Sat, 11 Jan 2020 18:35:10 +0000 Subject: [PATCH] [Kernel] Use user_language value as the slot to retrieve STFS strings from --- src/xenia/kernel/xam/content_manager.cc | 7 +++++-- src/xenia/vfs/devices/stfs_container_device.h | 12 ++++++++++++ src/xenia/xbox.h | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/xenia/kernel/xam/content_manager.cc b/src/xenia/kernel/xam/content_manager.cc index fd045cdaa..51f5a97e2 100644 --- a/src/xenia/kernel/xam/content_manager.cc +++ b/src/xenia/kernel/xam/content_manager.cc @@ -20,6 +20,8 @@ #include "xenia/vfs/devices/host_path_device.h" #include "xenia/vfs/devices/stfs_container_device.h" +DECLARE_int32(user_language); + namespace xe { namespace kernel { namespace xam { @@ -113,7 +115,7 @@ std::vector ContentManager::ListContent(uint32_t device_id, content_data.content_type = static_cast(header->metadata.content_type); content_data.display_name = - header->metadata.get_display_name(XLanguage::kEnglish); + header->metadata.get_display_name((XLanguage)cvars::user_language); // TODO: select localized display name // some games may expect different ones depending on language setting. map->Close(); @@ -196,7 +198,8 @@ X_RESULT ContentManager::CreateContent(std::string root_name, vfs::StfsHeader* header = new vfs::StfsHeader(); // TODO: set title_id, title_name & publisher from XDBF info header->metadata.content_type = (xe::vfs::XContentType)data.content_type; - header->metadata.set_display_name(data.display_name, XLanguage::kEnglish); + header->metadata.set_display_name(data.display_name, + (XLanguage)cvars::user_language); // TODO: set display name locale that's currently in use fwrite(header, sizeof(vfs::StfsHeader), 1, file); fclose(file); diff --git a/src/xenia/vfs/devices/stfs_container_device.h b/src/xenia/vfs/devices/stfs_container_device.h index 010392c4a..dd9c9a62c 100644 --- a/src/xenia/vfs/devices/stfs_container_device.h +++ b/src/xenia/vfs/devices/stfs_container_device.h @@ -206,6 +206,9 @@ struct XContentMetadata { std::wstring get_display_name(XLanguage lang) { uint32_t lang_id = (uint32_t)lang; lang_id--; + if (lang_id >= 12) { + lang_id = 0; // no room for this lang, store in english slot.. + } wchar_t* str = 0; if (lang_id >= 0 && lang_id < 9) { @@ -226,6 +229,9 @@ struct XContentMetadata { std::wstring get_description(XLanguage lang) { uint32_t lang_id = (uint32_t)lang; lang_id--; + if (lang_id >= 12) { + lang_id = 0; // no room for this lang, store in english slot.. + } wchar_t* str = 0; if (lang_id >= 0 && lang_id < 9) { @@ -263,6 +269,9 @@ struct XContentMetadata { bool set_display_name(const std::wstring& value, XLanguage lang) { uint32_t lang_id = (uint32_t)lang; lang_id--; + if (lang_id >= 12) { + lang_id = 0; // no room for this lang, store in english slot.. + } wchar_t* str = 0; if (lang_id >= 0 && lang_id < 9) { @@ -281,6 +290,9 @@ struct XContentMetadata { bool set_description(const std::wstring& value, XLanguage lang) { uint32_t lang_id = (uint32_t)lang; lang_id--; + if (lang_id >= 12) { + lang_id = 0; // no room for this lang, store in english slot.. + } wchar_t* str = 0; if (lang_id >= 0 && lang_id < 9) { diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index 3d33cff2f..a3ed8465a 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -367,7 +367,7 @@ enum class XLanguage : uint32_t { kItalian, kKorean, kTChinese, - kUnknown9, // unused? + kPortuguese, kUnknown10, // unused? kPolish, kRussian,