[Emulator] Added option for content installation

This commit is contained in:
Gliniak
2022-07-30 12:41:26 +02:00
parent 7595cdb52b
commit 433a8a8a5e
5 changed files with 126 additions and 0 deletions

View File

@@ -506,6 +506,9 @@ bool EmulatorWindow::Initialize() {
file_menu->AddChild(
MenuItem::Create(MenuItem::Type::kString, "&Open...", "Ctrl+O",
std::bind(&EmulatorWindow::FileOpen, this)));
file_menu->AddChild(
MenuItem::Create(MenuItem::Type::kString, "Install Content...",
std::bind(&EmulatorWindow::InstallContent, this)));
#ifdef DEBUG
file_menu->AddChild(
MenuItem::Create(MenuItem::Type::kString, "Close",
@@ -850,6 +853,35 @@ void EmulatorWindow::FileClose() {
}
}
void EmulatorWindow::InstallContent() {
std::filesystem::path path;
auto file_picker = xe::ui::FilePicker::Create();
file_picker->set_mode(ui::FilePicker::Mode::kOpen);
file_picker->set_type(ui::FilePicker::Type::kFile);
file_picker->set_multi_selection(false);
file_picker->set_title("Select Content Package");
file_picker->set_extensions({
{"All Files (*.*)", "*.*"},
});
if (file_picker->Show(window_.get())) {
auto selected_files = file_picker->selected_files();
if (!selected_files.empty()) {
path = selected_files[0];
}
}
if (!path.empty()) {
// Normalize the path and make absolute.
auto abs_path = std::filesystem::absolute(path);
auto result = emulator_->InstallContentPackage(abs_path);
if (XFAILED(result)) {
// TODO: Display a message box.
XELOGE("Failed to install content: {:08X}", result);
}
}
}
void EmulatorWindow::ShowContentDirectory() {
std::filesystem::path target_path;

View File

@@ -130,6 +130,7 @@ class EmulatorWindow {
void FileDrop(const std::filesystem::path& filename);
void FileOpen();
void FileClose();
void InstallContent();
void ShowContentDirectory();
void CpuTimeScalarReset();
void CpuTimeScalarSetHalf();