Пример #1
0
void show_mutations_titlebar(WINDOW *window, player *p, std::string menu_mode)
{
    werase(window);

    std::string caption = _("MUTATIONS -");
    int cap_offset = utf8_width(caption.c_str()) + 1;
    mvwprintz(window, 0,  0, c_blue, "%s", caption.c_str());

    std::stringstream pwr;
    pwr << string_format(_("Power: %d/%d"), int(p->power_level), int(p->max_power_level));
    int pwr_length = utf8_width(pwr.str().c_str()) + 1;

    std::string desc;
    int desc_length = getmaxx(window) - cap_offset - pwr_length;

    if(menu_mode == "reassigning") {
        desc = _("Reassigning.\nSelect a mutation to reassign or press SPACE to cancel.");
    } else if(menu_mode == "activating") {
        desc = _("<color_green>Activating</color>  <color_yellow>!</color> to examine, <color_yellow>=</color> to reassign.");
    } else if(menu_mode == "examining") {
        desc = _("<color_ltblue>Examining</color>  <color_yellow>!</color> to activate, <color_yellow>=</color> to reassign.");
    }
    fold_and_print(window, 0, cap_offset, desc_length, c_white, desc);
    fold_and_print(window, 1, 0, desc_length, c_white, _("Might need to use ? to assign the keys."));

    wrefresh(window);
}
Пример #2
0
void show_bionics_titlebar(WINDOW *window, player *p, bool activating, bool reassigning)
{
    werase(window);

    std::string caption = _("BIONICS -");
    int cap_offset = utf8_width(caption.c_str()) + 1;
    mvwprintz(window, 0,  0, c_blue, caption.c_str());

    std::stringstream pwr;
    pwr << _("Power: ") << int(p->power_level) << _("/") << int(p->max_power_level);
    int pwr_length = utf8_width(pwr.str().c_str()) + 1;
    mvwprintz(window, 0, getmaxx(window) - pwr_length, c_white, pwr.str().c_str());

    std::string desc;
    int desc_length = getmaxx(window) - cap_offset - pwr_length;

    if(reassigning) {
        desc = _("Reassigning.\nSelect a bionic to reassign or press SPACE to cancel.");
    } else if(activating) {
        desc = _("Activating. Press <color_yellow>!</color> to examine your implants.\nPress <color_yellow>=</color> to reassign a key.");
    } else {
        desc = _("Examining. Press <color_yellow>!</color> to activate your implants.\nPress <color_yellow>=</color> to reassign a key.");
    }
    fold_and_print(window, 0, cap_offset, desc_length, c_white, desc.c_str());

    wrefresh(window);
}
Пример #3
0
        void select( int entnum, uimenu *menu ) override {
            const int starty = 3;
            const int startx = menu->w_width - menu->pad_right;
            const std::string padding( menu->pad_right, ' ' );
            for( int y = 2; y < menu->w_height - 1; y++ ) {
                mvwprintw( menu->window, y, startx - 1, padding );
            }
            item tmp( standard_itype_ids[entnum], calendar::turn );
            mvwhline( menu->window, 1, startx, ' ', menu->pad_right - 1 );
            const std::string header = string_format( "#%d: %s%s%s", entnum,
                                       standard_itype_ids[entnum]->get_id().c_str(),
                                       ( incontainer ? _( " (contained)" ) : "" ),
                                       ( has_flag ? _( " (flagged)" ) : "" ) );
            mvwprintz( menu->window, 1, startx + ( menu->pad_right - 1 - header.size() ) / 2, c_cyan,
                       header );

            fold_and_print( menu->window, starty, startx, menu->pad_right - 1, c_light_gray, tmp.info( true ) );

            mvwprintz( menu->window, menu->w_height - 3, startx, c_green, msg );
            msg.erase();

            input_context ctxt( "UIMENU" );
            mvwprintw( menu->window, menu->w_height - 2, startx,
                       _( "[%s] find, [f] container, [F] flag, [%s] quit" ),
                       ctxt.get_desc( "FILTER" ).c_str(), ctxt.get_desc( "QUIT" ).c_str() );
        }
Пример #4
0
        virtual void select(int entnum, uimenu *menu) {
            const int starty = 3;
            const int startx = menu->w_width - menu->pad_right;
            const std::string padding(menu->pad_right, ' ');
            for(int y = 2; y < menu->w_height - 1; y++) {
                mvwprintw(menu->window, y, startx - 1, "%s", padding.c_str());
            }
            itype *ity = item_controller->find_template(standard_itype_ids[entnum]);

            if ( ity == NULL ) {
                return;
            }
            item tmp(ity, g->turn);
            const std::string header = string_format("#%d: %s%s", entnum, standard_itype_ids[entnum].c_str(),
                                       ( incontainer ? _(" (contained)") : "" ));
            mvwprintz(menu->window, 1, startx + ( menu->pad_right - 1 - header.size() ) / 2, c_cyan, "%s",
                      header.c_str());

            fold_and_print(menu->window, starty, startx, menu->pad_right - 1, c_white, tmp.info(true));

            mvwprintz(menu->window, menu->w_height - 3, startx, c_green, "%s", msg.c_str());
            msg.erase();

            mvwprintw(menu->window, menu->w_height - 2, startx, _("[/] find, [f] container, [q]uit"));
        }
