Skip to content

Instantly share code, notes, and snippets.

@voidproc
Last active August 27, 2023 02:21
Show Gist options
  • Save voidproc/7673170c54448179703ce08e0800a3b4 to your computer and use it in GitHub Desktop.
Save voidproc/7673170c54448179703ce08e0800a3b4 to your computer and use it in GitHub Desktop.
Platform::Web::Dialog::OpenFile の挙動の確認
# include <Siv3D.hpp> // OpenSiv3D v0.6
# if defined(SIV3D_WEBGPU_BACKEND)
SIV3D_SET(EngineOption::Renderer::WebGPU)
# endif
void Main()
{
Scene::SetBackground(ColorF{ 0 });
// OpenFile の結果
AsyncTask<Optional<String>> filePathTask;
// OpenFiles の結果
AsyncTask<Array<String>> filePathsTask;
while (System::Update())
{
if (SimpleGUI::ButtonAt(U"OpenFile", Scene::CenterF().movedBy(0, -24)))
{
filePathTask = Platform::Web::Dialog::OpenFile();
}
if (SimpleGUI::ButtonAt(U"OpenFiles", Scene::CenterF().movedBy(0, 24)))
{
filePathsTask = Platform::Web::Dialog::OpenFiles();
}
if (filePathTask.isReady())
{
Print << U"OpenFile ==> Task is ready";
const auto filePath = filePathTask.get();
if (filePath)
{
Print << U"path=" + (*filePath);
}
else
{
Print << U"no file";
}
}
if (filePathsTask.isReady())
{
Print << U"OpenFiles ==> Task is ready";
const auto filePaths = filePathsTask.get();
if (not filePaths.isEmpty())
{
for (auto& path : filePaths)
{
Print << path;
}
}
else
{
Print << U"no file";
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment