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

Fix redraw of various menus after keybinding help menu was drawn on top #36781

Merged
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
37 changes: 23 additions & 14 deletions src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,22 +736,30 @@ void color_manager::show_gui()
catacurses::window w_colors = catacurses::newwin( iContentHeight, FULL_SCREEN_WIDTH - 2,
point( 1 + iOffsetX, iHeaderHeight + 1 + iOffsetY ) );

draw_border( w_colors_border, BORDER_COLOR, _( " COLOR MANAGER " ) );
mvwputch( w_colors_border, point( 0, 3 ), BORDER_COLOR, LINE_XXXO ); // |-
mvwputch( w_colors_border, point( getmaxx( w_colors_border ) - 1, 3 ), BORDER_COLOR,
LINE_XOXX ); // -|

for( auto &iCol : vLines ) {
if( iCol > -1 ) {
mvwputch( w_colors_border, point( iCol + 1, FULL_SCREEN_HEIGHT - 1 ), BORDER_COLOR,
LINE_XXOX ); // _|_
mvwputch( w_colors_header, point( iCol, 3 ), BORDER_COLOR, LINE_XOXO );
/**
* All of the stuff in this lambda needs to be drawn (1) initially, and
* (2) after closing the HELP_KEYBINDINGS window (since it mangles the screen)
*/
const auto initial_draw = [&]() {
draw_border( w_colors_border, BORDER_COLOR, _( " COLOR MANAGER " ) );
mvwputch( w_colors_border, point( 0, 3 ), BORDER_COLOR, LINE_XXXO ); // |-
mvwputch( w_colors_border, point( getmaxx( w_colors_border ) - 1, 3 ), BORDER_COLOR,
LINE_XOXX ); // -|

for( auto &iCol : vLines ) {
if( iCol > -1 ) {
mvwputch( w_colors_border, point( iCol + 1, FULL_SCREEN_HEIGHT - 1 ), BORDER_COLOR,
LINE_XXOX ); // _|_
mvwputch( w_colors_header, point( iCol, 3 ), BORDER_COLOR, LINE_XOXO );
}
}
}
wrefresh( w_colors_border );
wrefresh( w_colors_border );

draw_header( w_colors_header );

draw_header( w_colors_header );
};

initial_draw();
int iCurrentLine = 0;
int iCurrentCol = 1;
int iStartPos = 0;
Expand Down Expand Up @@ -936,6 +944,7 @@ void color_manager::show_gui()
}

ui_colors.query();
initial_draw();

if( ui_colors.ret >= 0 && static_cast<size_t>( ui_colors.ret ) < name_color_map.size() ) {
bStuffChanged = true;
Expand All @@ -956,7 +965,7 @@ void color_manager::show_gui()

finalize(); // Need to recalculate caches
} else if( action == "HELP_KEYBINDINGS" ) {
draw_header( w_colors_header );
initial_draw();
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ bool main_menu::opening_screen()
get_options().show( true );
// The language may have changed- gracefully handle this.
init_strings();
print_menu( w_open, sel1, menu_offset );
} else if( sel2 == 1 ) {
input_context ctxt_default = get_default_mode_input_context();
ctxt_default.display_menu();
Expand Down
6 changes: 4 additions & 2 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,7 @@ std::string options_manager::show( bool ingame, const bool world_options_only )
const int iContentHeight = TERMY - 3 - iTooltipHeight - iWorldOffset;

std::map<int, bool> mapLines;
std::map<int, bool> mapLinesOriginal;
mapLines[4] = true;
mapLines[60] = true;

Expand All @@ -2439,6 +2440,7 @@ std::string options_manager::show( bool ingame, const bool world_options_only )
worldfactory::draw_worldgen_tabs( w_options_border, 1 );
}

