Skip to content

Commit

Permalink
Use point in main_menu.h and output.h (#33417)
Browse files Browse the repository at this point in the history
* Convert main_menu code to use points

* Automated refactoring

* Add overloads for output.h functions

* Automated refactoring of callers

* Port output function implementations
  • Loading branch information
jbytheway authored and ZhilkinSerg committed Aug 21, 2019
1 parent 55bcd4c commit 0235134
Show file tree
Hide file tree
Showing 26 changed files with 104 additions and 111 deletions.
4 changes: 2 additions & 2 deletions src/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ void draw_hit_mon_curses( const tripoint &center, 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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/auto_pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion src/bionics_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/crafting_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
4 changes: 2 additions & 2 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -7537,7 +7537,7 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &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 );
}

Expand Down Expand Up @@ -7810,7 +7810,8 @@ game::vmenu_ret game::list_monsters( const std::vector<Creature *> &monster_list
centerlistview( iActivePos, width );
draw_trail_to_square( iActivePos, false );

draw_scrollbar( w_monsters_border, iActive, iMaxRows, static_cast<int>( monster_list.size() ), 1 );
draw_scrollbar( w_monsters_border, iActive, iMaxRows, static_cast<int>( monster_list.size() ),
point_south );
wrefresh( w_monsters_border );
}

Expand Down
2 changes: 1 addition & 1 deletion src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() &&
Expand Down
Loading

0 comments on commit 0235134

Please sign in to comment.