summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--draw/wireframe-mesh.cpp4
-rw-r--r--draw/wireframe-mesh.hpp8
-rw-r--r--draw/wireframe-quad.hpp2
-rw-r--r--editor/editor.cpp10
-rw-r--r--editor/editor.hpp8
-rw-r--r--loader/loader-impl.cpp20
-rw-r--r--main/floormat-events.cpp4
-rw-r--r--src/loader.hpp2
-rw-r--r--src/tile-atlas.cpp2
-rw-r--r--src/tile-atlas.hpp8
10 files changed, 34 insertions, 34 deletions
diff --git a/draw/wireframe-mesh.cpp b/draw/wireframe-mesh.cpp
index 1304f141..55af19a1 100644
--- a/draw/wireframe-mesh.cpp
+++ b/draw/wireframe-mesh.cpp
@@ -27,7 +27,7 @@ GL::Texture2D mesh_base::make_constant_texture()
return tex;
}
-mesh_base::mesh_base(GL::MeshPrimitive primitive, Containers::ArrayView<const void> index_data,
+mesh_base::mesh_base(GL::MeshPrimitive primitive, ArrayView<const void> index_data,
std::size_t num_vertices, std::size_t num_indexes) :
_vertex_buffer{Containers::Array<Vector3>{ValueInit, num_vertices}, GL::BufferUsage::DynamicDraw},
_texcoords_buffer{Containers::Array<Vector2>{ValueInit, num_vertices}},
@@ -47,7 +47,7 @@ void mesh_base::draw(tile_shader& shader)
shader.draw(_mesh);
}
-void mesh_base::set_subdata(Containers::ArrayView<const void> array)
+void mesh_base::set_subdata(ArrayView<const void> array)
{
_vertex_buffer.setSubData(0, array);
}
diff --git a/draw/wireframe-mesh.hpp b/draw/wireframe-mesh.hpp
index f03659d3..9d736419 100644
--- a/draw/wireframe-mesh.hpp
+++ b/draw/wireframe-mesh.hpp
@@ -17,8 +17,8 @@ concept traits = requires (const T& x) {
{T::num_vertices} -> std::convertible_to<std::size_t>;
{T::num_indexes} -> std::convertible_to<std::size_t>;
{x.primitive} -> std::convertible_to<GL::MeshPrimitive>;
- {x.make_vertex_array() } -> std::convertible_to<Containers::ArrayView<const void>>;
- {T::make_index_array() } -> std::convertible_to<Containers::ArrayView<const void>>;
+ {x.make_vertex_array() } -> std::convertible_to<ArrayView<const void>>;
+ {T::make_index_array() } -> std::convertible_to<ArrayView<const void>>;
{x.on_draw()} -> std::same_as<void>;
};
@@ -29,10 +29,10 @@ struct mesh_base
GL::Texture2D _texture = make_constant_texture();
GL::Mesh _mesh;
- mesh_base(GL::MeshPrimitive primitive, Containers::ArrayView<const void> index_data,
+ mesh_base(GL::MeshPrimitive primitive, ArrayView<const void> index_data,
std::size_t num_vertices, std::size_t num_indexes);
void draw(tile_shader& shader);
- void set_subdata(Containers::ArrayView<const void> array);
+ void set_subdata(ArrayView<const void> array);
};
} // namespace wireframe
diff --git a/draw/wireframe-quad.hpp b/draw/wireframe-quad.hpp
index ccefa000..050eeb78 100644
--- a/draw/wireframe-quad.hpp
+++ b/draw/wireframe-quad.hpp
@@ -17,7 +17,7 @@ struct quad final
using vertex_array = std::array<Vector3, num_vertices>;
- static Containers::ArrayView<const void> make_index_array() { return {}; }
+ static ArrayView<const void> make_index_array() { return {}; }
vertex_array make_vertex_array() const;
void on_draw() const;
diff --git a/editor/editor.cpp b/editor/editor.cpp
index b353aa4d..bea41116 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -15,7 +15,7 @@ namespace floormat {
static const std::filesystem::path image_path{IMAGE_PATH, std::filesystem::path::generic_format};
-tile_editor::tile_editor(editor_mode mode, Containers::StringView name) : _name{ name}, _mode{ mode}
+tile_editor::tile_editor(editor_mode mode, StringView name) : _name{ name}, _mode{ mode}
{
load_atlases();
}
@@ -25,7 +25,7 @@ void tile_editor::load_atlases()
using atlas_array = std::vector<std::shared_ptr<tile_atlas>>;
for (auto& atlas : json_helper::from_json<atlas_array>(image_path/(_name + ".json")))
{
- Containers::StringView name = atlas->name();
+ StringView name = atlas->name();
if (auto x = name.findLast('.'); x)
name = name.prefix(x.data());
auto& [_, vec] = _permutation;
@@ -34,11 +34,11 @@ void tile_editor::load_atlases()
}
}
-std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(Containers::StringView str)
+std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(StringView str)
{
auto it = std::find_if(_atlases.begin(), _atlases.end(), [&](const auto& tuple) -> bool {
const auto& [x, _] = tuple;
- return Containers::StringView{x} == str;
+ return StringView{x} == str;
});
if (it == _atlases.end())
return nullptr;
@@ -46,7 +46,7 @@ std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(Containers::StringView str)
return it->second;
}
-std::shared_ptr<tile_atlas> tile_editor::atlas(Containers::StringView str)
+std::shared_ptr<tile_atlas> tile_editor::atlas(StringView str)
{
if (auto ptr = maybe_atlas(str); ptr)
return ptr;
diff --git a/editor/editor.hpp b/editor/editor.hpp
index d952b9ba..e7f81305 100644
--- a/editor/editor.hpp
+++ b/editor/editor.hpp
@@ -22,14 +22,14 @@ struct world;
struct tile_editor final
{
- tile_editor(editor_mode mode, Containers::StringView name);
- std::shared_ptr<tile_atlas> maybe_atlas(Containers::StringView str);
- std::shared_ptr<tile_atlas> atlas(Containers::StringView str);
+ tile_editor(editor_mode mode, StringView name);
+ std::shared_ptr<tile_atlas> maybe_atlas(StringView str);
+ std::shared_ptr<tile_atlas> atlas(StringView str);
auto cbegin() const { return _atlases.cbegin(); }
auto cend() const { return _atlases.cend(); }
auto begin() const { return _atlases.cbegin(); }
auto end() const { return _atlases.cend(); }
- Containers::StringView name() const { return _name; }
+ StringView name() const { return _name; }
editor_mode mode() const { return _mode; }
void clear_selection();
diff --git a/loader/loader-impl.cpp b/loader/loader-impl.cpp
index def67c1b..7c3e760c 100644
--- a/loader/loader-impl.cpp
+++ b/loader/loader-impl.cpp
@@ -6,8 +6,6 @@
#include <unordered_map>
#include <utility>
#include <optional>
-#include <Corrade/Containers/Optional.h>
-#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StringStlView.h>
#include <Corrade/PluginManager/PluginManager.h>
#include <Corrade/Utility/Resource.h>
@@ -21,6 +19,8 @@
#pragma GCC diagnostic ignored "-Walloca"
#endif
+using StringView = Corrade::Containers::StringView;
+
namespace floormat {
struct loader_impl final : loader_
@@ -36,9 +36,9 @@ struct loader_impl final : loader_
std::unordered_map<std::string, std::shared_ptr<struct tile_atlas>> atlas_map;
- std::string shader(Containers::StringView filename) override;
- Trade::ImageData2D tile_texture(Containers::StringView filename) override;
- std::shared_ptr<struct tile_atlas> tile_atlas(Containers::StringView filename, Vector2ub size) override;
+ StringView shader(StringView filename) override;
+ Trade::ImageData2D tile_texture(StringView filename) override;
+ std::shared_ptr<struct tile_atlas> tile_atlas(StringView filename, Vector2ub size) override;
static void set_application_working_directory();
@@ -46,7 +46,7 @@ struct loader_impl final : loader_
~loader_impl() override;
};
-std::string loader_impl::shader(Containers::StringView filename)
+StringView loader_impl::shader(StringView filename)
{
if (!shader_res)
shader_res = std::make_optional<Utility::Resource>("floormat/shaders");
@@ -56,11 +56,11 @@ std::string loader_impl::shader(Containers::StringView filename)
return ret;
}
-std::shared_ptr<tile_atlas> loader_impl::tile_atlas(Containers::StringView name, Vector2ub size)
+std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub size)
{
auto it = std::find_if(atlas_map.begin(), atlas_map.end(), [&](const auto& x) {
const auto& [k, v] = x;
- return Containers::StringView{k} == name;
+ return StringView{k} == name;
});
if (it != atlas_map.end())
return it->second;
@@ -70,7 +70,7 @@ std::shared_ptr<tile_atlas> loader_impl::tile_atlas(Containers::StringView name,
return atlas;
}
-Trade::ImageData2D loader_impl::tile_texture(Containers::StringView filename_)
+Trade::ImageData2D loader_impl::tile_texture(StringView filename_)
{
static_assert(IMAGE_PATH[sizeof(IMAGE_PATH)-2] == '/');
fm_assert(filename_.size() < 4096);
@@ -86,7 +86,7 @@ Trade::ImageData2D loader_impl::tile_texture(Containers::StringView filename_)
return off + filename_.size();
);
- for (const auto& extension : std::initializer_list<Containers::StringView>{ ".tga", ".png", ".webp", })
+ for (const auto& extension : std::initializer_list<StringView>{ ".tga", ".png", ".webp", })
{
std::memcpy(filename + len, extension.data(), extension.size());
filename[len + extension.size()] = '\0';
diff --git a/main/floormat-events.cpp b/main/floormat-events.cpp
index 3200728a..adc1c575 100644
--- a/main/floormat-events.cpp
+++ b/main/floormat-events.cpp
@@ -18,7 +18,7 @@ void main_impl::mousePressEvent(Platform::Sdl2Application::MouseEvent& event)
{
app.on_mouse_up_down({event.position(),
(SDL_Keymod)(std::uint16_t)event.modifiers(),
- mouse_button(event.button()),
+ mouse_button(SDL_BUTTON((std::uint8_t)event.button())),
std::uint8_t(std::min(255, event.clickCount()))},
true);
}
@@ -27,7 +27,7 @@ void main_impl::mouseReleaseEvent(Platform::Sdl2Application::MouseEvent& event)
{
app.on_mouse_up_down({event.position(),
(SDL_Keymod)(std::uint16_t)event.modifiers(),
- mouse_button(event.button()),
+ mouse_button(SDL_BUTTON((std::uint8_t)event.button())),
std::uint8_t(std::min(255, event.clickCount()))},
false);
}
diff --git a/src/loader.hpp b/src/loader.hpp
index f8e0e049..a521cf2d 100644
--- a/src/loader.hpp
+++ b/src/loader.hpp
@@ -15,7 +15,7 @@ struct tile_atlas;
struct loader_
{
- virtual std::string shader(Containers::StringView filename) = 0;
+ virtual StringView shader(Containers::StringView filename) = 0;
virtual Trade::ImageData2D tile_texture(Containers::StringView filename) = 0;
virtual std::shared_ptr<struct tile_atlas> tile_atlas(Containers::StringView filename, Vector2ub size) = 0;
static void destroy();
diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp
index 3f08bc9c..533cc8e9 100644
--- a/src/tile-atlas.cpp
+++ b/src/tile-atlas.cpp
@@ -7,7 +7,7 @@
namespace floormat {
-tile_atlas::tile_atlas(Containers::StringView name, const ImageView2D& image, Vector2ub tile_count) :
+tile_atlas::tile_atlas(StringView name, const ImageView2D& image, Vector2ub tile_count) :
texcoords_{make_texcoords_array(Vector2ui(image.size()), tile_count)},
name_{name}, size_{image.size()}, dims_{tile_count}
{
diff --git a/src/tile-atlas.hpp b/src/tile-atlas.hpp
index 97f9f408..b46cf686 100644
--- a/src/tile-atlas.hpp
+++ b/src/tile-atlas.hpp
@@ -1,8 +1,8 @@
#pragma once
+#include <Corrade/Containers/String.h>
#include <Magnum/Magnum.h>
#include <Magnum/GL/Texture.h>
#include <array>
-#include <string>
#include <memory>
namespace std::filesystem { class path; }
@@ -14,7 +14,7 @@ struct tile_atlas final
using quad = std::array<Vector3, 4>;
using texcoords = std::array<Vector2, 4>;
- tile_atlas(Containers::StringView name, const ImageView2D& img, Vector2ub tile_count);
+ tile_atlas(StringView name, const ImageView2D& img, Vector2ub tile_count);
texcoords texcoords_for_id(std::size_t id) const;
static constexpr quad floor_quad(Vector3 center, Vector2 size);
@@ -25,7 +25,7 @@ struct tile_atlas final
std::size_t num_tiles() const { return Vector2ui{dims_}.product(); }
Vector2ub num_tiles2() const { return dims_; }
GL::Texture2D& texture() { return tex_; }
- Containers::StringView name() const { return name_; }
+ StringView name() const { return name_; }
private:
static std::unique_ptr<const texcoords[]> make_texcoords_array(Vector2ui pixel_size, Vector2ub tile_count);
@@ -33,7 +33,7 @@ private:
std::unique_ptr<const texcoords[]> texcoords_;
GL::Texture2D tex_;
- std::string name_;
+ String name_;
Vector2ui size_;
Vector2ub dims_;
};