Пример #5
0
void show_bionics_titlebar(WINDOW *window, player *p, std::string menu_mode)
{
    werase(window);

    std::string caption = _("BIONICS -");
    int cap_offset = utf8_width(caption.c_str()) + 1;
    mvwprintz(window, 0,  0, c_blue, "%s", caption.c_str());

    std::stringstream pwr;
    pwr << _("Power: ") << int(p->power_level) << _("/") << int(p->max_power_level);
    int pwr_length = utf8_width(pwr.str().c_str()) + 1;
    mvwprintz(window, 0, getmaxx(window) - pwr_length, c_white, "%s", pwr.str().c_str());

    std::string desc;
    int desc_length = getmaxx(window) - cap_offset - pwr_length;

    if(menu_mode == "reassigning") {
        desc = _("Reassigning.\nSelect a bionic to reassign or press SPACE to cancel.");
    } else if(menu_mode == "activating") {
        desc = _("<color_green>Activating</color>  <color_yellow>!</color> to examine, <color_yellow>-</color> to remove, <color_yellow>=</color> to reassign.");
    } else if(menu_mode == "removing") {
        desc = _("<color_red>Removing</color>  <color_yellow>!</color> to activate, <color_yellow>-</color> to remove, <color_yellow>=</color> to reassign.");
    } else if(menu_mode == "examining") {
        desc = _("<color_ltblue>Examining</color>  <color_yellow>!</color> to activate, <color_yellow>-</color> to remove, <color_yellow>=</color> to reassign.");
    }
    fold_and_print(window, 0, cap_offset, desc_length, c_white, desc);

    wrefresh(window);
}
void mod_ui::draw_shift_information(WINDOW *win, int sy, int sx,
                                    const std::vector<std::string> mod_list, const int selection)
{
    const std::string can_shift_true = "<color_cyan>";
    const std::string can_shift_false = "<color_magenta>";
    const std::string can_shift_close = "</color>";

    std::string shift_string = "";
    if (can_shift_up(selection, mod_list)) {
        shift_string += can_shift_true;
    } else {
        shift_string += can_shift_false;
    }
    shift_string += "+" + can_shift_close;

    shift_string += " ";

    if (can_shift_down(selection, mod_list)) {
        shift_string += can_shift_true;
    } else {
        shift_string += can_shift_false;
    }
    shift_string += "-" + can_shift_close;
    fold_and_print(win, sy, sx, 4, c_black, shift_string.c_str());
}
void mod_ui::show_mod_information(WINDOW *win, int width, MOD_INFORMATION *mod, std::string note)
{
    const int infopanel_start_y = FULL_SCREEN_HEIGHT - 6;
    const int infopanel_start_x = 1;

    std::stringstream info;
    info.str("");
    // color the note red!
    if (note.size() > 0) {
        std::stringstream newnote;
        newnote << "<color_red>" << note << "</color>";
        note = newnote.str();
    }
    std::vector<std::string> dependencies = mod->dependencies;
    std::string dependency_string = "";
    if (dependencies.size() == 0) {
        dependency_string = _("[NONE]");
    } else {
        for (int i = 0; i < dependencies.size(); ++i) {
            if (i > 0) {
                dependency_string += ", ";
            }
            dependency_string += "[" + active_manager->mod_map[dependencies[i]]->name + "]";
        }
    }
    info << _("Name: ") << "\"" << mod->name << "\"  " << _("Author(s): ") << mod->author << "\n";
    info << _("Description: ") << "\"" << mod->description << "\"\n";
    info << _("Dependencies: ") << dependency_string << "\n";
    if (mod->_type == MT_SUPPLEMENTAL && note.size() > 0) {
        info << note;
    }
    fold_and_print(win, infopanel_start_y, infopanel_start_x, width, c_white, info.str().c_str());
}
Пример #8
0
int recipe::print_time( WINDOW *w, int ypos, int xpos, int width,
                        nc_color col, int batch ) const
{
    const int turns = batch_time( batch ) / 100;
    std::string text;
    if( turns < MINUTES( 1 ) ) {
        const int seconds = std::max( 1, turns * 6 );
        text = string_format( ngettext( "%d second", "%d seconds", seconds ), seconds );
    } else {
        const int minutes = ( turns % HOURS( 1 ) ) / MINUTES( 1 );
        const int hours = turns / HOURS( 1 );
        if( hours == 0 ) {
            text = string_format( ngettext( "%d minute", "%d minutes", minutes ), minutes );
        } else if( minutes == 0 ) {
            text = string_format( ngettext( "%d hour", "%d hours", hours ), hours );
        } else {
            const std::string h = string_format( ngettext( "%d hour", "%d hours", hours ), hours );
            const std::string m = string_format( ngettext( "%d minute", "%d minutes", minutes ), minutes );
            //~ A time duration: first is hours, second is minutes, e.g. "4 hours" "6 minutes"
            text = string_format( _( "%1$s and %2$s" ), h.c_str(), m.c_str() );
        }
    }
    text = string_format( _( "Time to complete: %s" ), text.c_str() );
    return fold_and_print( w, ypos, xpos, width, col, text );
}
void draw_description( WINDOW *win, bionic const &bio )
{
    werase( win );
    const int width = getmaxx( win );
    const std::string poweronly_string = build_bionic_poweronly_string( bio );
    int ypos = fold_and_print( win, 0, 0, width, c_white, bionic_info( bio.id ).name );
    if( !poweronly_string.empty() ) {
        ypos += fold_and_print( win, ypos, 0, width, c_ltgray,
                                _( "Power usage: %s" ), poweronly_string.c_str() );
    }
    ypos += 1 + fold_and_print( win, ypos, 0, width, c_ltblue, bionic_info( bio.id ).description );

    const bool each_bp_on_new_line = ypos + ( int )num_bp + 1 < getmaxy( win );
    ypos += fold_and_print( win, ypos, 0, width, c_ltgray,
                            list_occupied_bps( bio.id, _( "This bionic occupies the following body parts:" ),
                                    each_bp_on_new_line ) );
    wrefresh( win );
}
Пример #10
0
// returns number of printed lines
int fold_and_print(WINDOW *w, int begin_y, int begin_x, int width, nc_color base_color,
                   const char *mes, ...)
{
    va_list ap;
    va_start(ap, mes);
    const std::string text = vstring_format(mes, ap);
    va_end(ap);
    return fold_and_print(w, begin_y, begin_x, width, base_color, text);
}
Пример #11
0
void realDebugmsg( const char *filename, const char *line, const char *funcname, const char *mes,
                   ... )
{
    assert( filename != nullptr );
    assert( line != nullptr );
    assert( funcname != nullptr );

    va_list ap;
    va_start( ap, mes );
    const std::string text = vstring_format( mes, ap );
    va_end( ap );

    if( debug_fatal ) {
        throw std::runtime_error( string_format( "%s:%s [%s] %s", filename, line, funcname,
                                  text.c_str() ) );
    }

    DebugLog( D_ERROR, D_MAIN ) << filename << ":" << line << " [" << funcname << "] " << text;

    std::string msg_key( filename );
    msg_key += line;

    if( ignored_messages.count( msg_key ) > 0 ) {
        return;
    }

    if( stdscr == nullptr ) {
        std::cerr << text.c_str() << std::endl;
        abort();
    }

    fold_and_print( stdscr, 0, 0, getmaxx( stdscr ), c_ltred,
                    "\n \n" // Looks nicer with some space
                    " DEBUG    : %s\n \n"
                    " FUNCTION : %s\n"
                    " FILE     : %s\n"
                    " LINE     : %s\n \n"
                    " Press <color_white>spacebar</color> to continue the game...\n"
                    " Press <color_white>I</color> (or <color_white>i</color>) to also ignore this particular message in the future...",
                    text.c_str(), funcname, filename, line );

    for( bool stop = false; !stop; ) {
        switch( getch() ) {
            case 'i':
            case 'I':
                ignored_messages.insert( msg_key );
            // Falling through
            case ' ':
                stop = true;
                break;
        }
    }

    werase( stdscr );
    refresh();
}
Пример #12
0
/**
 * Prints a list of descriptions for all parts to the screen inside of a boxed window
 * @param win The window to draw in.
 * @param max_y Draw no further than this y-coordinate.
 * @param width The width of the window.
 * @param &p The index of the part being examined.
 * @param start_at Which vehicle part to start printing at.
 * @param start_limit the part index beyond which the display is full
 */
