Added AsloEngine 0.9.0 to Repository

This commit is contained in:
Aslan2142 2019-08-29 18:42:28 +02:00
parent d017dd84b3
commit 881e6c70f2
60 changed files with 2648 additions and 0 deletions

View file

@ -0,0 +1,52 @@
#include "headers/input_field.hpp"
namespace asloengine
{
InputField::InputField(sf::String _name, sf::Vector2f _size, sf::Font& _font, sf::Texture& _texture, uint _text_size, int _max_length, sf::String _default_text)
: text_vertical_offset(3.5), TextOnlyInputField(_name, _size, _font, _text_size, _max_length, _default_text), SpriteObject(_name, _texture), GameObject(_name) {}
InputField::~InputField() {}
void InputField::draw()
{
SpriteObject::draw();
//sf::FloatRect sprite_bounds = sprite.getLocalBounds();
//sf::View default_view = crop ? set_crop(position.x + (sprite_bounds.width - size.x) / 2, position.y, size.x, size.y * 1.5) : render_window->getView();
TextObject::draw();
//render_window->setView(default_view);
}
void InputField::on_main_property_update()
{
SpriteObject::on_main_property_update();
sf::FloatRect sprite_bounds = sprite.getLocalBounds();
sf::FloatRect text_bounds = text->getLocalBounds();
sf::Vector2f offset(0, -text_bounds.height / text_vertical_offset);
sf::Vector2f position_correction = calculate_child_position_centered(
sprite_bounds, text_bounds, offset, scale, rotation
);
text->setPosition(position.x + position_correction.x, position.y + position_correction.y);
text->setScale(scale);
text->setOrigin(origin);
text->setRotation(rotation);
sprite_bounds = sprite.getGlobalBounds();
update_clickable(sprite_bounds);
}
void InputField::on_start()
{
set_clickable(sprite.getGlobalBounds(), render_window);
}
}