display/source/CursesDisplay.cpp
// Draw the specified screen, full-screen.
Draw the specified screen, full-screen.
Draw the specified screen full - screen .
string CursesDisplay::display_screen(const Screen& current_screen)
{
  string result;
  refresh_terminal_size();
  MenuWrapper wrapper;
  WINDOW* screen_window = create_screen(TERMINAL_MAX_ROWS, TERMINAL_MAX_COLS, 0, 0);
  screens.push_back(screen_window);
  int current_row = 0;
  int current_col = 0;
  string title_text_sid = current_screen.get_title_text_sid();
  string header_text = StringTable::get(title_text_sid);
  if (!title_text_sid.empty() && header_text.empty())
  {
    header_text = title_text_sid;
  }
  uint num_pages = current_screen.get_num_pages();
  if (num_pages > 1)
  {
    ostringstream ss;
    ss << header_text << " (" << current_screen.get_current_page_number() << "/" << num_pages << ")";
    header_text = ss.str();
  }
  if (!header_text.empty())
  {
    display_header(header_text, screen_window, current_row);
    current_row += 2;
  }
  vector<ScreenComponentPtr> components = current_screen.get_current_page();
  uint line_incr = current_screen.get_line_increment();
  uint csize = components.size();
  for(uint i = 0; i < csize; i++)
  {
    ScreenComponentPtr component = components.at(i);
    ComponentAlignment ca = component->get_spacing_after();
    if (ca.get_override_default())
    {
      line_incr = ca.get_value();
    }
    if (component)
    {
      TextComponentPtr tc = dynamic_pointer_cast<TextComponent>(component);
      if (tc != nullptr)
      {
        display_text_component(screen_window, &current_row, &current_col, tc, line_incr);
      }
      else
      {
        OptionsComponentPtr oc = dynamic_pointer_cast<OptionsComponent>(component);
        if (oc != nullptr)
        {
          display_options_component(screen_window, &current_row, &current_col, oc);
          wrapper.add_options(oc);
        }
      }
      if (current_row == (static_cast<int>(TERMINAL_MAX_ROWS) - 1) && (i != csize-1))
      {
        PromptPtr prompt = current_screen.get_prompt();
        prompt_processor.show_prompt(screen_window, prompt, current_row, current_col, TERMINAL_MAX_ROWS, TERMINAL_MAX_COLS);
        result = prompt_processor.get_prompt(screen_window, wrapper, prompt);
        wrefresh(screen_window);
        wclear(screen_window);
        current_row = 0;
      }
    }
  }
  PromptPtr prompt = current_screen.get_prompt();
  prompt_processor.show_prompt(screen_window, prompt, current_row, current_col, TERMINAL_MAX_ROWS, TERMINAL_MAX_COLS);
  result = prompt_processor.get_prompt(screen_window, wrapper, prompt);
  wrefresh(screen_window);
  return result;
}
string CursesDisplay :: display_screen ( const Screen & current_screen ) { string result ; refresh_terminal_size ( ) ; MenuWrapper wrapper ; WINDOW * screen_window = create_screen ( TERMINAL_MAX_ROWS , TERMINAL_MAX_COLS , 0 , 0 ) ; screens . push_back ( screen_window ) ; int current_row = 0 ; int current_col = 0 ; string title_text_sid = current_screen . get_title_text_sid ( ) ; string header_text = StringTable :: get ( title_text_sid ) ; if ( ! title_text_sid . empty ( ) && header_text . empty ( ) ) { header_text = title_text_sid ; } uint num_pages = current_screen . get_num_pages ( ) ; if ( num_pages > 1 ) { ostringstream ss ; ss << header_text << " " << current_screen . get_current_page_number ( ) << " " << num_pages << " " ; header_text = ss . str ( ) ; } if ( ! header_text . empty ( ) ) { display_header ( header_text , screen_window , current_row ) ; current_row += 2 ; } vector < ScreenComponentPtr > components = current_screen . get_current_page ( ) ; uint line_incr = current_screen . get_line_increment ( ) ; uint csize = components . size ( ) ; for ( uint i = 0 ; i < csize ; i ++ ) { ScreenComponentPtr component = components . at ( i ) ; ComponentAlignment ca = component -> get_spacing_after ( ) ; if ( ca . get_override_default ( ) ) { line_incr = ca . get_value ( ) ; } if ( component ) { TextComponentPtr tc = dynamic_pointer_cast < TextComponent > ( component ) ; if ( tc != nullptr ) { display_text_component ( screen_window , & current_row , & current_col , tc , line_incr ) ; } else { OptionsComponentPtr oc = dynamic_pointer_cast < OptionsComponent > ( component ) ; if ( oc != nullptr ) { display_options_component ( screen_window , & current_row , & current_col , oc ) ; wrapper . add_options ( oc ) ; } } if ( current_row == ( static_cast < int > ( TERMINAL_MAX_ROWS ) - 1 ) && ( i != csize - 1 ) ) { PromptPtr prompt = current_screen . get_prompt ( ) ; prompt_processor . show_prompt ( screen_window , prompt , current_row , current_col , TERMINAL_MAX_ROWS , TERMINAL_MAX_COLS ) ; result = prompt_processor . get_prompt ( screen_window , wrapper , prompt ) ; wrefresh ( screen_window ) ; wclear ( screen_window ) ; current_row = 0 ; } } } PromptPtr prompt = current_screen . get_prompt ( ) ; prompt_processor . show_prompt ( screen_window , prompt , current_row , current_col , TERMINAL_MAX_ROWS , TERMINAL_MAX_COLS ) ; result = prompt_processor . get_prompt ( screen_window , wrapper , prompt ) ; wrefresh ( screen_window ) ; return result ; }
Draw the specified screen, full-screen.
Draw the specified screen full - screen .
// Display the header if the text is defined.  Some screens (like the quest list, // etc) will have this defined, while others (such as the new character-type // screens) will not. // The title might not be an actual resource string, but instead an already- // formatted message.  Use that if the lookup is empty but the sid is not. // Always allow for some space between the title and the components of the // screen, regardless of what the screen has set for line spacing. // Check to see if we should override the screen's line increment value. // Process the options... // Add them so that the prompt processor knows about the options in this set. // After each line, check to see if we need to throw up a prompt because // of hitting the end of the screen, but only if there's still stuff to // display. // We've shown the prompt, the user has intervened, and so // now we need to clear the window, reset the current row // back to 0 and keep displaying stuff from the screen. // Done!  Add an appropriate prompt.