本文整理汇总了C++中wprintz函数的典型用法代码示例。如果您正苦于以下问题:C++ wprintz函数的具体用法?C++ wprintz怎么用?C++ wprintz使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wprintz函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shortcut_print
//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;
}
示例2: print_inv_weight_vol
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);
}
示例3: draw_caravan_items
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);
}
示例4: print_inv_weight_vol
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);
}
示例5: print_inv_weight_vol
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);
}
示例6: hide
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);
}
示例7: mvwprintz
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;
}
示例8: hide
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);
}
示例9: mvwprintz
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;
}
示例10: mvwprintz
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);
}
示例11: draw_caravan_categories
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);
}
示例12: mvwprintz
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, "] ");
}
}
示例13: fold_and_print_from
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();
};
示例14: get_printable_fuel_types
/**
* 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" );
}
}
示例15: mvwprintz
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..."));
}
}