hedgewars/uInputHandler.pas
changeset 15006 f81b46f584c7
parent 15003 d84136589c04
child 15007 9d00a873bbcc
equal deleted inserted replaced
15005:1b3d788e7350 15006:f81b46f584c7
   185 end;
   185 end;
   186 
   186 
   187 procedure ProcessKey(code: LongInt; KeyDown: boolean);
   187 procedure ProcessKey(code: LongInt; KeyDown: boolean);
   188 var
   188 var
   189     Trusted: boolean;
   189     Trusted: boolean;
   190     s      : string;
   190     curBind, s: shortstring;
   191 begin
   191 begin
   192 if not(tkbd[code] xor KeyDown) then exit;
   192 if not(tkbd[code] xor KeyDown) then exit;
   193 tkbd[code]:= KeyDown;
   193 tkbd[code]:= KeyDown;
   194 
   194 
   195 Trusted:= (CurrentTeam <> nil)
   195 Trusted:= (CurrentTeam <> nil)
   225         ParseCommand('forcequit', true);
   225         ParseCommand('forcequit', true);
   226     end;
   226     end;
   227 
   227 
   228 if CurrentBinds.indices[code] > 0 then
   228 if CurrentBinds.indices[code] > 0 then
   229     begin
   229     begin
       
   230     curBind:= CurrentBinds.binds[CurrentBinds.indices[code]];
   230     if (code < cKeyMaxIndex - 2) // means not mouse buttons
   231     if (code < cKeyMaxIndex - 2) // means not mouse buttons
   231         and KeyDown
   232         and KeyDown
   232         and (not ((CurrentBinds.binds[CurrentBinds.indices[code]] = 'put') 
   233         and (not ((curBind = 'put')
   233                   or (CurrentBinds.binds[CurrentBinds.indices[code]] = 'ammomenu') 
   234                   or (curBind = 'ammomenu')
   234                   or (CurrentBinds.binds[CurrentBinds.indices[code]] = '+cur_u') 
   235                   or (curBind = '+cur_u')
   235                   or (CurrentBinds.binds[CurrentBinds.indices[code]] = '+cur_d') 
   236                   or (curBind = '+cur_d')
   236                   or (CurrentBinds.binds[CurrentBinds.indices[code]] = '+cur_l') 
   237                   or (curBind = '+cur_l')
   237                   or (CurrentBinds.binds[CurrentBinds.indices[code]] = '+cur_r')))
   238                   or (curBind = '+cur_r')))
   238         and (CurrentTeam <> nil) 
   239         and (CurrentTeam <> nil)
   239         and (not CurrentTeam^.ExtDriven) 
   240         and (not CurrentTeam^.ExtDriven)
   240         then bShowAmmoMenu:= false;
   241         then bShowAmmoMenu:= false;
   241 
   242 
   242     if KeyDown then
   243     if KeyDown then
   243         begin
   244         begin
   244         Trusted:= Trusted and (not isPaused); //releasing keys during pause should be allowed on the other hand
   245         Trusted:= Trusted and (not isPaused); //releasing keys during pause should be allowed on the other hand
   245 
   246 
   246         if CurrentBinds.binds[CurrentBinds.indices[code]] = 'switch' then
   247         if curBind = 'switch' then
   247             LocalMessage:= LocalMessage or gmSwitch
   248             LocalMessage:= LocalMessage or gmSwitch
   248         else if CurrentBinds.binds[CurrentBinds.indices[code]] = '+precise' then
   249         else if curBind = '+precise' then
   249             begin
   250             begin
   250             LocalMessage:= LocalMessage or gmPrecise;
   251             LocalMessage:= LocalMessage or gmPrecise;
   251             updateVolumeDelta(true);
   252             updateVolumeDelta(true);
   252             updateCursorMovementDelta(true, CursorMovementX, CursorMovementX);
   253             updateCursorMovementDelta(true, CursorMovementX, CursorMovementX);
   253             updateCursorMovementDelta(true, CursorMovementY, CursorMovementY);
   254             updateCursorMovementDelta(true, CursorMovementY, CursorMovementY);
   254             end;
   255             end;
   255 
   256 
   256         ParseCommand(CurrentBinds.binds[CurrentBinds.indices[code]], Trusted);
   257         ParseCommand(curBind, Trusted);
   257         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   258         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   258             ParseCommand('gencmd R', true)
   259             ParseCommand('gencmd R', true)
   259         end
   260         end
   260     else if (CurrentBinds.binds[CurrentBinds.indices[code]][1] = '+') then
   261     else if (curBind[1] = '+') then
   261         begin
   262         begin
   262         if CurrentBinds.binds[CurrentBinds.indices[code]] = '+precise' then
   263         if curBind = '+precise' then
   263             begin
   264             begin
   264             LocalMessage:= LocalMessage and (not gmPrecise);
   265             LocalMessage:= LocalMessage and (not gmPrecise);
   265             updateVolumeDelta(false);
   266             updateVolumeDelta(false);
   266             updateCursorMovementDelta(false, CursorMovementX, CursorMovementX);
   267             updateCursorMovementDelta(false, CursorMovementX, CursorMovementX);
   267             updateCursorMovementDelta(false, CursorMovementY, CursorMovementY);
   268             updateCursorMovementDelta(false, CursorMovementY, CursorMovementY);
   268             end;
   269             end;
   269         s:= CurrentBinds.binds[CurrentBinds.indices[code]];
   270         s:= curBind;
   270         s[1]:= '-';
   271         s[1]:= '-';
   271         ParseCommand(s, Trusted);
   272         ParseCommand(s, Trusted);
   272         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   273         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   273             ParseCommand('gencmd R', true)
   274             ParseCommand('gencmd R', true)
   274         end
   275         end
   275     else
   276     else
   276         begin
   277         begin
   277         if CurrentBinds.binds[CurrentBinds.indices[code]] = 'switch' then
   278         if curBind = 'switch' then
   278             LocalMessage:= LocalMessage and (not gmSwitch)
   279             LocalMessage:= LocalMessage and (not gmSwitch)
   279         end
   280         end
   280     end
   281     end
   281 end;
   282 end;
   282 
   283