本文整理汇总了C++中query_yn函数的典型用法代码示例。如果您正苦于以下问题:C++ query_yn函数的具体用法?C++ query_yn怎么用?C++ query_yn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了query_yn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exit_handler
void exit_handler(int s)
{
if (s != 2 || query_yn(_("Really Quit? All unsaved changes will be lost."))) {
erase(); // Clear screen
int ret;
#if (defined _WIN32 || defined WINDOWS)
ret = system("cls"); // Tell the terminal to clear itself
ret = system("color 07");
#else
ret = system("clear"); // Tell the terminal to clear itself
#endif
if (ret != 0) {
DebugLog( D_ERROR, DC_ALL ) << "system(\"clear\"): error returned: " << ret;
}
deinitDebug();
int exit_status = 0;
if( g != NULL ) {
if( g->game_error() ) {
exit_status = 1;
}
delete g;
}
endwin();
exit( exit_status );
}
}
示例2: exit_handler
void exit_handler(int s) {
if (s != 2 || query_yn(_("Really Quit? All unsaved changes will be lost."))) {
erase(); // Clear screen
endwin(); // End ncurses
int ret;
#if (defined _WIN32 || defined WINDOWS)
ret = system("cls"); // Tell the terminal to clear itself
ret = system("color 07");
#else
ret = system("clear"); // Tell the terminal to clear itself
#endif
if (ret != 0) {
DebugLog() << "main.cpp:exit_handler(): system(\"clear\"): error returned\n";
}
if(g != NULL) {
if(g->game_error()) {
delete g;
exit(1);
} else {
delete g;
exit(0);
}
}
exit(0);
}
}
示例3: exit_handler
void exit_handler(int s) {
bool bExit = false;
if (s == 2) {
if (query_yn("Really Quit? All unsaved changes will be lost.")) {
bExit = true;
}
} else if (s == -999) {
bExit = true;
} else {
//query_yn(g, "Signal received: %d", s);
bExit = true;
}
if (bExit) {
erase(); // Clear screen
endwin(); // End ncurses
#if (defined _WIN32 || defined WINDOWS)
system("cls"); // Tell the terminal to clear itself
system("color 07");
#else
system("clear"); // Tell the terminal to clear itself
#endif
exit(0);
}
}
示例4: zone_data
void zone_manager::add( const std::string &name, const zone_type_id &type,
const bool invert, const bool enabled, const tripoint &start, const tripoint &end,
std::shared_ptr<zone_options> options )
{
zone_data new_zone = zone_data( name, type, invert, enabled, start,
end, options );
//the start is a vehicle tile with cargo space
if( const cata::optional<vpart_reference> vp = g->m.veh_at( g->m.getlocal(
start ) ).part_with_feature( "CARGO", false ) ) {
// TODO:Allow for loot zones on vehicles to be larger than 1x1
if( start == end && query_yn( _( "Bind this zone to the cargo part here?" ) ) ) {
// TODO: refactor zone options for proper validation code
if( type == zone_type_id( "FARM_PLOT" ) ) {
popup( _( "You cannot add that type of zone to a vehicle." ), PF_NONE );
return;
}
create_vehicle_loot_zone( vp->vehicle(), vp->mount(), new_zone );
return;
}
}
//Create a regular zone
zones.push_back( new_zone );
cache_data();
}
示例5: pgettext
void trapfunc::sinkhole(int x, int y)
{
(void)x; (void)y; // unused
g->add_msg(_("You step into a sinkhole, and start to sink down!"));
g->u.add_memorial_log(pgettext("memorial_male", "Stepped into a sinkhole."),
pgettext("memorial_female", "Stepped into a sinkhole."));
if (g->u.has_amount("rope_30", 1) &&
query_yn(_("There is a sinkhole here. Throw your rope out to try to catch something?"))) {
int throwroll = rng(g->u.skillLevel("throw"),
g->u.skillLevel("throw") + g->u.str_cur + g->u.dex_cur);
if (throwroll >= 12) {
g->add_msg(_("The rope catches something!"));
if (rng(g->u.skillLevel("unarmed"),
g->u.skillLevel("unarmed") + g->u.str_cur) > 6) {
// Determine safe places for the character to get pulled to
std::vector<point> safe;
for (int i = g->u.posx - 1; i <= g->u.posx + 1; i++) {
for (int j = g->u.posy - 1; j <= g->u.posy + 1; j++) {
if (g->m.move_cost(i, j) > 0 && g->m.tr_at(i, j) != tr_pit)
safe.push_back(point(i, j));
}
}
if (safe.empty()) {
g->add_msg(_("There's nowhere to pull yourself to, and you sink!"));
g->u.use_amount("rope_30", 1);
g->m.spawn_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1), "rope_30");
g->m.ter_set(g->u.posx, g->u.posy, t_hole);
g->vertical_move(-1, true);
} else {
g->add_msg(_("You pull yourself to safety! The sinkhole collapses."));
int index = rng(0, safe.size() - 1);
g->m.ter_set(g->u.posx, g->u.posy, t_hole);
g->u.posx = safe[index].x;
g->u.posy = safe[index].y;
g->update_map(g->u.posx, g->u.posy);
}
} else {
g->add_msg(_("You're not strong enough to pull yourself out..."));
g->u.moves -= 100;
g->u.use_amount("rope_30", 1);
g->m.spawn_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1), "rope_30");
g->m.ter_set(g->u.posx, g->u.posy, t_hole);
g->vertical_move(-1, true);
}
} else {
g->add_msg(_("Your throw misses completely, and you sink!"));
if (one_in((g->u.str_cur + g->u.dex_cur) / 3)) {
g->u.use_amount("rope_30", 1);
g->m.spawn_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1), "rope_30");
}
g->m.ter_set(g->u.posx, g->u.posy, t_hole);
g->vertical_move(-1, true);
}
} else {
g->add_msg(_("You sink into the sinkhole!"));
g->m.ter_set(g->u.posx, g->u.posy, t_hole);
g->vertical_move(-1, true);
}
}
示例6: debugmsg
bool player::install_bionics(it_bionic *type)
{
if (type == NULL) {
debugmsg("Tried to install NULL bionic");
return false;
}
if (bionics.count(type->id) == 0) {
popup("invalid / unknown bionic id %s", type->id.c_str());
return false;
}
if (has_bionic(type->id)) {
if (!(type->id == "bio_power_storage" || type->id == "bio_power_storage_mkII")) {
popup(_("You have already installed this bionic."));
return false;
}
}
int chance_of_success = bionic_manip_cos(int_cur,
skillLevel("electronics"),
skillLevel("firstaid"),
skillLevel("mechanics"),
type->difficulty);
if (!query_yn(
_("WARNING: %i percent chance of genetic damage, blood loss, or damage to existing bionics! Install anyway?"),
100 - chance_of_success)) {
return false;
}
int pow_up = 0;
if (type->id == "bio_power_storage" || type->id == "bio_power_storage_mkII") {
pow_up = BATTERY_AMOUNT;
if (type->id == "bio_power_storage_mkII") {
pow_up = 250;
}
}
practice( "electronics", int((100 - chance_of_success) * 1.5) );
practice( "firstaid", int((100 - chance_of_success) * 1.0) );
practice( "mechanics", int((100 - chance_of_success) * 0.5) );
int success = chance_of_success - rng(1, 100);
if (success > 0) {
add_memorial_log(pgettext("memorial_male", "Installed bionic: %s."),
pgettext("memorial_female", "Installed bionic: %s."),
bionics[type->id]->name.c_str());
if (pow_up) {
max_power_level += pow_up;
add_msg_if_player(m_good, _("Increased storage capacity by %i"), pow_up);
} else {
add_msg(m_good, _("Successfully installed %s."), bionics[type->id]->name.c_str());
add_bionic(type->id);
}
} else {
add_memorial_log(pgettext("memorial_male", "Installed bionic: %s."),
pgettext("memorial_female", "Installed bionic: %s."),
bionics[type->id]->name.c_str());
bionics_install_failure(this, type, success);
}
g->refresh_all();
return true;
}
示例7: query_yn
void trapfunc::sinkhole(game *g, int x, int y)
{
g->add_msg("You step into a sinkhole, and start to sink down!");
if (g->u.has_amount(itm_rope_30, 1) &&
query_yn("Throw your rope to try to catch soemthing?")) {
int throwroll = rng(g->u.sklevel[sk_throw],
g->u.sklevel[sk_throw] + g->u.str_cur + g->u.dex_cur);
if (throwroll >= 12) {
g->add_msg("The rope catches something!");
if (rng(g->u.sklevel[sk_unarmed],
g->u.sklevel[sk_unarmed] + g->u.str_cur) > 6) {
// Determine safe places for the character to get pulled to
std::vector<point> safe;
for (int i = g->u.posx - 1; i <= g->u.posx + 1; i++) {
for (int j = g->u.posx - 1; j <= g->u.posx + 1; j++) {
if (g->m.move_cost(i, j) > 0 && g->m.tr_at(i, j) != tr_pit)
safe.push_back(point(i, j));
}
}
if (safe.size() == 0) {
g->add_msg("There's nowhere to pull yourself to, and you sink!");
g->u.use_amount(itm_rope_30, 1);
g->m.add_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1),
g->itypes[itm_rope_30], g->turn);
g->m.tr_at(g->u.posx, g->u.posy) = tr_pit;
g->vertical_move(-1, true);
} else {
g->add_msg("You pull yourself to safety! The sinkhole collapses.");
int index = rng(0, safe.size() - 1);
g->u.posx = safe[index].x;
g->u.posy = safe[index].y;
g->update_map(g->u.posx, g->u.posy);
g->m.tr_at(g->u.posx, g->u.posy) = tr_pit;
}
} else {
g->add_msg("You're not strong enough to pull yourself out...");
g->u.moves -= 100;
g->u.use_amount(itm_rope_30, 1);
g->m.add_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1),
g->itypes[itm_rope_30], g->turn);
g->vertical_move(-1, true);
}
} else {
g->add_msg("Your throw misses completely, and you sink!");
if (one_in((g->u.str_cur + g->u.dex_cur) / 3)) {
g->u.use_amount(itm_rope_30, 1);
g->m.add_item(g->u.posx + rng(-1, 1), g->u.posy + rng(-1, 1),
g->itypes[itm_rope_30], g->turn);
}
g->m.tr_at(g->u.posx, g->u.posy) = tr_pit;
g->vertical_move(-1, true);
}
} else {
g->add_msg("You sink into the sinkhole!");
g->vertical_move(-1, true);
}
}
示例8: WORLD
WORLDPTR worldfactory::make_new_world()
{
// Window variables
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;
// World to return after generating
WORLDPTR retworld = new WORLD();
// set up window
WINDOW *wf_win = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX);
// prepare tab display order
std::vector<worldgen_display> tabs;
std::vector<std::string> tab_strings;
tabs.push_back(&worldfactory::show_worldgen_tab_options);
tabs.push_back(&worldfactory::show_worldgen_tab_confirm);
tab_strings.push_back(_("World Gen Options"));
tab_strings.push_back(_("CONFIRMATION"));
int curtab = 0;
int lasttab; // give placement memory to menus, sorta.
const int numtabs = tabs.size();
while (curtab >= 0 && curtab < numtabs) {
lasttab = curtab;
draw_worldgen_tabs(wf_win, curtab, tab_strings);
curtab += (world_generator->*tabs[curtab])(wf_win, retworld);
if (curtab < 0) {
if (!query_yn(_("Do you want to abort World Generation?"))) {
curtab = lasttab;
}
}
}
if (curtab < 0) {
delete retworld;
return NULL;
}
// add world to world list
all_worlds[retworld->world_name] = retworld;
all_worldnames.push_back(retworld->world_name);
std::stringstream path;
path << SAVE_DIR << PATH_SEPARATOR << retworld->world_name;
retworld->world_path = path.str();
if (!save_world(retworld)) {
std::string worldname = retworld->world_name;
std::vector<std::string>::iterator it = std::find(all_worldnames.begin(), all_worldnames.end(), worldname);
all_worldnames.erase(it);
delete all_worlds[worldname];
delete retworld;
all_worlds.erase(worldname);
return NULL;
}
return retworld;
}
示例9: merge_vector
void auto_pickup::add_rule(const std::string &sRule)
{
vRules[CHARACTER].push_back(cRules(sRule, true, false));
merge_vector();
create_rules();
if (!OPTIONS["AUTO_PICKUP"] &&
query_yn(_("Autopickup is not enabled in the options. Enable it now?")) ) {
OPTIONS["AUTO_PICKUP"].setNext();
get_options().save();
}
}
示例10: addPickupRule
void addPickupRule(std::string sRule)
{
vAutoPickupRules[2].push_back(cPickupRules(sRule, true, false));
merge_vector();
createPickupRules();
if (!OPTIONS["AUTO_PICKUP"] &&
query_yn(_("Autopickup is not enabled in the options. Enable it now?")) ) {
OPTIONS["AUTO_PICKUP"].setNext();
save_options(true);
}
}
示例11: rules_class
void safemode::add_rule( const std::string &rule_in, const Creature::Attitude attitude_in,
const int proximity_in,
const rule_state state_in )
{
character_rules.push_back( rules_class( rule_in, true, ( state_in == RULE_WHITELISTED ),
attitude_in, proximity_in ) );
create_rules();
if( !get_option<bool>( "SAFEMODE" ) &&
query_yn( _( "Safe Mode is not enabled in the options. Enable it now?" ) ) ) {
get_options().get_option( "SAFEMODE" ).setNext();
get_options().save();
}
}
示例12: _
bool craft_command::query_continue( const std::vector<comp_selection<item_comp>> &missing_items,
const std::vector<comp_selection<tool_comp>> &missing_tools )
{
std::stringstream ss;
ss << _( "Some components used previously are missing. Continue?" );
if( !missing_items.empty() ) {
ss << std::endl << _( "Item(s): " );
component_list_string( ss, missing_items );
}
if( !missing_tools.empty() ) {
ss << std::endl << _( "Tool(s): " );
component_list_string( ss, missing_tools );
}
return query_yn( ss.str() );
}
示例13: exit_handler
void exit_handler(int s)
{
const int old_timeout = inp_mngr.get_timeout();
inp_mngr.reset_timeout();
if (s != 2 || query_yn(_("Really Quit? All unsaved changes will be lost."))) {
erase(); // Clear screen
deinitDebug();
int exit_status = 0;
if( g != NULL ) {
delete g;
}
endwin();
exit( exit_status );
}
inp_mngr.set_timeout( old_timeout );
}
示例14: exit_handler
void exit_handler(int s)
{
if (s != 2 || query_yn(_("Really Quit? All unsaved changes will be lost."))) {
erase(); // Clear screen
deinitDebug();
int exit_status = 0;
if( g != NULL ) {
if( g->game_error() ) {
exit_status = 1;
}
delete g;
}
endwin();
exit( exit_status );
}
}
示例15: point
tripoint start_location::find_player_initial_location() const
{
const bool using_existing_initial_overmap = overmap_buffer.has( 0, 0 );
// The coordinates of an overmap that is known to *not* exist. We can regenerate this
// as often we like.
point non_existing_omt = point( 0, 0 );
if( using_existing_initial_overmap ) {
// arbitrary, should be large enough to include all overmaps ever created
const int radius = 32;
for( const point omp : closest_points_first( radius, point( 0, 0 ) ) ) {
const overmap *omap = overmap_buffer.get_existing( omp.x, omp.y );
if( omap == nullptr ) {
if( non_existing_omt == point( 0, 0 ) ) {
non_existing_omt = omp;
}
continue;
}
const tripoint omtstart = omap->find_random_omt( target() );
if( omtstart != overmap::invalid_tripoint ) {
return omtstart + point( omp.x * OMAPX, omp.y * OMAPY );
}
}
}
while( true ) {
popup_nowait( _( "Please wait as we build your world" ) );
const overmap &initial_overmap = overmap_buffer.get( non_existing_omt.x, non_existing_omt.y );
const tripoint omtstart = initial_overmap.find_random_omt( target() );
if( omtstart != overmap::invalid_tripoint ) {
return omtstart + point( non_existing_omt.x * OMAPX, non_existing_omt.y * OMAPY );
}
if( !query_yn(
_( "The game could not create a world with a suitable starting location.\n\n"
"Depending on the world options, the starting location may never appear. If the problem persists, you can try another starting location, or change the world options.\n\n"
"Try again?" ) ) ) {
return overmap::invalid_tripoint;
}
overmap_buffer.clear();
}
}