# HG changeset patch
# User Xeli
# Date 1335726309 -7200
# Node ID ec308eabe09b23aaaeb4e87060b8063e1c16c9d0
# Parent  d5ac09894a1bbae8e2711f6652d1d472ebb19043
implement switch for the touch interface

diff -r d5ac09894a1b -r ec308eabe09b hedgewars/uTouch.pas
--- a/hedgewars/uTouch.pas	Sun Apr 29 18:08:46 2012 +0200
+++ b/hedgewars/uTouch.pas	Sun Apr 29 21:05:09 2012 +0200
@@ -265,12 +265,15 @@
         ParseTeamCommand('-attack');
     
     if widget = @utilityWidget then
-        if (CurrentHedgehog <> nil) and 
-           (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)then
-            begin
-            ParseTeamCommand('put');
-            targetted:= true;
-            end;
+        if (CurrentHedgehog <> nil)then
+            if(Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)then
+                begin
+                ParseTeamCommand('put');
+                targetted:= true;
+                end
+            else if CurAmmoGear^.AmmoType = amSwitch then
+                ParseTeamCommand('switch')
+            else WriteLnToConsole(inttostr(ord(Ammoz[CurrentHedgehog^.CurAmmoType].NameId)) + ' ' + inttostr(ord(sidSwitch)));
     end;
         
 if targetting then
diff -r d5ac09894a1b -r ec308eabe09b hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas	Sun Apr 29 18:08:46 2012 +0200
+++ b/hedgewars/uWorld.pas	Sun Apr 29 21:05:09 2012 +0200
@@ -1765,6 +1765,11 @@
         utilityWidget.sprite:= sprTargetButton;
         animateWidget(@utilityWidget, true, true);
         end
+    else if ammoType = amSwitch then
+        begin
+        utilityWidget.sprite:= sprTargetButton;
+        animateWidget(@utilityWidget, true, true);
+        end
     else if utilityWidget.show then
         animateWidget(@utilityWidget, true, false); 
 end;