diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-12 04:05:21 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-12 04:05:21 +0100 |
commit | 802c17175e595ddb3075465a1febc432262bcc3f (patch) | |
tree | 99d5ecabc8d2d62a09ab32976edfb9946ce81fcf | |
parent | f44e9d51013dbd153df3abc0c7b0ff1485ab65f2 (diff) |
use Corrade's Optional<T> instead of stl
-rw-r--r-- | editor/app.hpp | 10 | ||||
-rw-r--r-- | editor/camera.cpp | 4 | ||||
-rw-r--r-- | editor/editor.cpp | 6 | ||||
-rw-r--r-- | editor/editor.hpp | 4 | ||||
-rw-r--r-- | editor/events.cpp | 4 | ||||
-rw-r--r-- | loader/loader-impl.cpp | 5 | ||||
-rw-r--r-- | src/precomp.hpp | 1 |
7 files changed, 16 insertions, 18 deletions
diff --git a/editor/app.hpp b/editor/app.hpp index 63fcd6ae..b1e8f75c 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -11,10 +11,10 @@ #include "keys.hpp" #include <memory> -#include <optional> -#include <Magnum/ImGuiIntegration/Context.h> #include <Corrade/Containers/Pointer.h> +#include <Corrade/Containers/Optional.h> +#include <Magnum/ImGuiIntegration/Context.h> namespace floormat { @@ -26,8 +26,8 @@ struct fm_settings; struct anim_atlas; struct cursor_state final { - std::optional<Vector2i> pixel; - std::optional<global_coords> tile; + Optional<Vector2i> pixel; + Optional<global_coords> tile; bool in_imgui = false; }; @@ -47,7 +47,7 @@ private: int exec(); void update(float dt) override; - void update_cursor_tile(const std::optional<Vector2i>& pixel); + void update_cursor_tile(const Optional<Vector2i>& pixel); void maybe_initialize_chunk(const chunk_coords& pos, chunk& c) override; void maybe_initialize_chunk_(const chunk_coords& pos, chunk& c); diff --git a/editor/camera.cpp b/editor/camera.cpp index bb69c626..35d24ef4 100644 --- a/editor/camera.cpp +++ b/editor/camera.cpp @@ -56,13 +56,13 @@ void app::reset_camera_offset() update_cursor_tile(cursor.pixel); } -void app::update_cursor_tile(const std::optional<Vector2i>& pixel) +void app::update_cursor_tile(const Optional<Vector2i>& pixel) { cursor.pixel = pixel; if (pixel) cursor.tile = M->pixel_to_tile(Vector2d{*pixel}); else - cursor.tile = std::nullopt; + cursor.tile = NullOpt; } } // namespace floormat diff --git a/editor/editor.cpp b/editor/editor.cpp index 67d9f344..e2690101 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -18,7 +18,7 @@ tile_editor* editor::current_tile_editor() noexcept void editor::on_release() { - _last_pos = std::nullopt; + _last_pos = NullOpt; } auto editor::get_snap_value(snap_mode snap, int mods) const -> snap_mode @@ -72,7 +72,7 @@ void editor::on_mouse_move(world& world, global_coords& pos, int mods) } else on_click_(world, draw_coord, last.btn); - _last_pos = { pos, draw_coord, snap, last.btn }; + _last_pos = { InPlaceInit, pos, draw_coord, snap, last.btn }; } pos = draw_coord; } @@ -97,7 +97,7 @@ void editor::on_click(world& world, global_coords pos, int mods, button b) { if (auto* mode = current_tile_editor(); mode != nullptr) { - _last_pos = { pos, pos, mode->check_snap(mods), b }; + _last_pos = { InPlaceInit, pos, pos, mode->check_snap(mods), b }; on_click_(world, pos, b); } } diff --git a/editor/editor.hpp b/editor/editor.hpp index 1c9d9bec..4f667e96 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -8,9 +8,9 @@ #include "tile-editor.hpp" #include "scenery-editor.hpp" -#include <optional> #include <map> #include <memory> +#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/StringView.h> namespace floormat { @@ -58,7 +58,7 @@ private: snap_mode snap = snap_mode::none; button btn; }; - std::optional<drag_pos> _last_pos; + Optional<drag_pos> _last_pos; editor_mode _mode = editor_mode::floor; bool _dirty = false; }; diff --git a/editor/events.cpp b/editor/events.cpp index 821c9c4d..fc55cca2 100644 --- a/editor/events.cpp +++ b/editor/events.cpp @@ -175,13 +175,13 @@ void app::on_viewport_event(const Math::Vector2<int>& size) noexcept void app::on_focus_out() noexcept { - update_cursor_tile(std::nullopt); + update_cursor_tile(NullOpt); clear_keys(); } void app::on_mouse_leave() noexcept { - update_cursor_tile(std::nullopt); + update_cursor_tile(NullOpt); } void app::do_key(floormat::key k) diff --git a/loader/loader-impl.cpp b/loader/loader-impl.cpp index 5d97d91c..955ccf03 100644 --- a/loader/loader-impl.cpp +++ b/loader/loader-impl.cpp @@ -9,7 +9,6 @@ #include <unordered_map> #include <utility> #include <memory> -#include <optional> #include <Corrade/Containers/ArrayViewStl.h> #include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Pair.h> @@ -31,7 +30,7 @@ namespace floormat { struct loader_impl final : loader_ { - std::optional<Utility::Resource> shader_res; + Optional<Utility::Resource> shader_res; PluginManager::Manager<Trade::AbstractImporter> importer_plugins; Containers::Pointer<Trade::AbstractImporter> image_importer = importer_plugins.loadAndInstantiate("StbImageImporter"); @@ -60,7 +59,7 @@ struct loader_impl final : loader_ StringView loader_impl::shader(StringView filename) { if (!shader_res) - shader_res = std::make_optional<Utility::Resource>("floormat/shaders"); + shader_res = Optional<Utility::Resource>(InPlaceInit, "floormat/shaders"); auto ret = shader_res->getString(filename); if (ret.isEmpty()) fm_abort("can't find shader resource '%s'", filename.cbegin()); diff --git a/src/precomp.hpp b/src/precomp.hpp index 5ec264a4..f451b4d3 100644 --- a/src/precomp.hpp +++ b/src/precomp.hpp @@ -26,7 +26,6 @@ #include <tuple> #include <array> -#include <optional> #include <vector> #include <unordered_map> |