void vehicle::print_vparts_descs( const catacurses::window &win, int max_y, int width, int &p,
                                  int &start_at, int &start_limit ) const
{
    if( p < 0 || p >= ( int )parts.size() ) {
        return;
    }

    std::vector<int> pl = this->parts_at_relative( parts[p].mount.x, parts[p].mount.y );
    std::ostringstream msg;

    int lines = 0;
    /*
     * start_at and start_limit interaction is little tricky
     * start_at and start_limit start at 0 when moving to a new frame
     * if all the descriptions are displayed in the window, start_limit stays at 0 and
     *    start_at is capped at 0 - so no scrolling at all.
     * if all the descriptions aren't displayed, start_limit jumps to the last displayed part
     *    and the next scrollthrough can start there - so scrolling down happens.
     * when the scroll reaches the point where all the remaining descriptions are displayed in
     *    the window, start_limit is set to start_at again.
     * on the next attempted scrolldown, start_limit is set to the nth item, and start_at is
     *    capped to the nth item, so no more scrolling down.
     * start_at can always go down, but never below 0, so scrolling up is only possible after
     *    some scrolling down has occurred.
     * important! the calling function needs to track p, start_at, and start_limit, and set
     *    start_limit to 0 if p changes.
     */
    start_at = std::max( 0, std::min( start_at, start_limit ) );
    if( start_at ) {
        msg << "<color_yellow>" << "<  " << _( "More parts here..." ) << "</color>\n";
        lines += 1;
    }
    for( size_t i = start_at; i < pl.size(); i++ ) {
        const vehicle_part &vp = parts[ pl [ i ] ];
        std::ostringstream possible_msg;
        std::string name_color = string_format( "<color_%1$s>",
                                                string_from_color( vp.is_broken() ? c_dark_gray : c_light_green ) );
        possible_msg << name_color << vp.name() << "</color>\n";
        std::string desc_color = string_format( "<color_%1$s>",
                                                string_from_color( vp.is_broken() ? c_dark_gray : c_light_gray ) );
        int new_lines = 2 + vp.info().format_description( possible_msg, desc_color, width - 2 );
        possible_msg << "</color>\n";
        if( lines + new_lines <= max_y ) {
            msg << possible_msg.str();
            lines += new_lines;
            start_limit = start_at;
        } else {
            msg << "<color_yellow>" << _( "More parts here..." ) << "  >" << "</color>\n";
            start_limit = i;
            break;
        }
    }
    werase( win );
    fold_and_print( win, 0, 1, width, c_light_gray, msg.str() );
    wrefresh( win );
}
Пример #13
0
/**
 * Handles changing a tire.
 * @param reason INVALID_TARGET if there's no wheel in the selected square,
 *               LACK_TOOLS if the player is missing a tool.
 */
