[nostalgia/studio] MSVC fixes for NFDE file dialog
This commit is contained in:
parent
1dddf4ad9d
commit
ad412177ab
@ -4,11 +4,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/defines.hpp>
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
struct FDFilterItem {
|
||||
ox::String name;
|
||||
ox::String spec;
|
||||
#ifdef OX_OS_Windows
|
||||
using String = ox::BasicString<8, wchar_t>;
|
||||
#else
|
||||
using String = ox::String;
|
||||
#endif
|
||||
String name;
|
||||
String spec;
|
||||
};
|
||||
|
||||
ox::Result<ox::String> saveFile(const ox::Vector<FDFilterItem> &exts) noexcept;
|
||||
|
@ -14,8 +14,14 @@ namespace nostalgia::studio {
|
||||
|
||||
static ox::Result<ox::String> toResult(nfdresult_t r, const NFD::UniquePathN &path) noexcept {
|
||||
switch (r) {
|
||||
case NFD_OKAY:
|
||||
return ox::String(path.get());
|
||||
case NFD_OKAY: {
|
||||
ox::String out;
|
||||
for (auto i = 0u; path.get()[i]; ++i) {
|
||||
const auto c = static_cast<char>(path.get()[i]);
|
||||
oxIgnoreError(out.append(&c, 1));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
case NFD_CANCEL:
|
||||
return OxError(1, "Operation cancelled");
|
||||
default:
|
||||
@ -28,7 +34,9 @@ ox::Result<ox::String> saveFile(const ox::Vector<FDFilterItem> &filters) noexcep
|
||||
NFD::UniquePathN path;
|
||||
ox::Vector<nfdnfilteritem_t, 5> filterItems(filters.size());
|
||||
for (auto i = 0u; const auto &f : filters) {
|
||||
filterItems[i] = {f.name.c_str(), f.spec.c_str()};
|
||||
filterItems[i].name = f.name.c_str();
|
||||
filterItems[i].spec = f.spec.c_str();
|
||||
//filterItems[i] = {f.name.c_str(), f.spec.c_str()};
|
||||
++i;
|
||||
}
|
||||
return toResult(NFD::SaveDialog(path, filterItems.data(), filterItems.size()), path);
|
||||
|
Loading…
Reference in New Issue
Block a user