TETRIS: use updated TextRenderer
This commit is contained in:
+32
-5
@@ -390,6 +390,36 @@ tetrisZLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||
return retPiece;
|
||||
}
|
||||
|
||||
void updateTextSizeInternal(std::shared_ptr<SDLPP::RenderObject> input) {
|
||||
if(input->getKilled())
|
||||
return;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >( input )->setTextColor(
|
||||
*g_font, colors["text"], colors["text_out"], 0.1 );
|
||||
}
|
||||
|
||||
void updateSize() {
|
||||
// have to resize rectangles for the text to be resized correctly
|
||||
g_main_scene->updateSizeAndPosition();
|
||||
g_menu_scene->updateSizeAndPosition();
|
||||
g_game_over_scene->updateSizeAndPosition();
|
||||
g_options_scene->updateSizeAndPosition();
|
||||
|
||||
std::unordered_set<int> textObjects = { TEXT_ID, MENU_TEXT_ID, MENU_ITEM_ID };
|
||||
for( auto &x : g_main_scene->getObjects( textObjects ) ) {
|
||||
updateTextSizeInternal(x);
|
||||
}
|
||||
updateTextSizeInternal(g_score_texture);
|
||||
for( auto &x : g_menu_scene->getObjects( textObjects ) ) {
|
||||
updateTextSizeInternal(x);
|
||||
}
|
||||
for( auto &x : g_game_over_scene->getObjects( textObjects ) ) {
|
||||
updateTextSizeInternal(x);
|
||||
}
|
||||
for( auto &x : g_options_scene->getObjects( textObjects ) ) {
|
||||
updateTextSizeInternal(x);
|
||||
}
|
||||
}
|
||||
|
||||
void updateColors() {
|
||||
for ( auto &x : g_main_scene->getObjects( { BRICK_ID, SHADOW_ID } ) ) {
|
||||
x->specialAction( PIECE_ACTION_UPDATE_COLOR );
|
||||
@@ -408,7 +438,7 @@ void updateColors() {
|
||||
}
|
||||
for ( auto &x : g_main_scene->getObjects( { TEXT_ID } ) ) {
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >( x )->setTextColor(
|
||||
*g_font, colors["text"], colors["text_out"], 5 );
|
||||
*g_font, colors["text"], colors["text_out"], 0.1 );
|
||||
}
|
||||
g_menu_options[g_menu_select]->setColor( colors["menu_item_background"] );
|
||||
g_game_over_options[g_game_over_select]->setColor(
|
||||
@@ -424,8 +454,5 @@ void updateColors() {
|
||||
for ( auto &x : g_options_scene->getObjects( { MENU_BACKGROUND_ID } ) ) {
|
||||
x->setColor( colors["menu_background"] );
|
||||
}
|
||||
for ( auto &x : g_options_scene->getObjects( { MENU_ITEM_ID } ) ) {
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >( x )->setTextColor(
|
||||
*g_font, colors["text"], colors["text_out"] );
|
||||
}
|
||||
updateSize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user