Mario Editor: fix highlighting

This commit is contained in:
zvon 2021-06-04 14:49:24 +02:00
parent 301c4f3142
commit 76f55fd98c

View File

@ -166,6 +166,8 @@ void setToolColor( const std::string &color ) {
store = nullptr; store = nullptr;
break; break;
} }
if(store == nullptr)
return;
auto index = global_vars.tool.index % ( 2 * multiplier ); auto index = global_vars.tool.index % ( 2 * multiplier );
store->at( index )->setColor( color ); store->at( index )->setColor( color );
} }
@ -201,6 +203,8 @@ void updateToolSelection( int prev_index, ToolType::Value type ) {
default: default:
break; break;
} }
if(tool_vec == nullptr)
return;
auto cur = cur_page * multiplier; auto cur = cur_page * multiplier;
size_t prev = prev_index * multiplier; size_t prev = prev_index * multiplier;
for ( size_t i = prev; for ( size_t i = prev;
@ -215,9 +219,10 @@ void updateToolSelection( int prev_index, ToolType::Value type ) {
i++ ) { i++ ) {
tool_vec->at( i )->setHidden( false ); tool_vec->at( i )->setHidden( false );
} }
if ( global_vars.tool.index / multiplier == cur_page ) if ( global_vars.tool.index / multiplier == cur_page ) {
setToolColor(); setToolColor();
} }
}
void moveToolsLeft( ToolType::Value type ) { void moveToolsLeft( ToolType::Value type ) {
switch ( type ) { switch ( type ) {
@ -255,7 +260,7 @@ void moveToolsRight( ToolType::Value type ) {
} }
} }
void updateToolIndex( uint64_t new_index ) { void updateToolIndex( uint64_t new_index, ToolType::Value new_type ) {
int multiplier = 0; int multiplier = 0;
int *page = nullptr; int *page = nullptr;
switch ( global_vars.tool.type ) { switch ( global_vars.tool.type ) {
@ -274,6 +279,7 @@ void updateToolIndex( uint64_t new_index ) {
break; break;
} }
unsetToolColor(); unsetToolColor();
global_vars.tool.type = new_type;
global_vars.tool.index = new_index; global_vars.tool.index = new_index;
setToolColor(); setToolColor();
updateTool(); updateTool();
@ -284,6 +290,10 @@ void updateToolIndex( uint64_t new_index ) {
} }
} }
void updateToolIndex( uint64_t new_index ) {
updateToolIndex(new_index, global_vars.tool.type);
}
void selectLowerTool() { void selectLowerTool() {
int multiplier = 0; int multiplier = 0;
size_t max_index = 0; size_t max_index = 0;
@ -695,8 +705,7 @@ void pollEvents( SDLPP::Scene &scene ) {
global_vars.current_world_type = possibleLands[index]; global_vars.current_world_type = possibleLands[index];
updateWorld(); updateWorld();
} else if ( index < max_index ) { } else if ( index < max_index ) {
global_vars.tool.type = global_vars.mouse.tool_type; updateToolIndex( cur_page * multiplier + index, global_vars.mouse.tool_type );
updateToolIndex( cur_page * multiplier + index );
} }
} }
break; break;