summaryrefslogtreecommitdiffhomepage
path: root/loader
diff options
context:
space:
mode:
Diffstat (limited to 'loader')
-rw-r--r--loader/atlas.cpp6
-rw-r--r--loader/impl.hpp6
-rw-r--r--loader/json.cpp2
-rw-r--r--loader/loader.cpp9
-rw-r--r--loader/loader.hpp8
-rw-r--r--loader/vobj.cpp2
-rw-r--r--loader/wall-atlas.cpp4
7 files changed, 21 insertions, 16 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index c7bfbdbf..eb368952 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -56,9 +56,9 @@ std::shared_ptr<ground_atlas> loader_impl::ground_atlas(StringView name, Vector2
fm_soft_assert(check_atlas_name(name));
char buf[FILENAME_MAX];
- auto path = make_atlas_path(buf, IMAGE_PATH, name);
+ auto path = make_atlas_path(buf, GROUND_TILESET_PATH, name);
- auto atlas = std::make_shared<class ground_atlas>(path, name, texture(""_s, path), size, pass);
+ auto atlas = std::make_shared<class ground_atlas>(path, name, texture(""_s, path, false), size, pass);
ground_atlas_map[atlas->name()] = atlas;
return atlas;
}
@@ -107,7 +107,7 @@ std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView
}
}
- auto tex = texture(""_s, path);
+ auto tex = texture(""_s, path, false);
fm_soft_assert(!anim_info.object_name.isEmpty());
fm_soft_assert(anim_info.pixel_size.product() > 0);
diff --git a/loader/impl.hpp b/loader/impl.hpp
index 165b7c2f..ad82e46d 100644
--- a/loader/impl.hpp
+++ b/loader/impl.hpp
@@ -42,7 +42,7 @@ struct loader_impl final : loader_
StringView shader(StringView filename) noexcept override;
Trade::ImageData2D make_error_texture(Vector2ui size);
- Trade::ImageData2D texture(StringView prefix, StringView filename, bool fail_ok = true) noexcept(false) override;
+ Trade::ImageData2D texture(StringView prefix, StringView filename) noexcept(false) override;
// >-----> walls >----->
struct wall_index { uint32_t val = (uint32_t)-1; };
@@ -55,7 +55,7 @@ struct loader_impl final : loader_
std::shared_ptr<class wall_atlas> wall_atlas(StringView name, bool fail_ok = true) override;
ArrayView<const wall_info> wall_atlas_list() override;
void get_wall_atlas_list();
- const wall_info& make_invalid_wall_atlas();
+ const wall_info& make_invalid_wall_atlas() noexcept override;
std::shared_ptr<class wall_atlas> get_wall_atlas(StringView name, StringView path);
// >-----> tile >----->
@@ -64,7 +64,7 @@ struct loader_impl final : loader_
ArrayView<const std::shared_ptr<class ground_atlas>> ground_atlases(StringView filename) noexcept(false) override;
std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) override;
- std::shared_ptr<class ground_atlas> ground_atlas(StringView filename) noexcept(false) override;
+ std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, bool fail_ok) noexcept(false) override;
// >-----> anim >----->
tsl::robin_map<StringView, std::shared_ptr<class anim_atlas>> anim_atlas_map;
diff --git a/loader/json.cpp b/loader/json.cpp
index 8e2f329f..ed15edbc 100644
--- a/loader/json.cpp
+++ b/loader/json.cpp
@@ -58,7 +58,7 @@ ArrayView<const std::shared_ptr<class ground_atlas>> loader_impl::ground_atlases
if (!ground_atlas_array.empty()) [[likely]]
return ground_atlas_array;
ground_atlas_array = json_helper::from_json<std::vector<std::shared_ptr<class ground_atlas>>>(
- Path::join(loader_::IMAGE_PATH, filename));
+ Path::join(loader_::GROUND_TILESET_PATH, filename));
fm_assert(!ground_atlas_array.empty());
return ground_atlas_array;
}
diff --git a/loader/loader.cpp b/loader/loader.cpp
index 71be9b16..80599c3d 100644
--- a/loader/loader.cpp
+++ b/loader/loader.cpp
@@ -24,24 +24,27 @@ loader_::~loader_() noexcept = default;
StringView loader_::strip_prefix(StringView name)
{
- if (name.hasPrefix(IMAGE_PATH))
- return name.exceptPrefix(IMAGE_PATH.size());
+ if (name.hasPrefix(IMAGE_PATH_))
+ return name.exceptPrefix(IMAGE_PATH_.size());
if (name.hasPrefix(ANIM_PATH))
return name.exceptPrefix(ANIM_PATH.size());
if (name.hasPrefix(SCENERY_PATH))
return name.exceptPrefix(SCENERY_PATH.size());
if (name.hasPrefix(VOBJ_PATH))
return name.exceptPrefix(VOBJ_PATH.size());
+ if (name.hasPrefix(GROUND_TILESET_PATH))
+ return name.exceptPrefix(GROUND_TILESET_PATH.size());
if (name.hasPrefix(WALL_TILESET_PATH))
return name.exceptPrefix(WALL_TILESET_PATH.size());
return name;
}
-const StringView loader_::IMAGE_PATH = "images/"_s;
+const StringView loader_::IMAGE_PATH_ = "images/"_s;
const StringView loader_::ANIM_PATH = "anim/"_s;
const StringView loader_::SCENERY_PATH = "scenery/"_s;
const StringView loader_::TEMP_PATH = "../../../"_s;
const StringView loader_::VOBJ_PATH = "vobj/"_s;
+const StringView loader_::GROUND_TILESET_PATH = "ground/"_s;
const StringView loader_::WALL_TILESET_PATH = "walls/"_s;
} // namespace floormat
diff --git a/loader/loader.hpp b/loader/loader.hpp
index 63b5ea5c..fc58e61a 100644
--- a/loader/loader.hpp
+++ b/loader/loader.hpp
@@ -23,11 +23,12 @@ struct wall_info;
struct loader_
{
virtual StringView shader(StringView filename) noexcept = 0;
- virtual Trade::ImageData2D texture(StringView prefix, StringView filename, bool fail_ok = true) noexcept(false) = 0;
+ virtual Trade::ImageData2D texture(StringView prefix, StringView filename) noexcept(false) = 0;
virtual std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) = 0;
- virtual std::shared_ptr<class ground_atlas> ground_atlas(StringView filename) noexcept(false) = 0;
+ virtual std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, bool fail_ok = false) noexcept(false) = 0;
virtual ArrayView<const String> anim_atlas_list() = 0;
virtual std::shared_ptr<class anim_atlas> anim_atlas(StringView name, StringView dir = ANIM_PATH) noexcept(false) = 0;
+ virtual const wall_info& make_invalid_wall_atlas() noexcept = 0;
virtual std::shared_ptr<class wall_atlas> wall_atlas(StringView name, bool fail_ok = true) noexcept(false) = 0;
virtual ArrayView<const wall_info> wall_atlas_list() = 0;
static void destroy();
@@ -47,11 +48,12 @@ struct loader_
virtual ~loader_() noexcept;
- static const StringView IMAGE_PATH;
+ static const StringView IMAGE_PATH_;
static const StringView ANIM_PATH;
static const StringView SCENERY_PATH;
static const StringView TEMP_PATH;
static const StringView VOBJ_PATH;
+ static const StringView GROUND_TILESET_PATH;
static const StringView WALL_TILESET_PATH;
protected:
diff --git a/loader/vobj.cpp b/loader/vobj.cpp
index 9aa6fb39..a309fd6a 100644
--- a/loader/vobj.cpp
+++ b/loader/vobj.cpp
@@ -46,7 +46,7 @@ namespace floormat::loader_detail {
std::shared_ptr<class anim_atlas> loader_impl::make_vobj_anim_atlas(StringView name, StringView image_filename)
{
- auto tex = texture(VOBJ_PATH, image_filename);
+ auto tex = texture(VOBJ_PATH, image_filename, false);
anim_def def;
def.object_name = name;
const auto size = tex.pixels().size();
diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp
index 66dc3ba5..7d423b26 100644
--- a/loader/wall-atlas.cpp
+++ b/loader/wall-atlas.cpp
@@ -46,7 +46,7 @@ std::shared_ptr<wall_atlas> loader_impl::get_wall_atlas(StringView name, StringV
char buf[FILENAME_MAX];
auto filename = make_atlas_path(buf, path, name);
auto def = wall_atlas_def::deserialize(""_s.join({filename, ".json"_s}));
- auto tex = texture(""_s, filename, false);
+ auto tex = texture(""_s, filename);
fm_soft_assert(name == def.header.name);
fm_soft_assert(!def.frames.empty());
@@ -54,7 +54,7 @@ std::shared_ptr<wall_atlas> loader_impl::get_wall_atlas(StringView name, StringV
return atlas;
}
-const wall_info& loader_impl::make_invalid_wall_atlas()
+const wall_info& loader_impl::make_invalid_wall_atlas() noexcept
{
if (invalid_wall_atlas) [[likely]]
return *invalid_wall_atlas;