Skip to content

Commit

Permalink
feat(common-components): move layer to graphics namespace
Browse files Browse the repository at this point in the history
BREAKING CHANGE: All namespace using ecs::layer<> renamed to graphics::layer<>
  • Loading branch information
Milerius committed Oct 10, 2019
1 parent 0e03e73 commit 47f38ed
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 55 deletions.
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
2.0.0
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = 'Roman Sztergbaum Tolg Ay'

# The full version, including alpha/beta/rc tags
release = '0.0.2'
release = '2.0.0'


# -- General configuration ---------------------------------------------------
Expand Down
10 changes: 4 additions & 6 deletions examples/sfml/basis-draft/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <entt/entity/helper.hpp>
#include "antara/gaming/world/world.app.hpp"
#include "antara/gaming/ecs/component.position.hpp"
#include "antara/gaming/ecs/component.layer.hpp"
#include "antara/gaming/graphics/component.layer.hpp"
#include "antara/gaming/sfml/component.drawable.hpp"
#include "antara/gaming/sfml/graphic.system.hpp"
#include "antara/gaming/sfml/input.system.hpp"
Expand All @@ -26,8 +26,6 @@
#include "antara/gaming/scenes/base.scene.hpp"
#include "antara/gaming/sfml/audio.system.hpp"
#include "antara/gaming/sfml/resources.manager.hpp"
#include "../tic-tac-toe/game.scene.hpp"


class intro_scene;

Expand All @@ -52,7 +50,7 @@ class game_scene final : public antara::gaming::scenes::base_scene
static_cast<float>(window_info.y) /
2.f);
entity_registry_.assign<entt::tag<"game_scene"_hs>>(dummy_entity);
this->entity_registry_.assign<antara::gaming::ecs::component::layer<0>>(dummy_entity);
this->entity_registry_.assign<antara::gaming::graphics::layer<0>>(dummy_entity);


auto triangle_entity = entity_registry.create();
Expand All @@ -68,7 +66,7 @@ class game_scene final : public antara::gaming::scenes::base_scene
triangle[2].color = sf::Color::Green;

entity_registry_.assign<entt::tag<"game_scene"_hs>>(triangle_entity);
this->entity_registry_.assign<antara::gaming::ecs::component::layer<0>>(triangle_entity);
this->entity_registry_.assign<antara::gaming::graphics::layer<0>>(triangle_entity);

auto cross_entity = entity_registry.create();
auto &cross_cmp = entity_registry.assign<antara::gaming::sfml::vertex_array>(cross_entity,
Expand All @@ -87,7 +85,7 @@ class game_scene final : public antara::gaming::scenes::base_scene
}

entity_registry_.assign<entt::tag<"game_scene"_hs>>(cross_entity);
this->entity_registry_.assign<antara::gaming::ecs::component::layer<0>>(cross_entity);
this->entity_registry_.assign<antara::gaming::graphics::layer<0>>(cross_entity);
}

void update() noexcept final
Expand Down
8 changes: 4 additions & 4 deletions examples/sfml/tic-tac-toe/tic.tac.toe.factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <cmath>
#include <SFML/Graphics/RenderTexture.hpp>
#include <entt/entity/helper.hpp>
#include <antara/gaming/ecs/component.layer.hpp>
#include <antara/gaming/graphics/component.layer.hpp>
#include <antara/gaming/ecs/component.position.hpp>
#include <antara/gaming/sfml/component.drawable.hpp>
#include "tic.tac.toe.factory.hpp"
Expand Down Expand Up @@ -45,7 +45,7 @@ namespace tictactoe ::example

entity_registry.assign<entt::tag<"grid"_hs>>(grid_entity);
entity_registry.assign<entt::tag<"game_scene"_hs>>(grid_entity);
entity_registry.assign<ecs::component::layer<0>>(grid_entity);
entity_registry.assign<graphics::layer<0>>(grid_entity);
return grid_entity;
}

Expand Down Expand Up @@ -85,7 +85,7 @@ namespace tictactoe ::example

entity_registry.assign<entt::tag<"game_scene"_hs>>(x_entity);
entity_registry.assign<entt::tag<"player_x"_hs>>(x_entity);
entity_registry.assign<ecs::component::layer<1>>(x_entity);
entity_registry.assign<graphics::layer<1>>(x_entity);
return x_entity;
}

Expand All @@ -110,7 +110,7 @@ namespace tictactoe ::example
circle.setOutlineColor(sf::Color::Blue);

