Skip to content

Commit

Permalink
Dynamically scale overmap legend width (#36662)
Browse files Browse the repository at this point in the history
  • Loading branch information
Night-Pryanik authored and kevingranade committed Jan 4, 2020
1 parent 6df71be commit a758fa6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void game::init_ui( const bool resized )
/**
* Doing the same thing as above for the overmap
*/
static const int OVERMAP_LEGEND_WIDTH = 28;
OVERMAP_LEGEND_WIDTH = clamp( TERMX / 5, 28, 55 );
OVERMAP_WINDOW_HEIGHT = TERMY;
OVERMAP_WINDOW_WIDTH = TERMX - OVERMAP_LEGEND_WIDTH;
to_overmap_font_dimension( OVERMAP_WINDOW_WIDTH, OVERMAP_WINDOW_HEIGHT );
Expand Down
2 changes: 2 additions & 0 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ int FULL_SCREEN_HEIGHT;
int OVERMAP_WINDOW_HEIGHT;
int OVERMAP_WINDOW_WIDTH;

int OVERMAP_LEGEND_WIDTH;

static std::string rm_prefix( std::string str, char c1 = '<', char c2 = '>' );

scrollingcombattext SCT;
Expand Down
1 change: 1 addition & 0 deletions src/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ extern int FULL_SCREEN_WIDTH; // width of "full screen" popups
extern int FULL_SCREEN_HEIGHT; // height of "full screen" popups
extern int OVERMAP_WINDOW_WIDTH; // width of overmap window
extern int OVERMAP_WINDOW_HEIGHT; // height of overmap window
extern int OVERMAP_LEGEND_WIDTH; // width of overmap window legend

nc_color msgtype_to_color( game_message_type type, bool bOldMsg = false );

Expand Down
8 changes: 4 additions & 4 deletions src/overmap_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ void draw( const catacurses::window &w, const catacurses::window &wbar, const tr
}

// Clear the legend
for( int i = 1; i < 55; i++ ) {
for( int i = 1; i < getmaxx( wbar ); i++ ) {
for( int j = 0; j < TERMY; j++ ) {
mvwputch( wbar, point( i, j ), c_black, ' ' );
}
Expand Down Expand Up @@ -909,7 +909,7 @@ void draw( const catacurses::window &w, const catacurses::window &wbar, const tr
// NOLINTNEXTLINE(cata-use-named-point-constants)
mvwputch( wbar, point( 1, 1 ), ter.get_color(), ter.get_symbol() );

lines = fold_and_print( wbar, point( 3, 1 ), 25, c_light_gray,
lines = fold_and_print( wbar, point( 3, 1 ), getmaxx( wbar ) - 3, c_light_gray,
overmap_buffer.get_description_at( sm_pos ) );
}
} else if( viewing_weather ) {
Expand Down Expand Up @@ -959,7 +959,7 @@ void draw( const catacurses::window &w, const catacurses::window &wbar, const tr
int y = 16;

const auto print_hint = [&]( const std::string & action, nc_color color = c_magenta ) {
y += fold_and_print( wbar, point( 1, y ), 27, color, string_format( _( "%s - %s" ),
y += fold_and_print( wbar, point( 1, y ), getmaxx( wbar ) - 1, color, string_format( _( "%s - %s" ),
inp_ctxt->get_desc( action ),
inp_ctxt->get_action_name( action ) ) );
};
Expand Down Expand Up @@ -1311,7 +1311,7 @@ static void place_ter_or_special( tripoint &curs, const tripoint &orig, const bo

static tripoint display( const tripoint &orig, const draw_data_t &data = draw_data_t() )
{
g->w_omlegend = catacurses::newwin( TERMY, 28, point( TERMX - 28, 0 ) );
g->w_omlegend = catacurses::newwin( TERMY, OVERMAP_LEGEND_WIDTH, point( OVERMAP_WINDOW_WIDTH, 0 ) );
g->w_overmap = catacurses::newwin( OVERMAP_WINDOW_HEIGHT, OVERMAP_WINDOW_WIDTH, point_zero );

// Draw black padding space to avoid gap between map and legend
Expand Down

0 comments on commit a758fa6

Please sign in to comment.