[UI] Added detailed installation state to "Install Content" option
This commit is contained in:
@@ -611,14 +611,17 @@ void EmulatorWindow::ContentInstallDialog::OnDraw(ImGuiIO& io) {
|
|||||||
XContentTypeMap.at(entry.content_type_).c_str());
|
XContentTypeMap.at(entry.content_type_).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.installation_result_ != X_ERROR_SUCCESS) {
|
std::string result = fmt::format(
|
||||||
ImGui::Text("Status: %s (0x%08X)",
|
"Status: {}", xe::Emulator::installStateStringName[static_cast<uint8_t>(
|
||||||
entry.installation_error_message_.c_str(),
|
entry.installation_state_)]);
|
||||||
entry.installation_result_);
|
|
||||||
} else if (entry.currently_installed_size_ == entry.content_size_ &&
|
if (entry.installation_state_ == xe::Emulator::InstallState::failed) {
|
||||||
entry.installation_result_ == X_ERROR_SUCCESS) {
|
result += fmt::format(" - {} ({:08X})",
|
||||||
ImGui::Text("Status: Success");
|
entry.installation_error_message_.c_str(),
|
||||||
|
entry.installation_result_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::Text("%s", result.c_str());
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
|
||||||
if (entry.content_size_ > 0) {
|
if (entry.content_size_ > 0) {
|
||||||
|
|||||||
@@ -794,6 +794,7 @@ X_STATUS Emulator::ProcessContentPackageHeader(
|
|||||||
const auto header = vfs::XContentContainerDevice::ReadContainerHeader(path);
|
const auto header = vfs::XContentContainerDevice::ReadContainerHeader(path);
|
||||||
|
|
||||||
if (!header || !header->content_header.is_magic_valid()) {
|
if (!header || !header->content_header.is_magic_valid()) {
|
||||||
|
installation_info.installation_state_ = InstallState::failed;
|
||||||
installation_info.installation_result_ = X_STATUS_INVALID_PARAMETER;
|
installation_info.installation_result_ = X_STATUS_INVALID_PARAMETER;
|
||||||
installation_info.installation_error_message_ = "Invalid Package Type!";
|
installation_info.installation_error_message_ = "Invalid Package Type!";
|
||||||
XELOGE("Failed to initialize device");
|
XELOGE("Failed to initialize device");
|
||||||
@@ -828,6 +829,7 @@ X_STATUS Emulator::ProcessContentPackageHeader(
|
|||||||
installation_info.content_type_ =
|
installation_info.content_type_ =
|
||||||
static_cast<XContentType>(header->content_metadata.content_type);
|
static_cast<XContentType>(header->content_metadata.content_type);
|
||||||
installation_info.content_size_ = header->content_metadata.content_size;
|
installation_info.content_size_ = header->content_metadata.content_size;
|
||||||
|
installation_info.installation_state_ = InstallState::pending;
|
||||||
|
|
||||||
installation_info.icon_ = imgui_drawer_->LoadImGuiIcon(
|
installation_info.icon_ = imgui_drawer_->LoadImGuiIcon(
|
||||||
std::span<const uint8_t>(header->content_metadata.title_thumbnail,
|
std::span<const uint8_t>(header->content_metadata.title_thumbnail,
|
||||||
@@ -837,6 +839,8 @@ X_STATUS Emulator::ProcessContentPackageHeader(
|
|||||||
|
|
||||||
X_STATUS Emulator::InstallContentPackage(
|
X_STATUS Emulator::InstallContentPackage(
|
||||||
const std::filesystem::path& path, ContentInstallEntry& installation_info) {
|
const std::filesystem::path& path, ContentInstallEntry& installation_info) {
|
||||||
|
installation_info.installation_state_ = InstallState::preparing;
|
||||||
|
|
||||||
std::unique_ptr<vfs::XContentContainerDevice> device =
|
std::unique_ptr<vfs::XContentContainerDevice> device =
|
||||||
vfs::XContentContainerDevice::CreateContentDevice("", path);
|
vfs::XContentContainerDevice::CreateContentDevice("", path);
|
||||||
|
|
||||||
@@ -854,6 +858,7 @@ X_STATUS Emulator::InstallContentPackage(
|
|||||||
if (!std::filesystem::exists(content_root())) {
|
if (!std::filesystem::exists(content_root())) {
|
||||||
const std::error_code ec = xe::filesystem::CreateFolder(content_root());
|
const std::error_code ec = xe::filesystem::CreateFolder(content_root());
|
||||||
if (ec) {
|
if (ec) {
|
||||||
|
installation_info.installation_state_ = InstallState::failed;
|
||||||
installation_info.installation_error_message_ = ec.message();
|
installation_info.installation_error_message_ = ec.message();
|
||||||
installation_info.installation_result_ = X_STATUS_ACCESS_DENIED;
|
installation_info.installation_result_ = X_STATUS_ACCESS_DENIED;
|
||||||
return X_STATUS_ACCESS_DENIED;
|
return X_STATUS_ACCESS_DENIED;
|
||||||
@@ -862,6 +867,7 @@ X_STATUS Emulator::InstallContentPackage(
|
|||||||
|
|
||||||
const auto disk_space = std::filesystem::space(content_root());
|
const auto disk_space = std::filesystem::space(content_root());
|
||||||
if (disk_space.available < installation_info.content_size_ * 1.1f) {
|
if (disk_space.available < installation_info.content_size_ * 1.1f) {
|
||||||
|
installation_info.installation_state_ = InstallState::failed;
|
||||||
installation_info.installation_error_message_ = "Insufficient disk space!";
|
installation_info.installation_error_message_ = "Insufficient disk space!";
|
||||||
installation_info.installation_result_ = X_STATUS_DISK_FULL;
|
installation_info.installation_result_ = X_STATUS_DISK_FULL;
|
||||||
return X_STATUS_DISK_FULL;
|
return X_STATUS_DISK_FULL;
|
||||||
@@ -874,6 +880,7 @@ X_STATUS Emulator::InstallContentPackage(
|
|||||||
std::error_code error_code;
|
std::error_code error_code;
|
||||||
std::filesystem::create_directories(installation_path, error_code);
|
std::filesystem::create_directories(installation_path, error_code);
|
||||||
if (error_code) {
|
if (error_code) {
|
||||||
|
installation_info.installation_state_ = InstallState::failed;
|
||||||
installation_info.installation_error_message_ =
|
installation_info.installation_error_message_ =
|
||||||
"Cannot Create Content Directory!";
|
"Cannot Create Content Directory!";
|
||||||
installation_info.installation_result_ = error_code.value();
|
installation_info.installation_result_ = error_code.value();
|
||||||
@@ -882,6 +889,7 @@ X_STATUS Emulator::InstallContentPackage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
installation_info.content_size_ = device->data_size();
|
installation_info.content_size_ = device->data_size();
|
||||||
|
installation_info.installation_state_ = InstallState::installing;
|
||||||
|
|
||||||
vfs::VirtualFileSystem::ExtractContentHeader(device.get(), header_path);
|
vfs::VirtualFileSystem::ExtractContentHeader(device.get(), header_path);
|
||||||
|
|
||||||
@@ -889,9 +897,11 @@ X_STATUS Emulator::InstallContentPackage(
|
|||||||
device.get(), installation_path,
|
device.get(), installation_path,
|
||||||
installation_info.currently_installed_size_);
|
installation_info.currently_installed_size_);
|
||||||
if (error_code != X_ERROR_SUCCESS) {
|
if (error_code != X_ERROR_SUCCESS) {
|
||||||
|
installation_info.installation_state_ = InstallState::failed;
|
||||||
return error_code;
|
return error_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
installation_info.installation_state_ = InstallState::installed;
|
||||||
installation_info.currently_installed_size_ = installation_info.content_size_;
|
installation_info.currently_installed_size_ = installation_info.content_size_;
|
||||||
kernel_state()->BroadcastNotification(kXNotificationLiveContentInstalled, 0);
|
kernel_state()->BroadcastNotification(kXNotificationLiveContentInstalled, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,17 @@ class Emulator {
|
|||||||
|
|
||||||
X_STATUS LaunchDefaultModule(const std::filesystem::path& path);
|
X_STATUS LaunchDefaultModule(const std::filesystem::path& path);
|
||||||
|
|
||||||
|
enum class InstallState : uint8_t {
|
||||||
|
preparing,
|
||||||
|
pending,
|
||||||
|
installing,
|
||||||
|
installed,
|
||||||
|
failed
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr static std::string_view installStateStringName[5] = {
|
||||||
|
"Preparing", "Pending", "Installing", "Success", "Failed"};
|
||||||
|
|
||||||
struct ContentInstallEntry {
|
struct ContentInstallEntry {
|
||||||
ContentInstallEntry(std::filesystem::path path) : path_(path) {};
|
ContentInstallEntry(std::filesystem::path path) : path_(path) {};
|
||||||
|
|
||||||
@@ -245,9 +256,11 @@ class Emulator {
|
|||||||
|
|
||||||
uint64_t content_size_ = 0;
|
uint64_t content_size_ = 0;
|
||||||
uint64_t currently_installed_size_ = 0;
|
uint64_t currently_installed_size_ = 0;
|
||||||
|
XContentType content_type_{};
|
||||||
|
|
||||||
|
InstallState installation_state_{};
|
||||||
X_STATUS installation_result_{};
|
X_STATUS installation_result_{};
|
||||||
std::string installation_error_message_{};
|
std::string installation_error_message_{};
|
||||||
XContentType content_type_{};
|
|
||||||
|
|
||||||
std::unique_ptr<ui::ImmediateTexture> icon_;
|
std::unique_ptr<ui::ImmediateTexture> icon_;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user