mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
components cleanup
This commit is contained in:
@@ -20,8 +20,8 @@ namespace e2d
|
|||||||
|
|
||||||
actor& node(const node_iptr& value) noexcept;
|
actor& node(const node_iptr& value) noexcept;
|
||||||
|
|
||||||
node_iptr node() noexcept;
|
[[nodiscard]] node_iptr node() noexcept;
|
||||||
const_node_iptr node() const noexcept;
|
[[nodiscard]] const_node_iptr node() const noexcept;
|
||||||
private:
|
private:
|
||||||
node_iptr node_;
|
node_iptr node_;
|
||||||
};
|
};
|
||||||
@@ -34,7 +34,7 @@ namespace e2d
|
|||||||
bool operator()(
|
bool operator()(
|
||||||
actor& component,
|
actor& component,
|
||||||
const fill_context& ctx) const;
|
const fill_context& ctx) const;
|
||||||
|
|
||||||
bool operator()(
|
bool operator()(
|
||||||
asset_dependencies& dependencies,
|
asset_dependencies& dependencies,
|
||||||
const collect_context& ctx) const;
|
const collect_context& ctx) const;
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ namespace e2d
|
|||||||
camera& target(const render_target_ptr& value) noexcept;
|
camera& target(const render_target_ptr& value) noexcept;
|
||||||
camera& background(const color& value) noexcept;
|
camera& background(const color& value) noexcept;
|
||||||
|
|
||||||
i32 depth() const noexcept;
|
[[nodiscard]] i32 depth() const noexcept;
|
||||||
const b2u& viewport() const noexcept;
|
[[nodiscard]] const b2u& viewport() const noexcept;
|
||||||
const m4f& projection() const noexcept;
|
[[nodiscard]] const m4f& projection() const noexcept;
|
||||||
const render_target_ptr& target() const noexcept;
|
[[nodiscard]] const render_target_ptr& target() const noexcept;
|
||||||
const color& background() const noexcept;
|
[[nodiscard]] const color& background() const noexcept;
|
||||||
private:
|
private:
|
||||||
i32 depth_ = 0;
|
i32 depth_ = 0;
|
||||||
b2u viewport_ = b2u::zero();
|
b2u viewport_ = b2u::zero();
|
||||||
|
|||||||
@@ -21,25 +21,25 @@ namespace e2d
|
|||||||
// data access
|
// data access
|
||||||
|
|
||||||
flipbook_player& time(f32 value) noexcept;
|
flipbook_player& time(f32 value) noexcept;
|
||||||
f32 time() const noexcept;
|
[[nodiscard]] f32 time() const noexcept;
|
||||||
|
|
||||||
flipbook_player& speed(f32 value) noexcept;
|
flipbook_player& speed(f32 value) noexcept;
|
||||||
f32 speed() const noexcept;
|
[[nodiscard]] f32 speed() const noexcept;
|
||||||
|
|
||||||
flipbook_player& looped(bool value) noexcept;
|
flipbook_player& looped(bool value) noexcept;
|
||||||
bool looped() const noexcept;
|
[[nodiscard]] bool looped() const noexcept;
|
||||||
|
|
||||||
flipbook_player& stopped(bool value) noexcept;
|
flipbook_player& stopped(bool value) noexcept;
|
||||||
bool stopped() const noexcept;
|
[[nodiscard]] bool stopped() const noexcept;
|
||||||
|
|
||||||
flipbook_player& playing(bool value) noexcept;
|
flipbook_player& playing(bool value) noexcept;
|
||||||
bool playing() const noexcept;
|
[[nodiscard]] bool playing() const noexcept;
|
||||||
|
|
||||||
flipbook_player& sequence(str_hash value) 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;
|
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
|
// helpers
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace e2d
|
|||||||
bool operator()(
|
bool operator()(
|
||||||
flipbook_player& component,
|
flipbook_player& component,
|
||||||
const fill_context& ctx) const;
|
const fill_context& ctx) const;
|
||||||
|
|
||||||
bool operator()(
|
bool operator()(
|
||||||
asset_dependencies& dependencies,
|
asset_dependencies& dependencies,
|
||||||
const collect_context& ctx) const;
|
const collect_context& ctx) const;
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ namespace e2d
|
|||||||
label() = default;
|
label() = default;
|
||||||
label(const font_asset::ptr& font);
|
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;
|
label& text(str value) noexcept;
|
||||||
[[nodiscard]] const str& text() const noexcept;
|
[[nodiscard]] const str& text() const noexcept;
|
||||||
|
|
||||||
@@ -120,66 +114,6 @@ namespace e2d
|
|||||||
inline label::label(const font_asset::ptr& value)
|
inline label::label(const font_asset::ptr& value)
|
||||||
: font_(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 {
|
inline label& label::text(str value) noexcept {
|
||||||
text_ = std::move(value);
|
text_ = std::move(value);
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace e2d
|
|||||||
model_renderer(const model_asset::ptr& model);
|
model_renderer(const model_asset::ptr& model);
|
||||||
|
|
||||||
model_renderer& model(const model_asset::ptr& value) noexcept;
|
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:
|
private:
|
||||||
model_asset::ptr model_;
|
model_asset::ptr model_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ namespace e2d
|
|||||||
renderer& properties(render::property_block&& value) noexcept;
|
renderer& properties(render::property_block&& value) noexcept;
|
||||||
renderer& properties(const render::property_block& value);
|
renderer& properties(const render::property_block& value);
|
||||||
|
|
||||||
render::property_block& properties() noexcept;
|
[[nodiscard]] render::property_block& properties() noexcept;
|
||||||
const render::property_block& properties() const noexcept;
|
[[nodiscard]] const render::property_block& properties() const noexcept;
|
||||||
|
|
||||||
renderer& materials(vector<material_asset::ptr>&& value) noexcept;
|
renderer& materials(vector<material_asset::ptr>&& value) noexcept;
|
||||||
renderer& materials(const vector<material_asset::ptr>& value);
|
renderer& materials(const vector<material_asset::ptr>& value);
|
||||||
|
|
||||||
vector<material_asset::ptr>& materials() noexcept;
|
[[nodiscard]] vector<material_asset::ptr>& materials() noexcept;
|
||||||
const vector<material_asset::ptr>& materials() const noexcept;
|
[[nodiscard]] const vector<material_asset::ptr>& materials() const noexcept;
|
||||||
private:
|
private:
|
||||||
render::property_block properties_;
|
render::property_block properties_;
|
||||||
vector<material_asset::ptr> materials_;
|
vector<material_asset::ptr> materials_;
|
||||||
@@ -41,7 +41,7 @@ namespace e2d
|
|||||||
bool operator()(
|
bool operator()(
|
||||||
renderer& component,
|
renderer& component,
|
||||||
const fill_context& ctx) const;
|
const fill_context& ctx) const;
|
||||||
|
|
||||||
bool operator()(
|
bool operator()(
|
||||||
asset_dependencies& dependencies,
|
asset_dependencies& dependencies,
|
||||||
const collect_context& ctx) const;
|
const collect_context& ctx) const;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace e2d
|
|||||||
scene() = default;
|
scene() = default;
|
||||||
|
|
||||||
scene& depth(i32 value) noexcept;
|
scene& depth(i32 value) noexcept;
|
||||||
i32 depth() const noexcept;
|
[[nodiscard]] i32 depth() const noexcept;
|
||||||
private:
|
private:
|
||||||
i32 depth_ = 0;
|
i32 depth_ = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,24 +28,20 @@ namespace e2d
|
|||||||
sprite_renderer(const sprite_asset::ptr& sprite);
|
sprite_renderer(const sprite_asset::ptr& sprite);
|
||||||
|
|
||||||
sprite_renderer& tint(const color32& value) noexcept;
|
sprite_renderer& tint(const color32& value) noexcept;
|
||||||
const color32& tint() const noexcept;
|
[[nodiscard]] const color32& tint() const noexcept;
|
||||||
|
|
||||||
sprite_renderer& blending(blendings value) noexcept;
|
sprite_renderer& blending(blendings value) noexcept;
|
||||||
blendings blending() const noexcept;
|
[[nodiscard]] blendings blending() const noexcept;
|
||||||
|
|
||||||
sprite_renderer& filtering(bool value) 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;
|
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(
|
sprite_renderer& materials(flat_map<str_hash, material_asset::ptr> value) noexcept;
|
||||||
flat_map<str_hash, material_asset::ptr>&& value) noexcept;
|
[[nodiscard]] const flat_map<str_hash, material_asset::ptr>& materials() const noexcept;
|
||||||
sprite_renderer& materials(
|
[[nodiscard]] material_asset::ptr find_material(str_hash name) const noexcept;
|
||||||
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;
|
|
||||||
private:
|
private:
|
||||||
color32 tint_ = color32::white();
|
color32 tint_ = color32::white();
|
||||||
blendings blending_ = blendings::normal;
|
blendings blending_ = blendings::normal;
|
||||||
@@ -62,7 +58,7 @@ namespace e2d
|
|||||||
bool operator()(
|
bool operator()(
|
||||||
sprite_renderer& component,
|
sprite_renderer& component,
|
||||||
const fill_context& ctx) const;
|
const fill_context& ctx) const;
|
||||||
|
|
||||||
bool operator()(
|
bool operator()(
|
||||||
asset_dependencies& dependencies,
|
asset_dependencies& dependencies,
|
||||||
const collect_context& ctx) const;
|
const collect_context& ctx) const;
|
||||||
@@ -110,18 +106,13 @@ namespace e2d
|
|||||||
return sprite_;
|
return sprite_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline sprite_renderer& sprite_renderer::materials(
|
inline sprite_renderer& sprite_renderer::materials(flat_map<str_hash, material_asset::ptr> value) noexcept {
|
||||||
flat_map<str_hash, material_asset::ptr>&& value) noexcept
|
|
||||||
{
|
|
||||||
materials_ = std::move(value);
|
materials_ = std::move(value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline sprite_renderer& sprite_renderer::materials(
|
inline const flat_map<str_hash, material_asset::ptr>& sprite_renderer::materials() const noexcept {
|
||||||
const flat_map<str_hash, material_asset::ptr>& value)
|
return materials_;
|
||||||
{
|
|
||||||
materials_ = value;
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline material_asset::ptr sprite_renderer::find_material(str_hash name) const noexcept {
|
inline material_asset::ptr sprite_renderer::find_material(str_hash name) const noexcept {
|
||||||
@@ -130,8 +121,4 @@ namespace e2d
|
|||||||
? iter->second
|
? iter->second
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const flat_map<str_hash, material_asset::ptr>& sprite_renderer::materials() const noexcept {
|
|
||||||
return materials_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace e2d
|
|||||||
if ( ctx.root.HasMember("blending") ) {
|
if ( ctx.root.HasMember("blending") ) {
|
||||||
sprite_renderer::blendings blending = component.blending();
|
sprite_renderer::blendings blending = component.blending();
|
||||||
if ( !parse_blending(ctx.root["blending"].GetString(), 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;
|
return false;
|
||||||
}
|
}
|
||||||
component.blending(blending);
|
component.blending(blending);
|
||||||
|
|||||||
Reference in New Issue
Block a user