Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Brambor committed Aug 20, 2021
1 parent adf2ff8 commit 8e21424
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/player_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,34 +1134,32 @@ static bool handle_player_display_action( Character &you, unsigned int &line,
return done;
}

static std::pair<unsigned int, unsigned int> calculate_shared_column_win_height
static std::pair<unsigned, unsigned> calculate_shared_column_win_height
/**
* Calculate max allowed height of two windows sharing column space.
*/
(
const unsigned int available_height,
const unsigned int first_win_size_y_max,
const unsigned int second_win_size_y_max
const unsigned available_height,
unsigned first_win_size_y_max,
unsigned second_win_size_y_max
)
{
unsigned int first_win_size_y = first_win_size_y_max;
unsigned int second_win_size_y = second_win_size_y_max;
if( ( second_win_size_y_max + 1 + first_win_size_y_max ) > available_height ) {
// maximum space for either window if they're both the same size
unsigned max_shared_y = ( available_height - 1 ) / 2;
if( std::min( second_win_size_y_max, first_win_size_y_max ) > max_shared_y ) {
// both are larger than the shared size
second_win_size_y = max_shared_y;
first_win_size_y = available_height - 1 - second_win_size_y;
second_win_size_y_max = max_shared_y;
first_win_size_y_max = available_height - 1 - second_win_size_y_max;
} else if( first_win_size_y_max <= max_shared_y ) {
// first window is less than the shared size, so give space to second window
second_win_size_y = available_height - 1 - first_win_size_y_max;
second_win_size_y_max = available_height - 1 - first_win_size_y_max;
} else {
// second window is less than the shared size
first_win_size_y = available_height - 1 - second_win_size_y;
first_win_size_y_max = available_height - 1 - second_win_size_y_max;
}
}
return std::make_pair( first_win_size_y, second_win_size_y );
return std::make_pair( first_win_size_y_max, second_win_size_y_max );
}

void Character::disp_info()
Expand Down

0 comments on commit 8e21424

Please sign in to comment.