TETRIS: static_cast might be faster than dynamic cast
This commit is contained in:
parent
ad1805101c
commit
7f661630c0
@ -393,7 +393,7 @@ tetrisZLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||
void updateTextSizeInternal(std::shared_ptr<SDLPP::RenderObject> input) {
|
||||
if(input->getKilled())
|
||||
return;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >( input )->setTextColor(
|
||||
static_cast< SDLPP::TextRenderer* >( input.get() )->setTextColor(
|
||||
*g_font, colors["text"], colors["text_out"], 0.1 );
|
||||
}
|
||||
|
||||
@ -437,7 +437,7 @@ void updateColors() {
|
||||
x->setColor( colors["line"] );
|
||||
}
|
||||
for ( auto &x : g_main_scene->getObjects( { TEXT_ID } ) ) {
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >( x )->setTextColor(
|
||||
static_cast< SDLPP::TextRenderer* >( x.get() )->setTextColor(
|
||||
*g_font, colors["text"], colors["text_out"], 0.1 );
|
||||
}
|
||||
g_menu_options[g_menu_select]->setColor( colors["menu_item_background"] );
|
||||
|
@ -693,24 +693,24 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
if ( static_cast< size_t >( selected_color_scheme ) >=
|
||||
color_schemes_names.size() )
|
||||
selected_color_scheme = 0;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >(
|
||||
g_options_options[OPTIONS_MENU_COLOR_SCHEME] )
|
||||
static_cast< SDLPP::TextRenderer * >(
|
||||
g_options_options[OPTIONS_MENU_COLOR_SCHEME].get() )
|
||||
->changeText( "Color scheme: " +
|
||||
color_schemes_names[selected_color_scheme] );
|
||||
g_update_colors = true;
|
||||
break;
|
||||
case OPTIONS_MENU_SHADOW:
|
||||
g_show_shadow = !g_show_shadow;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >(
|
||||
g_options_options[OPTIONS_MENU_SHADOW] )
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
g_options_options[OPTIONS_MENU_SHADOW].get() )
|
||||
->changeText( std::string( "Show shadow: " ) +
|
||||
( g_show_shadow ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
break;
|
||||
case OPTIONS_MENU_3D:
|
||||
g_show_3d = !g_show_3d;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >(
|
||||
g_options_options[OPTIONS_MENU_3D] )
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
g_options_options[OPTIONS_MENU_3D].get() )
|
||||
->changeText( std::string( "Show block texture: " ) +
|
||||
( g_show_3d ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
@ -725,24 +725,24 @@ void handleKeyDownOptions( SDL_Keycode key ) {
|
||||
if ( selected_color_scheme == 0 )
|
||||
selected_color_scheme = color_schemes_names.size();
|
||||
selected_color_scheme--;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >(
|
||||
g_options_options[OPTIONS_MENU_COLOR_SCHEME] )
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
g_options_options[OPTIONS_MENU_COLOR_SCHEME].get() )
|
||||
->changeText( "Color scheme: " +
|
||||
color_schemes_names[selected_color_scheme] );
|
||||
g_update_colors = true;
|
||||
break;
|
||||
case OPTIONS_MENU_SHADOW:
|
||||
g_show_shadow = !g_show_shadow;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >(
|
||||
g_options_options[OPTIONS_MENU_SHADOW] )
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
g_options_options[OPTIONS_MENU_SHADOW].get() )
|
||||
->changeText( std::string( "Show shadow: " ) +
|
||||
( g_show_shadow ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
break;
|
||||
case OPTIONS_MENU_3D:
|
||||
g_show_3d = !g_show_3d;
|
||||
std::dynamic_pointer_cast< SDLPP::TextRenderer >(
|
||||
g_options_options[OPTIONS_MENU_3D] )
|
||||
static_cast< SDLPP::TextRenderer* >(
|
||||
g_options_options[OPTIONS_MENU_3D].get() )
|
||||
->changeText( std::string( "Show block texture: " ) +
|
||||
( g_show_3d ? "YES" : "NO" ) );
|
||||
g_update_colors = true;
|
||||
|
Loading…
Reference in New Issue
Block a user