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 a6f47c0
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions src/player_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ static std::vector<std::pair<bodypart_id, bool>> list_and_combine_bps( const Cha
}

static std::pair<int, int> subindex_around_cursor(
const int num_entries,
const int available_space,
const int cursor_pos,
const bool focused
)
const int num_entries, const int available_space, const int cursor_pos, const bool focused )
/**
* Return indexes [start, end) that should be displayed from list long `num_entries`,
* given that cursor is at position `cursor_pos` and we have `available_space` spaces.
Expand All @@ -119,13 +115,8 @@ static std::pair<int, int> subindex_around_cursor(
}

static void draw_scrollbar_next(
const int num_entries,
const int height,
const int width,
const int height_offset,
const int range_first,
const catacurses::window &win
)
const int num_entries, const int height, const int width, const int height_offset,
const int range_first, const catacurses::window &win )
/**
* Draw scrollbar if scrollable.
*/
Expand Down Expand Up @@ -1134,34 +1125,28 @@ 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(
const unsigned available_height, unsigned first_win_size_y_max, unsigned second_win_size_y_max )
/**
* 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
)
{
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 a6f47c0

Please sign in to comment.