void veh_interact::do_tirechange(task_reason reason)
{
    werase( w_msg );
    int msg_width = getmaxx(w_msg);
    switch( reason ) {
    case INVALID_TARGET:
        mvwprintz(w_msg, 0, 1, c_ltred, _("There is no wheel to change here."));
        wrefresh (w_msg);
        return;
    case LACK_TOOLS:
        fold_and_print(w_msg, 0, 1, msg_width - 2, c_ltgray,
                       _("To change a wheel you need a <color_%1$s>wrench</color> and a <color_%2$s>jack</color>."),
                       has_wrench ? "ltgreen" : "red",
                       has_jack ? "ltgreen" : "red");
        wrefresh (w_msg);
        return;
    }
    mvwprintz(w_mode, 0, 1, c_ltgray, _("Choose wheel to use as replacement:"));
    wrefresh (w_mode);
    int pos = 0;
    while (true) {
        sel_vpart_info = &(wheel_types[pos]);
        bool is_wheel = sel_vpart_info->has_flag("WHEEL");
        display_list (pos, wheel_types);
        itype_id itm = sel_vpart_info->item;
        bool has_comps = crafting_inv.has_amount(itm, 1);
        bool has_tools = has_jack && has_wrench;
        werase (w_msg);
        wrefresh (w_msg);
        char ch = input(); // See keypress.h
        int dx, dy;
        get_direction (dx, dy, ch);
        if ((ch == '\n' || ch == ' ') && has_comps && has_tools && is_wheel) {
            sel_cmd = 'c';
            return;
        } else {
            if (ch == KEY_ESCAPE || ch == 'q' ) {
                werase (w_list);
                wrefresh (w_list);
                werase (w_msg);
                break;
            }
        }
        if (dy == -1 || dy == 1) {
            pos += dy;
            if (pos < 0) {
                pos = wheel_types.size() - 1;
            } else if (pos >= wheel_types.size()) {
                pos = 0;
            }
        }
    }
}
Пример #14
0
void draw_description( const catacurses::window &win, const bionic &bio )
{
    werase( win );
    const int width = getmaxx( win );
    const std::string poweronly_string = build_bionic_poweronly_string( bio );
    int ypos = fold_and_print( win, 0, 0, width, c_white, bio.id->name );
    if( !poweronly_string.empty() ) {
        ypos += fold_and_print( win, ypos, 0, width, c_light_gray,
                                _( "Power usage: %s" ), poweronly_string );
    }
    ypos += 1 + fold_and_print( win, ypos, 0, width, c_light_blue, bio.id->description );

    // TODO: Unhide when enforcing limits
    if( get_option < bool >( "CBM_SLOTS_ENABLED" ) ) {
        const bool each_bp_on_new_line = ypos + static_cast<int>( num_bp ) + 1 < getmaxy( win );
        ypos += fold_and_print( win, ypos, 0, width, c_light_gray,
                                list_occupied_bps( bio.id, _( "This bionic occupies the following body parts:" ),
                                        each_bp_on_new_line ) );
    }
    wrefresh( win );
}
Пример #15
0
void draw_description( const catacurses::window &win, bionic const &bio )
{
    werase( win );
    const int width = getmaxx( win );
    const std::string poweronly_string = build_bionic_poweronly_string( bio );
    int ypos = fold_and_print( win, 0, 0, width, c_white, bio.id->name );
    if( !poweronly_string.empty() ) {
        ypos += fold_and_print( win, ypos, 0, width, c_light_gray,
                                _( "Power usage: %s" ), poweronly_string.c_str() );
    }
    ypos += 1 + fold_and_print( win, ypos, 0, width, c_light_blue, bio.id->description );

    // @todo: Unhide when enforcing limits
    if( g->u.has_trait( trait_id( "DEBUG_CBM_SLOTS" ) ) ) {
        const bool each_bp_on_new_line = ypos + ( int )num_bp + 1 < getmaxy( win );
        ypos += fold_and_print( win, ypos, 0, width, c_light_gray,
                                list_occupied_bps( bio.id, _( "This bionic occupies the following body parts:" ),
                                        each_bp_on_new_line ) );
    }
    wrefresh( win );
}
Пример #16
0
void realDebugmsg( const char *filename, const char *line, const char *funcname,
                   const std::string &text )
{
    assert( filename != nullptr );
    assert( line != nullptr );
    assert( funcname != nullptr );

    if( test_mode ) {
        test_dirty = true;
        std::cerr << filename << ":" << line << " [" << funcname << "] " << text << std::endl;
        return;
    }

    DebugLog( D_ERROR, D_MAIN ) << filename << ":" << line << " [" << funcname << "] " << text;

    std::string msg_key( filename );
    msg_key += line;

    if( ignored_messages.count( msg_key ) > 0 ) {
        return;
    }

    if( stdscr == nullptr ) {
        std::cerr << text << std::endl;
        abort();
    }

    fold_and_print( stdscr, 0, 0, getmaxx( stdscr ), c_light_red,
                    "\n \n" // Looks nicer with some space
                    " DEBUG    : %s\n \n"
                    " FUNCTION : %s\n"
                    " FILE     : %s\n"
                    " LINE     : %s\n \n"
                    " Press <color_white>spacebar</color> to continue the game...\n"
                    " Press <color_white>I</color> (or <color_white>i</color>) to also ignore this particular message in the future...",
                    text.c_str(), funcname, filename, line );

    for( bool stop = false; !stop; ) {
        switch( inp_mngr.get_input_event().get_first_input() ) {
            case 'i':
            case 'I':
                ignored_messages.insert( msg_key );
            /* fallthrough */
            case ' ':
                stop = true;
                break;
        }
    }

    werase( stdscr );
    refresh();
}
Пример #17
0
void robot_finds_kitten::instructions(WINDOW *w)
{
    int pos = 1;
    pos += fold_and_print(w, 0, 1, getmaxx(w) - 4, c_ltgray, _("robotfindskitten v22July2008"));
    pos += 1 + fold_and_print(w, pos, 1, getmaxx(w) - 4, c_ltgray, _("\
Originally by the illustrious Leonard Richardson, \
rewritten in PDCurses by Joseph Larson, \
ported to CDDA gaming system by a nutcase."));

    pos += 1 + fold_and_print(w, pos, 1, getmaxx(w) - 4, c_ltgray,
                              _("In this game, you are robot ("));
    draw_robot(w);
    wprintz(w, c_ltgray, _(")."));
    pos += 1 + fold_and_print(w, pos, 1, getmaxx(w) - 4, c_ltgray, _("\
Your job is to find kitten. This task is complicated by the existance of various things \
which are not kitten. Robot must touch items to determine if they are kitten or not. \
The game ends when robotfindskitten. Alternatively, you may end the game by hitting \
'q', 'Q' or the escape key."));
    fold_and_print(w, pos, 1, getmaxx(w) - 4, c_ltgray, _("Press any key to start."));
    wrefresh(w);
    getch();
}
Пример #18
0
void worldfactory::draw_modselection_borders(WINDOW *win, input_context *ctxtp)
{
    // make appropriate lines: X & Y coordinate of starting point, length, horizontal/vertical type
    int xs[] = {1, 1, (FULL_SCREEN_WIDTH / 2) + 2, (FULL_SCREEN_WIDTH / 2) - 4,
                (FULL_SCREEN_WIDTH / 2) + 2
               };
    int ys[] = {FULL_SCREEN_HEIGHT - 8, 4, 4, 3, 3};
    int ls[] = {FULL_SCREEN_WIDTH - 2, (FULL_SCREEN_WIDTH / 2) - 4, (FULL_SCREEN_WIDTH / 2) - 3,
                FULL_SCREEN_HEIGHT - 11, 1
               };
    bool hv[] = {true, true, true, false, false}; // horizontal line = true, vertical line = false

    for (int i = 0; i < 5; ++i) {
        int x = xs[i];
        int y = ys[i];
        int l = ls[i];
        if (hv[i]) {
            for (int j = 0; j < l; ++j) {
                mvwputch(win, y, x + j, BORDER_COLOR, LINE_OXOX); // _
            }
        } else {
            for (int j = 0; j < l; ++j) {
                mvwputch(win, y + j, x, BORDER_COLOR, LINE_XOXO); // |
            }
        }
    }

    // Add in connective characters
    mvwputch(win, 4, 0, BORDER_COLOR, LINE_XXXO);
    mvwputch(win, FULL_SCREEN_HEIGHT - 8, 0, BORDER_COLOR, LINE_XXXO);
    mvwputch(win, 4, FULL_SCREEN_WIDTH / 2 + 2, BORDER_COLOR, LINE_XXXO);

    mvwputch(win, 4, FULL_SCREEN_WIDTH - 1, BORDER_COLOR, LINE_XOXX);
    mvwputch(win, FULL_SCREEN_HEIGHT - 8, FULL_SCREEN_WIDTH - 1, BORDER_COLOR, LINE_XOXX);
    mvwputch(win, 4, FULL_SCREEN_WIDTH / 2 - 4, BORDER_COLOR, LINE_XOXX);

    mvwputch(win, 2, FULL_SCREEN_WIDTH / 2 - 4, BORDER_COLOR, LINE_OXXX); // -.-
    mvwputch(win, 2, FULL_SCREEN_WIDTH / 2 + 2, BORDER_COLOR, LINE_OXXX); // -.-

    mvwputch(win, FULL_SCREEN_HEIGHT - 8, FULL_SCREEN_WIDTH / 2 - 4, BORDER_COLOR, LINE_XXOX); // _|_
    mvwputch(win, FULL_SCREEN_HEIGHT - 8, FULL_SCREEN_WIDTH / 2 + 2, BORDER_COLOR, LINE_XXOX); // _|_

    // Add tips & hints
    fold_and_print(win, FULL_SCREEN_HEIGHT - 7, 2, getmaxx(win) - 4, c_green,
                   _("Press %s to save the list of active mods as default. Press %s for help."),
                   ctxtp->get_desc("SAVE_DEFAULT_MODS").c_str(),
                   ctxtp->get_desc("HELP_KEYBINDINGS").c_str()
                  );
    wrefresh(win);
    refresh();
}
Пример #19
0
void multipage(WINDOW *w, std::vector<std::string> text, std::string caption, int begin_y)
{
    int height = getmaxy(w);
    int width = getmaxx(w);

    //Do not erase the current screen if it's not first line of the text
    if (begin_y == 0) {
        werase(w);
    }

    /* TODO:
        issue:     # of lines in the paragraph > height -> inf. loop;
        solution:  split this paragraph in two pieces;
    */
    for (size_t i = 0; i < text.size(); i++) {
        if (begin_y == 0 && caption != "") {
            begin_y = fold_and_print(w, 0, 1, width - 2, c_white, caption) + 1;
        }
        std::vector<std::string> next_paragraph = foldstring(text[i].c_str(), width - 2);
        if (begin_y + next_paragraph.size() > height - ((i + 1) < text.size() ? 1 : 0)) {
            // Next page
            i--;
            mvwprintw(w, height - 1, 1, _("Press any key for more..."));
            wrefresh(w);
            refresh();
            getch();
            werase(w);
            begin_y = 0;
        } else {
            begin_y += fold_and_print(w, begin_y, 1, width - 2, c_white, text[i]) + 1;
        }
    }
    wrefresh(w);
    refresh();
    getch();
}
Пример #20
0
void realDebugmsg( const char *filename, const char *line, const char *mes, ... )
{
    va_list ap;
    va_start( ap, mes );
    const std::string text = vstring_format( mes, ap );
    va_end( ap );
    DebugLog( D_ERROR, D_MAIN ) << filename << ":" << line << " " << text;
    fold_and_print( stdscr, 0, 0, getmaxx( stdscr ), c_ltred, "DEBUG: %s\n  Press spacebar...",
                    text.c_str() );
    while( getch() != ' ' ) {
        // wait for spacebar
    }
    werase( stdscr );
    refresh();
}
Пример #21
0
void realDebugmsg(const char* filename, const char* line, const char *mes, ...)
{
 va_list ap;
 va_start(ap, mes);
 char buff[1024];
 vsprintf(buff, mes, ap);
 va_end(ap);
    fold_and_print(stdscr, 0, 0, getmaxx(stdscr), c_red, "DEBUG: %s\n  Press spacebar...", buff);
 std::ofstream fout;
 fout.open("debug.log", std::ios_base::app | std::ios_base::out);
 fout << filename << "[" << line << "]: " << buff << "\n";
 fout.close();
 while(getch() != ' ') ;
;
}
Пример #22
0
void realDebugmsg(const char *filename, const char *line, const char *mes, ...)
{
    va_list ap;
    va_start(ap, mes);
    const std::string text = vstring_format(mes, ap);
    va_end(ap);
    fold_and_print(stdscr, 0, 0, getmaxx(stdscr), c_red, "DEBUG: %s\n  Press spacebar...", text.c_str());
    std::ofstream fout;
    fout.open("debug.log", std::ios_base::app | std::ios_base::out);
    fout << filename << "[" << line << "]: " << text << "\n";
    fout.close();
    while (getch() != ' ') {
        // wait for spacebar
    }
    werase(stdscr);
}
Пример #23
0
/**
 * Handles draining water from a vehicle.
 * @param reason INVALID_TARGET if the vehicle has no water,
 *               LACK_TOOLS if the player has no hose.
 */
