hedgewars/uTouch.pas
changeset 14538 1dab5d92aca7
parent 14305 575baea4108b
child 15900 128ace913837
equal deleted inserted replaced
14537:ce40351e0690 14538:1dab5d92aca7
    20 
    20 
    21 unit uTouch;
    21 unit uTouch;
    22 
    22 
    23 interface
    23 interface
    24 
    24 
    25 uses SysUtils, uUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, GLUnit, uTypes, uCaptions, uAmmos, uWorld;
    25 uses SysUtils, uUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, GLUnit, uTypes, uCaptions, uWorld, uGearsHedgehog;
    26 
    26 
    27 
    27 
    28 procedure initModule;
    28 procedure initModule;
    29 procedure freeModule;
    29 procedure freeModule;
    30 
    30 
    87     targetting, targetted: boolean; //true when targetting an airstrike or the like
    87     targetting, targetted: boolean; //true when targetting an airstrike or the like
    88 
    88 
    89 procedure onTouchDown(x, y: Single; pointerId: TSDL_FingerId);
    89 procedure onTouchDown(x, y: Single; pointerId: TSDL_FingerId);
    90 var
    90 var
    91     finger: PTouch_Data;
    91     finger: PTouch_Data;
    92     xr, yr: LongWord;
    92     xr, yr, tmp: LongWord;
    93 begin
    93 begin
    94 xr:= round(x * cScreenWidth);
    94 xr:= round(x * cScreenWidth);
    95 yr:= round(y * cScreenHeight);
    95 yr:= round(y * cScreenHeight);
    96 
    96 
    97 finger:= addFinger(xr, yr, pointerId);
    97 finger:= addFinger(xr, yr, pointerId);
   157     finger^.pressedWidget:= @utilityWidget;
   157     finger^.pressedWidget:= @utilityWidget;
   158     moveCursor:= false;
   158     moveCursor:= false;
   159     if(CurrentHedgehog <> nil) then
   159     if(CurrentHedgehog <> nil) then
   160         begin
   160         begin
   161         if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable <> 0 then
   161         if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable <> 0 then
   162             ParseTeamCommand('/timer ' + inttostr((GetCurAmmoEntry(CurrentHedgeHog^)^.Timer div 1000) mod 5 + 1));
   162             begin
       
   163             tmp:= HHGetTimerMsg(CurrentHedgehog^.Gear);
       
   164             if tmp <> MSGPARAM_INVALID then
       
   165                 ParseTeamCommand('/timer ' + inttostr(tmp mod 5 + 1));
       
   166             end;
   163         end;
   167         end;
   164     exit;
   168     exit;
   165     end;
   169     end;
       
   170 
       
   171 if isOnWidget(utilityWidget2, finger^) then
       
   172     begin
       
   173     finger^.pressedWidget:= @utilityWidget2;
       
   174     moveCursor:= false;
       
   175     if(CurrentHedgehog <> nil) then
       
   176         begin
       
   177         if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_SetBounce <> 0 then
       
   178             begin
       
   179             tmp := HHGetBouncinessMsg(CurrentHedgehog^.Gear);
       
   180             if tmp <> MSGPARAM_INVALID then
       
   181                 begin
       
   182                 ParseTeamCommand('+precise');
       
   183                 ParseTeamCommand('timer ' + inttostr(tmp mod 5 + 1));
       
   184                 bounceButtonPressed:= true;
       
   185                 end;
       
   186             end;
       
   187         end;
       
   188     exit;
       
   189     end;
       
   190 
   166 dec(buttonsDown);//no buttonsDown, undo the inc() above
   191 dec(buttonsDown);//no buttonsDown, undo the inc() above
   167 if buttonsDown = 0 then
   192 if buttonsDown = 0 then
   168     begin
   193     begin
   169     moveCursor:= true;
   194     moveCursor:= true;
   170     case pointerCount of
   195     case pointerCount of
   494             begin
   519             begin
   495             ParseTeamCommand('-down');
   520             ParseTeamCommand('-down');
   496             aimingDown:= false;
   521             aimingDown:= false;
   497             end;
   522             end;
   498         end;
   523         end;
       
   524 
       
   525 if bounceButtonPressed then
       
   526     begin
       
   527     ParseTeamCommand('-precise');
       
   528     bounceButtonPressed:= false;
       
   529     end;
   499 end;
   530 end;
   500 
   531 
   501 function findFinger(id: TSDL_FingerId): PTouch_Data;
   532 function findFinger(id: TSDL_FingerId): PTouch_Data;
   502 var
   533 var
   503     index: LongWord;
   534     index: LongWord;
   625 var
   656 var
   626     index: Longword;
   657     index: Longword;
   627 begin
   658 begin
   628     buttonsDown:= 0;
   659     buttonsDown:= 0;
   629     pointerCount:= 0;
   660     pointerCount:= 0;
       
   661     bounceButtonPressed:= false;
   630 
   662 
   631     setLength(fingers, 4);
   663     setLength(fingers, 4);
   632     for index := 0 to (Length(fingers)-1) do
   664     for index := 0 to (Length(fingers)-1) do
   633         fingers[index].id := nilFingerId;
   665         fingers[index].id := nilFingerId;
   634 
   666