MCPcopy Create free account
hub / github.com/assaultcube/AC / key

Method key

source/src/menus.cpp:684–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682 }
683
684 virtual void key(int code, bool isdown)
685 {
686 keym *km;
687 if(!capture || !((km = findbindc(code)))) return;
688 if(code == SDLK_ESCAPE)
689 {
690 capture = false;
691 parent->init();
692 return;
693 }
694 bool known = newkeys.find(code) >= 0;
695 if(isdown)
696 {
697 if(!known)
698 {
699 if(km->actions[bindtype][0] && strcmp(km->actions[bindtype], bindcmd))
700 {
701 static defformatstring(keybound)("\f3Warning: \"%s\" key is already in use. You can press ESC to cancel.", km->name);
702 menuheader(parent, NULL, keybound);
703 }
704 newkeys.add(code);
705 concatformatstring(keynames, "%s or ", km->name);
706 keyname = keynames;
707 }
708 }
709 else
710 {
711 if(known && ++isup == newkeys.length())
712 {
713 for(keym **km = findbinda(bindcmd, bindtype); *km; km++) bindkey(*km, "", bindtype); // clear existing binds to this cmd
714 bool bindfailed = false;
715 loopv(newkeys) bindfailed = !bindc(newkeys[i], bindcmd, bindtype) || bindfailed;
716 if(bindfailed) conoutf("\f3could not bind key");
717 else parent->init(); // show new keys
718 }
719 }
720 }
721
722 virtual const char* gettext() { return text; }
723};

Callers

nothing calls this directly

Calls 12

findbindcFunction · 0.85
menuheaderFunction · 0.85
concatformatstringFunction · 0.85
findbindaFunction · 0.85
bindkeyFunction · 0.85
bindcFunction · 0.85
loopvFunction · 0.70
conoutfFunction · 0.70
initMethod · 0.45
findMethod · 0.45
addMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected