summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-12-02 02:23:37 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-12-02 02:23:37 +0100
commit316f7bef0d81f86eb099e6a07b517bb24ed4a3dd (patch)
treeb596622c1edb6570b1d7383c66a9aa09921c7acd /main
parent8f6fc959ffbb3c612e9115c9b155f5379bee66d8 (diff)
app, main: allow Magnum to parse argv --magnum-foo opts
Diffstat (limited to 'main')
-rw-r--r--main/main-impl.cpp5
-rw-r--r--main/main-impl.hpp2
-rw-r--r--main/setup.cpp17
3 files changed, 7 insertions, 17 deletions
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)