[Kernel] Added Property class and storing them for user
This commit is contained in:
@@ -71,11 +71,20 @@ X_HRESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
|
||||
|
||||
const util::XdbfGameData title_xdbf = kernel_state_->title_xdbf();
|
||||
if (title_xdbf.is_valid()) {
|
||||
const auto property = title_xdbf.GetProperty(property_id);
|
||||
const auto property_xdbf = title_xdbf.GetProperty(property_id);
|
||||
const XLanguage title_language = title_xdbf.GetExistingLanguage(
|
||||
static_cast<XLanguage>(XLanguage::kEnglish));
|
||||
const std::string desc =
|
||||
title_xdbf.GetStringTableEntry(title_language, property.string_id);
|
||||
const std::string desc = title_xdbf.GetStringTableEntry(
|
||||
title_language, property_xdbf.string_id);
|
||||
|
||||
Property property =
|
||||
Property(property_id, value_size,
|
||||
memory_->TranslateVirtual<uint8_t*>(value_ptr));
|
||||
|
||||
auto user = kernel_state_->user_profile(user_index);
|
||||
if (user) {
|
||||
user->AddProperty(&property);
|
||||
}
|
||||
XELOGD("XGIUserSetPropertyEx: Setting property: {}", desc);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,6 +212,30 @@ void UserProfile::SaveSetting(UserSetting* setting) {
|
||||
}
|
||||
}
|
||||
|
||||
bool UserProfile::AddProperty(const Property* property) {
|
||||
// Find if property already exits
|
||||
const Property* entry = GetProperty(property->GetPropertyId());
|
||||
if (entry) {
|
||||
entry = property;
|
||||
return true;
|
||||
}
|
||||
|
||||
properties_.push_back(*property);
|
||||
return true;
|
||||
}
|
||||
|
||||
const Property* UserProfile::GetProperty(const AttributeKey id) const {
|
||||
for (auto& entry : properties_) {
|
||||
if (entry.GetPropertyId().value != id.value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return &entry;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/byte_stream.h"
|
||||
#include "xenia/kernel/util/property.h"
|
||||
#include "xenia/kernel/util/xuserdata.h"
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
@@ -162,6 +163,9 @@ class UserProfile {
|
||||
void AddSetting(std::unique_ptr<UserSetting> setting);
|
||||
UserSetting* GetSetting(uint32_t setting_id);
|
||||
|
||||
bool AddProperty(const Property* property);
|
||||
const Property* GetProperty(const AttributeKey id) const;
|
||||
|
||||
std::map<uint32_t, uint32_t> contexts_;
|
||||
|
||||
private:
|
||||
@@ -170,6 +174,8 @@ class UserProfile {
|
||||
std::vector<std::unique_ptr<UserSetting>> setting_list_;
|
||||
std::unordered_map<uint32_t, UserSetting*> settings_;
|
||||
|
||||
std::vector<Property> properties_;
|
||||
|
||||
void LoadSetting(UserSetting*);
|
||||
void SaveSetting(UserSetting*);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user