summaryrefslogtreecommitdiffhomepage
path: root/loader
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-01-11 17:13:06 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-01-11 17:13:06 +0100
commit98416d95331c63affabf331afba0e1dcb307c430 (patch)
tree35402e1b6319aad0d5d928a75395da9162496a7d /loader
parentba90ba2ca91c448d80722985811fc6bddc6e9bf2 (diff)
w
Diffstat (limited to 'loader')
-rw-r--r--loader/ground-atlas.cpp33
-rw-r--r--loader/ground-info.hpp2
-rw-r--r--loader/loader.cpp1
-rw-r--r--loader/loader.hpp1
-rw-r--r--loader/wall-atlas.cpp7
-rw-r--r--loader/wall-info.hpp2
6 files changed, 25 insertions, 21 deletions
diff --git a/loader/ground-atlas.cpp b/loader/ground-atlas.cpp
index d93313ea..c4e4a516 100644
--- a/loader/ground-atlas.cpp
+++ b/loader/ground-atlas.cpp
@@ -4,24 +4,15 @@
#include "compat/exception.hpp"
#include "serialize/json-helper.hpp"
#include "serialize/corrade-string.hpp"
+#include "serialize/ground-atlas.hpp"
+#include "src/tile-defs.hpp"
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Utility/Path.h>
#include <Magnum/Trade/ImageData.h>
#include <Magnum/ImageView.h>
namespace floormat {
-
-using nlohmann::json;
using loader_detail::loader_impl;
-
-[[maybe_unused]] static void from_json(const json& j, ground_info& val)
-{
-}
-
-[[maybe_unused]] static void to_json(json& j, const ground_info& val)
-{
-}
-
} // namespace floormat
namespace floormat::loader_detail {
@@ -103,10 +94,28 @@ void loader_impl::get_ground_atlas_list()
for (auto& x : ground_atlas_array)
{
-
+ fm_soft_assert(x.name != "<invalid>"_s);
+ fm_soft_assert(check_atlas_name(x.name));
+ StringView name = x.name;
+ ground_atlas_map[name] = &x;
+ fm_debug_assert(name.data() == ground_atlas_map[name]->name.data());
}
fm_assert(!ground_atlas_map.empty());
}
+const ground_info& loader_impl::make_invalid_ground_atlas()
+{
+ if (invalid_ground_atlas) [[likely]]
+ return *invalid_ground_atlas;
+
+ auto atlas = std::make_shared<class ground_atlas>(
+ ""_s, loader.INVALID, make_error_texture(Vector2ui(iTILE_SIZE2)),
+ Vector2ub{1,1}, pass_mode::pass);
+ invalid_ground_atlas = Pointer<ground_info>{
+ InPlaceInit, atlas->name(),
+ atlas, atlas->num_tiles2(), atlas->pass_mode()};
+ return *invalid_ground_atlas;
+}
+
} // namespace floormat::loader_detail
diff --git a/loader/ground-info.hpp b/loader/ground-info.hpp
index 3b96428e..44c4c638 100644
--- a/loader/ground-info.hpp
+++ b/loader/ground-info.hpp
@@ -10,7 +10,7 @@ class ground_atlas;
struct ground_info
{
- String name; // todo add descr?
+ String name;
std::shared_ptr<ground_atlas> atlas;
Vector2ub size;
pass_mode pass;
diff --git a/loader/loader.cpp b/loader/loader.cpp
index 80599c3d..df712f39 100644
--- a/loader/loader.cpp
+++ b/loader/loader.cpp
@@ -39,6 +39,7 @@ StringView loader_::strip_prefix(StringView name)
return name;
}
+const StringView loader_::INVALID = "<invalid>"_s; // todo use it
const StringView loader_::IMAGE_PATH_ = "images/"_s;
const StringView loader_::ANIM_PATH = "anim/"_s;
const StringView loader_::SCENERY_PATH = "scenery/"_s;
diff --git a/loader/loader.hpp b/loader/loader.hpp
index 499a1f30..b62988ca 100644
--- a/loader/loader.hpp
+++ b/loader/loader.hpp
@@ -48,6 +48,7 @@ struct loader_
virtual ~loader_() noexcept;
+ static const StringView INVALID;
static const StringView IMAGE_PATH_;
static const StringView ANIM_PATH;
static const StringView SCENERY_PATH;
diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp
index 69666e8c..ce136fdb 100644
--- a/loader/wall-atlas.cpp
+++ b/loader/wall-atlas.cpp
@@ -23,17 +23,11 @@ using loader_detail::loader_impl;
val = {};
val.name = j["name"];
fm_soft_assert(loader.check_atlas_name(val.name));
- if (j.contains("descr"))
- val.descr = j["descr"];
- else
- val.descr = Path::split(val.name).second();
}
[[maybe_unused]] static void to_json(json& j, const wall_info& val)
{
j["name"] = val.name;
- if (val.descr)
- j["descr"] = val.descr;
}
} // namespace floormat
@@ -132,7 +126,6 @@ void loader_impl::get_wall_atlas_list()
{
fm_soft_assert(x.name != "<invalid>"_s);
fm_soft_assert(check_atlas_name(x.name));
- //x.atlas = get_wall_atlas(x.name, WALL_TILESET_PATH);
StringView name = x.name;
wall_atlas_map[name] = &x;
fm_debug_assert(name.data() == wall_atlas_map[name]->name.data());
diff --git a/loader/wall-info.hpp b/loader/wall-info.hpp
index acd5cdc4..9b586a10 100644
--- a/loader/wall-info.hpp
+++ b/loader/wall-info.hpp
@@ -8,7 +8,7 @@ class wall_atlas;
struct wall_info
{
- String name, descr{};
+ String name;
std::shared_ptr<wall_atlas> atlas;
};