diff options
Diffstat (limited to 'editor/app.cpp')
| -rw-r--r-- | editor/app.cpp | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/editor/app.cpp b/editor/app.cpp index 9ee59844..5920c6fb 100644 --- a/editor/app.cpp +++ b/editor/app.cpp @@ -30,36 +30,23 @@ int app::exec() return M->exec(); } -static const char* const true_values[] = { "1", "true", "yes", "y", "Y", "on", "ON", }; -static const char* const false_values[] = { "0", "false", "no", "n", "N", "off", "OFF", }; +static const char* const true_values[] = { "1", "true", "yes", "y", "Y", "on", "ON", "enable", "enabled", }; +static const char* const false_values[] = { "0", "false", "no", "n", "N", "off", "OFF", "disable", "disabled", }; static const char* const maybe_values[] = { "maybe", "m", "M", "default", }; template<typename T, typename U> static inline bool find_arg(const T& list, const U& value) { - return std::find_if(std::cbegin(list), std::cend(list), - [&](const auto& x) { return x == value; }) != std::cend(list); + return std::find_if(std::cbegin(list), std::cend(list), [&](const auto& x) { return x == value; }) != std::cend(list); } -static fm_tristate parse_tristate(StringView name, StringView str, fm_tristate def) -{ - if (find_arg(true_values, str)) - return fm_tristate::on; - else if (find_arg(false_values, str)) - return fm_tristate::off; - else if (find_arg(maybe_values, str)) - return fm_tristate::maybe; - - fm_warn("invalid '%s' argument '%s': should be true, false or default", name.data(), str.data()); - return def; -} - -static bool parse_bool(StringView name, StringView str, bool def) +static bool parse_bool(StringView name, const Corrade::Utility::Arguments& args, bool def) { + StringView str = args.value<StringView>(name); if (find_arg(true_values, str)) return true; else if (find_arg(false_values, str)) return false; - fm_warn("invalid '%s' argument '%s': should be true or false", name.data(), str.data()); + fm_warn("invalid '--%s' argument '%s': should be true or false", name.data(), str.data()); return def; } @@ -68,25 +55,19 @@ int app::run_from_argv(const int argc, const char* const* const argv) fm_settings opts; Corrade::Utility::Arguments args{}; args.addOption("vsync", "m") - .addOption("gpu-validation", "m") + .addOption("gpu-debug", "m") .addOption("msaa", "1") .parse(argc, argv); - opts.vsync = parse_tristate("--vsync", args.value<StringView>("vsync"), opts.vsync); - opts.msaa = parse_bool("--msaa", args.value<StringView>("msaa"), opts.msaa); - { - auto str = args.value<StringView>("gpu-validation"); - if (str == "no-error" || str == "NO-ERROR") - opts.gpu_debug = fm_gpu_debug::no_error; - else if (str == "robust" || str == "ROBUST") - opts.gpu_debug = fm_gpu_debug::robust; - else switch (parse_tristate("--gpu-validation", args.value<StringView>("gpu-validation"), fm_tristate::maybe)) - { - default: - case fm_tristate::on: opts.gpu_debug = fm_gpu_debug::on; break; - case fm_tristate::off: opts.gpu_debug = fm_gpu_debug::off; break; - } - } - opts.vsync = parse_tristate("--vsync", args.value<StringView>("vsync"), opts.vsync); + opts.vsync = parse_bool("vsync", args, opts.vsync); + opts.msaa = parse_bool("msaa", args, opts.msaa); + if (auto str = args.value<StringView>("gpu-validation"); str == "no-error" || str == "NO-ERROR") + opts.gpu_debug = fm_gpu_debug::no_error; + else if (str == "robust" || str == "ROBUST") + opts.gpu_debug = fm_gpu_debug::robust; + else + opts.gpu_debug = parse_bool("gpu-validation", args, opts.gpu_debug > fm_gpu_debug::off) + ? fm_gpu_debug::on + : fm_gpu_debug::off; int ret; Pointer<floormat_main> ptr; |