void veh_interact::do_drain(task_reason reason)
{
    werase (w_msg);
    int msg_width = getmaxx(w_msg);
    switch (reason) {
    case INVALID_TARGET:
        mvwprintz(w_msg, 0, 1, c_ltred, _("The vehicle has no water to siphon.") );
        wrefresh (w_msg);
        return;
    case LACK_TOOLS:
        fold_and_print(w_msg, 0, 1, msg_width - 2, c_ltgray,
                       _("You need a <color_red>hose</color> to siphon water.") );
        wrefresh (w_msg);
        return;
    }
    sel_cmd = 'd';
}
Пример #24
0
void draw_bionics_titlebar( const catacurses::window &window, player *p, bionic_menu_mode mode )
{
    werase( window );

    const int pwr_str_pos = right_print( window, 0, 1, c_white, string_format( _( "Power: %i/%i" ),
                                         p->power_level, p->max_power_level ) );
    std::string desc;
    if( mode == REASSIGNING ) {
        desc = _( "Reassigning.\nSelect a bionic to reassign or press SPACE to cancel." );
    } else if( mode == ACTIVATING ) {
        desc = _( "<color_green>Activating</color>  <color_yellow>!</color> to examine, <color_yellow>=</color> to reassign, <color_yellow>TAB</color> to switch tabs." );
    } else if( mode == EXAMINING ) {
        desc = _( "<color_light_blue>Examining</color>  <color_yellow>!</color> to activate, <color_yellow>=</color> to reassign, <color_yellow>TAB</color> to switch tabs." );
    }
    fold_and_print( window, 0, 1, pwr_str_pos, c_white, desc );

    wrefresh( window );
}
Пример #25
0
/**
 * Handles siphoning gas.
 * @param reason 1 if the vehicle has no gas, 2 if the player has no hose.
 */
