diff options
Diffstat (limited to 'main/editor.cpp')
| -rw-r--r-- | main/editor.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/main/editor.cpp b/main/editor.cpp index 4b291ea6..a83100c2 100644 --- a/main/editor.cpp +++ b/main/editor.cpp @@ -2,6 +2,7 @@ #include "serialize/json-helper.hpp" #include "serialize/tile-atlas.hpp" #include "src/loader.hpp" +#include "compat/assert.hpp" #include <filesystem> #include <vector> @@ -25,6 +26,22 @@ void tile_type::load_atlases() _atlases[name] = std::move(atlas); } } +std::shared_ptr<tile_atlas> tile_type::maybe_atlas(Containers::StringView str) +{ + auto it = _atlases.find(str); + if (it == _atlases.end()) + return nullptr; + else + return it->second; +} + +std::shared_ptr<tile_atlas> tile_type::atlas(Containers::StringView str) +{ + if (auto ptr = maybe_atlas(str); ptr) + return ptr; + else + ABORT("no such atlas: %s", str.cbegin()); +} editor_state::editor_state() { |