mapLinesOriginal = mapLines;
draw_borders_external( w_options_border, iTooltipHeight + 1 + iWorldOffset, mapLines,
world_options_only );
draw_borders_internal( w_options_header, mapLines );
Expand Down Expand Up @@ -2689,8 +2691,8 @@ std::string options_manager::show( bool ingame, const bool world_options_only )
}
}
} else if( action == "HELP_KEYBINDINGS" ) {
// keybinding screen erased the internal borders of main menu, restore it:
draw_borders_internal( w_options_header, mapLines );
draw_borders_external( w_options_border, iTooltipHeight + 1 + iWorldOffset, mapLinesOriginal,
world_options_only );
} else if( action == "QUIT" ) {
catacurses::clear();
catacurses::refresh();
Expand Down
87 changes: 49 additions & 38 deletions src/safemode_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,54 +82,62 @@ void safemode::show( const std::string &custom_name_in, bool is_safemode_in )
catacurses::newwin( content_height, FULL_SCREEN_WIDTH - 2,
point( 1 + offset_x, header_height + 1 + offset_y ) );

draw_border( w_border, BORDER_COLOR, custom_name_in );

mvwputch( w_border, point( 0, 3 ), c_light_gray, LINE_XXXO ); // |-
mvwputch( w_border, point( 79, 3 ), c_light_gray, LINE_XOXX ); // -|
/**
* All of the stuff in this lambda needs to be drawn (1) initially, and
* (2) after closing the HELP_KEYBINDINGS window (since it mangles the screen)
*/
const auto initial_draw = [&]() {
draw_border( w_border, BORDER_COLOR, custom_name_in );

mvwputch( w_border, point( 0, 3 ), c_light_gray, LINE_XXXO ); // |-
mvwputch( w_border, point( 79, 3 ), c_light_gray, LINE_XOXX ); // -|

for( auto &column : column_pos ) {
// _|_
mvwputch( w_border, point( column.second + 1, FULL_SCREEN_HEIGHT - 1 ), c_light_gray, LINE_XXOX );
}

for( auto &column : column_pos ) {
// _|_
mvwputch( w_border, point( column.second + 1, FULL_SCREEN_HEIGHT - 1 ), c_light_gray, LINE_XXOX );
}
wrefresh( w_border );

wrefresh( w_border );
static const std::vector<std::string> hotkeys = {{
translate_marker( "<A>dd" ), translate_marker( "<R>emove" ),
translate_marker( "<C>opy" ), translate_marker( "<M>ove" ),
translate_marker( "<E>nable" ), translate_marker( "<D>isable" ),
translate_marker( "<T>est" )
}
};

static const std::vector<std::string> hotkeys = {{
translate_marker( "<A>dd" ), translate_marker( "<R>emove" ),
translate_marker( "<C>opy" ), translate_marker( "<M>ove" ),
translate_marker( "<E>nable" ), translate_marker( "<D>isable" ),
translate_marker( "<T>est" )
int tmpx = 0;
for( auto &hotkey : hotkeys ) {
tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( hotkey ) ) + 2;
}
};

int tmpx = 0;
for( auto &hotkey : hotkeys ) {
tmpx += shortcut_print( w_header, point( tmpx, 0 ), c_white, c_light_green, _( hotkey ) ) + 2;
}
tmpx = 0;
tmpx += shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green,
_( "<+-> Move up/down" ) ) + 2;
tmpx += shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green,
_( "<Enter>-Edit" ) ) + 2;
shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green, _( "<Tab>-Switch Page" ) );

tmpx = 0;
tmpx += shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green,
_( "<+-> Move up/down" ) ) + 2;
tmpx += shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green,
_( "<Enter>-Edit" ) ) + 2;
shortcut_print( w_header, point( tmpx, 1 ), c_white, c_light_green, _( "<Tab>-Switch Page" ) );
for( int i = 0; i < 78; i++ ) {
mvwputch( w_header, point( i, 2 ), c_light_gray, LINE_OXOX ); // Draw line under header
}

