• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ query_yn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中query_yn函数的典型用法代码示例。如果您正苦于以下问题:C++ query_yn函数的具体用法?C++ query_yn怎么用?C++ query_yn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了query_yn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
    }
}
开发者ID:tetronimo,项目名称:Cataclysm-DDA,代码行数:30,代码来源:main.cpp


示例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);
    }
}
开发者ID:fergus-dall,项目名称:Cataclysm-DDA,代码行数:27,代码来源:main.cpp


示例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);
 }
}
开发者ID:cloudyrads,项目名称:Cataclysm-DDA,代码行数:27,代码来源:main.cpp


示例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();
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:26,代码来源:clzones.cpp


示例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);
 }
}
开发者ID:noppa354,项目名称:Cataclysm-DDA,代码行数:59,代码来源:trapfunc.cpp


示例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;
}
开发者ID:MisterTea,项目名称:Cataclysm-DDA,代码行数:59,代码来源:bionics.cpp


示例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);
 }
}
开发者ID:jkienzle,项目名称:CataclysmMod,代码行数:57,代码来源:trapfunc.cpp


示例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;
}
开发者ID:bdragon28,项目名称:Cataclysm-DDA,代码行数:57,代码来源:worldfactory.cpp


示例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();
    }
}
开发者ID:Reikim,项目名称:Cataclysm-DDA,代码行数:12,代码来源:auto_pickup.cpp


示例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);
    }
}
开发者ID:Tearlach,项目名称:Cataclysm-DDA,代码行数:12,代码来源:auto_pickup.cpp


示例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();
    }
}
开发者ID:Nukesor,项目名称:Cataclysm-DDA,代码行数:14,代码来源:safemode_ui.cpp


示例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() );
}
开发者ID:BevapDin,项目名称:Cataclysm-DDA,代码行数:18,代码来源:craft_command.cpp


示例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 );
}
开发者ID:Mshock777,项目名称:Cataclysm-DDA,代码行数:20,代码来源:main.cpp


示例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 );
    }
}
开发者ID:FlaKougar,项目名称:Cataclysm-DDA,代码行数:20,代码来源:main.cpp


示例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();
    }
}
开发者ID:nonymous,项目名称:Cataclysm-DDA,代码行数:41,代码来源:start_location.cpp


示例16: add_msg_if_player

bool player::disassemble( item &obj, int pos, bool ground, bool interactive )
{
    // check sufficient tools for disassembly
    std::string err;
    if( !can_disassemble( obj, crafting_inventory(), &err ) ) {
        if( interactive ) {
            add_msg_if_player( m_info, "%s", err.c_str() );
        }
        return false;
    }

    const auto &r = recipe_dictionary::get_uncraft( obj.typeId() );
    // last chance to back out
    if( interactive && get_option<bool>( "QUERY_DISASSEMBLE" ) ) {
        const auto components( r.disassembly_requirements().get_components() );
        std::ostringstream list;
        for( const auto &elem : components ) {
            list << "- " << elem.front().to_string() << std::endl;
        }

        if( !query_yn( _( "Disassembling the %s may yield:\n%s\nReally disassemble?" ), obj.tname().c_str(),
                       list.str().c_str() ) ) {
            return false;
        }
    }

    if( activity.id() != activity_id( "ACT_DISASSEMBLE" ) ) {
        assign_activity( activity_id( "ACT_DISASSEMBLE" ), r.time );
    } else if( activity.moves_left <= 0 ) {
        activity.moves_left = r.time;
    }

    activity.values.push_back( pos );
    activity.coords.push_back( ground ? this->pos() : tripoint_min );
    activity.str_values.push_back( r.result );

    return true;
}
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:38,代码来源:crafting.cpp


示例17: 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
         #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

         if(g != NULL) {
             if(g->game_error()) {
                 delete g;
                 exit(1);
             } else {
                 delete g;
                 exit(0);
             }
         }
         exit(0);
     }
}
开发者ID:GlyphGryph,项目名称:Cataclysm-DDA,代码行数:23,代码来源:main.cpp


示例18: get_acquirable_energy

