当前位置: 首页>>代码示例>>C++>>正文


C++ input_manager::get_keyname方法代码示例

本文整理汇总了C++中input_manager::get_keyname方法的典型用法代码示例。如果您正苦于以下问题:C++ input_manager::get_keyname方法的具体用法?C++ input_manager::get_keyname怎么用?C++ input_manager::get_keyname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在input_manager的用法示例。


在下文中一共展示了input_manager::get_keyname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: press_x

// TODO: merge this with input_context::get_desc
std::string input_context::press_x(const std::string &action_id, const std::string &key_bound_pre, const std::string &key_bound_suf, const std::string &key_unbound) const
{
    if (action_id == "ANY_INPUT") {
        return _("any key");
    }
    if (action_id == "COORDINATE") {
        return _("mouse movement");
    }
    const input_manager::t_input_event_list &events = inp_mngr.get_input_for_action(action_id, category);
    if (events.empty()) {
        return key_unbound;
    }
    std::ostringstream keyed;
    keyed << key_bound_pre;
    for (size_t j = 0; j < events.size(); j++) {
        for (size_t k = 0; k < events[j].sequence.size(); ++k) {
            keyed << inp_mngr.get_keyname(events[j].sequence[k], events[j].type);
        }
        if (j + 1 < events.size()) {
            keyed << _(" or ");
        }
    }
    keyed << key_bound_suf;
    return keyed.str();
}
开发者ID:QuantumTangler,项目名称:Cataclysm-DDA,代码行数:26,代码来源:input.cpp

示例2: _

const std::string input_context::get_desc( const std::string &action_descriptor,
        const unsigned int max_limit ) const
{
    if( action_descriptor == "ANY_INPUT" ) {
        return "(*)"; // * for wildcard
    }

    const std::vector<input_event> &events = inp_mngr.get_input_for_action( action_descriptor,
            category );

    if( events.empty() ) {
        return _( "Unbound!" );
    }

    std::vector<input_event> inputs_to_show;
    for( auto &events_i : events ) {
        const input_event &event = events_i;

        // Only display gamepad buttons if a gamepad is available.
        if( gamepad_available() || event.type != CATA_INPUT_GAMEPAD ) {
            inputs_to_show.push_back( event );
        }

        if( max_limit > 0 && inputs_to_show.size() == max_limit ) {
            break;
        }
    }

    std::stringstream rval;
    for( size_t i = 0; i < inputs_to_show.size(); ++i ) {
        for( size_t j = 0; j < inputs_to_show[i].sequence.size(); ++j ) {
            rval << inp_mngr.get_keyname( inputs_to_show[i].sequence[j], inputs_to_show[i].type );
        }

        // We're generating a list separated by "," and "or"
        if( i + 2 == inputs_to_show.size() ) {
            rval << _( " or " );
        } else if( i + 1 < inputs_to_show.size() ) {
            rval << ", ";
        }
    }
    return rval.str();
}
开发者ID:greenalgae3183,项目名称:Cataclysm-DDA,代码行数:43,代码来源:input.cpp

示例3: if

const std::string input_context::get_desc(const std::string &action_descriptor)
{
    if(action_descriptor == "ANY_INPUT") {
        return "(*)"; // * for wildcard
    }

    const std::vector<input_event> &events = inp_mngr.get_input_for_action(action_descriptor, category);

    if(events.size() == 0) {
        return UNDEFINED;
    }

    std::vector<input_event> inputs_to_show;
    for( size_t i = 0; i < events.size(); ++i ) {
        const input_event &event = events[i];

        // Only display gamepad buttons if a gamepad is available.
        if(gamepad_available() || event.type != CATA_INPUT_GAMEPAD) {
            inputs_to_show.push_back(event);
        }
    }

    std::stringstream rval;
    for( size_t i = 0; i < inputs_to_show.size(); ++i ) {
        for( size_t j = 0; j < inputs_to_show[i].sequence.size(); ++j ) {
            rval << inp_mngr.get_keyname(inputs_to_show[i].sequence[j], inputs_to_show[i].type);
        }

        // We're generating a list separated by "," and "or"
        if(i + 2 == inputs_to_show.size()) {
            rval << " or ";
        } else if(i + 1 < inputs_to_show.size()) {
            rval << ", ";
        }
    }
    return rval.str();
}
开发者ID:Levvy055,项目名称:Cataclysm-DDA,代码行数:37,代码来源:input.cpp


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