void veh_interact::do_siphon(int reason)
{
    werase (w_msg);
    int msg_width = getmaxx(w_msg);
    switch (reason)
    {
    case 1:
        mvwprintz(w_msg, 0, 1, c_ltred, _("The vehicle has no gasoline to siphon."));
        wrefresh (w_msg);
        return;
    case 2:
        fold_and_print(w_msg, 0, 1, msg_width-2, c_ltgray,
                       _("You need a <color_red>hose</color> to siphon fuel."));
        wrefresh (w_msg);
        return;
    }
    sel_cmd = 's';
}
Пример #26
0
int requirements::print_list( WINDOW *w, int ypos, int xpos, int width, nc_color col,
                              const inventory &crafting_inv, const std::vector< std::vector<T> > &objs )
{
    const int oldy = ypos;
    for( const auto & comp_list : objs ) {
        const bool has_one = any_marked_available( comp_list );
        std::ostringstream buffer;
        for( auto a = comp_list.begin(); a != comp_list.end(); ++a ) {
            if( a != comp_list.begin() ) {
                buffer << "<color_white> " << _( "OR" ) << "</color> ";
            }
            const std::string col = a->get_color( has_one, crafting_inv );
            buffer << "<color_" << col << ">" << a->to_string() << "</color>";
        }
        mvwprintz( w, ypos, xpos, col, "> " );
        ypos += fold_and_print( w, ypos, xpos + 2, width - 2, col, buffer.str() );
    }
    return ypos - oldy;
}
Пример #27
0
/**
 * Handles refilling a vehicle's fuel tank.
 * @param reason INVALID_TARGET if there's no fuel tank in the spot,
 *               LACK_TOOLS if the player has nothing to fill the tank with.
 */
void veh_interact::do_refill(task_reason reason)
{
    werase (w_msg);
    int msg_width = getmaxx(w_msg);
    switch (reason) {
    case INVALID_TARGET:
        mvwprintz(w_msg, 0, 1, c_ltred, _("There's no fuel tank here."));
        wrefresh (w_msg);
        return;
    case LACK_TOOLS:
        fold_and_print(w_msg, 0, 1, msg_width - 2, c_ltgray,
                       _("You need <color_red>%s</color>."),
                       ammo_name(vehicle_part_types[ptank->id].fuel_type).c_str());
        wrefresh (w_msg);
        return;
    }
    sel_cmd = 'f';
    sel_vehicle_part = ptank;
}
Пример #28
0
bool query_yn(const char *mes, ...)
{
    va_list ap;
    va_start(ap, mes);
    char buff[1024];
    vsprintf(buff, mes, ap);
    va_end(ap);

    bool force_uc = OPTIONS["FORCE_CAPITAL_YN"];
    std::string query;
    if (force_uc) {
        query = string_format(_("%s (Y/N - Case Sensitive)"), buff);
    } else {
        query = string_format(_("%s (y/n)"), buff);
    }

    int win_width = utf8_width(query.c_str()) + 2;
    win_width = (win_width < FULL_SCREEN_WIDTH - 2 ? win_width : FULL_SCREEN_WIDTH - 2);

    std::vector<std::string> textformatted;
    textformatted = foldstring(query, win_width);
    WINDOW *w = newwin(textformatted.size() + 2, win_width, (TERMY - 3) / 2,
                       (TERMX > win_width) ? (TERMX - win_width) / 2 : 0);

    fold_and_print(w, 1, 1, win_width, c_ltred, query.c_str());

    draw_border(w);

    wrefresh(w);
    char ch;
    do {
        ch = getch();
    } while (ch != '\n' && ch != ' ' && ch != KEY_ESCAPE && ch != 'Y'
             && ch != 'N' && (force_uc || (ch != 'y' && ch != 'n')));
    werase(w);
    wrefresh(w);
    delwin(w);
    refresh();
    if (ch == 'Y' || ch == 'y') {
        return true;
    }
    return false;
}
Пример #29
0
        virtual void select(int entnum, uimenu *menu) override
        {
            const int starty = 3;
            const int startx = menu->w_width - menu->pad_right;
            const std::string padding(menu->pad_right, ' ');
            for(int y = 2; y < menu->w_height - 1; y++) {
                mvwprintw(menu->window, y, startx - 1, "%s", padding.c_str());
            }
            item tmp(standard_itype_ids[entnum], calendar::turn);
            mvwhline( menu->window, 1, startx, ' ', menu->pad_right - 1 );
            const std::string header = string_format("#%d: %s%s", entnum, standard_itype_ids[entnum].c_str(),
                                       ( incontainer ? _(" (contained)") : "" ));
            mvwprintz(menu->window, 1, startx + ( menu->pad_right - 1 - header.size() ) / 2, c_cyan, "%s",
                      header.c_str());

            fold_and_print(menu->window, starty, startx, menu->pad_right - 1, c_ltgray, tmp.info(true));

            mvwprintz(menu->window, menu->w_height - 3, startx, c_green, "%s", msg.c_str());
            msg.erase();

            mvwprintw(menu->window, menu->w_height - 2, startx, _("[/] find, [f] container, [q]uit"));
        }
