hedgewars/uTouch.pas
changeset 6957 ab8034208fcd
parent 6956 7d9e2669c2f5
child 6961 d5ac09894a1b
equal deleted inserted replaced
6956:7d9e2669c2f5 6957:ab8034208fcd
    78     aimingCrosshair: boolean;
    78     aimingCrosshair: boolean;
    79     aimingUp, aimingDown: boolean; 
    79     aimingUp, aimingDown: boolean; 
    80     targetAngle: LongInt;
    80     targetAngle: LongInt;
    81 
    81 
    82     buttonsDown: Longword;
    82     buttonsDown: Longword;
    83     targetting: boolean; //true when targetting an airstrike or the like
    83     targetting, targetted: boolean; //true when targetting an airstrike or the like
    84 
    84 
    85 procedure onTouchDown(x,y: Longword; pointerId: TSDL_FingerId);
    85 procedure onTouchDown(x,y: Longword; pointerId: TSDL_FingerId);
    86 var 
    86 var 
    87     finger: PTouch_Data;
    87     finger: PTouch_Data;
    88 begin
    88 begin
    99     exit;
    99     exit;
   100 end;
   100 end;
   101 
   101 
   102 if isOnWidget(fireButton, finger^) then
   102 if isOnWidget(fireButton, finger^) then
   103     begin
   103     begin
   104     if not((CurrentHedgehog <> nil) and 
   104     ParseTeamCommand('+attack');
   105        (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)) then
       
   106         ParseTeamCommand('+attack');
       
   107     moveCursor:= false;
   105     moveCursor:= false;
   108     finger^.pressedWidget:= @fireButton;
   106     finger^.pressedWidget:= @fireButton;
   109     exit;
   107     exit;
   110     end;
   108     end;
   111 if isOnWidget(arrowLeft, finger^) then
   109 if isOnWidget(arrowLeft, finger^) then
   147     exit;
   145     exit;
   148     end;
   146     end;
   149 
   147 
   150 if isOnWidget(utilityWidget, finger^) then
   148 if isOnWidget(utilityWidget, finger^) then
   151     begin
   149     begin
       
   150     finger^.pressedWidget:= @utilityWidget;
       
   151     moveCursor:= false;
   152     if(CurrentHedgehog <> nil) then
   152     if(CurrentHedgehog <> nil) then
   153         begin
   153         begin
   154         if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable <> 0 then
   154         if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable <> 0 then
   155             ParseTeamCommand('/timer ' + inttostr((GetCurAmmoEntry(CurrentHedgeHog^)^.Timer div 1000) mod 5 + 1));
   155             ParseTeamCommand('/timer ' + inttostr((GetCurAmmoEntry(CurrentHedgeHog^)^.Timer div 1000) mod 5 + 1));
   156         end;
   156         end;
       
   157     exit;
   157     end; 
   158     end; 
   158 dec(buttonsDown);//no buttonsDown, undo the inc() above
   159 dec(buttonsDown);//no buttonsDown, undo the inc() above
   159 if buttonsDown = 0 then
   160 if buttonsDown = 0 then
   160     begin
   161     begin
   161     moveCursor:= true;
   162     moveCursor:= true;
   162     case pointerCount of
   163     case pointerCount of
   163         1:
   164         1:
   164             targetting:= (CurrentHedgehog <> nil) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0);
   165             targetting:= not(targetted) and (CurrentHedgehog <> nil) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0);
   165         2:
   166         2:
   166             begin
   167             begin
   167             moveCursor:= false;
   168             moveCursor:= false;
   168             pinchSize := calculateDelta(finger^, getSecondFinger(finger^)^);
   169             pinchSize := calculateDelta(finger^, getSecondFinger(finger^)^);
   169             baseZoomValue := ZoomValue
   170             baseZoomValue := ZoomValue
   257 
   258 
   258     if widget = @arrowDown then
   259     if widget = @arrowDown then
   259         ParseTeamCommand('-down');
   260         ParseTeamCommand('-down');
   260 
   261 
   261     if widget = @fireButton then
   262     if widget = @fireButton then
       
   263         ParseTeamCommand('-attack');
       
   264     
       
   265     if widget = @utilityWidget then
   262         if (CurrentHedgehog <> nil) and 
   266         if (CurrentHedgehog <> nil) and 
   263            (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)then
   267            (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)then
   264             ParseTeamCommand('put')
   268             begin
   265         else
   269             ParseTeamCommand('put');
   266             ParseTeamCommand('-attack');
   270             targetted:= true;
       
   271             end;
   267     end;
   272     end;
   268         
   273         
   269 if targetting then
   274 if targetting then
   270     AddCaption('Press the attack button to mark the target', cWhiteColor, capgrpAmmoInfo);
   275     AddCaption('Press the target button to mark the target', cWhiteColor, capgrpAmmoInfo);
   271  
   276  
   272 deleteFinger(pointerId);
   277 deleteFinger(pointerId);
   273 {$ENDIF}
   278 {$ENDIF}
   274 end;
   279 end;
   275 
   280