bool player::feed_reactor_with( item &it )
{
    if( !can_feed_reactor_with( it ) ) {
        return false;
    }

    const auto iter = plut_charges.find( it.typeId() );
    const int max_amount = iter != plut_charges.end() ? iter->second : 0;
    const int amount = std::min( get_acquirable_energy( it, rechargeable_cbm::reactor ), max_amount );

    if( amount >= PLUTONIUM_CHARGES * 10 &&
        !query_yn( _( "Thats a LOT of plutonium.  Are you sure you want that much?" ) ) ) {
        return false;
    }

    add_msg_player_or_npc( _( "You add your %s to your reactor's tank." ),
                           _( "<npcname> pours %s into their reactor's tank." ),
                           it.tname().c_str() );

    tank_plut += amount; // @todo Encapsulate
    it.charges -= 1;
    mod_moves( -250 );
    return true;
}
开发者ID:Caeous,项目名称:Cataclysm-DDA,代码行数:24,代码来源:consumption.cpp


示例19: newwin


//.........这里部分代码省略.........
                sTemp.str("");
                sTemp << i + 1;
                mvwprintz(w_options, i - iStartPos, 0, c_white, sTemp.str().c_str());
                mvwprintz(w_options, i - iStartPos, 4, c_white, "");

                if (iCurrentLine == i) {
                    wprintz(w_options, c_yellow, ">> ");
                } else {
                    wprintz(w_options, c_yellow, "   ");
                }

                wprintz(w_options, c_white, "%s", (OPTIONS[mPageItems[iCurrentPage][i]].getMenuText()).c_str());

                if (OPTIONS[mPageItems[iCurrentPage][i]].getValue() == "False") {
                    cLineColor = c_ltred;
                }

                mvwprintz(w_options, i - iStartPos, 62, (iCurrentLine == i) ? hilite(cLineColor) : cLineColor, "%s", (OPTIONS[mPageItems[iCurrentPage][i]].getValue()).c_str());
            }
        }

        //Draw Tabs
        mvwprintz(w_options_header, 0, 7, c_white, "");
        for (int i = 0; i < vPages.size(); i++) {
            if (mPageItems[i].size() > 0) { //skip empty pages
                wprintz(w_options_header, c_white, "[");
                wprintz(w_options_header, (iCurrentPage == i) ? hilite(c_white) : c_white, vPages[i].c_str());
                wprintz(w_options_header, c_white, "]");
                wputch(w_options_header, c_white, LINE_OXOX);
            }
        }

        wrefresh(w_options_header);

        fold_and_print(w_options_tooltip, 0, 0, 78, c_white, "%s", (OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].getTooltip() + "  #Default: " + OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].getDefaultText()).c_str());
        wrefresh(w_options_tooltip);

        wrefresh(w_options);

        ch = input();

        if (mPageItems[iCurrentPage].size() > 0 || ch == '\t') {
            switch(ch) {
                case 'j': //move down
                    iCurrentLine++;
                    if (iCurrentLine >= mPageItems[iCurrentPage].size()) {
                        iCurrentLine = 0;
                    }
                    break;
                case 'k': //move up
                    iCurrentLine--;
                    if (iCurrentLine < 0) {
                        iCurrentLine = mPageItems[iCurrentPage].size()-1;
                    }
                    break;
                case 'l': //set to prev value
                    OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].setNext();
                    bStuffChanged = true;
                    break;
                case 'h': //set to next value
                    OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].setPrev();
                    bStuffChanged = true;
                    break;
                case '>':
                case '\t': //Switch to next Page
                    iCurrentLine = 0;
                    do { //skip empty pages
                        iCurrentPage++;
                        if (iCurrentPage >= vPages.size()) {
                            iCurrentPage = 0;
                        }
                    } while(mPageItems[iCurrentPage].size() == 0);

                    break;
                case '<':
                    iCurrentLine = 0;
                    do { //skip empty pages
                        iCurrentPage--;
                        if (iCurrentPage < 0) {
                            iCurrentPage = vPages.size()-1;
                        }
                    } while(mPageItems[iCurrentPage].size() == 0);
                    break;
            }
        }
    } while(ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE);

    if (bStuffChanged) {
        if(query_yn(_("Save changes?"))) {
            save_options();
        } else {
            OPTIONS = OPTIONS_OLD;
        }
    }

    werase(w_options);
    werase(w_options_border);
    werase(w_options_header);
    werase(w_options_tooltip);
}
开发者ID:Redstonize,项目名称:Cataclysm-DDA,代码行数:101,代码来源:options.cpp


