//same as above, from current position size_t shortcut_print(WINDOW* w, nc_color color, nc_color colork, const char* fmt, ...) { va_list ap; va_start(ap,fmt); char buff[3000]; //TODO replace Magic Number vsprintf(buff, fmt, ap); va_end(ap); std::string tmp = buff; size_t pos = tmp.find_first_of('<'); size_t pos2 = tmp.find_first_of('>'); size_t len = 0; if(pos2!=std::string::npos && pos<pos2) { tmp.erase(pos,1); tmp.erase(pos2-1,1); wprintz(w, color, tmp.substr(0, pos).c_str()); wprintz(w, colork, "%s", tmp.substr(pos, pos2-pos-1).c_str()); wprintz(w, color, tmp.substr(pos2-1).c_str()); len = utf8_width(tmp.c_str()); } else { // no shutcut? wprintz(w, color, buff); len = utf8_width(buff); } return len; }
void print_inv_weight_vol(game *g, WINDOW* w_inv, int weight_carried, int vol_carried) { // Print weight mvwprintw(w_inv, 0, 39, _("Weight: ")); if (weight_carried >= g->u.weight_capacity()) { wprintz(w_inv, c_red, "%6.1f", g->u.convert_weight(weight_carried)); } else { wprintz(w_inv, c_ltgray, "%6.1f", g->u.convert_weight(weight_carried)); } wprintz(w_inv, c_ltgray, "/%-6.1f", g->u.convert_weight(g->u.weight_capacity())); // Print volume mvwprintw(w_inv, 0, 61, _("Volume: ")); if (vol_carried > g->u.volume_capacity() - 2) { wprintz(w_inv, c_red, "%3d", vol_carried); } else { wprintz(w_inv, c_ltgray, "%3d", vol_carried); } wprintw(w_inv, "/%-3d", g->u.volume_capacity() - 2); }
void draw_caravan_items(WINDOW *w, game *g, std::vector<itype_id> *items, std::vector<int> *counts, int offset, int item_selected) { // Print the item info first. This is important, because it contains \n which // will corrupt the item list. // Actually, clear the item info first. for (int i = 12; i <= 23; i++) mvwprintz(w, i, 1, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // THEN print it--if item_selected is valid if (item_selected < items->size()) { item tmp(g->itypes[ (*items)[item_selected] ], 0); // Dummy item to get info mvwprintz(w, 12, 0, c_white, tmp.info().c_str()); } // Next, clear the item list on the right for (int i = 1; i <= 23; i++) mvwprintz(w, i, 40, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // Finally, print the item list on the right for (int i = offset; i <= offset + 23 && i < items->size(); i++) { mvwprintz(w, i - offset + 1, 40, (item_selected == i ? h_white : c_white), g->itypes[ (*items)[i] ]->name.c_str()); wprintz(w, c_white, " x %s%d", ((*counts)[i] >= 10 ? "" : " "), (*counts)[i]); if ((*counts)[i] > 0) { int price = caravan_price(g->u, g->itypes[(*items)[i]]->price *(*counts)[i]); wprintz(w, (price > g->u.cash ? c_red : c_green), "($%s%d)", (price >= 100000 ? "" : (price >= 10000 ? " " : (price >= 1000 ? " " : (price >= 100 ? " " : (price >= 10 ? " " : " "))))), price); } } wrefresh(w); }
void print_inv_weight_vol(game *g, WINDOW* w_inv, int weight_carried, int vol_carried) { // Print weight mvwprintw(w_inv, 0, 43, "Weight: "); if (weight_carried >= g->u.weight_capacity() * .25) { wprintz(w_inv, c_red, "%4d", weight_carried); } else { wprintz(w_inv, c_ltgray, "%4d", weight_carried); } wprintz(w_inv, c_ltgray, "/%-4d", int(g->u.weight_capacity() * .25));//, g->u.weight_capacity()); // Print volume mvwprintw(w_inv, 0, 61, "Volume: "); if (vol_carried > g->u.volume_capacity() - 2) { wprintz(w_inv, c_red, "%3d", vol_carried); } else { wprintz(w_inv, c_ltgray, "%3d", vol_carried); } wprintw(w_inv, "/%-3d", g->u.volume_capacity() - 2); }
void print_inv_weight_vol(WINDOW* w_inv, int weight_carried, int vol_carried, int vol_capacity) { // Print weight mvwprintw(w_inv, 0, 32, _("Weight (%s): "), OPTIONS["USE_METRIC_WEIGHTS"].getValue() == "lbs" ? "lbs" : "kg"); if (weight_carried >= g->u.weight_capacity()) { wprintz(w_inv, c_red, "%6.1f", g->u.convert_weight(weight_carried)); } else { wprintz(w_inv, c_ltgray, "%6.1f", g->u.convert_weight(weight_carried)); } wprintz(w_inv, c_ltgray, "/%-6.1f", g->u.convert_weight(g->u.weight_capacity())); // Print volume mvwprintw(w_inv, 0, 61, _("Volume: ")); if (vol_carried > vol_capacity - 2) { wprintz(w_inv, c_red, "%3d", vol_carried); } else { wprintz(w_inv, c_ltgray, "%3d", vol_carried); } wprintw(w_inv, "/%-3d", vol_capacity - 2); }
void live_view::show(const int x, const int y) { if (!enabled || !w_live_view) { return; } bool did_hide = hide(false); // Clear window if it's visible if (!g->u.sees(x, y)) { if (did_hide) { wrefresh(*this); } return; } map &m = g->m; mvwprintz(*this, 0, START_COLUMN, c_white, "< "); wprintz(*this, c_green, _("Mouse View")); wprintz(*this, c_white, " >"); int line = START_LINE; // TODO: Z tripoint p( x, y, g->get_levz() ); g->print_all_tile_info( p, *this, START_COLUMN, line, true); if (m.can_put_items( p ) && m.sees_some_items( p, g->u)) { if(g->u.has_effect("blind") || g->u.worn_with_flag("BLIND")) { mvwprintz(*this, line++, START_COLUMN, c_yellow, _("There's something here, but you can't see what it is.")); } else { print_items(*this, m.i_at(p), line); } } #if (defined TILES || defined SDLTILES || defined _WIN32 || defined WINDOWS) // Because of the way the status UI is done, the live view window must // be tall enough to clear the entire height of the viewport below the // status bar. This hack allows the border around the live view box to // be drawn only as big as it needs to be, while still leaving the // window tall enough. Won't work for ncurses in Linux, but that doesn't // currently support the mouse. If and when it does, there'll need to // be a different code path here that works for ncurses. int full_height = w_live_view->height; if (line < w_live_view->height - 1) { w_live_view->height = (line > 11) ? line : 11; } last_height = w_live_view->height; #endif draw_border(*this); #if (defined TILES || defined SDLTILES || defined _WIN32 || defined WINDOWS) w_live_view->height = full_height; #endif inuse = true; wrefresh(*this); }
int monster::print_info(WINDOW* w, int vStart, int vLines, int column) { // First line of w is the border; the next two are terrain info, and after that // is a blank line. w is 13 characters tall, and we can't use the last one // because it's a border as well; so we have lines 4 through 11. // w is also 48 characters wide - 2 characters for border = 46 characters for us // vStart added because 'help' text in targeting win makes helpful info hard to find // at a glance. const int vEnd = vStart + vLines; mvwprintz(w, vStart++, column, c_white, "%s ", name().c_str()); nc_color color = c_white; std::string attitude = ""; get_Attitude(color, attitude); wprintz(w, color, "%s", attitude.c_str()); if (has_effect("downed")) wprintz(w, h_white, _("On ground")); else if (has_effect("stunned")) wprintz(w, h_white, _("Stunned")); else if (has_effect("beartrap")) wprintz(w, h_white, _("Trapped")); std::string damage_info; nc_color col; if (hp >= type->hp) { damage_info = _("It is uninjured"); col = c_green; } else if (hp >= type->hp * .8) { damage_info = _("It is lightly injured"); col = c_ltgreen; } else if (hp >= type->hp * .6) { damage_info = _("It is moderately injured"); col = c_yellow; } else if (hp >= type->hp * .3) { damage_info = _("It is heavily injured"); col = c_yellow; } else if (hp >= type->hp * .1) { damage_info = _("It is severely injured"); col = c_ltred; } else { damage_info = _("it is nearly dead"); col = c_red; } mvwprintz(w, vStart++, column, col, "%s", damage_info.c_str()); std::vector<std::string> lines = foldstring(type->description, getmaxx(w) - 1 - column); int numlines = lines.size(); for (int i = 0; i < numlines && vStart <= vEnd; i++) mvwprintz(w, vStart++, column, c_white, "%s", lines[i].c_str()); return vStart; }
void live_view::show(const int x, const int y) { if (!enabled || w_live_view == NULL) { return; } bool did_hide = hide(false); // Clear window if it's visible if (!g->u_see(x,y)) { if (did_hide) { wrefresh(w_live_view); } return; } map &m = g->m; mvwprintz(w_live_view, 0, START_COLUMN, c_white, "< "); wprintz(w_live_view, c_green, _("Mouse View")); wprintz(w_live_view, c_white, " >"); int line = START_LINE; g->print_all_tile_info(x, y, w_live_view, START_COLUMN, line, true); if (m.can_put_items(x, y)) { std::vector<item> &items = m.i_at(x, y); print_items(items, line); } #if (defined TILES || defined SDLTILES || defined _WIN32 || defined WINDOWS) // Because of the way the status UI is done, the live view window must // be tall enough to clear the entire height of the viewport below the // status bar. This hack allows the border around the live view box to // be drawn only as big as it needs to be, while still leaving the // window tall enough. Won't work for ncurses in Linux, but that doesn't // currently support the mouse. If and when it does, there'll need to // be a different code path here that works for ncurses. int full_height = w_live_view->height; if (line < w_live_view->height - 1) { w_live_view->height = (line > 11) ? line : 11; } last_height = w_live_view->height; #endif wborder(w_live_view, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); #if (defined TILES || defined SDLTILES || defined _WIN32 || defined WINDOWS) w_live_view->height = full_height; #endif inuse = true; wrefresh(w_live_view); }
int monster::print_info(WINDOW* w, int vStart, int vLines, int column) const { const int vEnd = vStart + vLines; mvwprintz(w, vStart++, column, c_white, "%s ", name().c_str()); nc_color color = c_white; std::string attitude = ""; get_Attitude(color, attitude); wprintz(w, color, "%s", attitude.c_str()); if (has_effect("downed")) { wprintz(w, h_white, _("On ground")); } else if (has_effect("stunned")) { wprintz(w, h_white, _("Stunned")); } else if (has_effect("beartrap")) { wprintz(w, h_white, _("Trapped")); } else if (has_effect("tied")) { wprintz(w, h_white, _("Tied")); } std::string damage_info; nc_color col; if (hp >= type->hp) { damage_info = _("It is uninjured"); col = c_green; } else if (hp >= type->hp * .8) { damage_info = _("It is lightly injured"); col = c_ltgreen; } else if (hp >= type->hp * .6) { damage_info = _("It is moderately injured"); col = c_yellow; } else if (hp >= type->hp * .3) { damage_info = _("It is heavily injured"); col = c_yellow; } else if (hp >= type->hp * .1) { damage_info = _("It is severely injured"); col = c_ltred; } else { damage_info = _("it is nearly dead"); col = c_red; } mvwprintz(w, vStart++, column, col, "%s", damage_info.c_str()); std::vector<std::string> lines = foldstring(type->description, getmaxx(w) - 1 - column); int numlines = lines.size(); for (int i = 0; i < numlines && vStart <= vEnd; i++) { mvwprintz(w, vStart++, column, c_white, "%s", lines[i].c_str()); } return vStart; }
void monster::print_info(game *g, WINDOW* w) { // First line of w is the border; the next two are terrain info, and after that // is a blank line. w is 13 characters tall, and we can't use the last one // because it's a border as well; so we have lines 4 through 11. // w is also 48 characters wide - 2 characters for border = 46 characters for us mvwprintz(w, 6, 1, type->color, type->name.c_str()); if (friendly != 0) { wprintz(w, c_white, " "); wprintz(w, h_white, "Friendly!"); } std::string damage_info; nc_color col; if (hp == type->hp) { damage_info = "It is uninjured"; col = c_green; } else if (hp >= type->hp * .8) { damage_info = "It is lightly injured"; col = c_ltgreen; } else if (hp >= type->hp * .6) { damage_info = "It is moderately injured"; col = c_yellow; } else if (hp >= type->hp * .3) { damage_info = "It is heavily injured"; col = c_yellow; } else if (hp >= type->hp * .1) { damage_info = "It is severly injured"; col = c_ltred; } else { damage_info = "it is nearly dead"; col = c_red; } mvwprintz(w, 7, 1, col, damage_info.c_str()); if (is_fleeing(g->u)) wprintz(w, c_white, ", and it is fleeing."); else wprintz(w, col, "."); std::string tmp = type->description; std::string out; size_t pos; int line = 8; do { pos = tmp.find_first_of('\n'); out = tmp.substr(0, pos); mvwprintz(w, line, 1, c_white, out.c_str()); tmp = tmp.substr(pos + 1); line++; } while (pos != std::string::npos && line < 12); }
void draw_caravan_categories(WINDOW *w, int category_selected, int total_price, int cash) { // Clear the window for (int i = 1; i <= 10; i++) mvwprintz(w, i, 1, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); mvwprintz(w, 1, 1, c_white, _("Your Cash:%6d"),cash); wprintz(w, c_ltgray, " -> "); wprintz(w, (total_price > cash ? c_red : c_green), "%d", cash - total_price); for (int i = 0; i < NUM_CARAVAN_CATEGORIES; i++) mvwprintz(w, i + 3, 1, (i == category_selected ? h_white : c_white), caravan_category_name( caravan_category(i) ).c_str()); wrefresh(w); }
void game::print_menu_items(WINDOW* w_in, std::vector<std::string> vItems, int iSel, int iOffsetY, int iOffsetX) { mvwprintz(w_in, iOffsetY, iOffsetX, c_black, ""); for (int i=0; i < vItems.size(); i++) { wprintz(w_in, c_ltgray, "["); if (iSel == i) { wprintz(w_in, h_white, vItems[i].c_str()); } else { wprintz(w_in, c_white, (vItems[i].substr(0, 1)).c_str()); wprintz(w_in, c_ltgray, (vItems[i].substr(1)).c_str()); } wprintz(w_in, c_ltgray, "] "); } }
int fold_and_print_from(WINDOW *w, int begin_y, int begin_x, int width, int begin_line, nc_color base_color, const std::string &text) { nc_color color = base_color; std::vector<std::string> textformatted; textformatted = foldstring(text, width); for (int line_num = 0; line_num < textformatted.size(); line_num++) { if (line_num >= begin_line) { wmove(w, line_num + begin_y - begin_line, begin_x); } // split into colourable sections std::vector<std::string> color_segments = split_by_color(textformatted[line_num]); // for each section, get the colour, and print it std::vector<std::string>::iterator it; for (it = color_segments.begin(); it != color_segments.end(); ++it) { if (!it->empty() && it->at(0) == '<') { color = get_color_from_tag(*it, base_color); } if (line_num >= begin_line) { std::string l = rm_prefix(*it); if(l != "--") { // -- is a newline! wprintz(w, color, "%s", rm_prefix(*it).c_str()); } } } } return textformatted.size(); };
/** * Prints all of the fuel indicators of the vehicle * @param win Pointer to the window to draw in. * @param y Y location to draw at. * @param x X location to draw at. * @param start_index Starting index in array of fuel gauges to start reading from * @param fullsize true if it's expected to print multiple rows * @param verbose true if there should be anything after the gauge (either the %, or number) * @param desc true if the name of the fuel should be at the end * @param isHorizontal true if the menu is not vertical */ void vehicle::print_fuel_indicators( const catacurses::window &win, int y, int x, int start_index, bool fullsize, bool verbose, bool desc, bool isHorizontal ) const { auto fuels = get_printable_fuel_types(); if( !fullsize ) { if( !fuels.empty() ) { print_fuel_indicator( win, y, x, fuels.front(), verbose, desc ); } return; } int yofs = 0; int max_gauge = ( ( isHorizontal ) ? 12 : 5 ) + start_index; int max_size = std::min( ( int )fuels.size(), max_gauge ); for( int i = start_index; i < max_size; i++ ) { const itype_id &f = fuels[i]; print_fuel_indicator( win, y + yofs, x, f, verbose, desc ); yofs++; } // check if the current index is less than the max size minus 12 or 5, to indicate that there's more if( ( start_index < ( int )fuels.size() - ( ( isHorizontal ) ? 12 : 5 ) ) ) { mvwprintz( win, y + yofs, x, c_light_green, ">" ); wprintz( win, c_light_gray, " for more" ); } }
void live_view::print_items(const map_stack &items, int &line) const { std::map<std::string, int> item_names; for( auto &item : items ) { std::string name = item.tname(); if (item_names.find(name) == item_names.end()) { item_names[name] = 0; } item_names[name] += 1; } int last_line = height - START_LINE - 1; bool will_overflow = line - 1 + (int)item_names.size() > last_line; for (std::map<std::string, int>::iterator it = item_names.begin(); it != item_names.end() && (!will_overflow || line < last_line); it++) { mvwprintz(w_live_view, line++, START_COLUMN, c_white, it->first.c_str()); if (it->second > 1) { wprintz(w_live_view, c_white, _(" [%d]"), it->second); } } if (will_overflow) { mvwprintz(w_live_view, line++, START_COLUMN, c_yellow, _("More items here...")); } }
// 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); char buff[6000]; //TODO replace Magic Number vsprintf(buff, mes, ap); va_end(ap); nc_color color = base_color; std::vector<std::string> textformatted; textformatted = foldstring(buff, width); for (int line_num=0; line_num<textformatted.size(); line_num++) { wmove(w, line_num+begin_y, begin_x); // split into colourable sections std::vector<std::string> color_segments = split_by_color(textformatted[line_num]); // for each section, get the colour, and print it std::vector<std::string>::iterator it; for (it = color_segments.begin(); it != color_segments.end(); ++it) { if (!it->empty() && it->at(0) == '<') { color = get_color_from_tag(*it, base_color); } wprintz(w, color, "%s", rm_prefix(*it).c_str()); } } return textformatted.size(); };
void game::print_menu_items(WINDOW *w_in, std::vector<std::string> vItems, int iSel, int iOffsetY, int iOffsetX, int spacing) { mvwprintz(w_in, iOffsetY, iOffsetX, c_black, ""); for (int i = 0; i < vItems.size(); i++) { wprintz(w_in, c_ltgray, "["); if (iSel == i) { shortcut_print(w_in, h_white, h_white, vItems[i].c_str()); } else { shortcut_print(w_in, c_ltgray, c_white, vItems[i].c_str()); } wprintz(w_in, c_ltgray, "]"); for (int j = 0; j < spacing; j++) { wprintz(w_in, c_ltgray, " "); } } }
int live_view::draw( const catacurses::window &win, int const max_height ) { if( !enabled ) { return 0; } // -1 for border. -1 because getmaxy() actually returns height, not y position. const int line_limit = max_height - 2; const visibility_variables &cache = g->m.get_visibility_variables_cache(); int line_out = START_LINE; g->print_all_tile_info( mouse_position, win, START_COLUMN, line_out, line_limit, false, cache ); const int live_view_box_height = std::min( max_height, std::max( line_out + 1, MIN_BOX_HEIGHT ) ); #if (defined TILES || defined _WIN32 || defined WINDOWS) // Because of the way the status UI is done, the live view window must // be tall enough to clear the entire height of the viewport below the // status bar. This hack allows the border around the live view box to // be drawn only as big as it needs to be, while still leaving the // window tall enough. Won't work for ncurses in Linux, but that doesn't // currently support the mouse. If and when it does, there will need to // be a different code path here that works for ncurses. const int original_height = win.get<cata_cursesport::WINDOW>()->height; win.get<cata_cursesport::WINDOW>()->height = live_view_box_height; #endif draw_border( win ); static const char *title_prefix = "< "; static const char *title = _( "Mouse View" ); static const char *title_suffix = " >"; static const std::string full_title = string_format( "%s%s%s", title_prefix, title, title_suffix ); const int start_pos = center_text_pos( full_title.c_str(), 0, getmaxx( win ) - 1 ); mvwprintz( win, 0, start_pos, c_white, title_prefix ); wprintz( win, c_green, title ); wprintz( win, c_white, title_suffix ); #if (defined TILES || defined _WIN32 || defined WINDOWS) win.get<cata_cursesport::WINDOW>()->height = original_height; #endif return live_view_box_height; }
/* * redraw borders, which is required in some cases ( look_around() ) */ void uimenu::redraw( bool redraw_callback ) { draw_border(window, border_color); if( !title.empty() ) { mvwprintz(window, 0, 1, border_color, "< "); wprintz(window, title_color, "%s", title.c_str() ); wprintz(window, border_color, " >"); } if ( !filter.empty() ) { mvwprintz(window, w_height - 1, 2, border_color, "< %s >", filter.c_str() ); mvwprintz(window, w_height - 1, 4, text_color, "%s", filter.c_str()); } (void)redraw_callback; // TODO /* // pending tests on if this is needed if ( redraw_callback && callback != NULL ) { callback->redraw(this); } */ }
void game::draw_sct() { for (std::vector<scrollingcombattext::cSCT>::iterator iter = SCT.vSCT.begin(); iter != SCT.vSCT.end(); ++iter) { const int iDY = POSY + (iter->getPosY() - (u.posy + u.view_offset_y)); const int iDX = POSX + (iter->getPosX() - (u.posx + u.view_offset_x)); mvwprintz(w_terrain, iDY, iDX, msgtype_to_color(iter->getMsgType("first"), (iter->getStep() >= SCT.iMaxSteps/2)), "%s", iter->getText("first").c_str()); wprintz(w_terrain, msgtype_to_color(iter->getMsgType("second"), (iter->getStep() >= SCT.iMaxSteps/2)), iter->getText("second").c_str()); } }
//same as above, from current position size_t shortcut_print(WINDOW *w, nc_color color, nc_color colork, const std::string &fmt) { std::string tmp = fmt; size_t pos = tmp.find_first_of('<'); size_t pos2 = tmp.find_first_of('>'); size_t len = 0; if(pos2 != std::string::npos && pos < pos2) { tmp.erase(pos, 1); tmp.erase(pos2 - 1, 1); wprintz(w, color, "%s", tmp.substr(0, pos).c_str()); wprintz(w, colork, "%s", tmp.substr(pos, pos2 - pos - 1).c_str()); wprintz(w, color, "%s", tmp.substr(pos2 - 1).c_str()); len = utf8_width(tmp.c_str()); } else { // no shutcut? wprintz(w, color, "%s", fmt.c_str()); len = utf8_width(fmt.c_str()); } return len; }
void game::print_menu_items(WINDOW *w_in, std::vector<std::string> vItems, int iSel, int iOffsetY, int iOffsetX, int spacing) { mvwprintz(w_in, iOffsetY, iOffsetX, c_black, ""); const int items_size = (int)vItems.size(); for (int i = 0; i < items_size; i++) { wprintz(w_in, c_ltgray, "["); if (iSel == i) { shortcut_print(w_in, h_white, h_white, vItems[i]); } else { shortcut_print(w_in, c_ltgray, c_white, vItems[i]); } wprintz(w_in, c_ltgray, "]"); // Don't print spaces after last item. if ( i != (items_size - 1)) { wprintz(w_in, c_ltgray, std::string(spacing, ' ').c_str()); } } }
/* * redraw borders, which is required in some cases ( look_around() ) */ void uimenu::redraw( bool redraw_callback ) { wattron(window, border_color); wborder(window, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); wattroff(window, border_color); if( title.size() > 0 ) { mvwprintz(window, 0, 1, border_color, "< "); wprintz(window, title_color, "%s", title.c_str() ); wprintz(window, border_color, " >"); } if ( filter.size() > 0 ) { mvwprintz(window,w_height-1,2,border_color,"< %s >",filter.c_str() ); mvwprintz(window,w_height-1,4,text_color,"%s",filter.c_str()); } /* // pending tests on if this is needed if ( redraw_callback && callback != NULL ) { callback->redraw(this); } */ }
void inventory_selector::print_inv_weight_vol(int weight_carried, int vol_carried, int vol_capacity) const { // Print weight mvwprintw(w_inv, 0, 32, _("Weight (%s): "), weight_units()); nc_color weight_color; if (weight_carried > g->u.weight_capacity()) { weight_color = c_red; } else { weight_color = c_ltgray; } wprintz(w_inv, weight_color, "%6.1f", convert_weight(weight_carried) + 0.05 ); // +0.05 to round up; wprintz(w_inv, c_ltgray, "/%-6.1f", convert_weight(g->u.weight_capacity())); // Print volume mvwprintw(w_inv, 0, 61, _("Volume: ")); if (vol_carried > vol_capacity) { wprintz(w_inv, c_red, "%3d", vol_carried); } else { wprintz(w_inv, c_ltgray, "%3d", vol_carried); } wprintw(w_inv, "/%-3d", vol_capacity); }
void main_menu::print_menu_items( const catacurses::window &w_in, std::vector<std::string> vItems, size_t iSel, int iOffsetY, int iOffsetX, int spacing ) { wmove( w_in, iOffsetY, iOffsetX ); for( size_t i = 0; i < vItems.size(); ++i ) { nc_color text_color; nc_color key_color; if( iSel == i ) { text_color = h_white; key_color = h_white; } else { text_color = c_light_gray; key_color = c_white; } wprintz( w_in, c_light_gray, "[" ); shortcut_print( w_in, text_color, key_color, vItems[i] ); wprintz( w_in, c_light_gray, "]" ); // Don't print spaces after last item. if( i != ( vItems.size() - 1 ) ) { wprintz( w_in, c_light_gray, std::string( spacing, ' ' ).c_str() ); } } }
void computer::print_error(const char *mes, ...) { // Translate the printf flags va_list ap; va_start(ap, mes); char buff[6000]; vsprintf(buff, mes, ap); va_end(ap); // Print the line. wprintz(w_terminal, c_red, " %s%s", buff, "\n"); // Reprint the border, in case we pushed a line over it wborder(w_terminal, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); wrefresh(w_terminal); }
void inventory_selector::print_inv_weight_vol(int weight_carried, int vol_carried, int vol_capacity) const { // Print weight mvwprintw(w_inv, 0, 32, _("Weight (%s): "), OPTIONS["USE_METRIC_WEIGHTS"].getValue() == "lbs" ? "lbs" : "kg"); nc_color weight_color; if (weight_carried > g->u.weight_capacity()) { weight_color = c_red; } else { weight_color = c_ltgray; } wprintz(w_inv, weight_color, "%6.1f", g->u.convert_weight(weight_carried) + 0.05 ); // +0.05 to round up; wprintz(w_inv, c_ltgray, "/%-6.1f", g->u.convert_weight(g->u.weight_capacity())); // Print volume mvwprintw(w_inv, 0, 61, _("Volume: ")); if (vol_carried > vol_capacity - 2) { wprintz(w_inv, c_red, "%3d", vol_carried); } else { wprintz(w_inv, c_ltgray, "%3d", vol_carried); } wprintw(w_inv, "/%-3d", vol_capacity - 2); }
/** * Prints a fuel gauge for a vehicle * @param w Pointer to the window to draw in. * @param y Y location to draw at. * @param x X location to draw at. * @param fuel_type ID of the fuel type to draw * @param verbose true if there should be anything after the gauge (either the %, or number) * @param desc true if the name of the fuel should be at the end */ void vehicle::print_fuel_indicator( const catacurses::window &win, int y, int x, const itype_id &fuel_type, bool verbose, bool desc ) const { const char fsyms[5] = { 'E', '\\', '|', '/', 'F' }; nc_color col_indf1 = c_light_gray; int cap = fuel_capacity( fuel_type ); int f_left = fuel_left( fuel_type ); nc_color f_color = item::find_type( fuel_type )->color; mvwprintz( win, y, x, col_indf1, "E...F" ); int amnt = cap > 0 ? f_left * 99 / cap : 0; int indf = ( amnt / 20 ) % 5; mvwprintz( win, y, x + indf, f_color, "%c", fsyms[indf] ); if( verbose ) { if( debug_mode ) { mvwprintz( win, y, x + 6, f_color, "%d/%d", f_left, cap ); } else { mvwprintz( win, y, x + 6, f_color, "%d", ( f_left * 100 ) / cap ); wprintz( win, c_light_gray, "%c", 045 ); } } if( desc ) { wprintz( win, c_light_gray, " - %s", item::nname( fuel_type ).c_str() ); } }
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(); }
/* * update the help text, which hijacks w_info's bottom border */ void editmap::uphelp (std::string txt1, std::string txt2, std::string title) { if ( txt1 != "" ) { mvwprintw(w_help, 0, 0, "%s", padding.c_str() ); mvwprintw(w_help, 1, 0, "%s", padding.c_str() ); mvwprintw(w_help, ( txt2 != "" ? 0 : 1 ), 0, _(txt1.c_str())); if ( txt2 != "" ) { mvwprintw(w_help, 1, 0, _(txt2.c_str())); } } if ( title != "" ) { int hwidth = getmaxx(w_help); for ( int i = 0; i < hwidth; i++ ) { // catacurses/sdl/etc have no hline() mvwaddch(w_help, 2, i, LINE_OXOX); } int starttxt = int( (hwidth - title.size() - 4) / 2 ); mvwprintw(w_help, 2, starttxt, "< "); wprintz(w_help, c_cyan, "%s", title.c_str() ); wprintw(w_help, " >"); } //mvwprintw(w_help, 0, 0, "%d,%d / %d,%d", target.x, target.y, origin.x, origin.y ); wrefresh(w_help); }