summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/tile-editor.cpp4
-rw-r--r--editor/tile-editor.hpp2
-rw-r--r--editor/wall-editor.cpp6
-rw-r--r--editor/wall-editor.hpp16
-rw-r--r--loader/atlas.cpp1
-rw-r--r--loader/json.cpp5
-rw-r--r--loader/loader.hpp2
-rw-r--r--loader/vobj.cpp1
-rw-r--r--loader/wall-atlas.cpp7
-rw-r--r--src/tile-atlas.cpp13
-rw-r--r--src/tile-atlas.hpp9
11 files changed, 38 insertions, 28 deletions
diff --git a/editor/tile-editor.cpp b/editor/tile-editor.cpp
index e8e4eb7a..6bca50f3 100644
--- a/editor/tile-editor.cpp
+++ b/editor/tile-editor.cpp
@@ -10,7 +10,7 @@
namespace floormat {
-tile_editor::tile_editor(StringView name) : _name{name}
+tile_editor::tile_editor()
{
load_atlases();
}
@@ -50,7 +50,7 @@ std::shared_ptr<tile_atlas> tile_editor::atlas(StringView str)
fm_throw("no such atlas: {}"_cf, str);
}
-StringView tile_editor::name() const noexcept { return _name; }
+StringView tile_editor::name() const noexcept { return "floor"_s; }
void tile_editor::clear_selection()
{
diff --git a/editor/tile-editor.hpp b/editor/tile-editor.hpp
index c0ff27f0..57347bf0 100644
--- a/editor/tile-editor.hpp
+++ b/editor/tile-editor.hpp
@@ -33,7 +33,7 @@ class tile_editor final
tile_image_proto get_selected_perm();
public:
- tile_editor(StringView name);
+ tile_editor();
std::shared_ptr<tile_atlas> maybe_atlas(StringView str);
std::shared_ptr<tile_atlas> atlas(StringView str);
auto cbegin() const noexcept { return _atlases.cbegin(); }
diff --git a/editor/wall-editor.cpp b/editor/wall-editor.cpp
index e6463d78..a216c8a6 100644
--- a/editor/wall-editor.cpp
+++ b/editor/wall-editor.cpp
@@ -1 +1,7 @@
#include "wall-editor.hpp"
+
+namespace floormat {
+
+
+
+} // namespace floormat
diff --git a/editor/wall-editor.hpp b/editor/wall-editor.hpp
index 87cfa8f7..815b91c6 100644
--- a/editor/wall-editor.hpp
+++ b/editor/wall-editor.hpp
@@ -1,10 +1,13 @@
#pragma once
+#include "editor-enums.hpp"
#include "src/rotation.hpp"
+#include "src/global-coords.hpp"
#include <memory>
#include <map>
namespace floormat {
+struct world;
class wall_atlas;
class wall_editor
@@ -13,13 +16,24 @@ class wall_editor
std::shared_ptr<wall_atlas> _selected_atlas;
rotation _r = rotation::N;
-public:
+ void load_atlases();
+public:
wall_editor();
+ StringView name() const;
enum rotation rotation() const { return _r; }
void set_rotation(enum rotation r);
void toggle_rotation();
+
+ std::shared_ptr<wall_atlas> get_selected() const { return _selected_atlas; }
+ void select_atlas(const std::shared_ptr<wall_atlas>& atlas);
+ void clear_selection();
+ bool is_atlas_selected(const std::shared_ptr<wall_atlas>& atlas) const;
+ bool is_anything_selected() const;
+
+ void place_tile(world& w, global_coords coords, const std::shared_ptr<wall_atlas>& atlas);
+ editor_snap_mode check_snap(int mods) const;
};
} // namespace floormat
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index e811e61e..de1d8e15 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -74,6 +74,7 @@ ArrayView<const String> loader_impl::anim_atlas_list()
{
if (anim_atlases.empty())
get_anim_atlas_list();
+ fm_assert(!anim_atlases.empty());
return anim_atlases;
}
diff --git a/loader/json.cpp b/loader/json.cpp
index 007bafeb..e9da0339 100644
--- a/loader/json.cpp
+++ b/loader/json.cpp
@@ -54,13 +54,10 @@ const scenery_proto& loader_impl::scenery(StringView name) noexcept(false)
namespace floormat {
-std::vector<std::shared_ptr<class tile_atlas>> loader_::tile_atlases(StringView filename, pass_mode p)
+std::vector<std::shared_ptr<class tile_atlas>> loader_::tile_atlases(StringView filename)
{
auto vec = json_helper::from_json<std::vector<std::shared_ptr<class tile_atlas>>>(
Path::join(loader_::IMAGE_PATH, filename));
- for (auto& x : vec)
- if (!x->pass_mode())
- x->set_pass_mode(p);
return vec;
}
diff --git a/loader/loader.hpp b/loader/loader.hpp
index a7dd8a7f..e7824aa5 100644
--- a/loader/loader.hpp
+++ b/loader/loader.hpp
@@ -38,7 +38,7 @@ struct loader_
static void destroy();
static loader_& default_loader() noexcept;
// todo move to ArrayView later, make non-static, and remove pass_mode
- static std::vector<std::shared_ptr<class tile_atlas>> tile_atlases(StringView filename, pass_mode p);
+ static std::vector<std::shared_ptr<class tile_atlas>> tile_atlases(StringView filename);
virtual const std::vector<serialized_scenery>& sceneries() = 0;
virtual const scenery_proto& scenery(StringView name) noexcept(false) = 0;
virtual StringView startup_directory() noexcept = 0;
diff --git a/loader/vobj.cpp b/loader/vobj.cpp
index b48275ab..9aa6fb39 100644
--- a/loader/vobj.cpp
+++ b/loader/vobj.cpp
@@ -91,6 +91,7 @@ ArrayView<const vobj_info> loader_impl::vobj_list()
{
if (vobjs.empty())
get_vobj_list();
+ fm_assert(!vobjs.empty());
return vobjs;
}
diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp
index 745c5eb8..9d5c8c2b 100644
--- a/loader/wall-atlas.cpp
+++ b/loader/wall-atlas.cpp
@@ -25,15 +25,15 @@ using nlohmann::json;
val = {};
val.name = j["name"];
fm_soft_assert(loader.check_atlas_name(val.name));
- if (j.contains("description"))
- val.descr = j["description"];
+ if (j.contains("descr"))
+ val.descr = j["descr"];
}
[[maybe_unused]] static void to_json(json& j, const wall_info& val)
{
j["name"] = val.name;
if (val.descr)
- j["description"] = val.descr;
+ j["descr"] = val.descr;
}
} // namespace floormat
@@ -112,6 +112,7 @@ ArrayView<const wall_info> loader_impl::wall_atlas_list()
{
if (wall_atlas_map.empty())
get_wall_atlas_list();
+ fm_assert(!wall_atlas_map.empty());
return wall_atlas_array;
}
diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp
index 1596247f..53156a84 100644
--- a/src/tile-atlas.cpp
+++ b/src/tile-atlas.cpp
@@ -12,9 +12,9 @@ namespace floormat {
using namespace floormat::Quads;
-tile_atlas::tile_atlas(StringView path, StringView name, const ImageView2D& image, Vector2ub tile_count, Optional<enum pass_mode> p) :
+tile_atlas::tile_atlas(StringView path, StringView name, const ImageView2D& image, Vector2ub tile_count, enum pass_mode p) :
texcoords_{make_texcoords_array(Vector2ui(image.size()), tile_count)},
- path_{path}, name_{name}, size_{image.size()}, dims_{tile_count}, passability{std::move(p)}
+ path_{path}, name_{name}, size_{image.size()}, dims_{tile_count}, passability{p}
{
constexpr auto variant_max = std::numeric_limits<variant_t>::max();
fm_soft_assert(num_tiles() <= variant_max);
@@ -54,13 +54,6 @@ auto tile_atlas::make_texcoords_array(Vector2ui pixel_size, Vector2ub tile_count
}
size_t tile_atlas::num_tiles() const { return Vector2ui{dims_}.product(); }
-Optional<enum pass_mode> tile_atlas::pass_mode() const { return passability; }
-enum pass_mode tile_atlas::pass_mode(enum pass_mode p) const { return passability ? *passability : p; }
-
-void tile_atlas::set_pass_mode(enum pass_mode p)
-{
- fm_assert(!passability || passability == p);
- passability = { InPlaceInit, p };
-}
+enum pass_mode tile_atlas::pass_mode() const { return passability; }
} // namespace floormat
diff --git a/src/tile-atlas.hpp b/src/tile-atlas.hpp
index 1a06db4a..347da166 100644
--- a/src/tile-atlas.hpp
+++ b/src/tile-atlas.hpp
@@ -24,11 +24,10 @@ class tile_atlas final
String path_, name_;
Vector2ui size_;
Vector2ub dims_;
- Optional<enum pass_mode> passability;
+ enum pass_mode passability;
public:
- // todo remove Optional when wall atlases are fully implemented -sh 20231122
- tile_atlas(StringView path, StringView name, const ImageView2D& img, Vector2ub tile_count, Optional<enum pass_mode> pass_mode);
+ tile_atlas(StringView path, StringView name, const ImageView2D& img, Vector2ub tile_count, enum pass_mode pass_mode);
texcoords texcoords_for_id(size_t id) const;
@@ -37,9 +36,7 @@ public:
Vector2ub num_tiles2() const { return dims_; }
GL::Texture2D& texture() { return tex_; }
StringView name() const { return name_; }
- Optional<enum pass_mode> pass_mode() const; // todo remove later
- enum pass_mode pass_mode(enum pass_mode p) const;
- void set_pass_mode(enum pass_mode p); // todo remove later
+ enum pass_mode pass_mode() const;
};