I've made a controls room for custom keymapping. I had an idea - if key is assigned to more than 1 control, then it shows up red. But it works only partially.
Spawn code:
with(instance_create(64,64,obj_button_key)) {
mytext="UP: ";
myKEY=global.keyUP;
mytype=1;
}
with(...
scr_keymap_conflict(argument0):
var ii;
ii = 0;
if (argument0 == global.keyUP) ii+=1;
if (argument0 == global.keyDOWN) ii+=1;
if (argument0 == global.keyLEFT) ii+=1;
if (argument0 == global.keyRIGHT) ii+=1;
if (argument0 == global.keySPRINT) ii+=1;
if (argument0 == global.keyCROUCH) ii+=1;
if (argument0 == global.keyGRENADE) ii+=1;
if (argument0 == global.keyACTION) ii+=1;
if (argument0 == global.keyCHAT) ii+=1;
if (argument0 == global.keyMELEE) ii+=1;
if (argument0 == global.keyDROP) ii+=1;
if (ii > 1) {
return true;
}
Draw:
if (active) {draw_set_color(c_yellow)}
else if (scr_keymap_conflict(myKEY)) {draw_set_color(c_red)}
else draw_set_color(c_gray);
...
It seems like there's a problem with scr_keymap_conflict(argument0)
giving invalid info, so some buttons turn red, but some don't, an example, if there are two vk_space
controls, then the first one will become red, but the second won't (I have a feeling that draw_set_color
is overwriting separate objects at random moments). Anyway, global.key...
hold ASCII real values (keyboard shortcuts). active
and mytype
are not important in this case. Anyone got any idea how to fix this?