本文整理汇总了C++中calendar::textify_period方法的典型用法代码示例。如果您正苦于以下问题:C++ calendar::textify_period方法的具体用法?C++ calendar::textify_period怎么用?C++ calendar::textify_period使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendar
的用法示例。
在下文中一共展示了calendar::textify_period方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display_messages
void Messages::display_messages()
{
WINDOW_PTR w_ptr {newwin(
FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH,
(TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0,
(TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0)};
WINDOW *const w = w_ptr.get();
input_context ctxt("MESSAGE_LOG");
ctxt.register_action("UP", _("Scroll up"));
ctxt.register_action("DOWN", _("Scroll down"));
ctxt.register_action("QUIT");
ctxt.register_action("HELP_KEYBINDINGS");
int offset = 0;
const int maxlength = FULL_SCREEN_WIDTH - 2 - 1;
const int bottom = FULL_SCREEN_HEIGHT - 2;
const int msg_count = size();
for (;;) {
werase(w);
draw_border(w);
mvwprintz(w, bottom + 1, 32, c_red, _("Press %s to return"), ctxt.get_desc("QUIT").c_str());
draw_scrollbar(w, offset, bottom, msg_count, 1);
int line = 1;
int lasttime = -1;
for( int i = offset; i < msg_count; ++i ) {
if (line > bottom) {
break;
}
const game_message &m = player_messages.impl_->history(i);
const nc_color col = m.get_color(player_messages.impl_->curmes);
const calendar timepassed = calendar::turn - m.time;
if (timepassed.get_turn() > lasttime) {
mvwprintz(w, line++, 3, c_ltblue, _("%s ago:"),
timepassed.textify_period().c_str());
lasttime = timepassed.get_turn();
}
for( const std::string &folded : foldstring(m.get_with_count(), maxlength) ) {
if (line > bottom) {
break;
}
mvwprintz(w, line++, 1, col, "%s", folded.c_str());
}
}
if (offset + 1 < msg_count) {
mvwprintz(w, bottom + 1, 5, c_magenta, "vvv");
}
if (offset > 0) {
mvwprintz(w, bottom + 1, maxlength - 3, c_magenta, "^^^");
}
wrefresh(w);
const std::string &action = ctxt.handle_input();
if (action == "DOWN" && offset + 1 < msg_count) {
offset++;
} else if (action == "UP" && offset > 0) {
offset--;
} else if (action == "QUIT") {
break;
}
}
player_messages.impl_->curmes = calendar::turn.get_turn();
}