diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-19 14:29:48 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-20 08:18:03 +0100 |
commit | f3c46930b43707e57979f08c85d53974f688380d (patch) | |
tree | 0b0e363ffe91ba50b3381011fddad7aceacbc497 /editor | |
parent | 9629cfc4a97241a01654518dd7b8b2636e415866 (diff) |
pass dt to tests
Diffstat (limited to 'editor')
-rw-r--r-- | editor/app.hpp | 4 | ||||
-rw-r--r-- | editor/tests-private.hpp | 6 | ||||
-rw-r--r-- | editor/tests.cpp | 9 | ||||
-rw-r--r-- | editor/tests/path-test.cpp | 11 | ||||
-rw-r--r-- | editor/tests/pathfinding.cpp | 8 | ||||
-rw-r--r-- | editor/tests/raycast-test.cpp | 4 | ||||
-rw-r--r-- | editor/tests/region-test.cpp | 6 | ||||
-rw-r--r-- | editor/update.cpp | 4 |
8 files changed, 24 insertions, 28 deletions
diff --git a/editor/app.hpp b/editor/app.hpp index a60d12bf..5d6723b3 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -171,8 +171,8 @@ private: [[nodiscard]] bool tests_handle_key(const key_event& e, bool is_down); [[nodiscard]] bool tests_handle_mouse_click(const mouse_button_event& e, bool is_down); [[nodiscard]] bool tests_handle_mouse_move(const mouse_move_event& e); - void tests_pre_update(); - void tests_post_update(); + void tests_pre_update(Ns dt); + void tests_post_update(Ns dt); void draw_tests_pane(float width); void draw_tests_overlay(); void tests_reset_mode(); diff --git a/editor/tests-private.hpp b/editor/tests-private.hpp index 6d137f67..e7882a8b 100644 --- a/editor/tests-private.hpp +++ b/editor/tests-private.hpp @@ -7,7 +7,7 @@ #include <cr/StringView.h> #include <cr/Pointer.h> -namespace floormat { struct app; } +namespace floormat { struct app; struct Ns; } namespace floormat::tests { @@ -21,8 +21,8 @@ struct base_test virtual bool handle_mouse_move(app& a, const mouse_move_event& e) = 0; virtual void draw_overlay(app& a) = 0; virtual void draw_ui(app& a, float width) = 0; - virtual void update_pre(app& a) = 0; - virtual void update_post(app& a) = 0; + virtual void update_pre(app& a, const Ns& dt) = 0; + virtual void update_post(app& a, const Ns& dt) = 0; virtual ~base_test() noexcept; diff --git a/editor/tests.cpp b/editor/tests.cpp index a5c2be3c..4da1553f 100644 --- a/editor/tests.cpp +++ b/editor/tests.cpp @@ -3,6 +3,7 @@ #include "app.hpp" #include "floormat/main.hpp" #include "floormat/events.hpp" +#include "src/nanosecond.inl" #include "imgui-raii.hpp" #define HAVE_LIBC 1 #include <SDL_keycode.h> @@ -45,16 +46,16 @@ safe_ptr<tests_data_> tests_data_::make() return safe_ptr<tests_data_>{new tests_data}; } -void app::tests_pre_update() +void app::tests_pre_update(Ns dt) { if (auto& x = tests().current_test) - x->update_pre(*this); + x->update_pre(*this, dt); } -void app::tests_post_update() +void app::tests_post_update(Ns dt) { if (auto& x = tests().current_test) - x->update_post(*this); + x->update_post(*this, dt); } bool app::tests_handle_mouse_click(const mouse_button_event& e, bool is_down) diff --git a/editor/tests/path-test.cpp b/editor/tests/path-test.cpp index 9f837128..cc7dc796 100644 --- a/editor/tests/path-test.cpp +++ b/editor/tests/path-test.cpp @@ -22,8 +22,8 @@ struct path_test final : base_test bool handle_mouse_move(app& a, const mouse_move_event& e) override; void draw_overlay(app& a) override; void draw_ui(app& a, float width) override; - void update_pre(app& a) override; - void update_post(app& a) override; + void update_pre(app& a, const Ns& dt) override; + void update_post(app&, const Ns&) override {} struct pending_s { @@ -144,7 +144,7 @@ void path_test::draw_overlay(app& a) } } -void path_test::update_pre(app& a) +void path_test::update_pre(app& a, const Ns&) { if (!has_pending) return; @@ -169,11 +169,6 @@ void path_test::update_pre(app& a) }; } -void path_test::update_post(app& a) -{ - (void)a; -} - void path_test::draw_ui(app&, float) { constexpr ImGuiTableFlags table_flags = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_ScrollY; diff --git a/editor/tests/pathfinding.cpp b/editor/tests/pathfinding.cpp index 303277c6..3299a626 100644 --- a/editor/tests/pathfinding.cpp +++ b/editor/tests/pathfinding.cpp @@ -78,8 +78,8 @@ struct pf_test final : base_test bool handle_mouse_move(app& a, const mouse_move_event&) override { return {}; } void draw_overlay(app& a) override; void draw_ui(app& a, float menu_bar_height) override; - void update_pre(app& a) override; - void update_post(app& a) override; + void update_pre(app& a, const Ns& dt) override; + void update_post(app& a, const Ns& dt) override; }; step_s pf_test::get_next_step(point from, point to) @@ -117,7 +117,7 @@ void pf_test::draw_ui(app& a, float) (void)a; } -void pf_test::update_pre(app& a) +void pf_test::update_pre(app& a, const Ns& dt) { if (!pending.has_value) return; @@ -127,7 +127,7 @@ void pf_test::update_pre(app& a) auto& c = *a.ensure_player_character(m.world()).ptr; } -void pf_test::update_post(app& a) +void pf_test::update_post(app& a, const Ns&) { } diff --git a/editor/tests/raycast-test.cpp b/editor/tests/raycast-test.cpp index 13199244..383264e7 100644 --- a/editor/tests/raycast-test.cpp +++ b/editor/tests/raycast-test.cpp @@ -252,12 +252,12 @@ struct raycast_test final : base_test } } - void update_pre(app&) override + void update_pre(app&, const Ns&) override { } - void update_post(app& a) override + void update_post(app& a, const Ns&) override { if (pending.exists) { diff --git a/editor/tests/region-test.cpp b/editor/tests/region-test.cpp index e24447c4..ca8addf3 100644 --- a/editor/tests/region-test.cpp +++ b/editor/tests/region-test.cpp @@ -52,8 +52,8 @@ struct region_test final : base_test bool handle_mouse_move(app&, const mouse_move_event&) override { return {}; } void draw_overlay(app& a) override; void draw_ui(app&, float) override; - void update_pre(app&) override {} - void update_post(app& a) override; + void update_pre(app&, const Ns&) override {} + void update_post(app& a, const Ns&) override; }; void region_test::draw_overlay(app& a) @@ -139,7 +139,7 @@ bool region_test::handle_mouse_click(app& a, const mouse_button_event& e, bool i return false; } -void region_test::update_post(app& a) +void region_test::update_post(app& a, const Ns&) { if (pending.exists) { diff --git a/editor/update.cpp b/editor/update.cpp index 6987b411..1fdbe31b 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -279,14 +279,14 @@ void app::update(Ns dt) M->world().collect(true); update_cursor_tile(cursor.pixel); - tests_pre_update(); + tests_pre_update(dt); apply_commands(*keys_); update_character(dt); update_world(dt); do_camera(dt, *keys_, get_key_modifiers()); clear_non_repeated_keys(); set_cursor(); - tests_post_update(); + tests_post_update(dt); } } // namespace floormat |