Пример #30
0
int worldfactory::show_worldgen_tab_modselection(WINDOW *win, WORLDPTR world)
{
    // Use active_mod_order of the world,
    // saves us from writing 'world->active_mod_order' all the time.
    std::vector<std::string> &active_mod_order = world->active_mod_order;
    {
        std::vector<std::string> tmp_mod_order;
        // clear active_mod_order and re-add all the mods, his ensures
        // that changes (like changing dependencies) get updated
        tmp_mod_order.swap(active_mod_order);
        for( auto &elem : tmp_mod_order ) {
            mman_ui->try_add( elem, active_mod_order );
        }
    }

    input_context ctxt("MODMANAGER_DIALOG");
    ctxt.register_updown();
    ctxt.register_action("LEFT", _("Switch to other list"));
    ctxt.register_action("RIGHT", _("Switch to other list"));
    ctxt.register_action("HELP_KEYBINDINGS");
    ctxt.register_action("QUIT");
    ctxt.register_action("NEXT_TAB");
    ctxt.register_action("PREV_TAB");
    ctxt.register_action("CONFIRM", _("Activate / deactive mod"));
    ctxt.register_action("ADD_MOD");
    ctxt.register_action("REMOVE_MOD");
    ctxt.register_action("SAVE_DEFAULT_MODS");

    const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0;
    const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0;

    // lots of small windows so that each section can be drawn to independently of the others as necessary
    WINDOW *w_header1, *w_header2, *w_shift, *w_list, *w_active, *w_description;
    w_header1 = newwin(1, FULL_SCREEN_WIDTH / 2 - 5, 3 + iOffsetY, 1 + iOffsetX);
    w_header2 = newwin(1, FULL_SCREEN_WIDTH / 2 - 4, 3 + iOffsetY,
                       FULL_SCREEN_WIDTH / 2 + 3 + iOffsetX);
    w_shift   = newwin(13, 5, 3 + iOffsetY, FULL_SCREEN_WIDTH / 2 - 3 + iOffsetX);
    w_list    = newwin(11, FULL_SCREEN_WIDTH / 2 - 4, 5 + iOffsetY, iOffsetX);
    w_active  = newwin(11, FULL_SCREEN_WIDTH / 2 - 4, 5 + iOffsetY,
                       FULL_SCREEN_WIDTH / 2 + 2 + iOffsetX);
    w_description = newwin(4, FULL_SCREEN_WIDTH - 2, 19 + iOffsetY, 1 + iOffsetX);

    draw_modselection_borders(win, &ctxt);
    std::vector<std::string> headers;
    headers.push_back(_("Mod List"));
    headers.push_back(_("Mod Load Order"));
    std::vector<WINDOW *> header_windows;
    header_windows.push_back(w_header1);
    header_windows.push_back(w_header2);

    int tab_output = 0;
    int last_active_header = 0;
    size_t active_header = 0;
    size_t useable_mod_count = mman_ui->usable_mods.size();
    int startsel[2] = {0, 0};
    int cursel[2] = {0, 0};

    bool redraw_headers = true;
    bool redraw_shift = true;
    bool redraw_description = true;
    bool redraw_list = true;
    bool redraw_active = true;
    bool selection_changed = false;

    while (tab_output == 0) {
        if (redraw_headers) {
            for (size_t i = 0; i < headers.size(); ++i) {
                werase(header_windows[i]);
                const int header_x = (getmaxx(header_windows[i]) - headers[i].size()) / 2;
                mvwprintz(header_windows[i], 0, header_x , c_cyan, "%s", headers[i].c_str());

                if (active_header == i) {
                    mvwputch(header_windows[i], 0, header_x - 3, c_red, '<');
                    mvwputch(header_windows[i], 0, header_x + headers[i].size() + 2, c_red, '>');
                }
                wrefresh(header_windows[i]);
            }
            redraw_list = true;
            redraw_active = true;
            redraw_shift = true;
            redraw_headers = false;
        }
        if (selection_changed) {
            if (active_header == 0) {
                redraw_list = true;
            }
            if (active_header == 1) {
                redraw_shift = true;
                redraw_active = true;
            }
            selection_changed = false;
            redraw_description = true;
        }
        if (redraw_description) {
            werase(w_description);

            MOD_INFORMATION *selmod = NULL;
            if (mman_ui->usable_mods.empty()) {
                // Do nothing, leave selmod == NULL
            } else if (active_header == 0) {
                selmod = mman->mod_map[mman_ui->usable_mods[cursel[0]]];
            } else if (!active_mod_order.empty()) {
                selmod = mman->mod_map[active_mod_order[cursel[1]]];
            }

            if (selmod != NULL) {
                fold_and_print(w_description, 0, 1, getmaxx(w_description) - 1,
                               c_white, mman_ui->get_information(selmod));
            }
            redraw_description = false;
            wrefresh(w_description);
        }
        if (redraw_list) {
            draw_mod_list( w_list, startsel[0], cursel[0], mman_ui->usable_mods, active_header == 0, _("--NO AVAILABLE MODS--") );
        }
        if (redraw_active) {
            draw_mod_list( w_active, startsel[1], cursel[1], active_mod_order, active_header == 1, _("--NO ACTIVE MODS--") );
        }
        if (redraw_shift) {
            werase(w_shift);
            if (active_header == 1) {
                std::stringstream shift_display;
                // get shift information for whatever is visible in the active list
                for (size_t i = startsel[1], c = 0; i < active_mod_order.size() &&
                     (int)c < getmaxy(w_active); ++i, ++c) {
                    if (mman_ui->can_shift_up(i, active_mod_order)) {
                        shift_display << "<color_blue>+</color> ";
                    } else {
                        shift_display << "<color_dkgray>+</color> ";
                    }
                    if (mman_ui->can_shift_down(i, active_mod_order)) {
                        shift_display << "<color_blue>-</color>";
                    } else {
                        shift_display << "<color_dkgray>-</color>";
                    }
                    shift_display << "\n";
                }
                fold_and_print(w_shift, 2, 1, getmaxx(w_shift), c_white, shift_display.str());
            }
            redraw_shift = false;
            wrefresh(w_shift);
        }
        refresh();

        last_active_header = active_header;
        const int next_header = (active_header == 1) ? 0 : 1;
        const int prev_header = (active_header == 0) ? 1 : 0;

        int selection = (active_header == 0) ? cursel[0] : cursel[1];
        int last_selection = selection;
        unsigned int next_selection = selection + 1;
        int prev_selection = selection - 1;
        if (active_header == 0) {
            next_selection = (next_selection >= useable_mod_count) ? 0 : next_selection;
            prev_selection = (prev_selection < 0) ? useable_mod_count - 1 : prev_selection;
        } else {
            next_selection = (next_selection >= active_mod_order.size()) ? 0 : next_selection;
            prev_selection = (prev_selection < 0) ? active_mod_order.size() - 1 : prev_selection;
        }

        const std::string action = ctxt.handle_input();

        if (action == "DOWN") {
            selection = next_selection;
        } else if (action == "UP") {
            selection = prev_selection;
        } else if (action == "RIGHT") {
            active_header = next_header;
        } else if (action == "LEFT") {
            active_header = prev_header;
        } else if (action == "CONFIRM") {
            if (active_header == 0 && !mman_ui->usable_mods.empty()) {
#ifndef LUA
                if (mman->mod_map[mman_ui->usable_mods[cursel[0]]]->need_lua) {
                    popup(_("Can't add mod. This mod requires Lua support."));
                    redraw_active = true;
                    redraw_shift = true;
                    draw_modselection_borders(win, &ctxt);
                    continue;
                }
#endif
                // try-add
                mman_ui->try_add(mman_ui->usable_mods[cursel[0]], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
            } else if (active_header == 1 && !active_mod_order.empty()) {
                // try-rem
                mman_ui->try_rem(cursel[1], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
                if (active_mod_order.empty()) {
                    // switch back to other list, we can't change
                    // anything in the empty active mods list.
                    active_header = 0;
                }
            }
        } else if (action == "ADD_MOD") {
            if (active_header == 1 && active_mod_order.size() > 1) {
                mman_ui->try_shift('+', cursel[1], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
            }
        } else if (action == "REMOVE_MOD") {
            if (active_header == 1 && active_mod_order.size() > 1) {
                mman_ui->try_shift('-', cursel[1], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
            }
        } else if (action == "NEXT_TAB") {
            tab_output = 1;
        } else if (action == "PREV_TAB") {
            tab_output = -1;
        } else if (action == "SAVE_DEFAULT_MODS") {
            if(mman->set_default_mods(active_mod_order)) {
                popup(_("Saved list of active mods as default"));
                draw_modselection_borders(win, &ctxt);
                redraw_headers = true;
            }
        } else if (action == "HELP_KEYBINDINGS") {
            // Redraw all the things!
            redraw_headers = true;
            redraw_shift = true;
            redraw_description = true;
            redraw_list = true;
            redraw_active = true;
            draw_worldgen_tabs( win, 0 );
            draw_modselection_borders( win, &ctxt );
        } else if (action == "QUIT") {
            tab_output = -999;
        }
        // RESOLVE INPUTS
        if (last_active_header != (int)active_header) {
            redraw_headers = true;
            redraw_shift = true;
            redraw_description = true;
        }
        if (last_selection != selection) {
            if (active_header == 0) {
                redraw_list = true;
                cursel[0] = selection;
            } else {
                redraw_active = true;
                redraw_shift = true;
                cursel[1] = selection;
            }
            redraw_description = true;
        }
        if (active_mod_order.empty()) {
            redraw_active = true;
            cursel[1] = 0;
        }

        if (active_header == 1) {
            if (active_mod_order.empty()) {
                cursel[1] = 0;
            } else {
                if (cursel[1] < 0) {
                    cursel[1] = 0;
                } else if (cursel[1] >= (int)active_mod_order.size()) {
                    cursel[1] = active_mod_order.size() - 1;
                }
            }
        }
        // end RESOLVE INPUTS
    }
    werase(w_header1);
    werase(w_header2);
    werase(w_shift);
    werase(w_list);
    werase(w_active);
    werase(w_description);

    delwin(w_header1);
    delwin(w_header2);
    delwin(w_shift);
    delwin(w_list);
    delwin(w_active);
    delwin(w_description);
    return tab_output;
}