summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/app.cpp22
-rw-r--r--editor/draw.cpp3
-rw-r--r--editor/imgui.cpp9
-rw-r--r--main/floormat-app.hpp2
-rw-r--r--main/floormat-main-impl.cpp10
-rw-r--r--main/floormat-main-impl.hpp7
-rw-r--r--main/floormat-main.hpp6
-rw-r--r--main/floormat.hpp4
8 files changed, 50 insertions, 13 deletions
diff --git a/editor/app.cpp b/editor/app.cpp
index 878e4052..44ca1530 100644
--- a/editor/app.cpp
+++ b/editor/app.cpp
@@ -66,11 +66,24 @@ int app::run_from_argv(const int argc, const char* const* const argv)
{
Corrade::Utility::Arguments args{};
args.addOption("vsync", "m")
- .addOption("gpu-validation", "1")
+ .addOption("gpu-validation", "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>("msaaa"), opts.msaa);
+ 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;
+ }
+ }
}
app application;
return application.exec();
@@ -94,3 +107,8 @@ extern "C" int __stdcall WinMain(void*, void*, void*, int)
#endif
} // namespace floormat
+
+int main(int argc, char** argv)
+{
+ return floormat::app::run_from_argv(argc, argv);
+}
diff --git a/editor/draw.cpp b/editor/draw.cpp
index 33188573..fe12489d 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -1,3 +1,4 @@
+#if 0
#include "app.hpp"
#include "main/floormat-main.hpp"
#include "shaders/tile-shader.hpp"
@@ -48,3 +49,5 @@ void app::draw()
}
} // namespace floormat
+
+#endif
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index aea34ae9..571c1c1b 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -78,10 +78,9 @@ void app::draw_editor_pane(tile_editor& type, float main_menu_height)
color_selected{1, 0.843f, 0, .8f},
color_hover{0, .8f, 1, .7f};
- if (ImGui::GetIO().WantTextInput && !isTextInputActive())
- startTextInput();
- else if (!ImGui::GetIO().WantTextInput && isTextInputActive())
- stopTextInput();
+ if (const bool active = M->is_text_input_active();
+ ImGui::GetIO().WantTextInput != active)
+ active ? M->start_text_input() : M->stop_text_input();
[[maybe_unused]] const raii_wrapper vars[] = {
push_style_var(ImGuiStyleVar_WindowPadding, {8, 8}),
@@ -126,7 +125,7 @@ void app::draw_editor_pane(tile_editor& type, float main_menu_height)
if (ed)
{
click_event();
- if (ed->is_atlas_selected(v))
+ if (ed->is_atlas_selected(v_))
{
ImGui::SameLine();
ImGui::Text(" (selected)");
diff --git a/main/floormat-app.hpp b/main/floormat-app.hpp
index c74ea461..6474b66a 100644
--- a/main/floormat-app.hpp
+++ b/main/floormat-app.hpp
@@ -18,7 +18,7 @@ struct chunk;
struct floormat_app
{
- floormat_app() noexcept;
+ explicit floormat_app() noexcept;
virtual ~floormat_app() noexcept;
fm_DECLARE_DELETED_COPY_ASSIGNMENT(floormat_app);
diff --git a/main/floormat-main-impl.cpp b/main/floormat-main-impl.cpp
index 7f2821d2..92f1c7ce 100644
--- a/main/floormat-main-impl.cpp
+++ b/main/floormat-main-impl.cpp
@@ -65,6 +65,7 @@ auto main_impl::make_gl_conf(const fm_settings& s) -> GLConfiguration
flags |= f::RobustAccess;
else if (s.gpu_debug == fm_gpu_debug::no_error)
flags |= f::NoError;
+ return GLConfiguration{}.setFlags(flags);
}
void main_impl::recalc_viewport(Vector2i size) noexcept
@@ -82,7 +83,7 @@ void main_impl::recalc_viewport(Vector2i size) noexcept
}
// NOLINTNEXTLINE(performance-unnecessary-value-param)
-main_impl::main_impl(floormat_app& app, fm_settings s) noexcept :
+main_impl::main_impl(floormat_app& app, fm_settings&& s) noexcept :
Platform::Sdl2Application{Arguments{fake_argc, fm_fake_argv},
make_conf(s), make_gl_conf(s)},
app{app}, s{std::move(s)}
@@ -209,10 +210,13 @@ const fm_settings& main_impl::settings() const noexcept { return s; }
Vector2i main_impl::window_size() const noexcept { return windowSize(); }
tile_shader& main_impl::shader() noexcept { return _shader; }
const tile_shader& main_impl::shader() const noexcept { return _shader; }
+bool main_impl::is_text_input_active() const noexcept { return const_cast<main_impl&>(*this).isTextInputActive(); }
+void main_impl::start_text_input() noexcept { startTextInput(); }
+void main_impl::stop_text_input() noexcept { stopTextInput(); }
-floormat_main* floormat_main::create(floormat_app& app, const fm_settings& options)
+floormat_main* floormat_main::create(floormat_app& app, fm_settings&& options)
{
- auto* ret = new main_impl(app, options);
+ auto* ret = new main_impl(app, std::move(options));
fm_assert(ret);
return ret;
}
diff --git a/main/floormat-main-impl.hpp b/main/floormat-main-impl.hpp
index 0406760a..9bcdc6de 100644
--- a/main/floormat-main-impl.hpp
+++ b/main/floormat-main-impl.hpp
@@ -17,7 +17,7 @@ struct floormat_app;
struct main_impl final : Platform::Sdl2Application, floormat_main
{
- main_impl(floormat_app& app, fm_settings opts) noexcept;
+ explicit main_impl(floormat_app& app, fm_settings&& opts) noexcept;
~main_impl() noexcept override;
int exec() override;
@@ -46,8 +46,13 @@ struct main_impl final : Platform::Sdl2Application, floormat_main
[[maybe_unused]] void keyPressEvent(KeyEvent& event) override;
[[maybe_unused]] void keyReleaseEvent(KeyEvent& event) override;
[[maybe_unused]] void anyEvent(SDL_Event& event) override;
+
void drawEvent() override;
+ bool is_text_input_active() const noexcept override;
+ void start_text_input() noexcept override;
+ void stop_text_input() noexcept override;
+
private:
floormat_app& app;
tile_shader _shader;
diff --git a/main/floormat-main.hpp b/main/floormat-main.hpp
index 3a4ed20e..66efeeec 100644
--- a/main/floormat-main.hpp
+++ b/main/floormat-main.hpp
@@ -31,12 +31,16 @@ struct floormat_main
virtual fm_settings& settings() noexcept = 0;
virtual const fm_settings& settings() const noexcept = 0;
+ virtual bool is_text_input_active() const noexcept = 0;
+ virtual void start_text_input() noexcept = 0;
+ virtual void stop_text_input() noexcept = 0;
+
virtual global_coords pixel_to_tile(Vector2d position) const noexcept = 0;
virtual world& world() noexcept = 0;
virtual SDL_Window* window() noexcept = 0;
- static floormat_main* create(floormat_app& app, const fm_settings& options);
+ static floormat_main* create(floormat_app& app, fm_settings&& options);
protected:
float _frame_time = 0;
diff --git a/main/floormat.hpp b/main/floormat.hpp
index d596c21b..9696cfbd 100644
--- a/main/floormat.hpp
+++ b/main/floormat.hpp
@@ -1,4 +1,5 @@
#pragma once
+#include "compat/defs.hpp"
#include <cstdint>
#include <Corrade/Containers/String.h>
#include <Magnum/Math/Vector2.h>
@@ -11,7 +12,10 @@ enum class fm_log_level : unsigned char { quiet, normal, verbose, };
struct fm_settings
{
+ inline fm_settings() noexcept = default;
virtual ~fm_settings() noexcept;
+ fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(fm_settings);
+ fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(fm_settings);
Magnum::Math::Vector2<int> resolution{1024, 768};
Corrade::Containers::String title{"Test"};