hedgewars/uWorld.pas
branchcursor_issues
changeset 5191 c7000a6b397b
parent 5149 9aa840fdf922
child 5247 bf6d4bc531d2
child 5285 af4dc03dd60d
child 5326 e73f1c043c85
equal deleted inserted replaced
5189:dc1fe432b293 5191:c7000a6b397b
    48     GLunit,
    48     GLunit,
    49     uVariables,
    49     uVariables,
    50     uUtils,
    50     uUtils,
    51     uTextures,
    51     uTextures,
    52     uRender,
    52     uRender,
    53     uCaptions
    53     uCaptions,
       
    54     uCursor
    54     ;
    55     ;
    55 
    56 
    56 var cWaveWidth, cWaveHeight: LongInt;
    57 var cWaveWidth, cWaveHeight: LongInt;
    57     AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt;
    58     AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt;
    58     tmpSurface: PSDL_Surface;
    59     tmpSurface: PSDL_Surface;
   171 cWaveWidth:= SpritesData[sprWater].Width;
   172 cWaveWidth:= SpritesData[sprWater].Width;
   172 //cWaveHeight:= SpritesData[sprWater].Height;
   173 //cWaveHeight:= SpritesData[sprWater].Height;
   173 cWaveHeight:= 32;
   174 cWaveHeight:= 32;
   174 
   175 
   175 cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50);
   176 cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50);
   176 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
   177 uCursor.init();
   177 prevPoint.X:= 0;
   178 prevPoint.X:= 0;
   178 prevPoint.Y:= cScreenHeight div 2;
   179 prevPoint.Y:= cScreenHeight div 2;
   179 WorldDx:=  - (LAND_WIDTH div 2) + cScreenWidth div 2;
   180 WorldDx:=  - (LAND_WIDTH div 2) + cScreenWidth div 2;
   180 WorldDy:=  - (LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
   181 WorldDy:=  - (LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
   181 AMSlotSize:= 33;
   182 AMSlotSize:= 33;
   209    if AMxShift = AMWidth then prevPoint.X:= 0;
   210    if AMxShift = AMWidth then prevPoint.X:= 0;
   210    if (cReducedQuality and rqSlowMenu) <> 0 then
   211    if (cReducedQuality and rqSlowMenu) <> 0 then
   211        AMxShift:= 0
   212        AMxShift:= 0
   212    else
   213    else
   213        if AMxShift > MENUSPEED then
   214        if AMxShift > MENUSPEED then
   214       	   dec(AMxShift, MENUSPEED)
   215            dec(AMxShift, MENUSPEED)
   215        else
   216        else
   216            AMxShift:= 0;
   217            AMxShift:= 0;
   217    end else
   218    end else
   218    begin
   219    begin
   219    if AMxShift = 0 then
   220    if AMxShift = 0 then
   220       begin
   221       begin
   221       CursorPoint.X:= cScreenWidth shr 1;
   222       CursorPoint.X:= cScreenWidth shr 1;
   222       CursorPoint.Y:= cScreenHeight shr 1;
   223       CursorPoint.Y:= cScreenHeight shr 1;
   223       prevPoint:= CursorPoint;
   224       prevPoint:= CursorPoint;
   224       SDL_WarpMouse(CursorPoint.X  + cScreenWidth div 2, cScreenHeight - CursorPoint.Y)
       
   225       end;
   225       end;
   226    if (cReducedQuality and rqSlowMenu) <> 0 then
   226    if (cReducedQuality and rqSlowMenu) <> 0 then
   227        AMxShift:= AMWidth
   227        AMxShift:= AMWidth
   228    else
   228    else
   229        if AMxShift < (AMWidth - MENUSPEED) then
   229        if AMxShift < (AMWidth - MENUSPEED) then
   250 x:= x - cOffsetY;
   250 x:= x - cOffsetY;
   251 y:= AMyOffset;
   251 y:= AMyOffset;
   252 dec(y, BORDERSIZE);
   252 dec(y, BORDERSIZE);
   253 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
   253 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
   254 for i:= 0 to cMaxSlotAmmoIndex do
   254 for i:= 0 to cMaxSlotAmmoIndex do
   255 	DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
   255     DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
   256 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
   256 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
   257 inc(y, BORDERSIZE);
   257 inc(y, BORDERSIZE);
   258 
   258 
   259 for i:= 0 to cMaxSlotIndex do
   259 for i:= 0 to cMaxSlotIndex do
   260     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   260     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   301 {$ELSE}
   301 {$ELSE}
   302 Slot:= 0;
   302 Slot:= 0;
   303 y:= cScreenHeight - AMyOffset;
   303 y:= cScreenHeight - AMyOffset;
   304 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   304 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   305 for i:= 0 to cMaxSlotAmmoIndex + 1 do
   305 for i:= 0 to cMaxSlotAmmoIndex + 1 do
   306 	DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
   306     DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
   307 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
   307 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
   308 dec(y, AMSlotSize);
   308 dec(y, AMSlotSize);
   309 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   309 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   310 for i:= 0 to cMaxSlotAmmoIndex do
   310 for i:= 0 to cMaxSlotAmmoIndex do
   311 	DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
   311     DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
   312 DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1);
   312 DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1);
   313 DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
   313 DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
   314 
   314 
   315 for i:= cMaxSlotIndex downto 0 do
   315 for i:= cMaxSlotIndex downto 0 do
   316     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   316     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   353         end;
   353         end;
   354 
   354 
   355 dec(y, BORDERSIZE);
   355 dec(y, BORDERSIZE);
   356 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
   356 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
   357 for i:= 0 to cMaxSlotAmmoIndex + 1 do
   357 for i:= 0 to cMaxSlotAmmoIndex + 1 do
   358 	DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
   358     DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
   359 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
   359 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
   360 {$ENDIF}
   360 {$ENDIF}
   361 
   361 
   362 if (Pos >= 0) then
   362 if (Pos >= 0) then
   363     begin
   363     begin
  1159 var EdgesDist, wdy, shs: LongInt;
  1159 var EdgesDist, wdy, shs: LongInt;
  1160     PrevSentPointTime: LongWord = 0;
  1160     PrevSentPointTime: LongWord = 0;
  1161 begin
  1161 begin
  1162 {$IFNDEF IPHONEOS}
  1162 {$IFNDEF IPHONEOS}
  1163 if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then
  1163 if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then
  1164 begin
  1164     uCursor.updatePosition();
  1165     SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
       
  1166     CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1);
       
  1167     CursorPoint.Y:= cScreenHeight - CursorPoint.Y;
       
  1168 end;
       
  1169 {$ENDIF}
  1165 {$ENDIF}
  1170 
  1166 
  1171 if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then
  1167 if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then
  1172     if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
  1168     if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
  1173     begin
  1169     begin
  1198     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
  1194     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
  1199     if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize;
  1195     if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize;
  1200     if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize;
  1196     if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize;
  1201 {$ENDIF}
  1197 {$ENDIF}
  1202     prevPoint:= CursorPoint;
  1198     prevPoint:= CursorPoint;
  1203     if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
  1199     //if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
  1204     exit
  1200     exit
  1205 end;
  1201 end;
  1206 
  1202 
  1207 if isCursorVisible then
  1203 if isCursorVisible then
  1208 begin
  1204 begin
  1253         CursorPoint.Y:= cScreenHeight div 2;
  1249         CursorPoint.Y:= cScreenHeight div 2;
  1254     end;
  1250     end;
  1255 
  1251 
  1256 // this moves the camera according to CursorPoint X and Y
  1252 // this moves the camera according to CursorPoint X and Y
  1257 prevPoint:= CursorPoint;
  1253 prevPoint:= CursorPoint;
  1258 if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y);
  1254 //if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y);
  1259 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
  1255 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
  1260 if WorldDy < wdy then WorldDy:= wdy;
  1256 if WorldDy < wdy then WorldDy:= wdy;
  1261 if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
  1257 if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
  1262 if WorldDx > 1024 then WorldDx:= 1024;
  1258 if WorldDx > 1024 then WorldDx:= 1024;
  1263 end;
  1259 end;