diff --git a/src/animation.cpp b/src/animation.cpp index 71eebdbe54400..6f5b6d587245b 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -471,7 +471,7 @@ void draw_hit_mon_curses( const tripoint ¢er, const monster &m, const player const bool dead ) { const tripoint p = relative_view_pos( u, center ); - hit_animation( p.x, p.y, red_background( m.type->color ), dead ? "%" : m.symbol() ); + hit_animation( p.xy(), red_background( m.type->color ), dead ? "%" : m.symbol() ); } } // namespace @@ -507,7 +507,7 @@ void draw_hit_player_curses( const game &g, const player &p, const int dam ) if( q.z == 0 ) { nc_color const col = !dam ? yellow_background( p.symbol_color() ) : red_background( p.symbol_color() ); - hit_animation( q.x, q.y, col, p.symbol() ); + hit_animation( q.xy(), col, p.symbol() ); } } } //namespace diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index bd7d4a5d0d81e..48dd287cb0ae3 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -174,7 +174,7 @@ void user_interface::show() const bool currentPageNonEmpty = !cur_rules.empty(); - draw_scrollbar( w_border, iLine, iContentHeight, cur_rules.size(), 5 ); + draw_scrollbar( w_border, iLine, iContentHeight, cur_rules.size(), point( 0, 5 ) ); wrefresh( w_border ); calcStartPos( iStartPos, iLine, iContentHeight, cur_rules.size() ); diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index f4040f2c15007..817ab763a05d3 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -468,7 +468,7 @@ void player::power_bionics() } } - draw_scrollbar( wBio, cursor, LIST_HEIGHT, current_bionic_list->size(), list_start_y ); + draw_scrollbar( wBio, cursor, LIST_HEIGHT, current_bionic_list->size(), point( 0, list_start_y ) ); #if defined(__ANDROID__) ctxt.get_registered_manual_keys().clear(); diff --git a/src/color.cpp b/src/color.cpp index ae907110a68c5..b49d37bebcecd 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -787,7 +787,7 @@ void color_manager::show_gui() calcStartPos( iStartPos, iCurrentLine, iContentHeight, iMaxColors ); - draw_scrollbar( w_colors_border, iCurrentLine, iContentHeight, iMaxColors, 5 ); + draw_scrollbar( w_colors_border, iCurrentLine, iContentHeight, iMaxColors, point( 0, 5 ) ); wrefresh( w_colors_border ); auto iter = name_color_map.begin(); diff --git a/src/construction.cpp b/src/construction.cpp index 1ff982dc09309..6a325daa211b1 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -579,7 +579,7 @@ int construction_menu( bool blueprint ) } } // Finished updating - draw_scrollbar( w_con, select, w_list_height, constructs.size(), 3 ); + draw_scrollbar( w_con, select, w_list_height, constructs.size(), point( 0, 3 ) ); wrefresh( w_con ); wrefresh( w_list ); diff --git a/src/crafting_gui.cpp b/src/crafting_gui.cpp index 2927be82e6b8a..244b97202fbe4 100644 --- a/src/crafting_gui.cpp +++ b/src/crafting_gui.cpp @@ -651,7 +651,7 @@ const recipe *select_crafting_recipe( int &batch_size ) } } - draw_scrollbar( w_data, line, dataLines, recmax, 0 ); + draw_scrollbar( w_data, line, dataLines, recmax, point_zero ); wrefresh( w_data ); if( isWide ) { diff --git a/src/creature.cpp b/src/creature.cpp index 622ec231a2da1..510850810bc55 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -776,13 +776,13 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack } else if( source != nullptr ) { if( source->is_player() ) { //player hits monster ranged - SCT.add( posx(), posy(), + SCT.add( point( posx(), posy() ), direction_from( point_zero, point( posx() - source->posx(), posy() - source->posy() ) ), get_hp_bar( dealt_dam.total_damage(), get_hp_max(), true ).first, m_good, message, gmtSCTcolor ); if( get_hp() > 0 ) { - SCT.add( posx(), posy(), + SCT.add( point( posx(), posy() ), direction_from( point_zero, point( posx() - source->posx(), posy() - source->posy() ) ), get_hp_bar( get_hp(), get_hp_max(), true ).first, m_good, //~ "hit points", used in scrolling combat text diff --git a/src/faction.cpp b/src/faction.cpp index 92ee720d40f87..495856162f1ba 100644 --- a/src/faction.cpp +++ b/src/faction.cpp @@ -659,7 +659,7 @@ void new_faction_manager::display() const case tab_mode::TAB_MYFACTION: if( active_vec_size > 0 ) { draw_scrollbar( w_missions, selection, entries_per_page, active_vec_size, - 3, 0 ); + point( 0, 3 ) ); for( size_t i = top_of_page; i < active_vec_size; i++ ) { const int y = i - top_of_page + 3; trim_and_print( w_missions, point( 1, y ), 28, selection == i ? hilite( col ) : col, @@ -679,7 +679,7 @@ void new_faction_manager::display() const case tab_mode::TAB_FOLLOWERS: if( !followers.empty() ) { draw_scrollbar( w_missions, selection, entries_per_page, active_vec_size, - 3, 0 ); + point( 0, 3 ) ); for( size_t i = top_of_page; i < active_vec_size; i++ ) { const int y = i - top_of_page + 3; trim_and_print( w_missions, point( 1, y ), 28, selection == i ? hilite( col ) : col, diff --git a/src/game.cpp b/src/game.cpp index 8d4667e4c01ec..9c7ade702cf76 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -6452,7 +6452,7 @@ void game::zones_manager() calcStartPos( start_index, active_index, max_rows, zone_cnt ); - draw_scrollbar( w_zones_border, active_index, max_rows, zone_cnt, 1 ); + draw_scrollbar( w_zones_border, active_index, max_rows, zone_cnt, point_south ); wrefresh( w_zones_border ); int iNum = 0; @@ -7537,7 +7537,7 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) centerlistview( active_pos, width ); draw_trail_to_square( active_pos, true ); } - draw_scrollbar( w_items_border, iActive, iMaxRows, iItemNum, 1 ); + draw_scrollbar( w_items_border, iActive, iMaxRows, iItemNum, point_south ); wrefresh( w_items_border ); } @@ -7810,7 +7810,8 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list centerlistview( iActivePos, width ); draw_trail_to_square( iActivePos, false ); - draw_scrollbar( w_monsters_border, iActive, iMaxRows, static_cast( monster_list.size() ), 1 ); + draw_scrollbar( w_monsters_border, iActive, iMaxRows, static_cast( monster_list.size() ), + point_south ); wrefresh( w_monsters_border ); } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index b6c8ac523646e..1567b094408ac 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -643,7 +643,7 @@ void iexamine::vending( player &p, const tripoint &examp ) elem->first.c_str() ); } - draw_scrollbar( w, cur_pos, list_lines, num_items, first_item_offset ); + draw_scrollbar( w, cur_pos, list_lines, num_items, point( 0, first_item_offset ) ); wrefresh( w ); // Item info diff --git a/src/input.cpp b/src/input.cpp index b903341ba5ef0..b9e98a330066b 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1028,7 +1028,7 @@ void input_context::display_menu() werase( w_help ); draw_border( w_help, BORDER_COLOR, _( "Keybindings" ), c_light_red ); draw_scrollbar( w_help, scroll_offset, display_height, - filtered_registered_actions.size(), 10, 0, c_white, true ); + filtered_registered_actions.size(), point( 0, 10 ), c_white, true ); fold_and_print( w_help, point( 2, 1 ), legwidth, c_white, legend.str() ); for( size_t i = 0; i + scroll_offset < filtered_registered_actions.size() && diff --git a/src/main_menu.cpp b/src/main_menu.cpp index 4b59e80877319..dca5133e8ef2c 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -64,7 +64,7 @@ void main_menu::clear_error() void main_menu::print_menu_items( const catacurses::window &w_in, const std::vector &vItems, - size_t iSel, int iOffsetY, int iOffsetX, int spacing ) + size_t iSel, point offset, int spacing ) { std::string text; for( size_t i = 0; i < vItems.size(); ++i ) { @@ -83,14 +83,13 @@ void main_menu::print_menu_items( const catacurses::window &w_in, } if( utf8_width( remove_color_tags( text ) ) > getmaxx( w_in ) ) { - iOffsetY -= std::ceil( utf8_width( remove_color_tags( text ) ) / getmaxx( w_in ) ); + offset.y -= std::ceil( utf8_width( remove_color_tags( text ) ) / getmaxx( w_in ) ); } - fold_and_print( w_in, point( iOffsetX, iOffsetY ), getmaxx( w_in ), c_light_gray, text, ']' ); + fold_and_print( w_in, offset, getmaxx( w_in ), c_light_gray, text, ']' ); } -void main_menu::print_menu( const catacurses::window &w_open, int iSel, const int iMenuOffsetX, - int iMenuOffsetY ) +void main_menu::print_menu( const catacurses::window &w_open, int iSel, const point &offset ) { // Clear Lines werase( w_open ); @@ -119,7 +118,7 @@ void main_menu::print_menu( const catacurses::window &w_open, int iSel, const in if( halloween_theme ) { fold_and_print_from( w_open, point_zero, 30, 0, c_white, halloween_spider() ); - fold_and_print_from( w_open, point( getmaxx( w_open ) - 25, iMenuOffsetY - 8 ), + fold_and_print_from( w_open, point( getmaxx( w_open ) - 25, offset.y - 8 ), 25, 0, c_white, halloween_graves() ); } @@ -155,13 +154,13 @@ void main_menu::print_menu( const catacurses::window &w_open, int iSel, const in menu_length += utf8_width( vMenuHotkeys[i][0] ); } } - const int free_space = std::max( 0, window_width - menu_length - iMenuOffsetX ); + const int free_space = std::max( 0, window_width - menu_length - offset.x ); const int spacing = free_space / ( static_cast( vMenuItems.size() ) + 1 ); const int width_of_spacing = spacing * ( vMenuItems.size() + 1 ); const int adj_offset = std::max( 0, ( free_space - width_of_spacing ) / 2 ); - const int final_offset = iMenuOffsetX + adj_offset + spacing; + const int final_offset = offset.x + adj_offset + spacing; - print_menu_items( w_open, vMenuItems, iSel, iMenuOffsetY, final_offset, spacing ); + print_menu_items( w_open, vMenuItems, iSel, point( final_offset, offset.y ), spacing ); catacurses::refresh(); wrefresh( w_open ); @@ -223,7 +222,7 @@ void main_menu::init_windows() w_open = catacurses::newwin( total_h, total_w, point( x0, y0 ) ); - iMenuOffsetY = total_h - 3; + menu_offset.y = total_h - 3; // note: if iMenuOffset is changed, // please update MOTD and credits to indicate how long they can be. @@ -342,7 +341,7 @@ void main_menu::display_text( const std::string &text, const std::string &title, fold_and_print_from( w_text, point_zero, width, selected, c_light_gray, text ); - draw_scrollbar( w_border, selected, height, iLines, 1, 0, BORDER_COLOR, true ); + draw_scrollbar( w_border, selected, height, iLines, point_south, BORDER_COLOR, true ); wrefresh( w_border ); wrefresh( w_text ); catacurses::refresh(); @@ -373,7 +372,7 @@ bool main_menu::opening_screen() get_help().load(); init_windows(); init_strings(); - print_menu( w_open, 0, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, 0, menu_offset ); if( !assure_dir_exist( FILENAMES["config_dir"] ) ) { popup( _( "Unable to make config directory. Check permissions." ) ); @@ -421,7 +420,7 @@ bool main_menu::opening_screen() // somehow this need to be here to actually work disable_ime(); - print_menu( w_open, sel1, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, sel1, menu_offset ); if( layer == 1 ) { if( sel1 == 0 ) { // Print MOTD. @@ -484,7 +483,7 @@ bool main_menu::opening_screen() } else { sel2 = 0; layer = 2; - print_menu( w_open, sel1, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, sel1, menu_offset ); switch( sel1 ) { case 1: @@ -510,8 +509,6 @@ bool main_menu::opening_screen() } std::vector special_names; - int xoffset = 32 + iMenuOffsetX + extra_w / 2; - int yoffset = iMenuOffsetY - 2; int xlen = 0; for( int i = 1; i < NUM_SPECIAL_GAMES; i++ ) { std::string spec_name = special_game_name( static_cast( i ) ); @@ -519,7 +516,8 @@ bool main_menu::opening_screen() xlen += spec_name.size() + 2; } xlen += special_names.size() - 1; - print_menu_items( w_open, special_names, sel2, yoffset, xoffset - ( xlen / 4 ) ); + point offset( menu_offset + point( -( xlen / 4 ) + 32 + extra_w / 2, -2 ) ); + print_menu_items( w_open, special_names, sel2, offset ); wrefresh( w_open ); catacurses::refresh(); @@ -569,18 +567,17 @@ bool main_menu::opening_screen() } else if( sel1 == 5 ) { // Settings Menu int settings_subs_to_display = vSettingsSubItems.size(); std::vector settings_subs; - int xoffset = 46 + iMenuOffsetX + extra_w / 2; - int yoffset = iMenuOffsetY - 2; int xlen = 0; for( int i = 0; i < settings_subs_to_display; ++i ) { settings_subs.push_back( vSettingsSubItems[i] ); xlen += vSettingsSubItems[i].size() + 2; // Open and close brackets added } xlen += settings_subs.size() - 1; + point offset = menu_offset + point( 46 + extra_w / 2 - ( xlen / 4 ), -2 ); if( settings_subs.size() > 1 ) { - xoffset -= 6; + offset.x -= 6; } - print_menu_items( w_open, settings_subs, sel2, yoffset, xoffset - ( xlen / 4 ) ); + print_menu_items( w_open, settings_subs, sel2, offset ); wrefresh( w_open ); catacurses::refresh(); std::string action = handle_input_timeout( ctxt ); @@ -617,7 +614,7 @@ bool main_menu::opening_screen() get_options().show( true ); // The language may have changed- gracefully handle this. init_strings(); - print_menu( w_open, sel1, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, sel1, menu_offset ); } else if( sel2 == 1 ) { input_context ctxt_default = get_default_mode_input_context(); ctxt_default.display_menu(); @@ -657,7 +654,7 @@ bool main_menu::new_character_tab() bool start = false; while( !start && sel1 == 1 && ( layer == 2 || layer == 3 ) ) { - print_menu( w_open, 1, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, 1, menu_offset ); if( layer == 2 && sel1 == 1 ) { // Then choose custom character, random character, preset, etc if( MAP_SHARING::isSharing() && @@ -667,7 +664,7 @@ bool main_menu::new_character_tab() continue; } - print_menu_items( w_open, vSubItems, sel2, iMenuOffsetY - 2, iMenuOffsetX ); + print_menu_items( w_open, vSubItems, sel2, menu_offset + point( 0, -2 ) ); wrefresh( w_open ); catacurses::refresh(); @@ -755,15 +752,15 @@ bool main_menu::new_character_tab() } else if( layer == 3 && sel1 == 1 ) { // Then view presets if( templates.empty() ) { - mvwprintz( w_open, point( iMenuOffsetX + 20 + extra_w / 2, iMenuOffsetY - 4 ), + mvwprintz( w_open, menu_offset + point( 20 + extra_w / 2, -4 ), c_red, "%s", _( "No templates found!" ) ); on_error(); } else { - mvwprintz( w_open, point( iMenuOffsetX + 20 + extra_w / 2, iMenuOffsetY - 2 ), + mvwprintz( w_open, menu_offset + point( 20 + extra_w / 2, -2 ), c_white, "%s", _( "Press 'd' to delete a preset." ) ); for( int i = 0; i < static_cast( templates.size() ); i++ ) { - int line = iMenuOffsetY - 4 - i; - mvwprintz( w_open, point( 20 + iMenuOffsetX + extra_w / 2, line ), + int line = menu_offset.y - 4 - i; + mvwprintz( w_open, point( 20 + menu_offset.x + extra_w / 2, line ), ( sel3 == i ? h_white : c_white ), "%s", templates[i] ); } @@ -775,7 +772,7 @@ bool main_menu::new_character_tab() clear_error(); sel1 = 1; layer = 2; - print_menu( w_open, sel1, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, sel1, menu_offset ); } else if( action == "DOWN" ) { if( sel3 > 0 ) { sel3--; @@ -791,7 +788,7 @@ bool main_menu::new_character_tab() } else if( action == "LEFT" || action == "QUIT" ) { sel1 = 1; layer = 2; - print_menu( w_open, sel1, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, sel1, menu_offset ); } else if( !templates.empty() && action == "DELETE_TEMPLATE" ) { if( query_yn( _( "Are you sure you want to delete %s?" ), templates[sel3].c_str() ) ) { @@ -871,15 +868,15 @@ bool main_menu::load_character_tab() } while( !start && sel1 == 2 && ( layer == 2 || layer == 3 ) ) { - print_menu( w_open, 2, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, 2, menu_offset ); if( layer == 2 && sel1 == 2 ) { if( all_worldnames.empty() ) { - mvwprintz( w_open, point( 15 + iMenuOffsetX + extra_w / 2, iMenuOffsetY - 2 ), + mvwprintz( w_open, menu_offset + point( 15 + extra_w / 2, -2 ), c_red, "%s", _( "No Worlds found!" ) ); on_error(); } else { for( int i = 0; i < static_cast( all_worldnames.size() ); ++i ) { - int line = iMenuOffsetY - 2 - i; + int line = menu_offset.y - 2 - i; std::string world_name = all_worldnames[i]; int savegames_count = world_generator->get_world( world_name )->world_saves.size(); nc_color color1, color2; @@ -890,7 +887,7 @@ bool main_menu::load_character_tab() color1 = c_white; color2 = h_white; } - mvwprintz( w_open, point( 15 + iMenuOffsetX + extra_w / 2, line ), + mvwprintz( w_open, point( 15 + menu_offset.x + extra_w / 2, line ), ( sel2 == i ? color2 : color1 ), "%s (%d)", world_name, savegames_count ); } @@ -932,19 +929,19 @@ bool main_menu::load_character_tab() savegames.erase( new_end, savegames.end() ); } - mvwprintz( w_open, point( 15 + iMenuOffsetX + extra_w / 2, iMenuOffsetY - 2 - sel2 ), h_white, "%s", - wn ); + mvwprintz( w_open, menu_offset + point( 15 + extra_w / 2, -2 - sel2 ), h_white, + "%s", wn ); if( savegames.empty() ) { - mvwprintz( w_open, point( 40 + iMenuOffsetX + extra_w / 2, iMenuOffsetY - 2 - sel2 ), + mvwprintz( w_open, menu_offset + point( 40 + extra_w / 2, -2 - sel2 ), c_red, "%s", _( "No save games found!" ) ); on_error(); } else { - int line = iMenuOffsetY - 2; + int line = menu_offset.y - 2; for( const auto &savename : savegames ) { - const bool selected = sel3 + line == iMenuOffsetY - 2; - mvwprintz( w_open, point( 40 + iMenuOffsetX + extra_w / 2, line-- ), + const bool selected = sel3 + line == menu_offset.y - 2; + mvwprintz( w_open, point( 40 + menu_offset.x + extra_w / 2, line-- ), selected ? h_white : c_white, "%s", savename.player_name() ); } @@ -970,7 +967,7 @@ bool main_menu::load_character_tab() } else if( action == "LEFT" || action == "QUIT" ) { layer = 2; sel3 = 0; - print_menu( w_open, sel1, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, sel1, menu_offset ); } if( action == "RIGHT" || action == "CONFIRM" ) { if( sel3 >= 0 && sel3 < static_cast( savegames.size() ) ) { @@ -1001,18 +998,17 @@ bool main_menu::load_character_tab() void main_menu::world_tab() { while( sel1 == 3 && ( layer == 2 || layer == 3 ) ) { - print_menu( w_open, 3, iMenuOffsetX, iMenuOffsetY ); + print_menu( w_open, 3, menu_offset ); if( layer == 3 ) { // World Menu // Show options for Destroy, Reset worlds. // Reset and Destroy ask for world to modify. // Reset empties world of everything but options, then makes new world within it. // Destroy asks for confirmation, then destroys everything in world and then removes world folder. - int xoffset = 40 + iMenuOffsetX + extra_w / 2; - int yoffset = iMenuOffsetY - 2 - sel2; + const point offset = menu_offset + point( 40 + extra_w / 2, -2 - sel2 ); const auto all_worldnames = world_generator->all_worldnames(); - mvwprintz( w_open, point( xoffset - 15, yoffset ), h_white, "%s", all_worldnames[sel2 - 1] ); + mvwprintz( w_open, offset + point( -15, 0 ), h_white, "%s", all_worldnames[sel2 - 1] ); for( size_t i = 0; i < vWorldSubItems.size(); ++i ) { nc_color text_color; @@ -1024,7 +1020,7 @@ void main_menu::world_tab() text_color = c_light_gray; key_color = c_white; } - wmove( w_open, point( xoffset, yoffset - i ) ); + wmove( w_open, offset + point( 0, -i ) ); wprintz( w_open, c_light_gray, "[" ); shortcut_print( w_open, text_color, key_color, vWorldSubItems[i] ); wprintz( w_open, c_light_gray, "]" ); @@ -1106,14 +1102,14 @@ void main_menu::world_tab() continue; } - mvwprintz( w_open, point( 25 + iMenuOffsetX + extra_w / 2, iMenuOffsetY - 2 ), + mvwprintz( w_open, menu_offset + point( 25 + extra_w / 2, -2 ), ( sel2 == 0 ? h_white : c_white ), "%s", _( "Create World" ) ); int i = 1; const auto all_worldnames = world_generator->all_worldnames(); for( auto it = all_worldnames.begin(); it != all_worldnames.end(); ++it, i++ ) { int savegames_count = world_generator->get_world( *it )->world_saves.size(); - int line = iMenuOffsetY - 2 - i; + int line = menu_offset.y - 2 - i; nc_color color1, color2; if( *it == "TUTORIAL" || *it == "DEFENSE" ) { color1 = c_light_cyan; @@ -1122,7 +1118,7 @@ void main_menu::world_tab() color1 = c_white; color2 = h_white; } - mvwprintz( w_open, point( 25 + iMenuOffsetX + extra_w / 2, line ), + mvwprintz( w_open, point( 25 + menu_offset.x + extra_w / 2, line ), ( sel2 == i ? color2 : color1 ), "%s (%d)", ( *it ).c_str(), savegames_count ); } diff --git a/src/main_menu.h b/src/main_menu.h index 4f541d3fc079f..52dab31754d9a 100644 --- a/src/main_menu.h +++ b/src/main_menu.h @@ -72,8 +72,7 @@ class main_menu int LAST_TERMY = 0; catacurses::window w_open; catacurses::window w_background; - int iMenuOffsetX = 0; - int iMenuOffsetY = 0; + point menu_offset; std::vector templates; int extra_w; std::vector savegames; @@ -85,24 +84,21 @@ class main_menu * @param vItems Main menu items * @param iSel Which index of vItems is selected. This menu item will be highlighted to * make it stand out from the other menu items. - * @param iOffsetY Offset of menu items, y coordinate - * @param iOffsetX Offset of menu items, x coordinate + * @param offset Offset of menu items * @param spacing: How many spaces to print between each menu item */ - void print_menu_items( const catacurses::window &w_in, const std::vector &vItems, - size_t iSel, - int iOffsetY, int iOffsetX, int spacing = 1 ); + void print_menu_items( const catacurses::window &w_in, + const std::vector &vItems, size_t iSel, + point offset, int spacing = 1 ); /** * Called by @ref opening_screen, this prints all the text that you see on the main menu * * @param w_open Window to print menu in * @param iSel which index in vMenuItems is selected - * @param iMenuOffsetX Menu location in window, x coordinate - * @param iMenuOffsetY Menu location in window, y coordinate + * @param offset Menu location in window */ - void print_menu( const catacurses::window &w_open, int iSel, int iMenuOffsetX, - int iMenuOffsetY ); + void print_menu( const catacurses::window &w_open, int iSel, const point &offset ); void display_text( const std::string &text, const std::string &title, int &selected ); diff --git a/src/martialarts.cpp b/src/martialarts.cpp index 04ec00a76a898..746d7c1d8a23d 100644 --- a/src/martialarts.cpp +++ b/src/martialarts.cpp @@ -1343,7 +1343,7 @@ bool ma_style_callback::key( const input_context &ctxt, const input_event &event werase( w ); fold_and_print_from( w, point( 2, 1 ), width, selected, c_light_gray, text ); draw_border( w, BORDER_COLOR, string_format( _( " Style: %s " ), _( ma.name ) ) ); - draw_scrollbar( w, selected, height, iLines, 1, 0, BORDER_COLOR, true ); + draw_scrollbar( w, selected, height, iLines, point_south, BORDER_COLOR, true ); wrefresh( w ); catacurses::refresh(); diff --git a/src/melee.cpp b/src/melee.cpp index 227c299147d2b..d2dc2875ad07a 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -1958,15 +1958,13 @@ void player_hit_message( player *attacker, const std::string &message, if( dam > 0 && attacker->is_player() ) { //player hits monster melee - SCT.add( t.posx(), - t.posy(), + SCT.add( point( t.posx(), t.posy() ), direction_from( point_zero, point( t.posx() - attacker->posx(), t.posy() - attacker->posy() ) ), get_hp_bar( dam, t.get_hp_max(), true ).first, m_good, sSCTmod, gmtSCTcolor ); if( t.get_hp() > 0 ) { - SCT.add( t.posx(), - t.posy(), + SCT.add( point( t.posx(), t.posy() ), direction_from( point_zero, point( t.posx() - attacker->posx(), t.posy() - attacker->posy() ) ), get_hp_bar( t.get_hp(), t.get_hp_max(), true ).first, m_good, //~ "hit points", used in scrolling combat text diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index b171ac52d7378..27f568c1817e0 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -470,7 +470,7 @@ bool talk_function::display_and_choose_opts( mission_data &mission_key, const tr mvwprintz( w_list, point( 1, i + 2 ), col, " %s", cur_key_list[current].name_display ); } - draw_scrollbar( w_list, sel, info_height + 1, cur_key_list.size(), 1 ); + draw_scrollbar( w_list, sel, info_height + 1, cur_key_list.size(), point_south ); wrefresh( w_list ); werase( w_info ); diff --git a/src/mission_ui.cpp b/src/mission_ui.cpp index fc185a59c21c0..ee1a4e109cdb0 100644 --- a/src/mission_ui.cpp +++ b/src/mission_ui.cpp @@ -97,7 +97,7 @@ void game::list_missions() tab == tab_mode::TAB_COMPLETED ? LINE_XOXX : LINE_XXXX ); // + || -| mvwputch( w_missions, point( 30, FULL_SCREEN_HEIGHT - 1 ), BORDER_COLOR, LINE_XXOX ); // _|_ - draw_scrollbar( w_missions, selection, entries_per_page, umissions.size(), 3, 0 ); + draw_scrollbar( w_missions, selection, entries_per_page, umissions.size(), point( 0, 3 ) ); for( int i = top_of_page; i <= bottom_of_page; i++ ) { const auto miss = umissions[i]; diff --git a/src/morale.cpp b/src/morale.cpp index fe3a727a9acbd..2cf12f611a652 100644 --- a/src/morale.cpp +++ b/src/morale.cpp @@ -577,7 +577,7 @@ void player_morale::display( int focus_eq ) mvwprintz( w, point( getmaxx( w ) - 8, win_h - 2 ), c_white, "%d", focus_eq ); fold_and_print_from( w, point( 2, win_h - 2 ), getmaxx( w ) - 9, 0, c_white, focus_equilibrium ); - draw_scrollbar( w, offset, rows_visible, rows_total, 4, 0 ); + draw_scrollbar( w, offset, rows_visible, rows_total, point( 0, 4 ) ); wrefresh( w ); diff --git a/src/newcharacter.cpp b/src/newcharacter.cpp index 17a2b5c8d4f66..82c81a8cbfcf6 100644 --- a/src/newcharacter.cpp +++ b/src/newcharacter.cpp @@ -1233,7 +1233,7 @@ tab_direction set_traits( const catacurses::window &w, avatar &u, points_left &p } for( int i = 0; i < used_pages; i++ ) { - draw_scrollbar( w, iCurrentLine[i], iContentHeight, traits_size[i], 5, page_width * i ); + draw_scrollbar( w, iCurrentLine[i], iContentHeight, traits_size[i], point( page_width * i, 5 ) ); } } @@ -1591,7 +1591,7 @@ tab_direction set_profession( const catacurses::window &w, avatar &u, points_lef ctxt.get_desc( "CHANGE_GENDER" ), sorted_profs[cur_id]->gender_appropriate_name( !u.male ) ); - draw_scrollbar( w, cur_id, iContentHeight, profs_length, 5 ); + draw_scrollbar( w, cur_id, iContentHeight, profs_length, point( 0, 5 ) ); wrefresh( w ); wrefresh( w_description ); @@ -1782,7 +1782,7 @@ tab_direction set_skills( const catacurses::window &w, avatar &u, points_left &p selected, COL_SKILL_USED, rec_disp ); draw_scrollbar( w, selected, iContentHeight, iLines, - 5, getmaxx( w ) - 1, BORDER_COLOR, true ); + point( getmaxx( w ) - 1, 5 ), BORDER_COLOR, true ); calcStartPos( cur_offset, cur_pos, iContentHeight, num_skills ); for( int i = cur_offset; i < num_skills && i - cur_offset < iContentHeight; ++i ) { @@ -1809,7 +1809,7 @@ tab_direction set_skills( const catacurses::window &w, avatar &u, points_left &p } } - draw_scrollbar( w, cur_pos, iContentHeight, num_skills, 5 ); + draw_scrollbar( w, cur_pos, iContentHeight, num_skills, point( 0, 5 ) ); wrefresh( w ); wrefresh( w_description ); @@ -2138,7 +2138,7 @@ tab_direction set_scenario( const catacurses::window &w, avatar &u, points_left wprintz( w_flags, c_light_gray, ( "\n" ) ); } - draw_scrollbar( w, cur_id, iContentHeight, scens_length, 5 ); + draw_scrollbar( w, cur_id, iContentHeight, scens_length, point( 0, 5 ) ); wrefresh( w ); wrefresh( w_description ); wrefresh( w_sorting ); diff --git a/src/options.cpp b/src/options.cpp index e4dad06a4ba87..c72ebdb729432 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2483,7 +2483,7 @@ std::string options_manager::show( bool ingame, const bool world_options_only ) } draw_scrollbar( w_options_border, iCurrentLine, iContentHeight, - mPageItems[iCurrentPage].size(), iTooltipHeight + 2 + iWorldOffset, 0, BORDER_COLOR ); + mPageItems[iCurrentPage].size(), point( 0, iTooltipHeight + 2 + iWorldOffset ), BORDER_COLOR ); wrefresh( w_options_border ); //Draw Tabs diff --git a/src/output.cpp b/src/output.cpp index 1ac2ee67667fc..0e79265c65812 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -854,8 +854,8 @@ input_event draw_item_info( const catacurses::window &win, const std::string &sI fold_and_print_from( win, point( b, line_num ), width - 1, selected, c_light_gray, buffer.str() ); - draw_scrollbar( win, selected, height, iLines, ( without_border && use_full_win ? 0 : 1 ), - scrollbar_left ? 0 : getmaxx( win ) - 1, BORDER_COLOR, true ); + draw_scrollbar( win, selected, height, iLines, point( scrollbar_left ? 0 : getmaxx( win ) - 1, + ( without_border && use_full_win ? 0 : 1 ) ), BORDER_COLOR, true ); } if( !without_border ) { @@ -1148,12 +1148,12 @@ void draw_subtab( const catacurses::window &w, int iOffsetX, const std::string & * If true, iCurrentLine can be at most iNumLines - iContentHeight. **/ void draw_scrollbar( const catacurses::window &window, const int iCurrentLine, - const int iContentHeight, const int iNumLines, const int iOffsetY, const int iOffsetX, + const int iContentHeight, const int iNumLines, const point &offset, nc_color bar_color, const bool bDoNotScrollToEnd ) { scrollbar() - .offset_x( iOffsetX ) - .offset_y( iOffsetY ) + .offset_x( offset.x ) + .offset_y( offset.y ) .content_size( iNumLines ) .viewport_pos( iCurrentLine ) .viewport_size( iContentHeight ) @@ -1287,7 +1287,7 @@ void calcStartPos( int &iStartPos, const int iCurrentLine, const int iContentHei } catacurses::window w_hit_animation; -void hit_animation( int iX, int iY, nc_color cColor, const std::string &cTile ) +void hit_animation( const point &p, nc_color cColor, const std::string &cTile ) { /* chtype chtOld = mvwinch(w, iY + VIEW_OFFSET_Y, iX + VIEW_OFFSET_X); @@ -1295,7 +1295,7 @@ void hit_animation( int iX, int iY, nc_color cColor, const std::string &cTile ) */ catacurses::window w_hit = - catacurses::newwin( 1, 1, point( iX + VIEW_OFFSET_X, iY + VIEW_OFFSET_Y ) ); + catacurses::newwin( 1, 1, p + point( VIEW_OFFSET_X, VIEW_OFFSET_Y ) ); if( !w_hit ) { return; //we passed in negative values (semi-expected), so let's not segfault } @@ -1681,7 +1681,7 @@ void display_table( const catacurses::window &w, const std::string &title, int c const int y = ( i / columns ) + 2; fold_and_print_from( w, point( x, y ), col_width, 0, c_white, data[i + offset * columns] ); } - draw_scrollbar( w, offset, rows, ( data.size() + columns - 1 ) / columns, 2, 0 ); + draw_scrollbar( w, offset, rows, ( data.size() + columns - 1 ) / columns, point( 0, 2 ) ); wrefresh( w ); // TODO: use input context int ch = inp_mngr.get_input_event().get_first_input(); @@ -1741,7 +1741,7 @@ scrollingcombattext::cSCT::cSCT( const int p_iPosX, const int p_iPosY, const dir } -void scrollingcombattext::add( const int p_iPosX, const int p_iPosY, direction p_oDir, +void scrollingcombattext::add( const point &pos, direction p_oDir, const std::string &p_sText, const game_message_type p_gmt, const std::string &p_sText2, const game_message_type p_gmt2, const std::string &p_sType ) @@ -1789,7 +1789,7 @@ void scrollingcombattext::add( const int p_iPosX, const int p_iPosY, direction p iter.advanceStepOffset(); } } - vSCT.insert( vSCT.begin(), cSCT( p_iPosX, p_iPosY, p_oDir, p_sText, p_gmt, p_sText2, p_gmt2, + vSCT.insert( vSCT.begin(), cSCT( pos.x, pos.y, p_oDir, p_sText, p_gmt, p_sText2, p_gmt2, p_sType ) ); } else { @@ -1800,7 +1800,7 @@ void scrollingcombattext::add( const int p_iPosX, const int p_iPosY, direction p iter->advanceStepOffset(); } } - vSCT.push_back( cSCT( p_iPosX, p_iPosY, p_oDir, p_sText, p_gmt, p_sText2, p_gmt2, p_sType ) ); + vSCT.push_back( cSCT( pos.x, pos.y, p_oDir, p_sText, p_gmt, p_sText2, p_gmt2, p_sType ) ); } } diff --git a/src/output.h b/src/output.h index 37d551a823d4a..2aeb5aad201df 100644 --- a/src/output.h +++ b/src/output.h @@ -530,7 +530,7 @@ std::string shortcut_text( nc_color shortcut_color, const std::string &fmt ); // short visual animation (player, monster, ...) (hit, dodge, ...) // cTile is a UTF-8 strings, and must be a single cell wide! -void hit_animation( int iX, int iY, nc_color cColor, const std::string &cTile ); +void hit_animation( const point &p, nc_color cColor, const std::string &cTile ); /** * @return Pair of a string containing the bar, and its color @@ -679,7 +679,7 @@ void draw_subtab( const catacurses::window &w, int iOffsetX, const std::string & bool bDecorate = true, bool bDisabled = false ); // Legacy function, use class scrollbar instead! void draw_scrollbar( const catacurses::window &window, int iCurrentLine, - int iContentHeight, int iNumLines, int iOffsetY = 0, int iOffsetX = 0, + int iContentHeight, int iNumLines, const point &offset = point_zero, nc_color bar_color = c_white, bool bDoNotScrollToEnd = false ); void calcStartPos( int &iStartPos, int iCurrentLine, int iContentHeight, int iNumEntries ); @@ -779,7 +779,7 @@ class scrollingcombattext std::vector vSCT; - void add( int p_iPosX, int p_iPosY, direction p_oDir, + void add( const point &pos, direction p_oDir, const std::string &p_sText, game_message_type p_gmt, const std::string &p_sText2 = "", game_message_type p_gmt2 = m_neutral, const std::string &p_sType = "" ); diff --git a/src/player.cpp b/src/player.cpp index 327efef9f1198..f0a05ff82f65d 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2978,7 +2978,7 @@ dealt_damage_instance player::deal_damage( Creature *source, body_part bp, if( is_player() && source ) { //monster hits player melee - SCT.add( posx(), posy(), + SCT.add( point( posx(), posy() ), direction_from( point_zero, point( posx() - source->posx(), posy() - source->posy() ) ), get_hp_bar( dam, get_hp_max( player::bp_to_hp( bp ) ) ).first, m_bad, body_part_name( bp ), m_neutral ); @@ -10023,7 +10023,8 @@ bool player::armor_absorb( damage_unit &du, item &armor ) add_msg_if_player( m_bad, format_string, pre_damage_name, damage_verb ); //item is damaged if( is_player() ) { - SCT.add( posx(), posy(), NORTH, remove_color_tags( pre_damage_name ), m_neutral, damage_verb, + SCT.add( point( posx(), posy() ), NORTH, remove_color_tags( pre_damage_name ), m_neutral, + damage_verb, m_info ); } @@ -10144,7 +10145,7 @@ void player::absorb_hit( body_part bp, damage_instance &dam ) if( destroy ) { if( g->u.sees( *this ) ) { - SCT.add( posx(), posy(), NORTH, remove_color_tags( pre_damage_name ), + SCT.add( point( posx(), posy() ), NORTH, remove_color_tags( pre_damage_name ), m_neutral, _( "destroyed" ), m_info ); } destroyed_armor_msg( *this, pre_damage_name ); diff --git a/src/player_display.cpp b/src/player_display.cpp index c8e5100f7db34..bd8d02f964b88 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -729,7 +729,8 @@ static void draw_skills_tab( const catacurses::window &w_skills, const catacurse } } - draw_scrollbar( w_skills, line, skill_win_size_y, static_cast( skillslist.size() ), 1 ); + draw_scrollbar( w_skills, line, skill_win_size_y, static_cast( skillslist.size() ), + point_south ); wrefresh( w_skills ); werase( w_info ); diff --git a/src/safemode_ui.cpp b/src/safemode_ui.cpp index 4f9046c9acff0..0976cedee6421 100644 --- a/src/safemode_ui.cpp +++ b/src/safemode_ui.cpp @@ -196,7 +196,7 @@ void safemode::show( const std::string &custom_name_in, bool is_safemode_in ) mvwprintz( w, point( 15, 10 ), c_white, _( "Press ~ to add a default ruleset to get started." ) ); } - draw_scrollbar( w_border, line, content_height, current_tab.size(), 5 ); + draw_scrollbar( w_border, line, content_height, current_tab.size(), point( 0, 5 ) ); wrefresh( w_border ); calcStartPos( start_pos, line, content_height, current_tab.size() ); diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index d15b37b79f3b6..2191a0fac1646 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -698,9 +698,9 @@ void worldfactory::draw_mod_list( const catacurses::window &w, int &start, size_ } if( first_line_is_category && iActive == 1 ) { // Ensure that the scrollbar starts at zero position - draw_scrollbar( w, 0, iMaxRows, static_cast( iModNum ), 0 ); + draw_scrollbar( w, 0, iMaxRows, static_cast( iModNum ), point_zero ); } else { - draw_scrollbar( w, static_cast( iActive ), iMaxRows, static_cast( iModNum ), 0 ); + draw_scrollbar( w, static_cast( iActive ), iMaxRows, static_cast( iModNum ), point_zero ); } wrefresh( w );