summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-02-24 08:59:46 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-02-24 08:59:46 +0100
commit83bca7d6861a701e8ba383a93076f346db393a33 (patch)
tree2f16b71ef17003d9eac0138f6ebb2dad02a9d99c
parenta68822c7e24d818b984ef6889c36d3b39202c887 (diff)
a
-rw-r--r--editor/events.cpp2
-rw-r--r--editor/inspect-types.cpp14
-rw-r--r--editor/inspect.cpp4
-rw-r--r--entity/constraints.hpp5
-rw-r--r--entity/metadata.hpp12
5 files changed, 25 insertions, 12 deletions
diff --git a/editor/events.cpp b/editor/events.cpp
index cc1c0d7a..d0a57d8b 100644
--- a/editor/events.cpp
+++ b/editor/events.cpp
@@ -152,7 +152,7 @@ void app::on_key_up_down(const key_event& event, bool is_down) noexcept
static_assert(key_GLOBAL >= key_NO_REPEAT);
if (x == key_COUNT)
- void();
+ is_down ? _imgui.handleKeyPressEvent(e) : _imgui.handleKeyReleaseEvent(e);
else if (x < key_GLOBAL && is_down ? _imgui.handleKeyPressEvent(e) : _imgui.handleKeyReleaseEvent(e))
clear_non_global_keys();
else if (x >= key_NO_REPEAT)
diff --git a/editor/inspect-types.cpp b/editor/inspect-types.cpp
index 235ee72e..d4feb1c3 100644
--- a/editor/inspect-types.cpp
+++ b/editor/inspect-types.cpp
@@ -6,9 +6,16 @@
#include "entity/types.hpp"
#include "inspect.hpp"
#include <Corrade/Containers/ArrayViewStl.h>
+#include <Corrade/Containers/String.h>
+
+//#define TEST_STR
namespace floormat::entities {
+#ifdef TEST_STR
+static String my_str;
+#endif
+
template<> struct entity_accessors<scenery_ref> {
static constexpr auto accessors()
{
@@ -29,11 +36,16 @@ template<> struct entity_accessors<scenery_ref> {
[](const scenery_ref& x) { return x.frame.passability; },
[](scenery_ref& x, pass_mode value) { x.frame.passability = value; }
},
- // todo pass_mode enum
entity::type<bool>::field{"interactive"_s,
[](const scenery_ref& x) { return x.frame.interactive; },
[](scenery_ref& x, bool value) { x.frame.interactive = value; }
}
+#ifdef TEST_STR
+ , entity::type<String>::field{"string"_s,
+ [](const scenery_ref&) { return my_str; },
+ [](scenery_ref&, String value) { my_str = std::move(value); }
+ }
+#endif
);
return tuple;
}
diff --git a/editor/inspect.cpp b/editor/inspect.cpp
index cd2904fc..aa17029a 100644
--- a/editor/inspect.cpp
+++ b/editor/inspect.cpp
@@ -53,11 +53,7 @@ int corrade_string_resize_callback(ImGuiInputTextCallbackData* data)
{
auto* my_str = reinterpret_cast<String*>(data->UserData);
fm_assert(my_str->begin() == data->Buf);
- String tmp = std::move(*my_str);
*my_str = String{ValueInit, (std::size_t)data->BufSize};
- auto len = std::min(tmp.size(), my_str->size());
- for (std::size_t i = 0; i < len; i++)
- (*my_str)[i] = tmp[i];
data->Buf = my_str->begin();
}
return 0;
diff --git a/entity/constraints.hpp b/entity/constraints.hpp
index cfe33bfe..b4989353 100644
--- a/entity/constraints.hpp
+++ b/entity/constraints.hpp
@@ -35,6 +35,11 @@ constexpr range<T>::operator erased_constraints::range() const noexcept
template<typename T> constexpr range<T>::operator std::pair<T, T>() const noexcept { return { min, max }; }
+template<> struct range<String>
+{
+ constexpr operator erased_constraints::range() const noexcept { return {}; }
+};
+
using max_length = erased_constraints::max_length;
using group = erased_constraints::group;
diff --git a/entity/metadata.hpp b/entity/metadata.hpp
index b373a927..e2d9eb67 100644
--- a/entity/metadata.hpp
+++ b/entity/metadata.hpp
@@ -123,9 +123,9 @@ public:
fm_DECLARE_DEFAULT_MOVE_COPY_ASSIGNMENTS(entity_field);
static constexpr decltype(auto) read(const R& reader, const Obj& x) { return detail::read_field<Obj, Type, R>::read(x, reader); }
- static constexpr void write(const W& writer, Obj& x, move_qualified<Type> v);
+ static constexpr void write(const W& writer, Obj& x, Type v);
constexpr decltype(auto) read(const Obj& x) const { return read(reader, x); }
- constexpr void write(Obj& x, move_qualified<Type> value) const { write(writer, x, value); }
+ constexpr void write(Obj& x, Type value) const { write(writer, x, std::move(value)); }
static constexpr bool can_write = !std::is_same_v<std::nullptr_t, decltype(entity_field<Obj, Type, R, W, Ts...>::writer)>;
static constexpr field_status is_enabled(const Predicate & p, const Obj& x);
@@ -149,9 +149,9 @@ public:
};
template<typename Obj, typename Type, FieldReader<Obj, Type> R, FieldWriter<Obj, Type> W, typename... Ts>
-constexpr void entity_field<Obj, Type, R, W, Ts...>::write(const W& writer, Obj& x, move_qualified<Type> v)
+constexpr void entity_field<Obj, Type, R, W, Ts...>::write(const W& writer, Obj& x, Type v)
{
- static_assert(can_write); detail::write_field<Obj, Type, W>::write(x, writer, v);
+ static_assert(can_write); detail::write_field<Obj, Type, W>::write(x, writer, std::move(v));
}
template<typename Obj, typename Type, FieldReader<Obj, Type> R, FieldWriter<Obj, Type> W, typename... Ts>
@@ -174,8 +174,8 @@ constexpr erased_accessor entity_field<Obj, Type, R, W, Ts...>::erased() const
constexpr auto writer_fn = [](void* obj, const writer_t* writer, void* value) {
auto& obj_ = *reinterpret_cast<Obj*>(obj);
const auto& writer_ = *reinterpret_cast<const W*>(writer);
- move_qualified<Type> value_ = std::move(*reinterpret_cast<Type*>(value));
- write(writer_, obj_, value_);
+ Type value_ = std::move(*reinterpret_cast<Type*>(value));
+ write(writer_, obj_, std::move(value_));
};
constexpr auto predicate_fn = [](const void* obj, const predicate_t* predicate) {
const auto& obj_ = *reinterpret_cast<const Obj*>(obj);