TODOs
This commit is contained in:
parent
2661d6ca76
commit
fa10620901
@ -50,19 +50,6 @@ void CircleRender::setOutlineColor( const std::string &color ) {
|
||||
polygon->setOutlineColor( color );
|
||||
}
|
||||
|
||||
void CircleRender::render() {
|
||||
if ( !getHidden() ) {
|
||||
if ( polygon )
|
||||
polygon->render( *renderer );
|
||||
else
|
||||
std::cerr << "I don't support textures on circles yet!" << std::endl;
|
||||
if ( hasCollisions() && renderer->getRenderColiders() ) {
|
||||
for ( const auto &col : getCollisions() )
|
||||
col->render( *renderer, colider_color );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::pair< std::pair< double, double >, std::pair< double, double > >
|
||||
CircleRender::getDoubleRect() const {
|
||||
return { { og_x - og_r, og_y - og_r }, { 2 * og_r, 2 * og_r } };
|
||||
|
@ -19,7 +19,6 @@ public:
|
||||
virtual void setColor( const std::string &color ) override;
|
||||
virtual void setOutlineColor( const std::string &color ) override;
|
||||
virtual void specialAction( int /*UNUSED*/ ) override{}
|
||||
virtual void render() override;
|
||||
virtual void custom_move( int /*UNUSED*/ ) override{}
|
||||
virtual std::pair< std::pair< double, double >,
|
||||
std::pair< double, double > >
|
||||
@ -43,8 +42,6 @@ private:
|
||||
void updateXY();
|
||||
double og_r;
|
||||
double r_;
|
||||
bool centerx = false;
|
||||
SDL_Rect rect;
|
||||
std::string color = "";
|
||||
};
|
||||
} // end of namespace SDLPP
|
||||
|
@ -45,19 +45,6 @@ void RectangleRender::setOutlineColor( const std::string &color ) {
|
||||
}
|
||||
polygon->setOutlineColor( color );
|
||||
}
|
||||
void RectangleRender::render() {
|
||||
if ( !getHidden() ) {
|
||||
if ( polygon )
|
||||
polygon->render( *renderer );
|
||||
if ( texture != NULL )
|
||||
SDL_RenderCopy( renderer->getRendererPtr(),
|
||||
texture->getTexturePtr(), NULL, &rect );
|
||||
if ( hasCollisions() && renderer->getRenderColiders() ) {
|
||||
for ( const auto &col : getCollisions() )
|
||||
col->render( *renderer, colider_color );
|
||||
}
|
||||
}
|
||||
}
|
||||
std::pair< std::pair< double, double >, std::pair< double, double > >
|
||||
RectangleRender::getDoubleRect() const {
|
||||
return { { og_x, og_y }, { og_w, og_h } };
|
||||
|
@ -22,7 +22,6 @@ public:
|
||||
virtual void setColor( const std::string &color ) override;
|
||||
virtual void setOutlineColor( const std::string &color ) override;
|
||||
virtual void specialAction( int /*UNUSED*/ ) override{}
|
||||
virtual void render() override;
|
||||
virtual void custom_move( int /*UNUSED*/ ) override {}
|
||||
virtual std::pair< std::pair< double, double >,
|
||||
std::pair< double, double > >
|
||||
@ -48,8 +47,6 @@ protected:
|
||||
double og_h;
|
||||
double w_;
|
||||
double h_;
|
||||
bool centerx = false;
|
||||
SDL_Rect rect;
|
||||
std::string color = "";
|
||||
};
|
||||
} // end of namespace SDLPP
|
||||
|
@ -2,6 +2,19 @@
|
||||
#include <cmath>
|
||||
|
||||
namespace SDLPP {
|
||||
void RenderObject::render() {
|
||||
if ( !getHidden() ) {
|
||||
if ( polygon )
|
||||
polygon->render( *renderer );
|
||||
if ( texture != NULL )
|
||||
SDL_RenderCopy( renderer->getRendererPtr(),
|
||||
texture->getTexturePtr(), NULL, &rect );
|
||||
if ( hasCollisions() && renderer->getRenderColiders() ) {
|
||||
for ( const auto &col : getCollisions() )
|
||||
col->render( *renderer, colider_color );
|
||||
}
|
||||
}
|
||||
}
|
||||
void RenderObject::setPos( double x, double y ) {
|
||||
og_x = x;
|
||||
og_y = y;
|
||||
|
@ -16,8 +16,7 @@ class SDLPPSCOPE RenderObject {
|
||||
public:
|
||||
RenderObject( const std::shared_ptr< Renderer > &r ) : renderer( r ) {}
|
||||
virtual ~RenderObject() {}
|
||||
// TODO maybe do basic render() that all descandants can inherit?
|
||||
virtual void render() = 0;
|
||||
virtual void render();
|
||||
virtual int leftmost() = 0;
|
||||
virtual int topmost() = 0;
|
||||
virtual int rightmost() = 0;
|
||||
@ -97,6 +96,8 @@ protected:
|
||||
uint64_t scene_id = -1;
|
||||
bool permanent = false;
|
||||
bool is_static = true;
|
||||
bool centerx = false;
|
||||
SDL_Rect rect;
|
||||
|
||||
private:
|
||||
void setSceneID( int id );
|
||||
|
@ -66,10 +66,7 @@ void TextRenderer::render() {
|
||||
col->render( *renderer, colider_color );
|
||||
}
|
||||
}
|
||||
// TODO move this to method updateTexture and call that function from this
|
||||
void TextRenderer::updateSizeAndPosition() {
|
||||
RectangleRender::updateSizeAndPosition();
|
||||
|
||||
void TextRenderer::updateTexture() {
|
||||
int fontSize = 0.6 * getRect().h;
|
||||
_config->getFont()->changeFontSize( fontSize );
|
||||
int intOutline = _config->getOutlineSize();
|
||||
@ -79,7 +76,10 @@ void TextRenderer::updateSizeAndPosition() {
|
||||
setTexture( *_config->getFont(), _text, _config->getColor(),
|
||||
_config->getOutlineColor(), intOutline );
|
||||
_config->getFont()->revertSize();
|
||||
|
||||
}
|
||||
void TextRenderer::updateSizeAndPosition() {
|
||||
RectangleRender::updateSizeAndPosition();
|
||||
updateTexture();
|
||||
updateDstRect();
|
||||
}
|
||||
std::shared_ptr< RenderObject > TextRenderer::copySelf() {
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual void copyTo( std::shared_ptr< RenderObject > other ) override;
|
||||
void updateTexture();
|
||||
void updateDstRect();
|
||||
void saveFontConfig( std::shared_ptr< Font > font, const std::string &color,
|
||||
const std::string &outline_color,
|
||||
|
Loading…
Reference in New Issue
Block a user