hedgewars/uWorld.pas
changeset 6676 21cf35a570a7
parent 6652 b043665dea3d
child 6682 bf3cf6e60673
equal deleted inserted replaced
6675:dab56311daa5 6676:21cf35a570a7
   195 
   195 
   196 //aligns it to the bottom of the screen, minus the border
   196 //aligns it to the bottom of the screen, minus the border
   197 SkyOffset:= 0;
   197 SkyOffset:= 0;
   198 HorizontOffset:= 0;
   198 HorizontOffset:= 0;
   199 
   199 
   200 {$IFDEF ANDROID}
   200 {$IFDEF USE_TOUCH_INTERFACE}
   201 //positioning of the buttons
   201 //positioning of the buttons
   202 buttonScale:= 1.5/cDefaultZoomLevel;
   202 buttonScale:= 1.5/cDefaultZoomLevel;
   203 firebuttonX:= (cScreenWidth shr 1) - Round(spritesData[sprFireButton].Texture^.h * buttonScale);
   203 firebuttonX:= (cScreenWidth shr 1) - Round(spritesData[sprFireButton].Texture^.h * buttonScale);
   204 firebuttonY:= -Round(spritesData[sprFireButton].Texture^.h* buttonScale) + cScreenHeight;
   204 firebuttonY:= -Round(spritesData[sprFireButton].Texture^.h* buttonScale) + cScreenHeight;
   205 firebuttonW:= Round(spritesData[sprFireButton].Texture^.w * buttonScale);
   205 firebuttonW:= Round(spritesData[sprFireButton].Texture^.w * buttonScale);
   264 begin
   264 begin
   265     SlotsNum:= 0;
   265     SlotsNum:= 0;
   266     for i:= 0 to cMaxSlotIndex do
   266     for i:= 0 to cMaxSlotIndex do
   267         if((i = 0) and (Ammo^[i,1].Count > 0)) or ((i <> 0) and (Ammo^[i,0].Count > 0)) then
   267         if((i = 0) and (Ammo^[i,1].Count > 0)) or ((i <> 0) and (Ammo^[i,0].Count > 0)) then
   268             inc(SlotsNum);
   268             inc(SlotsNum);
   269 {$IFDEF MOBILE}
   269 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   270     SlotsNumX:= SlotsNum;
   270     SlotsNumX:= SlotsNum;
   271     SlotsNumY:= cMaxSlotAmmoIndex + 2;
   271     SlotsNumY:= cMaxSlotAmmoIndex + 2;
   272 {$ELSE}
   272 {$ELSE}
   273     SlotsNumX:= cMaxSlotAmmoIndex + 1;
   273     SlotsNumX:= cMaxSlotAmmoIndex + 1;
   274     SlotsNumY:= SlotsNum + 1;
   274     SlotsNumY:= SlotsNum + 1;
   288     x:= AMRect.x;
   288     x:= AMRect.x;
   289     y:= AMRect.y;
   289     y:= AMRect.y;
   290     for i:= 0 to cMaxSlotIndex do
   290     for i:= 0 to cMaxSlotIndex do
   291         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   291         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   292             begin
   292             begin
   293 {$IFDEF MOBILE}
   293 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   294             y:= AMRect.y;
   294             y:= AMRect.y;
   295 {$ELSE}
   295 {$ELSE}
   296             x:= AMRect.x;
   296             x:= AMRect.x;
   297 {$ENDIF}
   297 {$ENDIF}
   298             for t:=0 to cMaxSlotAmmoIndex do
   298             for t:=0 to cMaxSlotAmmoIndex do
   313                     else //draw colored version
   313                     else //draw colored version
   314                         begin
   314                         begin
   315                             DrawSprite2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, 
   315                             DrawSprite2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, 
   316        						       y + AMSlotPadding, AMFrame);
   316        						       y + AMSlotPadding, AMFrame);
   317                         end;
   317                         end;
   318 {$IFDEF MOBILE}
   318 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   319 	    inc(y, AMSlotSize + 1); //the plus one is for the border
   319 	    inc(y, AMSlotSize + 1); //the plus one is for the border
   320 {$ELSE}
   320 {$ELSE}
   321 	    inc(x, AMSlotSize + 1);
   321 	    inc(x, AMSlotSize + 1);
   322 {$ENDIF}
   322 {$ENDIF}
   323 	    end;
   323 	    end;
   324 	end;
   324 	end;
   325 {$IFDEF MOBILE}
   325 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   326     inc(x, AMSlotSize + 1);
   326     inc(x, AMSlotSize + 1);
   327 {$ELSE}
   327 {$ELSE}
   328     inc(y, AMSlotSize + 1);
   328     inc(y, AMSlotSize + 1);
   329 {$ENDIF}
   329 {$ENDIF}
   330     end;
   330     end;
   383     begin
   383     begin
   384     AmmoMenuInvalidated:= false;
   384     AmmoMenuInvalidated:= false;
   385     FreeTexture(AmmoMenuTex);
   385     FreeTexture(AmmoMenuTex);
   386     AmmoMenuTex:= GetAmmoMenuTexture(Ammo);
   386     AmmoMenuTex:= GetAmmoMenuTexture(Ammo);
   387 
   387 
   388 {$IFDEF MOBILE}
   388 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   389     if isPhone() then
   389     if isPhone() then
   390         begin
   390         begin
   391         AmmoRect.x:= -(AmmoRect.w shr 1);
   391         AmmoRect.x:= -(AmmoRect.w shr 1);
   392         AmmoRect.y:= (cScreenHeight shr 1) - (AmmoRect.h shr 1);
   392         AmmoRect.y:= (cScreenHeight shr 1) - (AmmoRect.h shr 1);
   393         end
   393         end
   463     DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
   463     DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
   464 
   464 
   465     Pos:= -1;
   465     Pos:= -1;
   466     Slot:= -1;
   466     Slot:= -1;
   467     c:= -1;
   467     c:= -1;
   468 {$IFDEF MOBILE}
   468 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   469     for i:= 0 to cMaxSlotIndex do
   469     for i:= 0 to cMaxSlotIndex do
   470         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   470         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   471             begin
   471             begin
   472             inc(c);
   472             inc(c);
   473             g:= 0;
   473             g:= 0;
   547         end
   547         end
   548     else
   548     else
   549         FreeWeaponTooltip;
   549         FreeWeaponTooltip;
   550 
   550 
   551     if (WeaponTooltipTex <> nil) and (AMShiftX = 0) and (AMShiftY = 0) then
   551     if (WeaponTooltipTex <> nil) and (AMShiftX = 0) and (AMShiftY = 0) then
   552 {$IFDEF MOBILE}
   552 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   553         if not isPhone() then
   553         if not isPhone() then
   554             ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, AmmoRect.y - WeaponTooltipTex^.h - AMSlotSize);
   554             ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, AmmoRect.y - WeaponTooltipTex^.h - AMSlotSize);
   555 {$ELSE}
   555 {$ELSE}
   556         ShowWeaponTooltip(AmmoRect.x - WeaponTooltipTex^.w - 3, Min(AmmoRect.y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
   556         ShowWeaponTooltip(AmmoRect.x - WeaponTooltipTex^.w - 3, Min(AmmoRect.y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
   557 {$ENDIF}
   557 {$ENDIF}
   558 
   558 
   559     bSelected:= false;
   559     bSelected:= false;
   560 {$IFNDEF MOBILE}
   560 {$IFNDEF USE_LANDSCAPE_AMMOMENU}
   561    if (AMShiftX = 0) and (AMShiftY = 0) then
   561    if (AMShiftX = 0) and (AMShiftY = 0) then
   562         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
   562         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
   563 {$ENDIF}
   563 {$ENDIF}
   564 end;
   564 end;
   565 
   565 
  1087     end;
  1087     end;
  1088 
  1088 
  1089 // Captions
  1089 // Captions
  1090 DrawCaptions;
  1090 DrawCaptions;
  1091 
  1091 
  1092 {$IFDEF ANDROID}
  1092 {$IFDEF USE_TOUCH_INTERFACE}
  1093 // Draw buttons Related to the Touch interface
  1093 // Draw buttons Related to the Touch interface
  1094 DrawTexture(arrowLeftX, arrowLeftY,spritesData[sprArrowLeft].Texture, buttonScale);
  1094 DrawTexture(arrowLeftX, arrowLeftY,spritesData[sprArrowLeft].Texture, buttonScale);
  1095 DrawTexture(arrowRightX, arrowRightY,spritesData[sprArrowRight].Texture, buttonScale);
  1095 DrawTexture(arrowRightX, arrowRightY,spritesData[sprArrowRight].Texture, buttonScale);
  1096 DrawTexture(arrowUpX, arrowUpY,spritesData[sprArrowUp].Texture, buttonScale);
  1096 DrawTexture(arrowUpX, arrowUpY,spritesData[sprArrowUp].Texture, buttonScale);
  1097 DrawTexture(arrowDownX, arrowDownY,spritesData[sprArrowDown].Texture, buttonScale);
  1097 DrawTexture(arrowDownX, arrowDownY,spritesData[sprArrowDown].Texture, buttonScale);