mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
[XLast] Add presence getters
This commit is contained in:
parent
854b7df2ba
commit
12bf52b363
|
|
@ -89,6 +89,10 @@ XLast::~XLast() {}
|
||||||
std::u16string XLast::GetTitleName() const {
|
std::u16string XLast::GetTitleName() const {
|
||||||
std::string xpath = "/XboxLiveSubmissionProject/GameConfigProject";
|
std::string xpath = "/XboxLiveSubmissionProject/GameConfigProject";
|
||||||
|
|
||||||
|
if (!HasXLast()) {
|
||||||
|
return std::u16string();
|
||||||
|
}
|
||||||
|
|
||||||
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return std::u16string();
|
return std::u16string();
|
||||||
|
|
@ -104,6 +108,10 @@ XLast::GetProductInformationAttributes() const {
|
||||||
std::string xpath =
|
std::string xpath =
|
||||||
"/XboxLiveSubmissionProject/GameConfigProject/ProductInformation";
|
"/XboxLiveSubmissionProject/GameConfigProject/ProductInformation";
|
||||||
|
|
||||||
|
if (!HasXLast()) {
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return attributes;
|
return attributes;
|
||||||
|
|
@ -140,6 +148,10 @@ std::vector<XLanguage> XLast::GetSupportedLanguages() const {
|
||||||
std::string xpath = fmt::format(
|
std::string xpath = fmt::format(
|
||||||
"/XboxLiveSubmissionProject/GameConfigProject/LocalizedStrings");
|
"/XboxLiveSubmissionProject/GameConfigProject/LocalizedStrings");
|
||||||
|
|
||||||
|
if (!HasXLast()) {
|
||||||
|
return launguages;
|
||||||
|
}
|
||||||
|
|
||||||
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return launguages;
|
return launguages;
|
||||||
|
|
@ -166,6 +178,10 @@ std::u16string XLast::GetLocalizedString(uint32_t string_id,
|
||||||
"LocalizedString[@id = \"{}\"]",
|
"LocalizedString[@id = \"{}\"]",
|
||||||
string_id);
|
string_id);
|
||||||
|
|
||||||
|
if (!HasXLast()) {
|
||||||
|
return std::u16string();
|
||||||
|
}
|
||||||
|
|
||||||
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
const pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return std::u16string();
|
return std::u16string();
|
||||||
|
|
@ -182,6 +198,66 @@ std::u16string XLast::GetLocalizedString(uint32_t string_id,
|
||||||
return xe::to_utf16(locale_node.child_value());
|
return xe::to_utf16(locale_node.child_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::optional<uint32_t> XLast::GetPresenceStringId(
|
||||||
|
const uint32_t context_id) {
|
||||||
|
std::string xpath = fmt::format(
|
||||||
|
"/XboxLiveSubmissionProject/GameConfigProject/Presence/"
|
||||||
|
"PresenceMode[@contextValue = \"{}\"]",
|
||||||
|
context_id);
|
||||||
|
|
||||||
|
std::optional<uint32_t> id = std::nullopt;
|
||||||
|
|
||||||
|
if (!HasXLast()) {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
const auto string_id = node.node().attribute("stringId").value();
|
||||||
|
id = xe::string_util::from_string<uint32_t>(string_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::optional<uint32_t> XLast::GetPropertyStringId(
|
||||||
|
const uint32_t property_id) {
|
||||||
|
std::string xpath = fmt::format(
|
||||||
|
"/XboxLiveSubmissionProject/GameConfigProject/Properties/Property[@id = "
|
||||||
|
"\"0x{:08X}\"]",
|
||||||
|
property_id);
|
||||||
|
|
||||||
|
std::optional<uint32_t> value = std::nullopt;
|
||||||
|
|
||||||
|
if (!HasXLast()) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
const auto string_id_value = node.node().attribute("stringId").value();
|
||||||
|
value = xe::string_util::from_string<uint32_t>(string_id_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::u16string XLast::GetPresenceRawString(const uint32_t presence_value,
|
||||||
|
const XLanguage language) {
|
||||||
|
const std::optional<uint32_t> presence_string_id =
|
||||||
|
GetPresenceStringId(presence_value);
|
||||||
|
|
||||||
|
std::u16string raw_presence = u"";
|
||||||
|
|
||||||
|
if (presence_string_id.has_value()) {
|
||||||
|
raw_presence = GetLocalizedString(presence_string_id.value(), language);
|
||||||
|
}
|
||||||
|
|
||||||
|
return raw_presence;
|
||||||
|
}
|
||||||
|
|
||||||
XLastMatchmakingQuery* XLast::GetMatchmakingQuery(
|
XLastMatchmakingQuery* XLast::GetMatchmakingQuery(
|
||||||
const uint32_t query_id) const {
|
const uint32_t query_id) const {
|
||||||
std::string xpath = fmt::format(
|
std::string xpath = fmt::format(
|
||||||
|
|
@ -190,6 +266,11 @@ XLastMatchmakingQuery* XLast::GetMatchmakingQuery(
|
||||||
query_id);
|
query_id);
|
||||||
|
|
||||||
XLastMatchmakingQuery* query = nullptr;
|
XLastMatchmakingQuery* query = nullptr;
|
||||||
|
|
||||||
|
if (!HasXLast()) {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
pugi::xpath_node node = parsed_xlast_->select_node(xpath.c_str());
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return query;
|
return query;
|
||||||
|
|
@ -215,7 +296,7 @@ std::vector<uint32_t> XLast::GetAllValuesFromNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
void XLast::Dump(std::string file_name) const {
|
void XLast::Dump(std::string file_name) const {
|
||||||
if (xlast_decompressed_xml_.empty()) {
|
if (!HasXLast()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#define XENIA_KERNEL_UTIL_XLAST_H_
|
#define XENIA_KERNEL_UTIL_XLAST_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
@ -78,6 +79,10 @@ class XLast {
|
||||||
std::vector<XLanguage> GetSupportedLanguages() const;
|
std::vector<XLanguage> GetSupportedLanguages() const;
|
||||||
std::u16string GetLocalizedString(uint32_t string_id,
|
std::u16string GetLocalizedString(uint32_t string_id,
|
||||||
XLanguage language) const;
|
XLanguage language) const;
|
||||||
|
const std::optional<uint32_t> GetPresenceStringId(const uint32_t context_id);
|
||||||
|
const std::optional<uint32_t> GetPropertyStringId(const uint32_t property_id);
|
||||||
|
const std::u16string GetPresenceRawString(const uint32_t presence_value,
|
||||||
|
const XLanguage language);
|
||||||
XLastMatchmakingQuery* GetMatchmakingQuery(uint32_t query_id) const;
|
XLastMatchmakingQuery* GetMatchmakingQuery(uint32_t query_id) const;
|
||||||
static std::vector<uint32_t> GetAllValuesFromNode(
|
static std::vector<uint32_t> GetAllValuesFromNode(
|
||||||
const pugi::xpath_node node, const std::string child_name,
|
const pugi::xpath_node node, const std::string child_name,
|
||||||
|
|
@ -85,6 +90,8 @@ class XLast {
|
||||||
|
|
||||||
void Dump(std::string file_name) const;
|
void Dump(std::string file_name) const;
|
||||||
|
|
||||||
|
const bool HasXLast() const { return !xlast_decompressed_xml_.empty(); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string GetLocaleStringFromLanguage(XLanguage language) const;
|
std::string GetLocaleStringFromLanguage(XLanguage language) const;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue