Skip to content

Commit

Permalink
Merge pull request #40095 from Qrox/migrate-ui-13
Browse files Browse the repository at this point in the history
Migrate overmap_ui.cpp to ui_adaptor
  • Loading branch information
ZhilkinSerg authored May 3, 2020
2 parents 964fe80 + f3bd0d4 commit 08f6210
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 159 deletions.
2 changes: 0 additions & 2 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,6 @@ class game
catacurses::window w_pixel_minimap;
//only a pointer, can refer to w_messages_short or w_messages_long

catacurses::window w_blackspace;

// View offset based on the driving speed (if any)
// that has been added to u.view_offset,
// Don't write to this directly, always use set_driving_view_offset
Expand Down
50 changes: 0 additions & 50 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1822,56 +1822,6 @@ std::string get_labeled_bar( const double val, const int width, const std::strin
return get_labeled_bar( val, width, label, ratings.begin(), ratings.end() );
}

/**
* Display data in table, each cell contains one entry from the
* data vector. Allows vertical scrolling if the data does not fit.
* Data is displayed using fold_and_print_from, which allows coloring!
* @param columns Number of columns, can be 1. Make sure each entry
* of the data vector fits into one cell.
* @param title The title text, displayed on top.
* @param w The window to draw this in, the whole widow is used.
* @param data Text data to fill.
*/
void display_table( const catacurses::window &w, const std::string &title, int columns,
const std::vector<std::string> &data )
{
const int width = getmaxx( w ) - 2; // -2 for border
const int rows = getmaxy( w ) - 2 - 1; // -2 for border, -1 for title
const int col_width = width / columns;
int offset = 0;

// FIXME: temporarily disable redrawing of lower UIs before this UI is migrated to `ui_adaptor`
ui_adaptor ui( ui_adaptor::disable_uis_below {} );

#if defined(__ANDROID__)
// no bindings, but give it its own input context so stale buttons don't hang around.
input_context ctxt( "DISPLAY_TABLE" );
#endif
for( ;; ) {
werase( w );
draw_border( w, BORDER_COLOR, title, c_white );
for( int i = 0; i < rows * columns; i++ ) {
if( i + offset * columns >= static_cast<int>( data.size() ) ) {
break;
}
const int x = 2 + ( i % columns ) * col_width;
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, point( 0, 2 ) );
wrefresh( w );
// TODO: use input context
int ch = inp_mngr.get_input_event().get_first_input();
if( ch == KEY_DOWN && ( ( offset + 1 ) * columns ) < static_cast<int>( data.size() ) ) {
offset++;
} else if( ch == KEY_UP && offset > 0 ) {
offset--;
} else if( ch == ' ' || ch == '\n' || ch == KEY_ESCAPE ) {
break;
}
}
}

scrollingcombattext::cSCT::cSCT( const point &p_pos, const 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,
Expand Down
2 changes: 0 additions & 2 deletions src/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ void center_print( const catacurses::window &w, int y, const nc_color &FG,
const std::string &text );
int right_print( const catacurses::window &w, int line, int right_indent,
const nc_color &FG, const std::string &text );
void display_table( const catacurses::window &w, const std::string &title, int columns,
const std::vector<std::string> &data );
void scrollable_text( const catacurses::window &w, const std::string &title,
const std::string &text );
void scrollable_text( const std::function<catacurses::window()> &init_window,
Expand Down
Loading

0 comments on commit 08f6210

Please sign in to comment.