示例20: caravan_items


//.........这里部分代码省略.........
      }
     }
     draw_caravan_categories(w, category_selected, total_price, g->u.cash);
     draw_caravan_items(w, g, &(items[category_selected]),
                       &(item_count[category_selected]), offset, item_selected);
     draw_caravan_borders(w, current_window);
    }
    break;

   case '-':
   case 'h':
    if (current_window == 1 && items[category_selected].size() > 0 &&
        item_count[category_selected][item_selected] > 0) {
     item_count[category_selected][item_selected]--;
     itype_id tmp_itm = items[category_selected][item_selected];
     total_price -= caravan_price(g->u, g->itypes[tmp_itm]->price);
     if (category_selected == CARAVAN_CART) { // Find the item in its category
      for (int i = 1; i < NUM_CARAVAN_CATEGORIES; i++) {
       for (int j = 0; j < items[i].size(); j++) {
        if (items[i][j] == tmp_itm)
         item_count[i][j]--;
       }
      }
     } else { // Decrease / remove the item in the shopping cart
      bool found_item = false;
      for (int i = 0; i < items[0].size() && !found_item; i++) {
       if (items[0][i] == tmp_itm) {
        found_item = true;
        item_count[0][i]--;
        if (item_count[0][i] == 0) {
         item_count[0].erase(item_count[0].begin() + i);
         items[0].erase(items[0].begin() + i);
        }
       }
      }
     }
     draw_caravan_categories(w, category_selected, total_price, g->u.cash);
     draw_caravan_items(w, g, &(items[category_selected]),
                       &(item_count[category_selected]), offset, item_selected);
     draw_caravan_borders(w, current_window);
    }
    break;

   case '\t':
    current_window = (current_window + 1) % 2;
    draw_caravan_borders(w, current_window);
    break;

   case KEY_ESCAPE:
    if (query_yn("Really buy nothing?")) {
     cancel = true;
     done = true;
    } else {
     draw_caravan_categories(w, category_selected, total_price, g->u.cash);
     draw_caravan_items(w, g, &(items[category_selected]),
                       &(item_count[category_selected]), offset, item_selected);
     draw_caravan_borders(w, current_window);
    }
    break;

   case '\n':
    if (total_price > g->u.cash)
     popup("You can't afford those items!");
    else if ((items[0].empty() && query_yn("Really buy nothing?")) ||
             (!items[0].empty() &&
              query_yn("Buy %d items, leaving you with $%d?", items[0].size(),
                       g->u.cash - total_price)))
     done = true;
    if (!done) { // We canceled, so redraw everything
     draw_caravan_categories(w, category_selected, total_price, g->u.cash);
     draw_caravan_items(w, g, &(items[category_selected]),
                       &(item_count[category_selected]), offset, item_selected);
     draw_caravan_borders(w, current_window);
    }
    break;
  } // switch (ch)

 } // while (!done)

 if (!cancel) {
  g->u.cash -= total_price;
  bool dropped_some = false;
  for (int i = 0; i < items[0].size(); i++) {
   item tmp(g->itypes[ items[0][i] ], g->turn);
   tmp = tmp.in_its_container(&(g->itypes));
   for (int j = 0; j < item_count[0][i]; j++) {
    if (g->u.volume_carried() + tmp.volume() <= g->u.volume_capacity() &&
        g->u.weight_carried() + tmp.weight() <= g->u.weight_capacity() &&
        g->u.inv.size() < inv_chars.size())
     g->u.i_add(tmp);
    else { // Could fit it in the inventory!
     dropped_some = true;
     g->m.add_item(g->u.posx, g->u.posy, tmp);
    }
   }
  }
  if (dropped_some)
   g->add_msg("You drop some items.");
 }
}
开发者ID:Dirkkun,项目名称:Cataclysm-DDA,代码行数:101,代码来源:defense.cpp



注:本文中的query_yn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ queue函数代码示例发布时间:2022-05-30
下一篇:
C++ query_temp函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap