update blackmatov modules

This commit is contained in:
BlackMATov
2021-01-15 21:05:52 +07:00
parent b8cb858aa7
commit 715667f426
24 changed files with 56 additions and 56 deletions

View File

@@ -108,7 +108,7 @@ namespace e2d::ecsex
Opts&&... opts)
{
static thread_local vector<ecs::entity> to_remove_components;
DEFER([](){ to_remove_components.clear(); });
DEFER_HPP([](){ to_remove_components.clear(); });
owner.for_each_component<T>([](const ecs::entity& e, const T&){
to_remove_components.push_back(e);
@@ -163,7 +163,7 @@ namespace e2d::ecsex
std::tuple<ecs::entity, Ts...>> components;
const std::size_t begin_index = components.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
components.erase(
components.begin() + begin_index,
components.end());
@@ -187,7 +187,7 @@ namespace e2d::ecsex
std::tuple<ecs::const_entity, Ts...>> components;
const std::size_t begin_index = components.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
components.erase(
components.begin() + begin_index,
components.end());
@@ -214,7 +214,7 @@ namespace e2d::ecsex
std::tuple<ecs::entity, Ts...>> components;
const std::size_t begin_index = components.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
components.erase(
components.begin() + begin_index,
components.end());
@@ -243,7 +243,7 @@ namespace e2d::ecsex
std::tuple<ecs::const_entity, Ts...>> components;
const std::size_t begin_index = components.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
components.erase(
components.begin() + begin_index,
components.end());

View File

@@ -82,7 +82,7 @@ namespace e2d::impl
}
ImGui::PushID(co.find());
DEFER([](){ ImGui::PopID(); });
DEFER_HPP([](){ ImGui::PopID(); });
const bool inspector_opened = ImGui::CollapsingHeader(
component_inspector<Component>::title,
@@ -90,7 +90,7 @@ namespace e2d::impl
const char* component_popup_context_str_id = "e2d_component_popup_context";
if ( ImGui::BeginPopupContextItem(component_popup_context_str_id) ) {
DEFER([](){ ImGui::EndPopup(); });
DEFER_HPP([](){ ImGui::EndPopup(); });
auto disabled_co = co.owner().template component<disabled<Component>>();
if ( bool enabled = !disabled_co; ImGui::Checkbox("Enabled", &enabled) ) {
@@ -137,7 +137,7 @@ namespace e2d::impl
}
ImGui::PushID(co.find());
DEFER([](){ ImGui::PopID(); });
DEFER_HPP([](){ ImGui::PopID(); });
if ( !co.owner().template component<disabled<Component>>() ) {
inspector_(co, ctx);

View File

@@ -153,7 +153,7 @@ namespace e2d::nodes
static thread_local vector<intrusive_ptr<Node>> parents;
const std::size_t begin_index = parents.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
parents.erase(
parents.begin() + begin_index,
parents.end());
@@ -184,7 +184,7 @@ namespace e2d::nodes
static thread_local vector<intrusive_ptr<Node>> children;
const std::size_t begin_index = children.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
children.erase(
children.begin() + begin_index,
children.end());
@@ -253,7 +253,7 @@ namespace e2d::nodes
static thread_local vector<gcomponent<Component>> components;
const std::size_t begin_index = components.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
components.erase(
components.begin() + begin_index,
components.end());
@@ -284,7 +284,7 @@ namespace e2d::nodes
static thread_local vector<gcomponent<Component>> components;
const std::size_t begin_index = components.size();
DEFER([begin_index](){
DEFER_HPP([begin_index](){
components.erase(
components.begin() + begin_index,
components.end());

View File

@@ -37,7 +37,7 @@ namespace e2d::imgui_utils
template < typename... Args >
void show_colored_text(const color& color, str_view fmt, Args&&... args) {
ImGui::PushStyleColor(ImGuiCol_Text, make_vec4(color));
DEFER([](){ ImGui::PopStyleColor(); });
DEFER_HPP([](){ ImGui::PopStyleColor(); });
show_formatted_text(fmt, std::forward<Args>(args)...);
}
@@ -54,7 +54,7 @@ namespace e2d::imgui_utils
}
if ( ImGui::BeginCombo(label_cstr, preview_cstr) ) {
DEFER([](){ ImGui::EndCombo(); });
DEFER_HPP([](){ ImGui::EndCombo(); });
for ( std::size_t i = 0; i < enum_hpp::size<E>(); ++i ) {
str_view item_name = enum_hpp::names<E>()[i];
@@ -80,10 +80,10 @@ namespace e2d::imgui_utils
template < typename F, typename... Args >
void with_disabled_flag(F&& f, Args&&... args) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
DEFER([](){ ImGui::PopItemFlag(); });
DEFER_HPP([](){ ImGui::PopItemFlag(); });
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
DEFER([](){ ImGui::PopStyleVar(); });
DEFER_HPP([](){ ImGui::PopStyleVar(); });
std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
}

View File

@@ -45,7 +45,7 @@ namespace e2d::imgex
char* id_cstr = static_cast<char*>(E2D_CLEAR_ALLOCA(id.size() + 1));
std::memcpy(id_cstr, id.data(), id.size());
if ( DEFER([](){ ImGui::EndChild(); });
if ( DEFER_HPP([](){ ImGui::EndChild(); });
ImGui::BeginChild(id_cstr, ImVec2(0.f, 0.f), border, flags) )
{
f();
@@ -58,7 +58,7 @@ namespace e2d::imgex
std::memcpy(label_cstr, label.data(), label.size());
if ( ImGui::BeginMenu(label_cstr) ) {
DEFER([](){ ImGui::EndMenu(); });
DEFER_HPP([](){ ImGui::EndMenu(); });
f();
}
}
@@ -66,7 +66,7 @@ namespace e2d::imgex
template < typename F >
void with_menu_bar(F&& f) {
if ( ImGui::BeginMenuBar() ) {
DEFER([](){ ImGui::EndMenuBar(); });
DEFER_HPP([](){ ImGui::EndMenuBar(); });
f();
}
}
@@ -77,7 +77,7 @@ namespace e2d::imgex
std::memcpy(id_cstr, id.data(), id.size());
if ( ImGui::BeginPopup(id_cstr) ) {
DEFER([](){ ImGui::EndPopup(); });
DEFER_HPP([](){ ImGui::EndPopup(); });
f();
}
}
@@ -87,7 +87,7 @@ namespace e2d::imgex
char* name_cstr = static_cast<char*>(E2D_CLEAR_ALLOCA(name.size() + 1));
std::memcpy(name_cstr, name.data(), name.size());
if ( DEFER([](){ ImGui::End(); });
if ( DEFER_HPP([](){ ImGui::End(); });
ImGui::Begin(name_cstr, opened, flags) )
{
f();
@@ -118,7 +118,7 @@ namespace e2d::imgex
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.f, 0.f));
ImGui::Begin("e2d_dock_space_window", nullptr, window_flags);
DEFER([](){ ImGui::End(); });
DEFER_HPP([](){ ImGui::End(); });
ImGui::PopStyleVar(3);

View File

@@ -34,7 +34,7 @@ namespace e2d::dbgui_widgets
ImGui::Text("pressed keys:");
ImGui::Indent();
DEFER([](){ ImGui::Unindent(); });
DEFER_HPP([](){ ImGui::Unindent(); });
const vector<keyboard_key> pressed_keys = i.keyboard().pressed_keys();
for ( keyboard_key pk : pressed_keys ) {
@@ -46,7 +46,7 @@ namespace e2d::dbgui_widgets
ImGui::Text("pressed buttons:");
ImGui::Indent();
DEFER([](){ ImGui::Unindent(); });
DEFER_HPP([](){ ImGui::Unindent(); });
const vector<mouse_button> pressed_buttons = i.mouse().pressed_buttons();
for ( mouse_button mb : pressed_buttons ) {

View File

@@ -220,7 +220,7 @@ namespace e2d
}
if ( ImGui::TreeNode("clipping") ) {
DEFER([](){ ImGui::TreePop(); });
DEFER_HPP([](){ ImGui::TreePop(); });
if ( f32 znear = c->znear();
ImGui::DragFloat("znear", &znear, 1.f) )
@@ -240,7 +240,7 @@ namespace e2d
///TODO(BlackMat): add 'view' inspector
if ( ImGui::TreeNode("viewport") ) {
DEFER([](){ ImGui::TreePop(); });
DEFER_HPP([](){ ImGui::TreePop(); });
if ( b2f viewport = c->viewport();
ImGui::DragFloat2("position", viewport.position.data(), 0.01f) )

View File

@@ -221,7 +221,7 @@ namespace e2d
c->points().size());
if ( ImGui::TreeNode(points_label.c_str()) ) {
DEFER([](){ ImGui::TreePop(); });
DEFER_HPP([](){ ImGui::TreePop(); });
int count = math::numeric_cast<int>(c->points().size());
if ( ImGui::DragInt("count", &count, 1.f, 0, std::numeric_limits<int>::max()) ) {
@@ -230,7 +230,7 @@ namespace e2d
for ( std::size_t i = 0; i < c->points().size(); ++i ) {
ImGui::PushID(math::numeric_cast<int>(i));
DEFER([](){ ImGui::PopID(); });
DEFER_HPP([](){ ImGui::PopID(); });
if ( v2f point = c->points()[i];
ImGui::DragFloat2("###point", point.data(), 1.f) )

View File

@@ -25,7 +25,7 @@ namespace e2d
}
if ( ImGui::BeginPopup(add_component_popup_str_id) ) {
DEFER([](){ ImGui::EndPopup(); });
DEFER_HPP([](){ ImGui::EndPopup(); });
for ( const auto& p : inspector_impls_ ) {
imgui_utils::with_disabled_flag_ex(

View File

@@ -217,12 +217,12 @@ namespace
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.f, 0.f));
ImGui::Begin("e2d_gizmos_window", nullptr, window_flags);
DEFER([](){ ImGui::End(); });
DEFER_HPP([](){ ImGui::End(); });
ImGui::PopStyleVar(3);
ImGui::PushClipRect(clip_rect.Min, clip_rect.Max, true);
DEFER([](){ ImGui::PopClipRect(); });
DEFER_HPP([](){ ImGui::PopClipRect(); });
std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
}

View File

@@ -181,13 +181,13 @@ namespace
const actor& root_a)
{
static thread_local vector<gcomponent<widget>> item_ws;
DEFER([](){ item_ws.clear(); });
DEFER_HPP([](){ item_ws.clear(); });
nodes::extract_components_from_children<widget>(
root_a.node(),
std::back_inserter(item_ws));
DEFER([&root_yn](){
DEFER_HPP([&root_yn](){
YGNodeRemoveAllChildren(root_yn.as_root.get());
});

View File

@@ -106,7 +106,7 @@ namespace e2d::render_system_impl
flush();
}
ERROR_DEFER([this](){
ERROR_DEFER_HPP([this](){
clear(false);
});
@@ -143,7 +143,7 @@ namespace e2d::render_system_impl
template < typename Index, typename Vertex >
render::property_block& batcher<Index, Vertex>::flush() {
DEFER([this](){
DEFER_HPP([this](){
clear(false);
});
@@ -179,7 +179,7 @@ namespace e2d::render_system_impl
.indices(index_buffer_)
.add_vertices(vertex_buffer_);
DEFER([this](){
DEFER_HPP([this](){
property_cache_.clear();
});

View File

@@ -121,7 +121,7 @@ namespace e2d::render_system_impl
const model& mdl = mdl_r.model()->content();
const mesh& msh = mdl.mesh()->content();
DEFER([this](){
DEFER_HPP([this](){
property_cache_.clear();
});
@@ -197,7 +197,7 @@ namespace e2d::render_system_impl
return;
}
DEFER([this](){
DEFER_HPP([this](){
property_cache_.clear();
});

View File

@@ -126,7 +126,7 @@ namespace e2d::touch_system_impl::impl
const b2f& camera_viewport)
{
static thread_local std::vector<v2f> points;
DEFER([](){ points.clear(); });
DEFER_HPP([](){ points.clear(); });
if ( points.capacity() < c.points.size() ) {
points.reserve(math::max(points.capacity() * 2u, c.points.size()));

View File

@@ -17,7 +17,7 @@ namespace
scene,
actor>> scenes;
DEFER([](){ scenes.clear(); });
DEFER_HPP([](){ scenes.clear(); });
ecsex::extract_components<scene, actor>(
owner,
std::back_inserter(scenes),
@@ -62,7 +62,7 @@ namespace
//
static thread_local std::vector<gcomponent<touchable>> parents;
DEFER([](){ parents.clear(); });
DEFER_HPP([](){ parents.clear(); });
nodes::extract_components_from_parents<touchable>(
target_actor->node(),
@@ -115,7 +115,7 @@ namespace
namespace e2d::touch_system_impl
{
void dispatcher::dispatch_all_events(ecs::registry& owner) {
DEFER([this](){ events_.clear(); });
DEFER_HPP([this](){ events_.clear(); });
owner.for_each_component<events<touchable_events::event>>([
](const ecs::const_entity&, events<touchable_events::event>& es) {

View File

@@ -38,7 +38,7 @@ namespace
: strings::rformat("%0 %1", icon_name, component_name);
ImGui::PushID(root.get());
DEFER([](){ ImGui::PopID(); });
DEFER_HPP([](){ ImGui::PopID(); });
ImGuiTreeNodeFlags tree_node_flags =
ImGuiTreeNodeFlags_OpenOnArrow |
@@ -58,7 +58,7 @@ namespace
tree_node_flags,
"%s", tree_node_name.c_str());
DEFER([tree_node_opened](){
DEFER_HPP([tree_node_opened](){
if ( tree_node_opened ) {
ImGui::TreePop();
}
@@ -73,7 +73,7 @@ namespace
}
if ( ImGui::BeginPopupContextItem() ) {
DEFER([](){ ImGui::EndPopup(); });
DEFER_HPP([](){ ImGui::EndPopup(); });
if ( ImGui::MenuItem("Add child") ) {
gobject inst = w.instantiate();

View File

@@ -91,7 +91,7 @@ namespace
});
gobject root_i(make_intrusive<gobject_state>(world, ent));
ERROR_DEFER([&root_i](){
ERROR_DEFER_HPP([&root_i](){
delete_instance(root_i);
});
@@ -108,7 +108,7 @@ namespace
for ( const prefab& child_prefab : root_prefab.children() ) {
gobject child_i = new_instance(world, child_prefab);
ERROR_DEFER([&child_i](){
ERROR_DEFER_HPP([&child_i](){
delete_instance(child_i);
});
gcomponent<actor> root_a{root_i};
@@ -158,7 +158,7 @@ namespace e2d
gobject world::instantiate(const prefab& prefab, const node_iptr& parent) {
gobject inst = new_instance(*this, prefab);
ERROR_DEFER([inst](){
ERROR_DEFER_HPP([inst](){
delete_instance(inst);
});
@@ -173,7 +173,7 @@ namespace e2d
gobject world::instantiate(const prefab& prefab, const node_iptr& parent, const t2f& transform) {
gobject inst = new_instance(*this, prefab);
ERROR_DEFER([inst](){
ERROR_DEFER_HPP([inst](){
delete_instance(inst);
});

View File

@@ -8,7 +8,7 @@
using namespace e2d;
TEST_CASE("filesystem") {
DEFER([](){
DEFER_HPP([](){
filesystem::remove_file("files_test");
});
SECTION("files") {

View File

@@ -8,7 +8,7 @@
using namespace e2d;
TEST_CASE("images") {
DEFER([](){
DEFER_HPP([](){
filesystem::remove_file("image_save_test.jpg");
filesystem::remove_file("image_save_test.png");
filesystem::remove_file("image_save_test.tga");