[Emulator] Added possiblity to install multiple packages at once
This commit is contained in:
parent
79ffbe3971
commit
5d1b641197
|
@ -864,30 +864,29 @@ void EmulatorWindow::FileClose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmulatorWindow::InstallContent() {
|
void EmulatorWindow::InstallContent() {
|
||||||
std::filesystem::path path;
|
std::vector<std::filesystem::path> paths;
|
||||||
|
|
||||||
auto file_picker = xe::ui::FilePicker::Create();
|
auto file_picker = xe::ui::FilePicker::Create();
|
||||||
file_picker->set_mode(ui::FilePicker::Mode::kOpen);
|
file_picker->set_mode(ui::FilePicker::Mode::kOpen);
|
||||||
file_picker->set_type(ui::FilePicker::Type::kFile);
|
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_title("Select Content Package");
|
||||||
file_picker->set_extensions({
|
file_picker->set_extensions({
|
||||||
{"All Files (*.*)", "*.*"},
|
{"All Files (*.*)", "*.*"},
|
||||||
});
|
});
|
||||||
if (file_picker->Show(window_.get())) {
|
if (file_picker->Show(window_.get())) {
|
||||||
auto selected_files = file_picker->selected_files();
|
paths = file_picker->selected_files();
|
||||||
if (!selected_files.empty()) {
|
|
||||||
path = selected_files[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!path.empty()) {
|
if (!paths.empty()) {
|
||||||
// Normalize the path and make absolute.
|
for (auto path : paths) {
|
||||||
auto abs_path = std::filesystem::absolute(path);
|
// Normalize the path and make absolute.
|
||||||
auto result = emulator_->InstallContentPackage(abs_path);
|
auto abs_path = std::filesystem::absolute(path);
|
||||||
if (XFAILED(result)) {
|
auto result = emulator_->InstallContentPackage(abs_path);
|
||||||
// TODO: Display a message box.
|
if (XFAILED(result)) {
|
||||||
XELOGE("Failed to install content: {:08X}", result);
|
// TODO: Display a message box.
|
||||||
|
XELOGE("Failed to install content: {:08X}", result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ bool Win32FilePicker::Show(Window* parent_window) {
|
||||||
// TODO(benvanik): FileSaveDialog.
|
// TODO(benvanik): FileSaveDialog.
|
||||||
assert_true(mode() == Mode::kOpen);
|
assert_true(mode() == Mode::kOpen);
|
||||||
|
|
||||||
Microsoft::WRL::ComPtr<IFileDialog> file_dialog;
|
Microsoft::WRL::ComPtr<IFileOpenDialog> file_dialog;
|
||||||
HRESULT hr =
|
HRESULT hr =
|
||||||
CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER,
|
CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER,
|
||||||
IID_PPV_ARGS(&file_dialog));
|
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.
|
// Obtain the result once the user clicks the 'Open' button.
|
||||||
// The result is an IShellItem object.
|
// The result is an IShellItem object.
|
||||||
Microsoft::WRL::ComPtr<IShellItem> shell_item;
|
Microsoft::WRL::ComPtr<IShellItemArray> shell_items;
|
||||||
hr = file_dialog->GetResult(&shell_item);
|
hr = file_dialog->GetResults(&shell_items);
|
||||||
if (!SUCCEEDED(hr)) {
|
if (!SUCCEEDED(hr)) {
|
||||||
return false;
|
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<std::filesystem::path> selected_files;
|
std::vector<std::filesystem::path> 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<IShellItem> 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue