components cleanup

This commit is contained in:
2019-11-14 04:01:26 +07:00
parent 2f88594303
commit c1f593c567
9 changed files with 35 additions and 114 deletions

View File

@@ -20,8 +20,8 @@ namespace e2d
actor& node(const node_iptr& value) noexcept;
node_iptr node() noexcept;
const_node_iptr node() const noexcept;
[[nodiscard]] node_iptr node() noexcept;
[[nodiscard]] const_node_iptr node() const noexcept;
private:
node_iptr node_;
};
@@ -34,7 +34,7 @@ namespace e2d
bool operator()(
actor& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;

View File

@@ -22,11 +22,11 @@ namespace e2d
camera& target(const render_target_ptr& value) noexcept;
camera& background(const color& value) noexcept;
i32 depth() const noexcept;
const b2u& viewport() const noexcept;
const m4f& projection() const noexcept;
const render_target_ptr& target() const noexcept;
const color& background() const noexcept;
[[nodiscard]] i32 depth() const noexcept;
[[nodiscard]] const b2u& viewport() const noexcept;
[[nodiscard]] const m4f& projection() const noexcept;
[[nodiscard]] const render_target_ptr& target() const noexcept;
[[nodiscard]] const color& background() const noexcept;
private:
i32 depth_ = 0;
b2u viewport_ = b2u::zero();

View File

@@ -21,25 +21,25 @@ namespace e2d
// data access
flipbook_player& time(f32 value) noexcept;
f32 time() const noexcept;
[[nodiscard]] f32 time() const noexcept;
flipbook_player& speed(f32 value) noexcept;
f32 speed() const noexcept;
[[nodiscard]] f32 speed() const noexcept;
flipbook_player& looped(bool value) noexcept;
bool looped() const noexcept;
[[nodiscard]] bool looped() const noexcept;
flipbook_player& stopped(bool value) noexcept;
bool stopped() const noexcept;
[[nodiscard]] bool stopped() const noexcept;
flipbook_player& playing(bool value) noexcept;
bool playing() const noexcept;
[[nodiscard]] bool playing() const noexcept;
flipbook_player& sequence(str_hash value) noexcept;
str_hash sequence() const noexcept;
[[nodiscard]] str_hash sequence() const noexcept;
flipbook_player& flipbook(const flipbook_asset::ptr& value) noexcept;
const flipbook_asset::ptr& flipbook() const noexcept;
[[nodiscard]] const flipbook_asset::ptr& flipbook() const noexcept;
// helpers
@@ -65,7 +65,7 @@ namespace e2d
bool operator()(
flipbook_player& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;

View File

@@ -34,12 +34,6 @@ namespace e2d
label() = default;
label(const font_asset::ptr& font);
label(label&& other) noexcept;
label& operator=(label&& other) noexcept;
label(const label& other);
label& operator=(const label& other);
label& text(str value) noexcept;
[[nodiscard]] const str& text() const noexcept;
@@ -120,66 +114,6 @@ namespace e2d
inline label::label(const font_asset::ptr& value)
: font_(value) {}
inline label::label(label&& other) noexcept
: text_(std::move(other.text_))
, font_(std::move(other.font_))
, tint_(other.tint_)
, halign_(other.halign_)
, valign_(other.valign_)
, leading_(other.leading_)
, tracking_(other.tracking_)
, text_width_(other.text_width_)
, glyph_dilate_(other.glyph_dilate_)
, outline_width_(other.outline_width_)
, outline_color_(other.outline_color_) {}
inline label& label::operator=(label&& other) noexcept {
if ( this != &other ) {
text_ = std::move(other.text_);
font_ = std::move(other.font_);
tint_ = other.tint_;
halign_ = other.halign_;
valign_ = other.valign_;
leading_ = other.leading_;
tracking_ = other.tracking_;
text_width_ = other.text_width_;
glyph_dilate_ = other.glyph_dilate_;
outline_width_ = other.outline_width_;
outline_color_ = other.outline_color_;
}
return *this;
}
inline label::label(const label& other)
: text_(other.text_)
, font_(other.font_)
, tint_(other.tint_)
, halign_(other.halign_)
, valign_(other.valign_)
, leading_(other.leading_)
, tracking_(other.tracking_)
, text_width_(other.text_width_)
, glyph_dilate_(other.glyph_dilate_)
, outline_width_(other.outline_width_)
, outline_color_(other.outline_color_) {}
inline label& label::operator=(const label& other) {
if ( this != &other ) {
text_ = other.text_;
font_ = other.font_;
tint_ = other.tint_;
halign_ = other.halign_;
valign_ = other.valign_;
leading_ = other.leading_;
tracking_ = other.tracking_;
text_width_ = other.text_width_;
glyph_dilate_ = other.glyph_dilate_;
outline_width_ = other.outline_width_;
outline_color_ = other.outline_color_;
}
return *this;
}
inline label& label::text(str value) noexcept {
text_ = std::move(value);
return *this;

View File

@@ -19,7 +19,7 @@ namespace e2d
model_renderer(const model_asset::ptr& model);
model_renderer& model(const model_asset::ptr& value) noexcept;
const model_asset::ptr& model() const noexcept;
[[nodiscard]] const model_asset::ptr& model() const noexcept;
private:
model_asset::ptr model_;
};

View File

@@ -20,14 +20,14 @@ namespace e2d
renderer& properties(render::property_block&& value) noexcept;
renderer& properties(const render::property_block& value);
render::property_block& properties() noexcept;
const render::property_block& properties() const noexcept;
[[nodiscard]] render::property_block& properties() noexcept;
[[nodiscard]] const render::property_block& properties() const noexcept;
renderer& materials(vector<material_asset::ptr>&& value) noexcept;
renderer& materials(const vector<material_asset::ptr>& value);
vector<material_asset::ptr>& materials() noexcept;
const vector<material_asset::ptr>& materials() const noexcept;
[[nodiscard]] vector<material_asset::ptr>& materials() noexcept;
[[nodiscard]] const vector<material_asset::ptr>& materials() const noexcept;
private:
render::property_block properties_;
vector<material_asset::ptr> materials_;
@@ -41,7 +41,7 @@ namespace e2d
bool operator()(
renderer& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;

View File

@@ -17,7 +17,7 @@ namespace e2d
scene() = default;
scene& depth(i32 value) noexcept;
i32 depth() const noexcept;
[[nodiscard]] i32 depth() const noexcept;
private:
i32 depth_ = 0;
};

View File

@@ -28,24 +28,20 @@ namespace e2d
sprite_renderer(const sprite_asset::ptr& sprite);
sprite_renderer& tint(const color32& value) noexcept;
const color32& tint() const noexcept;
[[nodiscard]] const color32& tint() const noexcept;
sprite_renderer& blending(blendings value) noexcept;
blendings blending() const noexcept;
[[nodiscard]] blendings blending() const noexcept;
sprite_renderer& filtering(bool value) noexcept;
bool filtering() const noexcept;
[[nodiscard]] bool filtering() const noexcept;
sprite_renderer& sprite(const sprite_asset::ptr& value) noexcept;
const sprite_asset::ptr& sprite() const noexcept;
[[nodiscard]] const sprite_asset::ptr& sprite() const noexcept;
sprite_renderer& materials(
flat_map<str_hash, material_asset::ptr>&& value) noexcept;
sprite_renderer& materials(
const flat_map<str_hash, material_asset::ptr>& value);
material_asset::ptr find_material(str_hash name) const noexcept;
const flat_map<str_hash, material_asset::ptr>& materials() const noexcept;
sprite_renderer& materials(flat_map<str_hash, material_asset::ptr> value) noexcept;
[[nodiscard]] const flat_map<str_hash, material_asset::ptr>& materials() const noexcept;
[[nodiscard]] material_asset::ptr find_material(str_hash name) const noexcept;
private:
color32 tint_ = color32::white();
blendings blending_ = blendings::normal;
@@ -62,7 +58,7 @@ namespace e2d
bool operator()(
sprite_renderer& component,
const fill_context& ctx) const;
bool operator()(
asset_dependencies& dependencies,
const collect_context& ctx) const;
@@ -110,18 +106,13 @@ namespace e2d
return sprite_;
}
inline sprite_renderer& sprite_renderer::materials(
flat_map<str_hash, material_asset::ptr>&& value) noexcept
{
inline sprite_renderer& sprite_renderer::materials(flat_map<str_hash, material_asset::ptr> value) noexcept {
materials_ = std::move(value);
return *this;
}
inline sprite_renderer& sprite_renderer::materials(
const flat_map<str_hash, material_asset::ptr>& value)
{
materials_ = value;
return *this;
inline const flat_map<str_hash, material_asset::ptr>& sprite_renderer::materials() const noexcept {
return materials_;
}
inline material_asset::ptr sprite_renderer::find_material(str_hash name) const noexcept {
@@ -130,8 +121,4 @@ namespace e2d
? iter->second
: nullptr;
}
inline const flat_map<str_hash, material_asset::ptr>& sprite_renderer::materials() const noexcept {
return materials_;
}
}

View File

@@ -75,7 +75,7 @@ namespace e2d
if ( ctx.root.HasMember("blending") ) {
sprite_renderer::blendings blending = component.blending();
if ( !parse_blending(ctx.root["blending"].GetString(), blending) ) {
the<debug>().error("LABEL: Incorrect formatting of 'blending' property");
the<debug>().error("SPRITE_RENDERER: Incorrect formatting of 'blending' property");
return false;
}
component.blending(blending);