hedgewars/uWorld.pas
changeset 6688 b2084a00a4cf
parent 6685 ef706fccfb0a
child 6691 79c96abd06d6
equal deleted inserted replaced
6687:98be933770e0 6688:b2084a00a4cf
    34 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    34 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    35 procedure HideMission;
    35 procedure HideMission;
    36 procedure ShakeCamera(amount: LongInt);
    36 procedure ShakeCamera(amount: LongInt);
    37 procedure InitCameraBorders;
    37 procedure InitCameraBorders;
    38 procedure InitTouchInterface;
    38 procedure InitTouchInterface;
       
    39 procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean);
    39 procedure MoveCamera;
    40 procedure MoveCamera;
    40 procedure onFocusStateChanged;
    41 procedure onFocusStateChanged;
    41 
    42 
    42 implementation
    43 implementation
    43 uses
    44 uses
   217 firebutton.y:= -Round(spritesData[sprFireButton].Texture^.h* buttonScale) + cScreenHeight;
   218 firebutton.y:= -Round(spritesData[sprFireButton].Texture^.h* buttonScale) + cScreenHeight;
   218 firebutton.width:= Round(spritesData[sprFireButton].Texture^.w * buttonScale);
   219 firebutton.width:= Round(spritesData[sprFireButton].Texture^.w * buttonScale);
   219 firebutton.height:= Round(spritesData[sprFireButton].Texture^.h * buttonScale);
   220 firebutton.height:= Round(spritesData[sprFireButton].Texture^.h * buttonScale);
   220 firebutton.hOffset:= 0;
   221 firebutton.hOffset:= 0;
   221 firebutton.vOffset:= 0;
   222 firebutton.vOffset:= 0;
       
   223 firebutton.sprite:= sprFireButton;
       
   224 firebutton.show:= true;
   222 
   225 
   223 backjump.x:= (cScreenWidth shr 1) - Round(spritesData[sprbackjump].Texture^.h * 2 * buttonScale);
   226 backjump.x:= (cScreenWidth shr 1) - Round(spritesData[sprbackjump].Texture^.h * 2 * buttonScale);
   224 backjump.y:= -Round(spritesData[sprbackjump].Texture^.h * 1.2 *  buttonScale) + cScreenHeight;
   227 backjump.y:= -Round(spritesData[sprbackjump].Texture^.h * 1.2 *  buttonScale) + cScreenHeight;
   225 backjump.width:= Round(spritesData[sprbackjump].Texture^.w * buttonScale);
   228 backjump.width:= Round(spritesData[sprbackjump].Texture^.w * buttonScale);
   226 backjump.height:= Round(spritesData[sprbackjump].Texture^.h * buttonScale);
   229 backjump.height:= Round(spritesData[sprbackjump].Texture^.h * buttonScale);
   227 backjump.hOffset:= 0;
   230 backjump.hOffset:= 0;
   228 backjump.vOffset:= 0;
   231 backjump.vOffset:= 0;
       
   232 backjump.sprite:= sprbackjump;
       
   233 backjump.show:= true;
   229 
   234 
   230 forwardjump.x:= (cScreenWidth shr 1) - Round(spritesData[sprforwardjump].Texture^.h * 1.2 * buttonScale);
   235 forwardjump.x:= (cScreenWidth shr 1) - Round(spritesData[sprforwardjump].Texture^.h * 1.2 * buttonScale);
   231 forwardjump.y:= -Round(spritesData[sprforwardjump].Texture^.h * 2 * buttonScale) + cScreenHeight;
   236 forwardjump.y:= -Round(spritesData[sprforwardjump].Texture^.h * 2 * buttonScale) + cScreenHeight;
   232 forwardjump.width:= Round(spritesData[sprforwardjump].Texture^.w * buttonScale);
   237 forwardjump.width:= Round(spritesData[sprforwardjump].Texture^.w * buttonScale);
   233 forwardjump.height:= Round(spritesData[sprforwardjump].Texture^.h * buttonScale);
   238 forwardjump.height:= Round(spritesData[sprforwardjump].Texture^.h * buttonScale);
   234 forwardjump.hOffset:= 0;
   239 forwardjump.hOffset:= 0;
   235 forwardjump.vOffset:= 0;
   240 forwardjump.vOffset:= 0;
   236 
   241 forwardjump.sprite:= sprforwardjump;
   237 arrowLeft.x:= -(cScreenWidth shr 1);
   242 forwardjump.show:= true;
   238 arrowLeft.y:= -Round(spritesData[sprArrowLeft].Texture^.h*buttonScale) + cScreenHeight  - Round(spritesData[sprArrowLeft].Texture^.h*buttonScale);
   243 
   239 arrowLeft.width:= Round(spritesData[sprArrowLeft].Texture^.h * buttonScale);
   244 with arrowLeft do
   240 arrowLeft.height:= Round(spritesData[sprArrowLeft].Texture^.h * buttonScale);
   245     begin
   241 arrowLeft.hOffset:= 0;
   246     show:= true;
   242 arrowLeft.vOffset:= 0;
   247     sprite:= sprArrowLeft;
   243 
   248     x:= -(cScreenWidth shr 1);
   244 arrowRight.x:= -(cScreenWidth shr 1)+ Round(spritesData[sprArrowUp].Texture^.h * buttonScale *2);
   249     y:= -Round(spritesData[sprite].Texture^.h*buttonScale) + cScreenHeight  - Round(spritesData[sprite].Texture^.h*buttonScale);
   245 arrowRight.y:= -Round(spritesData[sprArrowRight].Texture^.h*buttonScale) + cScreenHeight - Round(spritesData[sprArrowRight].Texture^.h*buttonScale);
   250     width:= Round(spritesData[sprite].Texture^.h * buttonScale);
   246 arrowRight.width:= Round(spritesData[sprArrowRight].Texture^.w * buttonScale);
   251     height:= Round(spritesData[sprite].Texture^.h * buttonScale);
   247 arrowRight.height:= Round(spritesData[sprArrowRight].Texture^.h * buttonScale);
   252     hOffset:= 0;
   248 arrowRight.hOffset:= 0;
   253     vOffset:= 0;
   249 arrowRight.vOffset:= 0;
   254     end;
   250 
   255 with arrowRight do
   251 arrowUp.x:= -(cScreenWidth shr 1) + Round(spritesData[sprArrowUp].Texture^.h * buttonScale);
   256     begin
   252 arrowUp.y:= -Round(spritesData[sprArrowUp].Texture^.h*buttonScale) + cScreenHeight - Round(spritesData[sprArrowUp].Texture^.h*buttonScale*2);
   257     show:= true;
   253 arrowUp.width:= Round(spritesData[sprArrowUp].Texture^.w * buttonScale);
   258     sprite:= sprArrowRight;
   254 arrowUp.height:= Round(spritesData[sprArrowUp].Texture^.h * buttonScale);
   259     x:= -(cScreenWidth shr 1)+ Round(spritesData[sprite].Texture^.h * buttonScale);
   255 arrowUp.hOffset:= 0;
   260     y:= -Round(spritesData[sprite].Texture^.h*buttonScale) + cScreenHeight - Round(spritesData[sprite].Texture^.h*buttonScale);
   256 arrowUp.vOffset:= 0;
   261     width:= Round(spritesData[sprite].Texture^.w * buttonScale);
   257 
   262     height:= Round(spritesData[sprite].Texture^.h * buttonScale);
   258 arrowDown.x:= -(cScreenWidth shr 1) + Round(spritesData[sprArrowUp].Texture^.h * buttonScale);
   263     hOffset:= 0;
   259 arrowDown.y:= -Round(spritesData[sprArrowDown].Texture^.h*buttonscale) + cScreenHeight;
   264     vOffset:= 0;
   260 arrowDown.width:= Round(spritesData[sprArrowDown].Texture^.w * buttonScale);
   265     with moveAnim do
   261 arrowDown.height:= Round(spritesData[sprArrowDown].Texture^.h * buttonScale);
   266         begin
   262 arrowDown.hOffset:= 0;
   267         targetToX:= arrowRight.x;
   263 arrowDown.vOffset:= 0;
   268         targetToY:= arrowRight.y;
       
   269         targetFromX:= arrowRight.x + Round(spritesData[sprArrowUp].Texture^.h * buttonScale);
       
   270         targetFromY:= arrowRight.y;
       
   271         end;
       
   272     end;
       
   273 
       
   274 with arrowUp do
       
   275     begin
       
   276     show:= false;
       
   277     sprite:= sprArrowUp;
       
   278     x:= -(cScreenWidth shr 1) + Round(spritesData[sprite].Texture^.h * buttonScale);
       
   279     y:= arrowRight.y;
       
   280     width:= Round(spritesData[sprite].Texture^.w * buttonScale);
       
   281     height:= Round(spritesData[sprite].Texture^.h * buttonScale);
       
   282     hOffset:= 0;
       
   283     vOffset:= 0;
       
   284     with moveAnim do
       
   285          begin
       
   286          targetToX:= arrowUp.x;
       
   287          targetToY:= arrowUp.y;
       
   288          targetFromX:= arrowUp.x;
       
   289          targetFromY:= -Round(spritesData[sprite].Texture^.h*buttonScale) + cScreenHeight - Round(spritesData[sprite].Texture^.h*buttonScale*2);
       
   290          end;
       
   291     end;
       
   292 
       
   293 with arrowDown do
       
   294     begin
       
   295     show:= false;
       
   296     sprite:= sprArrowDown;
       
   297     x:= -(cScreenWidth shr 1) + Round(spritesData[sprArrowUp].Texture^.h * buttonScale);
       
   298     y:= arrowRight.y;
       
   299     width:= Round(spritesData[sprArrowDown].Texture^.w * buttonScale);
       
   300     height:= Round(spritesData[sprArrowDown].Texture^.h * buttonScale);
       
   301     hOffset:= 0;
       
   302     vOffset:= 0;
       
   303     with moveAnim do
       
   304         begin
       
   305         targetToX:= arrowDown.x;
       
   306         targetToY:= arrowDown.y;
       
   307         targetFromX:= arrowDown.x;
       
   308         targetFromY:= -Round(spritesData[sprArrowDown].Texture^.h*buttonscale) + cScreenHeight;
       
   309         end;
       
   310     end;
   264 
   311 
   265 pauseButton.x:= cScreenWidth div 2 - Round(spritesData[sprPauseButton].Texture^.w * buttonscale);
   312 pauseButton.x:= cScreenWidth div 2 - Round(spritesData[sprPauseButton].Texture^.w * buttonscale);
   266 pauseButton.y:= 0; //-Round(spritesData[sprPauseButton].Texture^.h * buttonscale);
   313 pauseButton.y:= 0; //-Round(spritesData[sprPauseButton].Texture^.h * buttonscale);
   267 pauseButton.width:= Round(spritesData[sprPauseButton].Texture^.w * buttonScale);;
   314 pauseButton.width:= Round(spritesData[sprPauseButton].Texture^.w * buttonScale);;
   268 pauseButton.height:= Round(spritesData[sprPauseButton].Texture^.h * buttonScale);;
   315 pauseButton.height:= Round(spritesData[sprPauseButton].Texture^.h * buttonScale);;
   269 pauseButton.hOffset:= 0;
   316 pauseButton.hOffset:= 0;
   270 pauseButton.vOffset:= 0;
   317 pauseButton.vOffset:= 0;
       
   318 pauseButton.sprite:= sprPauseButton;
       
   319 pauseButton.show:= true;
   271 
   320 
   272 {$ENDIF}
   321 {$ENDIF}
   273 end;
   322 end;
   274 
   323 
   275 // for uStore texture resetting
   324 // for uStore texture resetting
   567                 begin
   616                 begin
   568                 bShowAmmoMenu:= false;
   617                 bShowAmmoMenu:= false;
   569                 SetWeapon(Ammo^[Slot, Pos].AmmoType);
   618                 SetWeapon(Ammo^[Slot, Pos].AmmoType);
   570                 bSelected:= false;
   619                 bSelected:= false;
   571                 FreeWeaponTooltip;
   620                 FreeWeaponTooltip;
       
   621 
   572                 exit
   622                 exit
   573                 end;
   623                 end;
   574             end
   624             end
   575         end
   625         end
   576     else
   626     else
  1117 // Captions
  1167 // Captions
  1118 DrawCaptions;
  1168 DrawCaptions;
  1119 
  1169 
  1120 {$IFDEF USE_TOUCH_INTERFACE}
  1170 {$IFDEF USE_TOUCH_INTERFACE}
  1121 // Draw buttons Related to the Touch interface
  1171 // Draw buttons Related to the Touch interface
       
  1172 DrawScreenWidget(@arrowLeft);
       
  1173 DrawScreenWidget(@arrowRight);
       
  1174 DrawScreenWidget(@arrowUp);
       
  1175 DrawScreenWidget(@arrowDown);
       
  1176 
       
  1177 DrawScreenWidget(@fireButton);
       
  1178 DrawScreenWidget(@backjump);
       
  1179 DrawScreenWidget(@forwardjump);
       
  1180 DrawScreenWidget(@pauseButton);
       
  1181 {
  1122 DrawTexture(arrowLeft.x, arrowLeft.y, spritesData[sprArrowLeft].Texture, buttonScale);
  1182 DrawTexture(arrowLeft.x, arrowLeft.y, spritesData[sprArrowLeft].Texture, buttonScale);
  1123 DrawTexture(arrowRight.x, arrowRight.y, spritesData[sprArrowRight].Texture, buttonScale);
  1183 DrawTexture(arrowRight.x, arrowRight.y, spritesData[sprArrowRight].Texture, buttonScale);
  1124 DrawTexture(arrowUp.x, arrowUp.y, spritesData[sprArrowUp].Texture, buttonScale);
  1184 DrawTexture(arrowUp.x, arrowUp.y, spritesData[sprArrowUp].Texture, buttonScale);
  1125 DrawTexture(arrowDown.x, arrowDown.y, spritesData[sprArrowDown].Texture, buttonScale);
  1185 DrawTexture(arrowDown.x, arrowDown.y, spritesData[sprArrowDown].Texture, buttonScale);
  1126 
  1186 
  1127 DrawTexture(fireButton.x, firebutton.y, spritesData[sprFireButton].Texture, buttonScale);
  1187 DrawTexture(fireButton.x, firebutton.y, spritesData[sprFireButton].Texture, buttonScale);
  1128 DrawTexture(backjump.x, backjump.y, spritesData[sprBackjump].Texture, buttonScale);
  1188 DrawTexture(backjump.x, backjump.y, spritesData[sprBackjump].Texture, buttonScale);
  1129 DrawTexture(forwardjump.x, forwardjump.y, spritesData[sprForwardjump].Texture, buttonScale);
  1189 DrawTexture(forwardjump.x, forwardjump.y, spritesData[sprForwardjump].Texture, buttonScale);
  1130 DrawTexture(pauseButton.x, pauseButton.y, spritesData[sprPauseButton].Texture, buttonScale);
  1190 DrawTexture(pauseButton.x, pauseButton.y, spritesData[sprPauseButton].Texture, buttonScale);
  1131 {$ENDIF}
  1191 }{$ENDIF}
  1132 
  1192 
  1133 // Teams Healths
  1193 // Teams Healths
  1134 if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
  1194 if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
  1135     begin
  1195     begin
  1136     SetScale(1.5);
  1196     SetScale(1.5);
  1567 begin
  1627 begin
  1568 if (not cHasFocus) and (GameState <> gsConfirm) then
  1628 if (not cHasFocus) and (GameState <> gsConfirm) then
  1569     ParseCommand('quit', true);
  1629     ParseCommand('quit', true);
  1570 end;
  1630 end;
  1571 
  1631 
       
  1632 procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean);
       
  1633 begin
       
  1634 with widget^ do
       
  1635     begin
       
  1636     show:= showWidget;
       
  1637     if fade then fadeAnimStart:= RealTicks;
       
  1638     
       
  1639     with moveAnim do
       
  1640         begin
       
  1641         animate:= true;
       
  1642         startTime:= RealTicks;
       
  1643         targetFromX:= targetFromX xor targetToX;//swap From <-> To
       
  1644         targetToX:= targetFromX xor targetToX;
       
  1645         targetFromX:= targetFromX xor targetToX;
       
  1646         targetFromY:= targetFromY xor targetToY;
       
  1647         targetToY:= targetFromY xor targetToY;
       
  1648         targetFromY:= targetFromY xor targetToY;
       
  1649         end;
       
  1650     end;
       
  1651 end;
       
  1652 
  1572 
  1653 
  1573 procedure initModule;
  1654 procedure initModule;
  1574 begin
  1655 begin
  1575 fpsTexture:= nil;
  1656 fpsTexture:= nil;
  1576 FollowGear:= nil;
  1657 FollowGear:= nil;