33 std::unique_ptr<std::shared_ptr<FolderResult>> owner(
34 static_cast<std::shared_ptr<FolderResult>*
>(
userdata));
35 auto& result = **owner;
38 result.finished.store(
true, std::memory_order_release);
41 std::expected<std::optional<std::string>, std::string>
chooseFolder()
43 auto result = std::make_shared<FolderResult>();
45 new std::shared_ptr<FolderResult>(result),
nullptr,
nullptr,
false);
47 while (!result->finished.load(std::memory_order_acquire))
53 if (!result->error.empty())
return std::unexpected(result->error);
54 if (
quit || result->path.empty())
return std::optional<std::string>{};
55 return std::optional<std::string>{result->path};
60 std::span<const std::string_view>
arguments)
68 if (
argument.starts_with(
"--edition="))
71 return std::unexpected(
"--edition was specified twice");
73 const auto value =
argument.substr(std::string_view(
"--edition=").size());
76 else return std::unexpected(
"--edition requires usa or europe");
78 else if (
argument.starts_with(
"--language="))
81 return std::unexpected(
"--language was specified twice");
83 const auto value =
argument.substr(std::string_view(
"--language=").size());
87 else return std::unexpected(
"--language requires en-us, en-uk or fr");
90 return std::unexpected(
"resource context switches require --edition=usa|europe or --language=en-us|en-uk|fr");
96 return std::unexpected(
97 "--data-root requires one absolute installation folder");
100 else if (
argument ==
"--data-overrides")
105 return std::unexpected(
106 "--data-overrides requires one absolute manifest path");
109 else if (
argument ==
"--check-resources")
112 return std::unexpected(
"--check-resources was specified twice");
122 const std::filesystem::path
root{
125 if (!paths)
return std::unexpected(paths.error().detail);
129 environment,
"MONOPOLY_DATA_ROOT",
value.c_str(),
true))
137 return std::unexpected(
"resource board edition must be USA or Europe");
139 return std::unexpected(
"resource language must have a source-defined bank triplet");
153 const std::filesystem::path
path{
155 if (!
path.is_absolute())
156 return std::unexpected(
157 "--data-overrides requires an absolute manifest path");
159 std::error_code
error;
160 if (!std::filesystem::is_regular_file(
path,
error))
161 return std::unexpected(
162 "data override manifest does not exist or is not a file");
181 details =
"The configured installation folder is invalid.\n";
186 const auto root = paths->roots().front().u8string();
187 std::cout <<
"Resource folder: "
188 << std::string(
root.begin(),
root.end()) <<
'\n';
191 std::cout <<
"All eight required banks and the language catalog "
192 "can be opened. Gameplay assets remain to be exercised.\n";
195 const auto overrides =
199 const auto&
error = overrides.error();
201 std::cerr <<
"DATA override manifest failed ["
203 << std::string(
path.begin(),
path.end())
204 <<
": " <<
error.detail <<
'\n';
207 std::cout <<
"Loose DATA overrides: "
208 << overrides->size() <<
" logical items.\n";
215 <<
"] " <<
issue.detail <<
'\n';
218 else details +=
"Cannot read: ";
227 const std::string message =
228 "Choose the game installation folder containing Dat_Mon.\n\n" +
229 details +
"\nThe original game files are required to start.";
230 const std::array<SDL_MessageBoxButtonData, 2>
buttons{{
235 "Monopoly - Game files", message.c_str(),
240 std::cerr <<
"Resource setup dialog failed: " <<
SDL_GetError() <<
'\n';
247 std::cerr <<
"Folder selection failed: " <<
folder.error() <<
'\n';
249 "Monopoly - Folder selection",
folder.error().c_str(),
nullptr);
256 std::cerr <<
"Selected folder is invalid: " << selected.error() <<
'\n';
258 "Monopoly - Game files",
"The selected folder cannot be used.",
nullptr);
std::atomic< bool > finished
static std::expected< ResourcePaths, DataError > create(std::span< const std::filesystem::path > roots)
const LanguageBankTriplet * findLanguageBankTriplet(LanguageId language) noexcept
std::vector< DataError > inspectResourceInstallation(const ResourcePaths &paths, ResourceContext context, ArchiveOpenOptions options)
std::string_view dataErrorCodeName(DataErrorCode code) noexcept
std::expected< std::vector< DataSourceOverride >, DataError > loadLooseDataOverrides(const std::filesystem::path &manifestPath)
data::ResourceContext resourceContext() noexcept
std::optional< std::filesystem::path > dataOverrideManifest()
std::expected< void, std::string > selectResourceContext(data::ResourceContext context)
ResourceSetupResult prepareResources(bool interactive)
std::expected< ResourceArguments, std::string > parseResourceArguments(std::span< const std::string_view > arguments)
std::expected< void, std::string > selectDataOverrideManifest(std::string_view utf8Path)
std::expected< void, std::string > selectResourceRoot(std::string_view utf8Root)
const data::ResourcePaths * resourcePaths() noexcept
std::optional< std::string > dataOverrides
std::optional< std::string > dataRoot
data::ResourceContext context
std::vector< std::string_view > remaining