diff options
Diffstat (limited to 'editor/vobj-editor.hpp')
-rw-r--r-- | editor/vobj-editor.hpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/editor/vobj-editor.hpp b/editor/vobj-editor.hpp new file mode 100644 index 00000000..3ebf7bd8 --- /dev/null +++ b/editor/vobj-editor.hpp @@ -0,0 +1,65 @@ +#pragma once +#include "src/entity-type.hpp" +#include <memory> +//#include <Corrade/Containers/ArrayView.h> + +namespace Corrade::Containers { +template<typename T> class BasicStringView; +using StringView = BasicStringView<const char>; +template<typename T> class ArrayView; +} // namespace Corrade::Containers + +namespace floormat { + +struct world; +struct global_coords; +struct entity; +struct anim_atlas; +struct vobj_info; + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +struct vobj_factory +{ + constexpr vobj_factory() = default; + virtual constexpr ~vobj_factory() noexcept = default; + virtual const vobj_info& info() const = 0; + virtual entity_type type() const = 0; + virtual std::shared_ptr<entity> make(world& w, object_id id, global_coords pos) const = 0; + + StringView name() const; + StringView descr() const; + std::shared_ptr<anim_atlas> atlas() const; +}; + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +struct vobj_editor final +{ + vobj_editor(); + + void select_type(entity_type type); + void clear_selection(); + + [[nodiscard]] static const vobj_factory* get_factory(entity_type type); + bool is_type_selected(entity_type type) const; + bool is_anything_selected() const; + + static void place_tile(world& w, global_coords pos, const vobj_factory& factory); + + static auto cbegin() noexcept { return _types.cbegin(); } + static auto cend() noexcept { return _types.cend(); } + static auto begin() noexcept { return _types.cbegin(); } + static auto end() noexcept { return _types.cend(); } + +private: + static const ArrayView<const vobj_factory* const> _types; + const vobj_factory* _selected = nullptr; +}; + +} // namespace floormat |