diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc index d130bc286..65a6f5e0e 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -864,30 +864,29 @@ void EmulatorWindow::FileClose() { } void EmulatorWindow::InstallContent() { - std::filesystem::path path; + std::vector paths; 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_multi_selection(true); 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]; - } + paths = file_picker->selected_files(); } - 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); + if (!paths.empty()) { + for (auto path : paths) { + // 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); + } } } } diff --git a/src/xenia/ui/file_picker_win.cc b/src/xenia/ui/file_picker_win.cc index 5cb467ca1..b4364d383 100644 --- a/src/xenia/ui/file_picker_win.cc +++ b/src/xenia/ui/file_picker_win.cc @@ -114,7 +114,7 @@ bool Win32FilePicker::Show(Window* parent_window) { // TODO(benvanik): FileSaveDialog. assert_true(mode() == Mode::kOpen); - Microsoft::WRL::ComPtr file_dialog; + Microsoft::WRL::ComPtr file_dialog; HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&file_dialog)); @@ -192,23 +192,30 @@ bool Win32FilePicker::Show(Window* parent_window) { // Obtain the result once the user clicks the 'Open' button. // The result is an IShellItem object. - Microsoft::WRL::ComPtr shell_item; - hr = file_dialog->GetResult(&shell_item); + Microsoft::WRL::ComPtr shell_items; + hr = file_dialog->GetResults(&shell_items); if (!SUCCEEDED(hr)) { return false; } - // We are just going to print out the name of the file for sample sake. - PWSTR file_path = nullptr; - hr = shell_item->GetDisplayName(SIGDN_FILESYSPATH, &file_path); - if (!SUCCEEDED(hr)) { - return false; - } std::vector selected_files; - selected_files.push_back(std::filesystem::path(file_path)); - set_selected_files(selected_files); - CoTaskMemFree(file_path); + DWORD items_count = 0; + shell_items->GetCount(&items_count); + // Iterate over selected files + for (DWORD i = 0; i < items_count; i++) { + Microsoft::WRL::ComPtr shell_item; + shell_items->GetItemAt(i, &shell_item); + // We are just going to print out the name of the file for sample sake. + PWSTR file_path = nullptr; + hr = shell_item->GetDisplayName(SIGDN_FILESYSPATH, &file_path); + if (!SUCCEEDED(hr)) { + return false; + } + selected_files.push_back(std::filesystem::path(file_path)); + CoTaskMemFree(file_path); + } + set_selected_files(selected_files); return true; }