Set the window title from the module resource pool

This commit is contained in:
x1nixmzeng 2016-01-07 00:58:05 +00:00
parent 729a1af0d5
commit 321e2d8873
2 changed files with 21 additions and 2 deletions

View File

@ -35,6 +35,7 @@
#include "xenia/vfs/devices/host_path_device.h" #include "xenia/vfs/devices/host_path_device.h"
#include "xenia/vfs/devices/stfs_container_device.h" #include "xenia/vfs/devices/stfs_container_device.h"
#include "xenia/vfs/virtual_file_system.h" #include "xenia/vfs/virtual_file_system.h"
#include "xenia/xdbf/xdbf_utils.h"
DEFINE_double(time_scalar, 1.0, DEFINE_double(time_scalar, 1.0,
"Scalar used to speed or slow time (1x, 2x, 1/2x, etc)."); "Scalar used to speed or slow time (1x, 2x, 1/2x, etc).");
@ -498,7 +499,7 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path,
// Allow xam to request module loads. // Allow xam to request module loads.
auto xam = kernel_state()->GetKernelModule<kernel::xam::XamModule>("xam.xex"); auto xam = kernel_state()->GetKernelModule<kernel::xam::XamModule>("xam.xex");
int result = 0; X_STATUS result = X_STATUS_SUCCESS;
auto next_module = module_path; auto next_module = module_path;
while (next_module != "") { while (next_module != "") {
XELOGI("Launching module %s", next_module.c_str()); XELOGI("Launching module %s", next_module.c_str());
@ -514,6 +515,24 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path,
return X_STATUS_UNSUCCESSFUL; return X_STATUS_UNSUCCESSFUL;
} }
// Try and load the resource database (xex only)
char title[9] = { 0 };
sprintf(title, "%08X", module->title_id());
uint32_t resource_data = 0;
uint32_t resource_size = 0;
if (XSUCCEEDED(module->GetSection(title, &resource_data, &resource_size))) {
auto xdb_ptr = module->memory()->TranslateVirtual(resource_data);
if (xdb_ptr != nullptr) {
xe::xdbf::XdbfWrapper db;
if (db.initialize(xdb_ptr, static_cast<size_t>(resource_size))) {
// TODO(x1nixmzeng): Set the application icon
std::wstring title(xe::to_wstring(xe::xdbf::get_title(db)));
display_window_->set_title(title);
}
}
}
main_thread_ = main_xthread->thread(); main_thread_ = main_xthread->thread();
WaitUntilExit(); WaitUntilExit();

View File

@ -208,7 +208,7 @@ X_STATUS UserModule::GetSection(const char* name, uint32_t* out_section_data,
return X_STATUS_NOT_FOUND; return X_STATUS_NOT_FOUND;
} }
uint32_t count = (resource_header->size - 4) / 16; uint32_t count = (resource_header->size - 4) / sizeof(xex2_resource);
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
auto& res = resource_header->resources[i]; auto& res = resource_header->resources[i];
if (std::strncmp(name, res.name, 8) == 0) { if (std::strncmp(name, res.name, 8) == 0) {