Skip to content

Commit

Permalink
vehicle part descriptions: more scrolling fixes, always display if po…
Browse files Browse the repository at this point in the history
…ssible

limit the maximum amount of scroll based on the size of the w_msg, prevent
accumulation of scroll passed the maximum or minimum amount, and always
display the vehicle part descriptions if the w_msg isn't being used to
display something else.
  • Loading branch information
mlangsdorf committed Jul 25, 2018
1 parent 464ada3 commit 9202303
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ void veh_interact::do_main_loop()
bool redraw = false;
int dx = 0;
int dy = 0;
if(main_context.get_direction(dx, dy, action)) {
move_cursor(dx, dy);
if( main_context.get_direction( dx, dy, action ) ) {
move_cursor( dx, dy );
} else if( action == "QUIT" ) {
finish = true;
} else if( action == "INSTALL" ) {
Expand Down Expand Up @@ -316,10 +316,8 @@ void veh_interact::do_main_loop()
redraw = do_relabel( msg );
} else if ( action == "FUEL_LIST_DOWN" ) {
move_fuel_cursor( 1 );
move_cursor( 0, 0 );
} else if ( action == "FUEL_LIST_UP" ) {
move_fuel_cursor( -1 );
move_cursor( 0, 0 );
} else if ( action == "DESC_LIST_DOWN" ) {
move_cursor( 0, 0, 1 );
} else if ( action == "DESC_LIST_UP" ) {
Expand All @@ -344,8 +342,9 @@ void veh_interact::do_main_loop()
werase( w_msg );
fold_and_print( w_msg, 0, 1, getmaxx( w_msg ) - 2, c_light_red, msg );
wrefresh( w_msg );
} else {
move_cursor( 0, 0 );
}

}
}

Expand Down
8 changes: 5 additions & 3 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2887,14 +2887,14 @@ int vehicle::print_part_list( const catacurses::window &win, int y1, const int m

/**
* Prints a list of descriptions for all parts to the screen inside of a boxed window
* highlighting a selected one.
* @param win The window to draw in.
* @param max_y Draw no further than this y-coordinate.
* @param width The width of the window.
* @param &p The index of the part being examined.
* @param start_at Which vehicle part to start printing at.
*/
void vehicle::print_vparts_descs( const catacurses::window &win, int max_y, int width, int &p, int start_at ) const
void vehicle::print_vparts_descs( const catacurses::window &win, int max_y, int width, int &p,
int &start_at ) const
{
if( p < 0 || p >= ( int )parts.size() ) {
return;
Expand All @@ -2904,7 +2904,9 @@ void vehicle::print_vparts_descs( const catacurses::window &win, int max_y, int
std::ostringstream msg;

int lines = 0;
start_at = std::max( start_at, 0 );
/* never start before the start of the list */
/* guess the number of entries that can fit in the window, and don't scroll past that */
start_at = std::min( std::max( start_at, 0 ), max_y / 6 );
if( start_at ) {
msg << "<color_yellow>" << "< " << _( "More parts here..." ) << "</color>\n";
lines += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ class vehicle

// Vehicle parts descriptions - descriptions for all the parts on a single tile
void print_vparts_descs( const catacurses::window &win, int max_y, int width, int &p,
int start_at ) const;
int &start_at ) const;

/**
* Operate vehicle controls
Expand Down

0 comments on commit 9202303

Please sign in to comment.