entity_registry.assign<entt::tag<"game_scene"_hs>>(o_entity);
entity_registry.assign<ecs::component::layer<1>>(o_entity);
entity_registry.assign<graphics::layer<1>>(o_entity);
return o_entity;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/ecs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target_sources(antara_ecs_shared_sources PRIVATE
antara/gaming/ecs/component.position.cpp
antara/gaming/ecs/event.add.base.system.cpp)
target_include_directories(antara_ecs_shared_sources PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(antara_ecs_shared_sources PUBLIC antara::core EnTT strong_type expected range-v3 antara::default_settings antara::timer antara::event doom::meta)
target_link_libraries(antara_ecs_shared_sources PUBLIC antara::core antara::geometry antara::graphics EnTT strong_type expected range-v3 antara::default_settings antara::timer antara::event doom::meta)
add_library(antara::ecs ALIAS antara_ecs_shared_sources)

if (ANTARA_BUILD_UNIT_TESTS)
Expand Down
23 changes: 8 additions & 15 deletions modules/ecs/antara/gaming/ecs/all.components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@
#pragma once

#include <meta/sequence/list.hpp>
#include "antara/gaming/ecs/component.layer.hpp"
#include <meta/sequence/concat.hpp>
#include <meta/sequence/flatten.hpp>
#include "antara/gaming/ecs/component.position.hpp"
#include "antara/gaming/graphics/all.graphics.components.hpp"
#include "antara/gaming/geometry/all.geometry.components.hpp"

namespace antara::gaming::ecs::component
{
using components_list = doom::meta::list<
layer_0,
layer_1,
layer_2,
layer_3,
layer_4,
layer_5,
layer_6,
layer_7,
layer_8,
layer_9,
layer_10,
layer_11,
position>;
using internal_components_list = doom::meta::list<position>;
using list_component_list = doom::meta::list<internal_components_list, geometry::components_list, graphics::components_list>;
using components_list = doom::meta::flatten<list_component_list>;
//using intermediate_list = doom::meta::concat<internal_components_list, geometry::components_list>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/******************************************************************************
* Copyright © 2013-2019 The Komodo Platform Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* Komodo Platform software, including this file may be copied, modified, *
* propagated or distributed except according to the terms contained in the *
* LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/

#pragma once

#include <meta/sequence/list.hpp>
#include "antara/gaming/geometry/component.circle.hpp"

namespace antara::gaming::geometry
{
using components_list = doom::meta::list<circle>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/******************************************************************************
* Copyright © 2013-2019 The Komodo Platform Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* Komodo Platform software, including this file may be copied, modified, *
* propagated or distributed except according to the terms contained in the *
* LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/

#pragma once

#include <meta/sequence/list.hpp>
#include "antara/gaming/graphics/component.layer.hpp"

namespace antara::gaming::graphics
{
using components_list = doom::meta::list<layer_0,
layer_1,
layer_2,
layer_3,
layer_4,
layer_5,
layer_6,
layer_7,
layer_8,
layer_9,
layer_10,
layer_11>;
}
16 changes: 10 additions & 6 deletions modules/graphics/antara/gaming/graphics/component.color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

#pragma once

#include <utility>
#include <cstdint>
#include <utility>
#include "antara/gaming/core/safe.refl.hpp"

namespace antara::gaming::graphics
{
Expand Down Expand Up @@ -68,19 +69,22 @@ namespace antara::gaming::graphics

struct outline_color : color
{
template <typename ... TArgs>
constexpr outline_color(TArgs&& ...args) noexcept : graphics::color(std::forward<TArgs>(args)...)
template<typename ... TArgs>
constexpr outline_color(TArgs &&...args) noexcept : graphics::color(std::forward<TArgs>(args)...)
{

}
};

struct fill_color : color
{
template <typename ... TArgs>
constexpr fill_color(TArgs&& ...args) noexcept : graphics::color(std::forward<TArgs>(args)...)
template<typename ... TArgs>
constexpr fill_color(TArgs &&...args) noexcept : graphics::color(std::forward<TArgs>(args)...)
{

}
};
}
}

REFL_AUTO(type(antara::gaming::graphics::outline_color), field(r), field(g), field(b), field(a))
REFL_AUTO(type(antara::gaming::graphics::fill_color), field(r), field(g), field(b), field(a))
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cstddef>
#include "antara/gaming/core/safe.refl.hpp"

namespace antara::gaming::ecs::component
namespace antara::gaming::graphics
{
inline constexpr std::size_t max_layer = 12ull;

Expand All @@ -42,15 +42,15 @@ namespace antara::gaming::ecs::component
using layer_11 = layer<11>;
}

REFL_AUTO(type(antara::gaming::ecs::component::layer_0))
REFL_AUTO(type(antara::gaming::ecs::component::layer_1))
REFL_AUTO(type(antara::gaming::ecs::component::layer_2))
REFL_AUTO(type(antara::gaming::ecs::component::layer_3))
REFL_AUTO(type(antara::gaming::ecs::component::layer_4))
REFL_AUTO(type(antara::gaming::ecs::component::layer_5))
REFL_AUTO(type(antara::gaming::ecs::component::layer_6))
REFL_AUTO(type(antara::gaming::ecs::component::layer_7))
REFL_AUTO(type(antara::gaming::ecs::component::layer_8))
REFL_AUTO(type(antara::gaming::ecs::component::layer_9))
REFL_AUTO(type(antara::gaming::ecs::component::layer_10))
REFL_AUTO(type(antara::gaming::ecs::component::layer_11))
REFL_AUTO(type(antara::gaming::graphics::layer_0))
REFL_AUTO(type(antara::gaming::graphics::layer_1))
REFL_AUTO(type(antara::gaming::graphics::layer_2))
REFL_AUTO(type(antara::gaming::graphics::layer_3))
REFL_AUTO(type(antara::gaming::graphics::layer_4))
REFL_AUTO(type(antara::gaming::graphics::layer_5))
REFL_AUTO(type(antara::gaming::graphics::layer_6))
REFL_AUTO(type(antara::gaming::graphics::layer_7))
REFL_AUTO(type(antara::gaming::graphics::layer_8))
REFL_AUTO(type(antara::gaming::graphics::layer_9))
REFL_AUTO(type(antara::gaming::graphics::layer_10))
REFL_AUTO(type(antara::gaming::graphics::layer_11))
6 changes: 3 additions & 3 deletions modules/sfml/antara/gaming/sfml/graphic.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "antara/gaming/config/config.game.maker.hpp"
#include "antara/gaming/event/canvas.resized.hpp"
#include "antara/gaming/ecs/component.position.hpp"
#include "antara/gaming/ecs/component.layer.hpp"
#include "antara/gaming/graphics/component.layer.hpp"
#include "antara/gaming/sfml/graphic.system.hpp"
#include "antara/gaming/sfml/component.drawable.hpp"

Expand Down Expand Up @@ -117,7 +117,7 @@ namespace antara::gaming::sfml
template<size_t Layer, typename DrawableType>
void graphic_system::draw() noexcept
{
this->entity_registry_.view<DrawableType, ecs::component::layer<Layer>>().each(
this->entity_registry_.view<DrawableType, graphics::layer<Layer>>().each(
[this](auto entity,
auto &&drawable,
[[maybe_unused]] auto &&) {
Expand Down Expand Up @@ -145,7 +145,7 @@ namespace antara::gaming::sfml

void graphic_system::draw_all_layers() noexcept
{
draw_all_layers(std::make_index_sequence<ecs::component::max_layer>{});
draw_all_layers(std::make_index_sequence<graphics::max_layer>{});
}

void graphic_system::on_window_resized_event(const event::window_resized &) noexcept
Expand Down
4 changes: 2 additions & 2 deletions modules/sfml/antara/gaming/sfml/komodo.intro.scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace antara::gaming::sfml
sf::Vector2f(window_info.x, window_info.y))).drawable;
rect.setFillColor(sf::Color(0, 0, 0, 0));
entity_registry.assign<entt::tag<"intro_scene"_hs>>(entity);
entity_registry.assign<ecs::component::layer<2>>(entity);
entity_registry.assign<graphics::layer<2>>(entity);

rect.setFillColor(sf::Color(0, 0, 0, 0));
rect.setSize(sf::Vector2f(window_info.x, window_info.y));
Expand All @@ -91,7 +91,7 @@ namespace antara::gaming::sfml
va.append(sf::Vertex(sf::Vector2f(window_info.x, window_info.y), sf::Color(0, 176, 163)));
va.append(sf::Vertex(sf::Vector2f(0, window_info.x), sf::Color(0, 67, 106)));
entity_registry.assign<entt::tag<"intro_scene"_hs>>(entity);
entity_registry.assign<ecs::component::layer<0>>(entity);
entity_registry.assign<graphics::layer<0>>(entity);

//! Give the fresh entity
return entity;
Expand Down
6 changes: 3 additions & 3 deletions modules/sfml/antara/gaming/sfml/komodo.intro.scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <SFML/Graphics.hpp>
#include "antara/gaming/config/config.game.hpp"
#include "antara/gaming/scenes/base.scene.hpp"
#include "antara/gaming/ecs/component.layer.hpp"
#include <antara/gaming/ecs/component.position.hpp>
#include "antara/gaming/ecs/component.position.hpp"
#include "antara/gaming/graphics/component.layer.hpp"
#include "antara/gaming/sfml/resources.manager.hpp"
#include "antara/gaming/sfml/component.audio.hpp"
#include "antara/gaming/sfml/component.drawable.hpp"
Expand Down Expand Up @@ -53,7 +53,7 @@ namespace antara::gaming::sfml
auto &sprite = entity_registry.assign<antara::gaming::sfml::sprite>(entity, sf::Sprite(*texture)).drawable;
sprite.setOrigin(sprite.getLocalBounds().width * 0.5f, sprite.getLocalBounds().height * 0.5f);
entity_registry.assign<entt::tag<"intro_scene"_hs>>(entity);
entity_registry.assign<antara::gaming::ecs::component::layer<current_layer>>(entity);
entity_registry.assign<antara::gaming::graphics::layer<current_layer>>(entity);

//! Give the fresh entity
return entity;
Expand Down

0 comments on commit 47f38ed

Please sign in to comment.