diff options
-rw-r--r-- | editor/app.cpp | 13 | ||||
-rw-r--r-- | floormat/settings.hpp | 9 | ||||
-rw-r--r-- | main/main-impl.cpp | 5 | ||||
-rw-r--r-- | main/main-impl.hpp | 2 | ||||
-rw-r--r-- | main/setup.cpp | 17 |
5 files changed, 18 insertions, 28 deletions
diff --git a/editor/app.cpp b/editor/app.cpp index a0c086cf..ed374dd8 100644 --- a/editor/app.cpp +++ b/editor/app.cpp @@ -77,22 +77,25 @@ static int atoi_(const char* str) return negative ? result : -result; } -fm_settings app::parse_cmdline(int argc, const char* const* argv) +fm_settings app::parse_cmdline(int argc, const char* const* const argv) { fm_settings opts; Corrade::Utility::Arguments args{}; - args.addOption("vsync", "1") - .addOption("gpu-debug", "1") + args.addOption("vsync", "1").setFromEnvironment("vsync", "FLOORMAT_VSYNC").setHelp("vsync", "", "true|false") + .addOption("gpu-debug", "1").setFromEnvironment("gpu-debug", "FLOORMAT_GPU_DEBUG").setHelp("gpu-debug", "", "robust|on|off|no-error") + .addSkippedPrefix("magnum") .parse(argc, argv); opts.vsync = parse_bool("vsync", args, opts.vsync); - if (auto str = args.value<StringView>("gpu-debug"); str == "no-error" || str == "none") + if (auto str = args.value<StringView>("gpu-debug"); str == "no-error"_s) opts.gpu_debug = fm_gpu_debug::no_error; - else if (str == "robust" || str == "full") + else if (str == "robust"_s || str == "full"_s) opts.gpu_debug = fm_gpu_debug::robust; else opts.gpu_debug = parse_bool("gpu-debug", args, opts.gpu_debug > fm_gpu_debug::off) ? fm_gpu_debug::on : fm_gpu_debug::off; + opts.argc = argc; + opts.argv = argv; return opts; } diff --git a/floormat/settings.hpp b/floormat/settings.hpp index aed65dea..65ae5a42 100644 --- a/floormat/settings.hpp +++ b/floormat/settings.hpp @@ -7,8 +7,6 @@ namespace floormat { enum class fm_gpu_debug : char { no_error = 1, off, on, robust, }; -enum class fm_tristate : char { maybe = -1, on, off }; -enum class fm_log_level : unsigned char { quiet, normal, verbose, }; struct fm_settings { @@ -17,12 +15,11 @@ struct fm_settings fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(fm_settings); fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(fm_settings); + String title = "Test"_s; + const char* const* argv = nullptr; int argc = 0; Magnum::Math::Vector2<int> resolution{1024, 720}; - Corrade::Containers::String title{"Test"}; - Corrade::Containers::String disabled_extensions; // TODO - bool vsync = true; fm_gpu_debug gpu_debug = fm_gpu_debug::on; - fm_log_level log_level = fm_log_level::normal; + bool vsync = true; bool resizable : 1 = true, fullscreen : 1 = false, fullscreen_desktop : 1 = false, diff --git a/main/main-impl.cpp b/main/main-impl.cpp index 1da2d4ee..01aea1ca 100644 --- a/main/main-impl.cpp +++ b/main/main-impl.cpp @@ -1,5 +1,7 @@ #include "main-impl.hpp" #include "compat/assert.hpp" +#include <cstdlib> +#include <cstdio> #include <Magnum/Platform/Sdl2Application.h> namespace floormat { @@ -28,8 +30,7 @@ int main_impl::exec() floormat_main* floormat_main::create(floormat_app& app, fm_settings&& options) { - int fake_argc = 0; - auto* ret = new main_impl(app, std::move(options), fake_argc); + auto* ret = new main_impl(app, std::move(options), options.argc, const_cast<char**>(options.argv)); fm_assert(ret); return ret; } diff --git a/main/main-impl.hpp b/main/main-impl.hpp index 74ed8222..a96d6aee 100644 --- a/main/main-impl.hpp +++ b/main/main-impl.hpp @@ -23,7 +23,7 @@ template<typename Atlas, typename T> struct clickable; struct main_impl final : Platform::Sdl2Application, floormat_main { - explicit main_impl(floormat_app& app, fm_settings&& opts, int& fake_argc) noexcept; + explicit main_impl(floormat_app& app, fm_settings&& opts, int& argc, char** argv) noexcept; ~main_impl() noexcept override; int exec() override; diff --git a/main/setup.cpp b/main/setup.cpp index 38df0ccf..742272a8 100644 --- a/main/setup.cpp +++ b/main/setup.cpp @@ -2,11 +2,12 @@ #include "compat/fpu.hpp" #include <algorithm> #include <Corrade/Containers/StringView.h> +#include <Corrade/Containers/StringIterable.h> namespace floormat { -main_impl::main_impl(floormat_app& app, fm_settings&& se, int& fake_argc) noexcept : - Platform::Sdl2Application{Arguments{fake_argc, nullptr}, +main_impl::main_impl(floormat_app& app, fm_settings&& se, int& argc, char** argv) noexcept : + Platform::Sdl2Application{Arguments{argc, argv}, make_conf(se), make_gl_conf(se)}, s{std::move(se)}, app{app} { @@ -43,18 +44,6 @@ auto main_impl::make_window_flags(const fm_settings& s) -> Configuration::Window auto main_impl::make_conf(const fm_settings& s) -> Configuration { - switch (s.log_level) - { - default: - SDL_setenv("MAGNUM_LOG_LEVEL", "normal", 1); - break; - case fm_log_level::quiet: - SDL_setenv("MAGNUM_LOG_LEVEL", "quiet", 1); - break; - case fm_log_level::verbose: - SDL_setenv("MAGNUM_LOG_LEVEL", "verbose", 1); - break; - } return Configuration{} .setTitle(s.title) .setSize(s.resolution, Configuration::DpiScalingPolicy::Virtual) |