179 {$ENDIF} |
188 {$ENDIF} |
180 var x, y, i, t, l, g: LongInt; |
189 var x, y, i, t, l, g: LongInt; |
181 Slot, Pos: LongInt; |
190 Slot, Pos: LongInt; |
182 Ammo: PHHAmmo; |
191 Ammo: PHHAmmo; |
183 begin |
192 begin |
184 if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false; |
193 if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or |
185 if bShowAmmoMenu then |
194 ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then |
186 begin |
195 bShowAmmoMenu:= false; |
187 FollowGear:= nil; |
196 if bShowAmmoMenu then |
188 if AMxShift = MENUWIDTH then prevPoint.X:= 0; |
197 begin |
189 if cReducedQuality then |
198 FollowGear:= nil; |
190 AMxShift:= 0 |
199 if AMxShift = MENUWIDTH then |
191 else |
200 prevPoint.X:= 0; |
192 if AMxShift > 0 then dec(AMxShift, MENUSPEED); |
201 if cReducedQuality then |
193 end else |
202 AMxShift:= 0 |
194 begin |
203 else |
195 if AMxShift = 0 then |
204 if AMxShift > 0 then |
196 begin |
205 dec(AMxShift, MENUSPEED); |
197 CursorPoint.X:= cScreenWidth shr 1; |
206 end |
198 CursorPoint.Y:= cScreenHeight shr 1; |
207 else |
199 prevPoint:= CursorPoint; |
208 begin |
200 SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y) |
209 if AMxShift = 0 then |
201 end; |
210 begin |
202 if cReducedQuality then |
211 CursorPoint.X:= cScreenWidth shr 1; |
203 AMxShift:= MENUWIDTH |
212 CursorPoint.Y:= cScreenHeight shr 1; |
204 else |
213 prevPoint:= CursorPoint; |
205 if AMxShift < MENUWIDTH then inc(AMxShift, MENUSPEED); |
214 SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y) |
206 end; |
215 end; |
207 Ammo:= nil; |
216 if cReducedQuality then |
208 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then |
217 AMxShift:= MENUWIDTH |
209 Ammo:= CurrentHedgehog^.Ammo |
218 else |
210 else if (LocalAmmo <> -1) then |
219 if AMxShift < MENUWIDTH then |
211 Ammo:= GetAmmoByNum(LocalAmmo); |
220 inc(AMxShift, MENUSPEED); |
212 Slot:= 0; |
221 end; |
213 Pos:= -1; |
222 |
214 if Ammo = nil then |
223 Ammo:= nil; |
215 begin |
224 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and |
216 bShowAmmoMenu:= false; |
225 (CurrentHedgehog^.BotLevel = 0) then |
217 exit |
226 Ammo:= CurrentHedgehog^.Ammo |
218 end; |
227 else |
219 SlotsNum:= 0; |
228 if (LocalAmmo <> -1) then |
220 x:= (cScreenWidth shr 1) - MENUWIDTH + AMxShift; |
229 Ammo:= GetAmmoByNum(LocalAmmo); |
221 y:= cScreenHeight - 40; |
230 Slot:= 0; |
|
231 Pos:= -1; |
|
232 if Ammo = nil then |
|
233 begin |
|
234 bShowAmmoMenu:= false; |
|
235 exit |
|
236 end; |
|
237 SlotsNum:= 0; |
|
238 x:= (cScreenWidth shr 1) - MENUWIDTH + AMxShift; |
|
239 y:= cScreenHeight - 40; |
222 |
240 |
223 {$IFDEF IPHONEOS} |
241 {$IFDEF IPHONEOS} |
224 dec(y); |
242 dec(y); |
225 DrawSprite(sprAMBordersIPhone, x, y, 0); |
243 DrawSprite(sprAMBordersIPhone, x, y, 0); |
226 dec(y); |
244 dec(y); |
227 DrawSprite(sprAMBordersIPhone, x, y, 1); |
245 DrawSprite(sprAMBordersIPhone, x, y, 1); |
228 dec(y, 33); |
246 dec(y, 33); |
229 DrawSprite(sprAMSlotNameIPhone, x, y, 0); |
247 DrawSprite(sprAMSlotNameIPhone, x, y, 0); |
230 {$ELSE} |
248 {$ELSE} |
231 dec(y); |
249 dec(y); |
232 DrawSprite(sprAMBorders, x, y, 0); |
250 DrawSprite(sprAMBorders, x, y, 0); |
233 dec(y); |
251 dec(y); |
234 DrawSprite(sprAMBorders, x, y, 1); |
252 DrawSprite(sprAMBorders, x, y, 1); |
235 dec(y, 33); |
253 dec(y, 33); |
236 DrawSprite(sprAMSlotName, x, y, 0); |
254 DrawSprite(sprAMSlotName, x, y, 0); |
237 {$ENDIF} |
255 {$ENDIF} |
238 |
256 |
239 for i:= cMaxSlotIndex downto 0 do |
257 for i:= cMaxSlotIndex downto 0 do |
240 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
258 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
241 begin |
|
242 if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i; |
|
243 dec(y, 33); |
|
244 inc(SlotsNum); |
|
245 {$IFDEF IPHONEOS} |
|
246 DrawSprite(sprAMSlotIPhone, x, y, 0); |
|
247 {$ELSE} |
|
248 DrawSprite(sprAMSlot, x, y, 0); |
|
249 DrawSprite(sprAMSlotKeys, x + 2, y + 1, i); |
|
250 {$ENDIF} |
|
251 t:= 0; |
|
252 {$IFDEF IPHONEOS} |
|
253 g:= -1; |
|
254 {$ELSE} |
|
255 g:= 0; |
|
256 {$ENDIF} |
|
257 while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
|
258 begin |
259 begin |
259 if (Ammo^[i, t].AmmoType <> amNothing) then |
260 if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then |
|
261 Slot:= i; |
|
262 dec(y, 33); |
|
263 inc(SlotsNum); |
|
264 {$IFDEF IPHONEOS} |
|
265 DrawSprite(sprAMSlotIPhone, x, y, 0); |
|
266 g:= -1; |
|
267 {$ELSE} |
|
268 DrawSprite(sprAMSlot, x, y, 0); |
|
269 DrawSprite(sprAMSlotKeys, x + 2, y + 1, i); |
|
270 g:= 0; |
|
271 {$ENDIF} |
|
272 t:= 0; |
|
273 |
|
274 while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
260 begin |
275 begin |
261 l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
276 if (Ammo^[i, t].AmmoType <> amNothing) then |
262 |
|
263 if l >= 0 then |
|
264 begin |
277 begin |
265 DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
278 l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
266 if l < 100 then DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l); |
279 |
267 end else |
280 if l >= 0 then |
268 DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
281 begin |
269 if (Slot = i) |
282 DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
270 and (CursorPoint.X >= x + g * 33 + 35) |
283 if l < 100 then |
271 and (CursorPoint.X < x + g * 33 + 68) then |
284 DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l); |
272 begin |
285 end |
273 if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0); |
286 else |
274 Pos:= t; |
287 DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
|
288 if (Slot = i) and (CursorPoint.X >= x + g * 33 + 35) and (CursorPoint.X < x + g * 33 + 68) then |
|
289 begin |
|
290 if (l < 0) then |
|
291 DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0); |
|
292 Pos:= t; |
|
293 end; |
|
294 inc(g); |
275 end; |
295 end; |
276 inc(g) |
296 inc(t); |
277 end; |
297 end; |
278 inc(t) |
298 end; |
279 end |
299 dec(y, 1); |
280 end; |
|
281 dec(y, 1); |
|
282 {$IFDEF IPHONEOS} |
300 {$IFDEF IPHONEOS} |
283 DrawSprite(sprAMBordersIPhone, x, y, 0); |
301 DrawSprite(sprAMBordersIPhone, x, y, 0); |
284 {$ELSE} |
302 {$ELSE} |
285 DrawSprite(sprAMBorders, x, y, 0); |
303 DrawSprite(sprAMBorders, x, y, 0); |
286 {$ENDIF} |
304 {$ENDIF} |
287 |
305 |
288 if (Pos >= 0) then |
306 if (Pos >= 0) then |
289 begin |
307 begin |
290 if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then |
308 if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then |
291 if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then |
309 if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then |
292 begin |
310 begin |
293 amSel:= Ammo^[Slot, Pos].AmmoType; |
311 amSel:= Ammo^[Slot, Pos].AmmoType; |
294 RenderWeaponTooltip(amSel) |
312 RenderWeaponTooltip(amSel) |
295 end; |
313 end; |
296 |
314 |
297 DrawTexture(cScreenWidth div 2 - (MENUWIDTH - 10) + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
315 DrawTexture(cScreenWidth div 2 - (MENUWIDTH - 10) + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
298 |
316 |
299 if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
317 if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
300 DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]); |
318 DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]); |
301 |
319 |
302 if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then |
320 if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then |
303 begin |
321 begin |
304 bShowAmmoMenu:= false; |
322 bShowAmmoMenu:= false; |
305 SetWeapon(Ammo^[Slot, Pos].AmmoType); |
323 SetWeapon(Ammo^[Slot, Pos].AmmoType); |
306 bSelected:= false; |
324 bSelected:= false; |
307 FreeWeaponTooltip; |
325 FreeWeaponTooltip; |
308 exit |
326 exit(); |
309 end; |
327 end; |
310 end |
328 end |
311 else |
329 else |
312 FreeWeaponTooltip; |
330 FreeWeaponTooltip; |
313 |
331 |
314 if (WeaponTooltipTex <> nil) and (AMxShift = 0) then |
332 if (WeaponTooltipTex <> nil) and (AMxShift = 0) then |
315 ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, min(y, cScreenHeight - WeaponTooltipTex^.h - 40)); |
333 ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, min(y, cScreenHeight - WeaponTooltipTex^.h - 40)); |
316 |
334 |
317 bSelected:= false; |
335 bSelected:= false; |
318 if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
336 if AMxShift = 0 then |
|
337 DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
319 end; |
338 end; |
320 |
339 |
321 procedure MoveCamera; forward; |
340 procedure MoveCamera; forward; |
322 |
341 |
323 procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
342 procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
324 var VertexBuffer: array [0..3] of TVertex2f; |
343 var VertexBuffer: array [0..3] of TVertex2f; |
325 r: TSDL_Rect; |
344 r: TSDL_Rect; |
326 lw, lh: GLfloat; |
345 lw, lh: GLfloat; |
327 begin |
346 begin |
328 WaterColorArray[0].a := Alpha; |
347 WaterColorArray[0].a := Alpha; |
329 WaterColorArray[1].a := Alpha; |
348 WaterColorArray[1].a := Alpha; |
330 WaterColorArray[2].a := Alpha; |
349 WaterColorArray[2].a := Alpha; |
331 WaterColorArray[3].a := Alpha; |
350 WaterColorArray[3].a := Alpha; |
332 |
351 |
333 lw:= cScreenWidth / cScaleFactor; |
352 lw:= wScreen / cScaleFactor; |
334 lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; |
353 lh:= trunc(hScreen / cScaleFactor) + hScreen div 2 + 16; |
335 // Water |
354 |
336 r.y:= OffsetY + WorldDy + cWaterLine; |
355 // Water |
337 if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then |
356 r.y:= OffsetY + WorldDy + cWaterLine; |
338 begin |
357 if WorldDy < trunc(hScreen / cScaleFactor) + hScreen div 2 - cWaterLine then |
339 if r.y < 0 then r.y:= 0; |
358 begin |
340 |
359 if r.y < 0 then |
341 glDisable(GL_TEXTURE_2D); |
360 r.y:= 0; |
342 VertexBuffer[0].X:= -lw; |
361 |
343 VertexBuffer[0].Y:= r.y; |
362 glDisable(GL_TEXTURE_2D); |
344 VertexBuffer[1].X:= lw; |
363 VertexBuffer[0].X:= -lw; |
345 VertexBuffer[1].Y:= r.y; |
364 VertexBuffer[0].Y:= r.y; |
346 VertexBuffer[2].X:= lw; |
365 VertexBuffer[1].X:= lw; |
347 VertexBuffer[2].Y:= lh; |
366 VertexBuffer[1].Y:= r.y; |
348 VertexBuffer[3].X:= -lw; |
367 VertexBuffer[2].X:= lw; |
349 VertexBuffer[3].Y:= lh; |
368 VertexBuffer[2].Y:= lh; |
350 |
369 VertexBuffer[3].X:= -lw; |
351 glEnableClientState (GL_COLOR_ARRAY); |
370 VertexBuffer[3].Y:= lh; |
352 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); |
371 |
353 |
372 glEnableClientState (GL_COLOR_ARRAY); |
354 glEnableClientState(GL_VERTEX_ARRAY); |
373 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); |
355 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
374 |
356 |
375 glEnableClientState(GL_VERTEX_ARRAY); |
357 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
376 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
358 |
377 |
359 glDisableClientState(GL_VERTEX_ARRAY); |
378 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
360 glDisableClientState(GL_COLOR_ARRAY); |
379 |
361 |
380 glDisableClientState(GL_VERTEX_ARRAY); |
362 glColor4ub($FF, $FF, $FF, $FF); // disable coloring |
381 glDisableClientState(GL_COLOR_ARRAY); |
363 glEnable(GL_TEXTURE_2D) |
382 |
364 end |
383 Tint($FF, $FF, $FF, $FF); // disable coloring |
|
384 glEnable(GL_TEXTURE_2D); |
|
385 end; |
365 end; |
386 end; |
366 |
387 |
367 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte); |
388 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte); |
368 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
389 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
369 lw, waves, shift: GLfloat; |
390 lw, waves, shift: GLfloat; |
370 begin |
391 begin |
371 lw:= cScreenWidth / cScaleFactor; |
392 lw:= wScreen / cScaleFactor; |
372 waves:= lw * 2 / cWaveWidth; |
393 waves:= lw * 2 / cWaveWidth; |
373 |
394 |
374 Tint( |
395 Tint((tnt * WaterColorArray[2].r div 255) + (255-tnt), |
375 (tnt * WaterColorArray[2].r div 255) + (255-tnt) |
396 (tnt * WaterColorArray[2].g div 255) + (255-tnt), |
376 , (tnt * WaterColorArray[2].g div 255) + (255-tnt) |
397 (tnt * WaterColorArray[2].b div 255) + (255-tnt), |
377 , (tnt * WaterColorArray[2].b div 255) + (255-tnt) |
398 255 |
378 , 255 |
|
379 ); |
399 ); |
380 |
400 |
381 glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id); |
401 glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id); |
382 |
402 |
383 VertexBuffer[0].X:= -lw; |
403 VertexBuffer[0].X:= -lw; |