for( int i = 0; i < 78; i++ ) {
mvwputch( w_header, point( i, 2 ), c_light_gray, LINE_OXOX ); // Draw line under header
}
for( auto &pos : column_pos ) {
mvwputch( w_header, point( pos.second, 2 ), c_light_gray, LINE_OXXX );
mvwputch( w_header, point( pos.second, 3 ), c_light_gray, LINE_XOXO );
}

for( auto &pos : column_pos ) {
mvwputch( w_header, point( pos.second, 2 ), c_light_gray, LINE_OXXX );
mvwputch( w_header, point( pos.second, 3 ), c_light_gray, LINE_XOXO );
}
mvwprintz( w_header, point( 1, 3 ), c_white, "#" );
mvwprintz( w_header, point( column_pos[COLUMN_RULE] + 4, 3 ), c_white, _( "Rules" ) );
mvwprintz( w_header, point( column_pos[COLUMN_ATTITUDE] + 2, 3 ), c_white, _( "Attitude" ) );
mvwprintz( w_header, point( column_pos[COLUMN_PROXIMITY] + 2, 3 ), c_white, _( "Dist" ) );
mvwprintz( w_header, point( column_pos[COLUMN_WHITE_BLACKLIST] + 2, 3 ), c_white, _( "B/W" ) );

mvwprintz( w_header, point( 1, 3 ), c_white, "#" );
mvwprintz( w_header, point( column_pos[COLUMN_RULE] + 4, 3 ), c_white, _( "Rules" ) );
mvwprintz( w_header, point( column_pos[COLUMN_ATTITUDE] + 2, 3 ), c_white, _( "Attitude" ) );
mvwprintz( w_header, point( column_pos[COLUMN_PROXIMITY] + 2, 3 ), c_white, _( "Dist" ) );
mvwprintz( w_header, point( column_pos[COLUMN_WHITE_BLACKLIST] + 2, 3 ), c_white, _( "B/W" ) );
wrefresh( w_header );
};

wrefresh( w_header );
initial_draw();

int tab = GLOBAL_TAB;
int line = 0;
Expand Down Expand Up @@ -245,6 +253,9 @@ void safemode::show( const std::string &custom_name_in, bool is_safemode_in )
tab = MAX_TAB - 1;
line = 0;
}
} else if( action == "HELP_KEYBINDINGS" ) {
// de-mangle parts of the screen
initial_draw();
} else if( action == "QUIT" ) {
break;
} else if( tab == CHARACTER_TAB && g->u.name.empty() ) {
Expand Down
8 changes: 7 additions & 1 deletion src/worldfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ std::string worldfactory::pick_random_name()
return get_next_valid_worldname();
}

int worldfactory::show_worldgen_tab_options( const catacurses::window &/*win*/, WORLDPTR world )
int worldfactory::show_worldgen_tab_options( const catacurses::window &win, WORLDPTR world )
{
get_options().set_world_options( &world->WORLD_OPTIONS );
const std::string action = get_options().show( false, true );
Expand All @@ -591,6 +591,10 @@ int worldfactory::show_worldgen_tab_options( const catacurses::window &/*win*/,
} else if( action == "NEXT_TAB" ) {
return 1;

} else if( action == "HELP_KEYBINDINGS" ) {
draw_worldgen_tabs( win, 1 );
catacurses::refresh();

} else if( action == "QUIT" ) {
return -999;
}
Expand Down Expand Up @@ -1194,6 +1198,8 @@ int worldfactory::show_worldgen_tab_confirm( const catacurses::window &win, WORL
} else if( action == "PICK_RANDOM_WORLDNAME" ) {
mvwprintz( w_confirmation, point( namebar_x, namebar_y ), c_light_gray, line_of_32_underscores );
world->world_name = worldname = pick_random_name();
} else if( action == "HELP_KEYBINDINGS" ) {
draw_worldgen_tabs( win, 2 );
} else if( action == "QUIT" ) {
// Cache the current name just in case they say No to the exit query.
world->world_name = worldname;
Expand Down