Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically scale overmap legend width #36662

Merged
merged 1 commit into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overmap window can have a different w´font than the rest of the game windows. Have you checked what happens when the overmap font is much larger and what if it the font is much smaller? I assume it's possible the overmap window itself overlays the legend window. Or the legend window is just too much to the left, so it's under the overmap window.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked what happens when the overmap font is much larger and what if it the font is much smaller?

No, I tested it only on default font dimensions.

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