本文整理汇总了C++中input_manager::remove_input_for_action方法的典型用法代码示例。如果您正苦于以下问题:C++ input_manager::remove_input_for_action方法的具体用法?C++ input_manager::remove_input_for_action怎么用?C++ input_manager::remove_input_for_action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类input_manager
的用法示例。
在下文中一共展示了input_manager::remove_input_for_action方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display_help
//.........这里部分代码省略.........
const long raw_input_char = ctxt.get_raw_input().get_first_input();
if (action == "ADD_LOCAL" || raw_input_char == '+') {
status = s_add;
} else if (action == "ADD_GLOBAL" || raw_input_char == '=') {
status = s_add_global;
} else if (action == "REMOVE" || raw_input_char == '-') {
status = s_remove;
} else if (action == "ANY_INPUT") {
const size_t hotkey_index = hotkeys.find_first_of(raw_input_char);
if (status == s_show || hotkey_index == std::string::npos ) {
continue;
}
const size_t action_index = hotkey_index + scroll_offset;
if( action_index >= org_registered_actions.size() ) {
continue;
}
const std::string &action_id = org_registered_actions[action_index];
// Check if this entry is local or global.
bool is_local = false;
inp_mngr.get_action_attributes(action_id, category, &is_local);
const std::string name = get_action_name(action_id);
if (status == s_remove && (!OPTIONS["QUERY_KEYBIND_REMOVAL"] ||
query_yn(_("Clear keys for %s?"), name.c_str()))) {
// If it's global, reset the global actions.
std::string category_to_access = category;
if (!is_local) {
category_to_access = default_context_id;
}
inp_mngr.remove_input_for_action(action_id, category_to_access);
changed = true;
} else if (status == s_add_global && is_local) {
// Disallow adding global actions to an action that already has a local defined.
popup(_("There are already local keybindings defined for this action, please remove them first."));
} else if (status == s_add || status == s_add_global) {
const long newbind = popup_getkey(_("New key for %s:"), name.c_str());
const input_event new_event(newbind, CATA_INPUT_KEYBOARD);
const std::string conflicts = get_conflicts(new_event);
const bool has_conflicts = !conflicts.empty();
bool resolve_conflicts = false;
if (has_conflicts) {
resolve_conflicts = query_yn(
_("This key conflicts with %s. Remove this key from the conflicting command(s), and continue?"),
conflicts.c_str());
}
if (!has_conflicts || resolve_conflicts) {
if (resolve_conflicts) {
clear_conflicting_keybindings(new_event);
}
// We might be adding a local or global action.
std::string category_to_access = category;
if (status == s_add_global) {
category_to_access = default_context_id;
}
inp_mngr.add_input_for_action(action_id, category_to_access, new_event);
changed = true;
}
}
示例2: display_menu
//.........这里部分代码省略.........
// keys, e.g. '+', '-', '=', in order to prevent the user from
// entering an unrecoverable state.
if( action == "ADD_LOCAL" || raw_input_char == '+' ) {
status = s_add;
} else if( action == "ADD_GLOBAL" || raw_input_char == '=' ) {
status = s_add_global;
} else if( action == "REMOVE" || raw_input_char == '-' ) {
status = s_remove;
} else if( action == "ANY_INPUT" ) {
const size_t hotkey_index = hotkeys.find_first_of( raw_input_char );
if( hotkey_index == std::string::npos ) {
continue;
}
const size_t action_index = hotkey_index + scroll_offset;
if( action_index >= filtered_registered_actions.size() ) {
continue;
}
const std::string &action_id = filtered_registered_actions[action_index];
// Check if this entry is local or global.
bool is_local = false;
inp_mngr.get_action_attributes( action_id, category, &is_local );
const std::string name = get_action_name( action_id );
if( status == s_remove && ( !get_option<bool>( "QUERY_KEYBIND_REMOVAL" ) ||
query_yn( _( "Clear keys for %s?" ), name.c_str() ) ) ) {
// If it's global, reset the global actions.
std::string category_to_access = category;
if( !is_local ) {
category_to_access = default_context_id;
}
inp_mngr.remove_input_for_action( action_id, category_to_access );
changed = true;
} else if( status == s_add_global && is_local ) {
// Disallow adding global actions to an action that already has a local defined.
popup( _( "There are already local keybindings defined for this action, please remove them first." ) );
} else if( status == s_add || status == s_add_global ) {
const long newbind = popup_getkey( _( "New key for %s:" ), name.c_str() );
const input_event new_event( newbind, CATA_INPUT_KEYBOARD );
if( action_uses_input( action_id, new_event ) ) {
popup_getkey( _( "This key is already used for %s." ), name.c_str() );
status = s_show;
continue;
}
const std::string conflicts = get_conflicts( new_event );
const bool has_conflicts = !conflicts.empty();
bool resolve_conflicts = false;
if( has_conflicts ) {
resolve_conflicts = query_yn(
_( "This key conflicts with %s. Remove this key from the conflicting command(s), and continue?" ),
conflicts.c_str() );
}
if( !has_conflicts || resolve_conflicts ) {
if( resolve_conflicts ) {
clear_conflicting_keybindings( new_event );
}
// We might be adding a local or global action.
std::string category_to_access = category;
if( status == s_add_global ) {