diff options
-rw-r--r-- | editor/ground-editor.cpp | 4 | ||||
-rw-r--r-- | editor/ground-editor.hpp | 2 | ||||
-rw-r--r-- | editor/imgui-editors.cpp | 14 | ||||
-rw-r--r-- | editor/scenery-editor.hpp | 2 | ||||
-rw-r--r-- | editor/vobj-editor.cpp | 9 | ||||
-rw-r--r-- | editor/vobj-editor.hpp | 9 | ||||
-rw-r--r-- | editor/wall-editor.cpp | 2 | ||||
-rw-r--r-- | editor/wall-editor.hpp | 2 |
8 files changed, 23 insertions, 21 deletions
diff --git a/editor/ground-editor.cpp b/editor/ground-editor.cpp index 4ab697ee..55b779b5 100644 --- a/editor/ground-editor.cpp +++ b/editor/ground-editor.cpp @@ -35,7 +35,7 @@ void ground_editor::load_atlases() else loader.invalid_ground_atlas(); fm_assert(g.atlas); - _atlases[g.name] = &g; + _atlases[g.name] = g; } fm_assert(!_atlases.empty()); } @@ -43,7 +43,7 @@ void ground_editor::load_atlases() std::shared_ptr<ground_atlas> ground_editor::maybe_atlas(StringView str) { if (auto it = _atlases.find(str); it != _atlases.end()) - return it->second->atlas; + return it->second.atlas; else return nullptr; } diff --git a/editor/ground-editor.hpp b/editor/ground-editor.hpp index a7de3333..748da946 100644 --- a/editor/ground-editor.hpp +++ b/editor/ground-editor.hpp @@ -17,7 +17,7 @@ class ground_editor final enum selection_mode : unsigned char { sel_none, sel_tile, sel_perm, }; struct tuple; - std::map<StringView, const ground_cell*> _atlases; + std::map<String, ground_cell> _atlases; tile_image_proto _selected_tile; safe_ptr<tuple> _permutation; selection_mode _selection_mode = sel_none; diff --git a/editor/imgui-editors.cpp b/editor/imgui-editors.cpp index 3b884a19..0e821909 100644 --- a/editor/imgui-editors.cpp +++ b/editor/imgui-editors.cpp @@ -39,23 +39,23 @@ StringView scenery_type_to_string(const scenery_& sc) } } -StringView scenery_path(const wall_cell* wa) { return wa->atlas->name(); } +StringView scenery_path(const wall_cell& wa) { return wa.atlas->name(); } StringView scenery_name(StringView, const scenery_& sc) { return sc.name; } StringView scenery_name(StringView, const vobj_& vobj) { return vobj.descr; } -StringView scenery_name(StringView, const wall_cell* w) { return w->name; } +StringView scenery_name(StringView, const wall_cell& w) { return w.name; } std::shared_ptr<anim_atlas> get_atlas(const scenery_& sc) { return sc.proto.atlas; } std::shared_ptr<anim_atlas> get_atlas(const vobj_& vobj) { return vobj.factory->atlas(); } -std::shared_ptr<wall_atlas> get_atlas(const wall_cell* w) { return w->atlas; } +std::shared_ptr<wall_atlas> get_atlas(const wall_cell& w) { return w.atlas; } Vector2ui get_size(const auto&, anim_atlas& atlas) { return atlas.frame(atlas.first_rotation(), 0).size; } Vector2ui get_size(const auto&, wall_atlas& atlas) { auto sz = atlas.image_size(); return { std::max(1u, std::min(sz.y()*3/2, sz.x())), sz.y() }; } bool is_selected(const scenery_editor& ed, const scenery_& sc) { return ed.is_item_selected(sc); } bool is_selected(const vobj_editor& vo, const vobj_& sc) { return vo.is_item_selected(sc); } -bool is_selected(const wall_editor& wa, const wall_cell* sc) { return wa.is_atlas_selected(sc->atlas); } +bool is_selected(const wall_editor& wa, const wall_cell& sc) { return wa.is_atlas_selected(sc.atlas); } void select_tile(scenery_editor& ed, const scenery_& sc) { ed.select_tile(sc); } void select_tile(vobj_editor& vo, const vobj_& sc) { vo.select_tile(sc); } -void select_tile(wall_editor& wa, const wall_cell* sc) { wa.select_atlas(sc->atlas); } +void select_tile(wall_editor& wa, const wall_cell& sc) { wa.select_atlas(sc.atlas); } auto get_texcoords(const auto&, anim_atlas& atlas) { return atlas.texcoords_for_frame(atlas.first_rotation(), 0, !atlas.group(atlas.first_rotation()).mirror_from.isEmpty()); } -auto get_texcoords(const wall_cell* w, wall_atlas& atlas) { auto sz = get_size(w, atlas); return Quads::texcoords_at({}, sz, atlas.image_size()); } +auto get_texcoords(const wall_cell& w, wall_atlas& atlas) { auto sz = get_size(w, atlas); return Quads::texcoords_at({}, sz, atlas.image_size()); } void draw_editor_tile_pane_atlas(ground_editor& ed, StringView name, const std::shared_ptr<ground_atlas>& atlas, Vector2 dpi) { @@ -276,7 +276,7 @@ void app::draw_editor_pane(float main_menu_height) { if (ed) for (const auto& [k, v] : *ed) - draw_editor_tile_pane_atlas(*ed, k, v->atlas, dpi); + draw_editor_tile_pane_atlas(*ed, k, v.atlas, dpi); else if (sc) impl_draw_editor_scenery_pane<scenery_editor>(*sc, dpi); else if (vo) diff --git a/editor/scenery-editor.hpp b/editor/scenery-editor.hpp index 873124a8..4801d005 100644 --- a/editor/scenery-editor.hpp +++ b/editor/scenery-editor.hpp @@ -43,7 +43,7 @@ public: private: void load_atlases(); - std::map<StringView, scenery_> _atlases; + std::map<String, scenery_> _atlases; scenery_ _selected; }; diff --git a/editor/vobj-editor.cpp b/editor/vobj-editor.cpp index bfe88d71..0cfa64d6 100644 --- a/editor/vobj-editor.cpp +++ b/editor/vobj-editor.cpp @@ -22,7 +22,10 @@ void vobj_editor::clear_selection() { _selected = nullptr; } auto vobj_editor::get_selected() const -> const vobj_* { - return _selected; + if (_selected) + return _selected; + else + return {}; } auto vobj_editor::get_type(StringView name) -> const vobj_* @@ -91,13 +94,13 @@ std::shared_ptr<object> light_factory::make(world& w, object_id id, global_coord return ret; } -auto vobj_editor::make_vobj_type_map() -> std::map<StringView, vobj_> +auto vobj_editor::make_vobj_type_map() -> std::map<String, vobj_> { constexpr auto add = [](auto& m, std::unique_ptr<vobj_factory>&& x) { StringView name = x->name(), descr = x->descr(); m[name] = vobj_editor::vobj_{ name, descr, std::move(x) }; }; - std::map<StringView, vobj_editor::vobj_> map; + std::map<String, vobj_> map; add(map, std::make_unique<light_factory>()); return map; } diff --git a/editor/vobj-editor.hpp b/editor/vobj-editor.hpp index 7bcc32b6..0057504c 100644 --- a/editor/vobj-editor.hpp +++ b/editor/vobj-editor.hpp @@ -3,7 +3,7 @@ #include "src/object-id.hpp" #include <memory> #include <map> -#include <Corrade/Containers/StringView.h> +#include <cr/String.h> namespace floormat { @@ -31,10 +31,9 @@ class vobj_editor final { public: struct vobj_ final { - StringView name, descr; + String name, descr; std::unique_ptr<vobj_factory> factory; }; - vobj_editor(); void select_tile(const vobj_& type); @@ -53,9 +52,9 @@ public: auto end() const noexcept { return _types.cend(); } private: - static std::map<StringView, vobj_> make_vobj_type_map(); + static std::map<String, vobj_> make_vobj_type_map(); - std::map<StringView, vobj_> _types = make_vobj_type_map(); + std::map<String, vobj_> _types = make_vobj_type_map(); const vobj_* _selected = nullptr; }; diff --git a/editor/wall-editor.cpp b/editor/wall-editor.cpp index 1e50290b..73a5487a 100644 --- a/editor/wall-editor.cpp +++ b/editor/wall-editor.cpp @@ -57,7 +57,7 @@ void wall_editor::load_atlases() else loader.invalid_wall_atlas(); fm_assert(wa.atlas); - _atlases[wa.name] = &wa; + _atlases[wa.name] = wa; } fm_assert(!_atlases.empty()); diff --git a/editor/wall-editor.hpp b/editor/wall-editor.hpp index b58dd72a..48b6ebf3 100644 --- a/editor/wall-editor.hpp +++ b/editor/wall-editor.hpp @@ -13,7 +13,7 @@ class wall_atlas; class wall_editor { - std::map<StringView, const wall_cell*> _atlases; + std::map<String, wall_cell> _atlases; std::shared_ptr<wall_atlas> _selected_atlas; enum rotation _r = rotation::N; |