author  koda 
Sat, 03 Jul 2010 00:11:23 +0200  
changeset 3611  ed00aa2b339e 
parent 3594  aeca3d8f1b29 
child 3629  86212d2b116a 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
3236
4ab3917d7d44
Update (c) lines to 2010 as unc0rr requested  they all had varying values so I just took the first year mentioned, then tacked on 2010
nemo
parents:
3204
diff
changeset

3 
* Copyright (c) 20042010 Andrey Korotaev <unC0Rr@gmail.com> 
4  4 
* 
183  5 
* This program is free software; you can redistribute it and/or modify 
6 
* it under the terms of the GNU General Public License as published by 

7 
* the Free Software Foundation; version 2 of the License 

4  8 
* 
183  9 
* This program is distributed in the hope that it will be useful, 
10 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 

11 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12 
* GNU General Public License for more details. 

4  13 
* 
183  14 
* You should have received a copy of the GNU General Public License 
15 
* along with this program; if not, write to the Free Software 

16 
* Foundation, Inc., 59 Temple Place  Suite 330, Boston, MA 021111307, USA 

4  17 
*) 
18 

2630  19 
{$INCLUDE "options.inc"} 
20 

4  21 
unit uWorld; 
22 
interface 

2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

23 
uses SDLh, uGears, uConsts, uFloat, uRandom; 
2630  24 

4  25 

2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

26 
var FollowGear: PGear; 
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

27 
WindBarWidth: LongInt; 
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

28 
bShowAmmoMenu: boolean; 
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

29 
bSelected: boolean; 
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

30 
bShowFinger: boolean; 
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

31 
Frames: Longword; 
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

32 
WaterColor, DeepWaterColor: TSDL_Color; 
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

33 
WorldDx: LongInt; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

34 
WorldDy: LongInt; 
3248  35 
SkyOffset: LongInt; 
36 
HorizontOffset: LongInt; 

2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

37 
{$IFDEF COUNTTICKS} 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

38 
cntTicks: LongWord; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

39 
{$ENDIF} 
3463  40 
cOffsetY: LongInt; 
3405  41 

3038  42 
procedure initModule; 
43 
procedure freeModule; 

2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

44 

b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

45 
procedure InitWorld; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

46 
procedure DrawWorld(Lag: LongInt); 
2905  47 
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); 
48 
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); 

2786  49 
procedure HideMission; 
3032  50 
procedure ShakeCamera(amount: LongWord); 
4  51 

52 
implementation 

3407  53 
uses uStore, uMisc, uTeams, uIO, uKeys, uLocale, uSound, uAmmos, uVisualGears, uChat, uLandTexture, uLand, GLunit; 
1807  54 

4  55 
type TCaptionStr = record 
762  56 
Tex: PTexture; 
4  57 
EndTime: LongWord; 
58 
end; 

59 

2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

60 
var cWaveWidth, cWaveHeight: LongInt; 
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

61 
Captions: array[TCapGroup] of TCaptionStr; 
3434  62 
AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt; 
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

63 
tmpSurface: PSDL_Surface; 
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

64 
fpsTexture: PTexture; 
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

65 
timeTexture: PTexture; 
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

66 
FPS: Longword; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

67 
CountTicks: Longword; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

68 
SoundTimerTicks: Longword; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

69 
prevPoint: TPoint; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

70 
amSel: TAmmoType = amNothing; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

71 
missionTex: PTexture; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

72 
missionTimer: LongInt; 
4  73 

74 
procedure InitWorld; 

2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

75 
var i, t: LongInt; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

76 
cp: PClan; 
2863  77 
g: ansistring; 
78 

2904  79 
// helper functions to create the goal/game mode string 
2908  80 
function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; 
2905  81 
var t: ansistring; 
2904  82 
begin 
83 
if (GameFlags and gf) <> 0 then 

84 
begin 

85 
t:= inttostr(i); 

86 
s:= s + format(trgoal[si], t) + '' 

87 
end; 

88 
AddGoal:= s; 

89 
end; 

90 

2908  91 
function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring; 
2863  92 
begin 
2904  93 
if (GameFlags and gf) <> 0 then 
94 
s:= s + trgoal[si] + ''; 

2863  95 
AddGoal:= s; 
96 
end; 

4  97 
begin 
3405  98 
missionTimer:= 0; 
2786  99 

2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

100 
if (GameFlags and gfRandomOrder) <> 0 then // shuffle them up a bit 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

101 
begin 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

102 
for i:= 0 to ClansCount * 4 do 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

103 
begin 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

104 
t:= GetRandom(ClansCount); 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

105 
if t <> 0 then 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

106 
begin 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

107 
cp:= ClansArray[0]; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

108 
ClansArray[0]:= ClansArray[t]; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

109 
ClansArray[t]:= cp; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

110 
ClansArray[t]^.ClanIndex:= t; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

111 
ClansArray[0]^.ClanIndex:= 0; 
2856
cc70797a0b75
Adjust LocalClan when shuffling, set to 1 in case all local clans are bots.
nemo
parents:
2855
diff
changeset

112 
if (LocalClan = t) then LocalClan:= 0 
cc70797a0b75
Adjust LocalClan when shuffling, set to 1 in case all local clans are bots.
nemo
parents:
2855
diff
changeset

113 
else if (LocalClan = 0) then LocalClan:= t 
2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

114 
end; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

115 
end; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

116 
CurrentTeam:= ClansArray[0]^.Teams[0]; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

117 
end; 
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset

118 

2908  119 
// if special game flags/settings are changed, add them to the game mode notice window and then show it 
2863  120 
g:= ''; // no text/things to note yet 
2908  121 

2958  122 
// check different game flags (goals/game modes first for now) 
123 
g:= AddGoal(g, gfKing, gidKing); // king? 

124 

125 
// other important flags 

126 
g:= AddGoal(g, gfForts, gidForts); // forts? 

127 
g:= AddGoal(g, gfLowGravity, gidLowGravity); // low gravity? 

128 
g:= AddGoal(g, gfInvulnerable, gidInvulnerable); // invulnerability? 

129 
g:= AddGoal(g, gfVampiric, gidVampiric); // vampirism? 

130 
g:= AddGoal(g, gfKarma, gidKarma); // karma? 

131 
g:= AddGoal(g, gfPlaceHog, gidPlaceHog); // placement? 

132 
g:= AddGoal(g, gfArtillery, gidArtillery); // artillery? 

133 
g:= AddGoal(g, gfSolidLand, gidSolidLand); // solid land? 

134 
g:= AddGoal(g, gfSharedAmmo, gidSharedAmmo); // shared ammo? 

135 

2908  136 
// modified damage modificator? 
137 
if cDamagePercent <> 100 then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

138 
g:= AddGoal(g, gfAny, gidDamageModifier, cDamagePercent); 
2908  139 

3107  140 
// fade in 
141 
ScreenFade:= sfFromBlack; 

142 
ScreenFadeValue:= sfMax; 

143 
ScreenFadeSpeed:= 1; 

144 

2908  145 
// modified mine timers? 
146 
if cMinesTime <> 3000 then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

147 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

148 
if cMinesTime = 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

149 
g:= AddGoal(g, gfMines, gidNoMineTimer) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

150 
else if cMinesTime < 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

151 
g:= AddGoal(g, gfMines, gidRandomMineTimer) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

152 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

153 
g:= AddGoal(g, gfMines, gidMineTimer, cMinesTime div 1000); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

154 
end; 
2908  155 

2863  156 
// if the string has been set, show it for (default timeframe) seconds 
157 
if g <> '' then ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], g, 1, 0); 

158 

1825  159 
cWaveWidth:= SpritesData[sprWater].Width; 
2268
053eb81e60ee
little experiment to see if this improve appearance of laser/ufo/cake/laser guided missile  of course, can't actually see it until unc0rr restores waves
nemo
parents:
2226
diff
changeset

160 
//cWaveHeight:= SpritesData[sprWater].Height; 
053eb81e60ee
little experiment to see if this improve appearance of laser/ufo/cake/laser guided missile  of course, can't actually see it until unc0rr restores waves
nemo
parents:
2226
diff
changeset

161 
cWaveHeight:= 32; 
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

162 

284  163 
cGearScrEdgesDist:= Min(cScreenWidth div 2  100, cScreenHeight div 2  50); 
74  164 
SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); 
2197  165 
prevPoint.X:= 0; 
74  166 
prevPoint.Y:= cScreenHeight div 2; 
1760  167 
WorldDx:=  (LAND_WIDTH div 2) + cScreenWidth div 2; 
2139
5a083e71a71d
Properly decrement sniper rifle if timed out. Try to get camera position straight for once.
nemo
parents:
2119
diff
changeset

168 
WorldDy:=  (LAND_HEIGHT  (playHeight div 2)) + (cScreenHeight div 2); 
3434  169 
AMSlotSize:= 33; 
170 
{$IFDEF IPHONEOS} 

171 
AMxOffset:= 10; 

3464  172 
AMyOffset:= 10 + 123; // moved downwards 
3434  173 
AMWidth:= (cMaxSlotAmmoIndex + 1) * AMSlotSize + AMxOffset; 
174 
{$ELSE} 

175 
AMxOffset:= 10; 

176 
AMyOffset:= 60; 

177 
AMWidth:= (cMaxSlotAmmoIndex + 2) * AMSlotSize + AMxOffset; 

178 
{$ENDIF} 

179 
AMxShift:= AMWidth; 

3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

180 
SkyOffset:= 0; 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

181 
HorizontOffset:= 0; 
161  182 
end; 
183 

3405  184 

956  185 
procedure ShowAmmoMenu; 
161  186 
const MENUSPEED = 15; 
3434  187 
const BORDERSIZE = 2; 
188 
var x, y, i, t, g: LongInt; 

189 
Slot, Pos, STurns: LongInt; 

2855
7e6adeb57427
Show the ammo menu of the last local nonbot team when not local turn. needs testing
nemo
parents:
2851
diff
changeset

190 
Ammo: PHHAmmo; 
161  191 
begin 
3434  192 
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 bShowAmmoMenu then 

194 
begin 

195 
FollowGear:= nil; 

196 
if AMxShift = AMWidth then prevPoint.X:= 0; 

3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

197 
if (cReducedQuality and rqSlowMenu) <> 0 then 
3434  198 
AMxShift:= 0 
199 
else 

200 
if AMxShift > MENUSPEED then 

201 
dec(AMxShift, MENUSPEED) 

202 
else 

203 
AMxShift:= 0; 

204 
end else 

205 
begin 

206 
if AMxShift = 0 then 

207 
begin 

208 
CursorPoint.X:= cScreenWidth shr 1; 

209 
CursorPoint.Y:= cScreenHeight shr 1; 

210 
prevPoint:= CursorPoint; 

211 
SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight  CursorPoint.Y) 

212 
end; 

3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

213 
if (cReducedQuality and rqSlowMenu) <> 0 then 
3434  214 
AMxShift:= AMWidth 
215 
else 

216 
if AMxShift < (AMWidth  MENUSPEED) then 

217 
inc(AMxShift, MENUSPEED) 

218 
else 

219 
AMxShift:= AMWidth; 

220 
end; 

221 
Ammo:= nil; 

222 
if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then 

223 
Ammo:= CurrentHedgehog^.Ammo 

224 
else if (LocalAmmo <> 1) then 

225 
Ammo:= GetAmmoByNum(LocalAmmo); 

226 
Pos:= 1; 

227 
if Ammo = nil then 

2971  228 
begin 
3434  229 
bShowAmmoMenu:= false; 
230 
exit 

2971  231 
end; 
3434  232 
SlotsNum:= 0; 
233 
x:= (cScreenWidth shr 1)  AMWidth + AMxShift; 

3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

234 

095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

235 
{$IFDEF IPHONEOS} 
3434  236 
Slot:= cMaxSlotIndex; 
3463  237 
x:= x  cOffsetY; 
3464  238 
y:= AMyOffset; 
3434  239 
dec(y, BORDERSIZE); 
240 
DrawSprite(sprAMCorners, x  BORDERSIZE, y, 0); 

241 
for i:= 0 to cMaxSlotAmmoIndex do 

242 
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); 

243 
DrawSprite(sprAMCorners, x + AMWidth  AMxOffset, y, 1); 

244 
inc(y, BORDERSIZE); 

245 

246 
for i:= 0 to cMaxSlotIndex do 

247 
if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then 

248 
begin 

249 
if (cScreenHeight  CursorPoint.Y >= y) and (cScreenHeight  CursorPoint.Y < y + AMSlotSize) then Slot:= i; 

250 
inc(SlotsNum); 

251 
DrawSprite(sprAMBorderVertical, x  BORDERSIZE, y, 0); 

252 
t:= 0; 

253 
g:= 0; 

254 
while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do 

255 
begin 

256 
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); 

257 
if (Ammo^[i, t].AmmoType <> amNothing) then 

258 
begin 

259 
STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns  CurrentTeam^.Clan^.TurnNumber; 

260 

261 
if STurns >= 0 then 

262 
begin 

263 
DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)1); 

264 
if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize  16, y + AMSlotSize  16, STurns); 

265 
end else 

266 
DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)1); 

267 
if (Slot = i) 

268 
and (CursorPoint.X >= x + g * AMSlotSize) 

269 
and (CursorPoint.X < x + (g + 1) * AMSlotSize) then 

270 
begin 

271 
if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); 

272 
Pos:= t; 

273 
end; 

274 
inc(g) 

275 
end; 

276 
inc(t) 

277 
end; 

278 
for g:= g to cMaxSlotAmmoIndex do 

279 
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); 

280 
DrawSprite(sprAMBorderVertical, x + AMWidth  AMxOffset, y, 1); 

281 
inc(y, AMSlotSize); 

282 
end; 

283 

284 
DrawSprite(sprAMCorners, x  BORDERSIZE, y, 2); 

285 
for i:= 0 to cMaxSlotAmmoIndex do 

286 
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); 

287 
DrawSprite(sprAMCorners, x + AMWidth  AMxOffset, y, 3); 

3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

288 
{$ELSE} 
3434  289 
Slot:= 0; 
290 
y:= cScreenHeight  AMyOffset; 

291 
DrawSprite(sprAMCorners, x  BORDERSIZE, y, 2); 

292 
for i:= 0 to cMaxSlotAmmoIndex + 1 do 

293 
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); 

294 
DrawSprite(sprAMCorners, x + AMWidth  AMxOffset, y, 3); 

295 
dec(y, AMSlotSize); 

296 
DrawSprite(sprAMBorderVertical, x  BORDERSIZE, y, 0); 

297 
for i:= 0 to cMaxSlotAmmoIndex do 

298 
DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2); 

299 
DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1); 

300 
DrawSprite(sprAMBorderVertical, x + AMWidth  AMxOffset, y, 1); 

301 

302 
for i:= cMaxSlotIndex downto 0 do 

303 
if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then 

304 
begin 

305 
if (cScreenHeight  CursorPoint.Y >= y  AMSlotSize) and (cScreenHeight  CursorPoint.Y < y) then Slot:= i; 

306 
dec(y, AMSlotSize); 

307 
inc(SlotsNum); 

308 
DrawSprite(sprAMBorderVertical, x  BORDERSIZE, y, 0); 

309 
DrawSprite(sprAMSlot, x, y, 1); 

310 
DrawSprite(sprAMSlotKeys, x, y + 1, i); 

311 
t:= 0; 

312 
g:= 1; 

313 
while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do 

314 
begin 

315 
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); 

316 
if (Ammo^[i, t].AmmoType <> amNothing) then 

317 
begin 

318 
STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns  CurrentTeam^.Clan^.TurnNumber; 

319 

320 
if STurns >= 0 then 

321 
begin 

322 
DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)1); 

323 
if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize  16, y + AMSlotSize  16, STurns); 

324 
end else 

325 
DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)1); 

326 
if (Slot = i) 

327 
and (CursorPoint.X >= x + g * AMSlotSize) 

328 
and (CursorPoint.X < x + (g + 1) * AMSlotSize) then 

329 
begin 

330 
if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); 

331 
Pos:= t; 

332 
end; 

333 
inc(g) 

334 
end; 

335 
inc(t) 

336 
end; 

337 
for g:= g to cMaxSlotAmmoIndex + 1 do 

338 
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); 

339 
DrawSprite(sprAMBorderVertical, x + AMWidth  AMxOffset, y, 1); 

340 
end; 

341 

342 
dec(y, BORDERSIZE); 

343 
DrawSprite(sprAMCorners, x  BORDERSIZE, y, 0); 

344 
for i:= 0 to cMaxSlotAmmoIndex + 1 do 

345 
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); 

346 
DrawSprite(sprAMCorners, x + AMWidth  AMxOffset, y, 1); 

3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

347 
{$ENDIF} 
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

348 

3434  349 
if (Pos >= 0) then 
350 
begin 

351 
if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then 

352 
if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

353 
begin 
3434  354 
amSel:= Ammo^[Slot, Pos].AmmoType; 
355 
RenderWeaponTooltip(amSel) 

356 
end; 

357 

358 
{$IFNDEF IPHONEOS} 

359 
DrawTexture(cScreenWidth div 2  (AMWidth  10) + AMxShift, cScreenHeight  AMyOffset  25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); 

3405  360 

3434  361 
if Ammo^[Slot, Pos].Count < AMMO_INFINITE then 
362 
DrawTexture(cScreenWidth div 2 + AMxOffset  45, cScreenHeight  AMyOffset  25, CountTexz[Ammo^[Slot, Pos].Count]); 

363 
{$ENDIF} 

1529
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset

364 

3434  365 
if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns  CurrentTeam^.Clan^.TurnNumber < 0) then 
366 
begin 

367 
bShowAmmoMenu:= false; 

368 
SetWeapon(Ammo^[Slot, Pos].AmmoType); 

369 
bSelected:= false; 

370 
FreeWeaponTooltip; 

371 
exit 

3405  372 
end; 
3434  373 
end 
374 
else 

375 
FreeWeaponTooltip; 

3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

376 
{$IFDEF IPHONEOS} 
3434  377 
if (WeaponTooltipTex <> nil) and (AMxShift = 0) then 
378 
ShowWeaponTooltip(x  WeaponTooltipTex^.w  3, AMyOffset  1); 

3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

379 
{$ELSE} 
3434  380 
if (WeaponTooltipTex <> nil) and (AMxShift = 0) then 
381 
ShowWeaponTooltip(x  WeaponTooltipTex^.w  3, min(y + 1, cScreenHeight  WeaponTooltipTex^.h  40)); 

3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset

382 
{$ENDIF} 
961
a9a349b2b3fa
Use turnsleft sprites to indicate turns left to activate ammo
unc0rr
parents:
956
diff
changeset

383 

3434  384 
bSelected:= false; 
385 
if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight  CursorPoint.Y, (RealTicks shr 6) mod 8) 

4  386 
end; 
387 

162  388 
procedure MoveCamera; forward; 
389 

3104  390 
procedure DrawWater(Alpha: byte; OffsetY: LongInt); 
1915  391 
var VertexBuffer: array [0..3] of TVertex2f; 
392 
r: TSDL_Rect; 

2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

393 
lw, lh: GLfloat; 
1915  394 
begin 
3405  395 
WaterColorArray[0].a := Alpha; 
396 
WaterColorArray[1].a := Alpha; 

397 
WaterColorArray[2].a := Alpha; 

398 
WaterColorArray[3].a := Alpha; 

2269
00f5704f5f39
add extra semiopaque layer of water to discolour objects in the water.
nemo
parents:
2268
diff
changeset

399 

3463  400 
lw:= cScreenWidth / cScaleFactor; 
401 
lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; 

3405  402 

403 
// Water 

404 
r.y:= OffsetY + WorldDy + cWaterLine; 

3463  405 
if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2  cWaterLine then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

406 
begin 
3405  407 
if r.y < 0 then 
408 
r.y:= 0; 

1915  409 

3405  410 
glDisable(GL_TEXTURE_2D); 
411 
VertexBuffer[0].X:= lw; 

412 
VertexBuffer[0].Y:= r.y; 

413 
VertexBuffer[1].X:= lw; 

414 
VertexBuffer[1].Y:= r.y; 

415 
VertexBuffer[2].X:= lw; 

416 
VertexBuffer[2].Y:= lh; 

417 
VertexBuffer[3].X:= lw; 

418 
VertexBuffer[3].Y:= lh; 

1915  419 

3405  420 
glEnableClientState (GL_COLOR_ARRAY); 
421 
glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); 

1915  422 

3405  423 
glEnableClientState(GL_VERTEX_ARRAY); 
424 
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); 

2171
8208946331ba
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents:
2162
diff
changeset

425 

3405  426 
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); 
1915  427 

3405  428 
glDisableClientState(GL_VERTEX_ARRAY); 
429 
glDisableClientState(GL_COLOR_ARRAY); 

1915  430 

3407  431 
glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required 
3405  432 
glEnable(GL_TEXTURE_2D); 
433 
end; 

1915  434 
end; 
435 

3376  436 
procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte); 
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

437 
var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

438 
lw, waves, shift: GLfloat; 
2288  439 
begin 
3463  440 
lw:= cScreenWidth / cScaleFactor; 
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

441 
waves:= lw * 2 / cWaveWidth; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

442 

3407  443 
Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255  tnt, 
444 
LongInt(tnt) * WaterColorArray[2].g div 255 + 255  tnt, 

445 
LongInt(tnt) * WaterColorArray[2].b div 255 + 255  tnt, 

446 
255 

3089  447 
); 
448 

2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

449 
glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id); 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

450 

87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

451 
VertexBuffer[0].X:= lw; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

452 
VertexBuffer[0].Y:= cWaterLine + WorldDy + dY; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

453 
VertexBuffer[1].X:= lw; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

454 
VertexBuffer[1].Y:= VertexBuffer[0].Y; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

455 
VertexBuffer[2].X:= lw; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

456 
VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprWater].Height; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

457 
VertexBuffer[3].X:= lw; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

458 
VertexBuffer[3].Y:= VertexBuffer[2].Y; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

459 

2374  460 
shift:=  lw / cWaveWidth; 
2495  461 
TextureBuffer[0].X:= shift + ((  WorldDx + LongInt(RealTicks shr 6) * Dir + dX) mod cWaveWidth) / (cWaveWidth  1); 
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

462 
TextureBuffer[0].Y:= 0; 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

463 
TextureBuffer[1].X:= TextureBuffer[0].X + waves; 
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2434
diff
changeset

464 
TextureBuffer[1].Y:= TextureBuffer[0].Y; 
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2434
diff
changeset

465 
TextureBuffer[2].X:= TextureBuffer[1].X; 
2553  466 
TextureBuffer[2].Y:= SpritesData[sprWater].Texture^.ry; 
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

467 
TextureBuffer[3].X:= TextureBuffer[0].X; 
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2434
diff
changeset

468 
TextureBuffer[3].Y:= TextureBuffer[2].Y; 
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

469 

87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

470 
glEnableClientState(GL_VERTEX_ARRAY); 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

471 
glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

472 

87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

473 
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

474 
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

475 
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

476 

87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

477 
glDisableClientState(GL_TEXTURE_COORD_ARRAY); 
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

478 
glDisableClientState(GL_VERTEX_ARRAY); 
3390  479 
Tint($FF, $FF, $FF, $FF); 
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

480 

87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset

481 
{for i:= 1 to cWaterSprCount do 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

482 
DrawSprite(sprWater, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

483 
i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth)  (cScreenWidth div 2), 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

484 
cWaterLine + WorldDy + dY, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

485 
0)} 
2288  486 
end; 
487 

3089  488 
procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt); 
3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

489 
var i, w, h, lw, lh, rw, rh, sw: LongInt; 
2426  490 
begin 
3405  491 
sw:= round(cScreenWidth / cScaleFactor); 
492 
if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

493 
begin 
3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

494 
w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

495 
h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; 
3405  496 
i:= Shift mod w; 
497 
if i > 0 then dec(i, w); 

498 
dec(i, w * (sw div w + 1)); 

499 
repeat 

3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

500 
DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY  h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); 
3405  501 
inc(i, w) 
502 
until i > sw 

503 
end 

504 
else 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

505 
begin 
3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

506 
w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

507 
h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

508 
lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale; 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

509 
lh:= SpritesData[sprL].Height * SpritesData[spr].Texture^.Scale; 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

510 
rw:= SpritesData[sprR].Width * SpritesData[spr].Texture^.Scale; 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

511 
rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale; 
3405  512 
dec(Shift, w div 2); 
3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

513 
DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY  h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

514 

3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

515 
i:= Shift  lw; 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

516 
while i >= sw  lw do 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

517 
begin 
3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

518 
DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY  lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale); 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

519 
dec(i, lw); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

520 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

521 

3405  522 
i:= Shift + w; 
523 
while i <= sw do 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

524 
begin 
3537
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

525 
DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY  rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale); 
8f5b3108f29c
New approach to the lowres problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset

526 
inc(i, rw) 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

527 
end 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

528 
end 
2426  529 
end; 
530 

531 

956  532 
procedure DrawWorld(Lag: LongInt); 
371  533 
var i, t: LongInt; 
4  534 
r: TSDL_Rect; 
107  535 
tdx, tdy: Double; 
175  536 
grp: TCapGroup; 
174  537 
s: string[15]; 
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset

538 
highlight: Boolean; 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

539 
offset, offsetX, offsetY, ScreenBottom: LongInt; 
3113  540 
VertexBuffer: array [0..3] of TVertex2f; 
4  541 
begin 
3523  542 
if not isPaused then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

543 
begin 
3523  544 
if ZoomValue < zoom then 
3444  545 
begin 
3523  546 
zoom:= zoom  0.002 * Lag; 
547 
if ZoomValue > zoom then 

548 
zoom:= ZoomValue 

549 
end 

550 
else 

551 
if ZoomValue > zoom then 

3444  552 
begin 
3523  553 
zoom:= zoom + 0.002 * Lag; 
554 
if ZoomValue < zoom then 

555 
zoom:= ZoomValue 

3611  556 
end 
3444  557 
end 
3611  558 
else 
559 
ZoomValue:= zoom; 

2376  560 

3611  561 
// Sky 
562 
glClear(GL_COLOR_BUFFER_BIT); 

563 
//glPushMatrix; 

564 
//glScalef(1.0, 1.0, 1.0); 

756  565 

3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

566 
if not isPaused then 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

567 
MoveCamera; 
162  568 

3611  569 
if (cReducedQuality and rqNoBackground) = 0 then 
1812  570 
begin 
3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

571 
// Offsets relative to camera  spare them to wimpier cpus, no bg or flakes for them anyway 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

572 
ScreenBottom:= (WorldDy  trunc(cScreenHeight/cScaleFactor)  (cScreenHeight div 2) + cWaterLine); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

573 
offsetY:= 10 * min(0, 145  ScreenBottom); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

574 
SkyOffset:= offsetY div 35 + cWaveHeight; 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

575 
HorizontOffset:= SkyOffset; 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

576 
if ScreenBottom > SkyOffset then 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

577 
HorizontOffset:= HorizontOffset + ((ScreenBottomSkyOffset) div 20); 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

578 

3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

579 
// background 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

580 
DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

581 
DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset); 
3611  582 
end; 
4  583 

3611  584 
DrawVisualGears(0); 
585 

586 
if (cReducedQuality and rq2DWater) = 0 then 

587 
begin 

3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

588 
// Waves 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

589 
DrawWater(255, SkyOffset); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

590 
DrawWaves( 1, 0  WorldDx div 32,  cWaveHeight + offsetY div 35, 64); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

591 
DrawWaves( 1, 25 + WorldDx div 25,  cWaveHeight + offsetY div 38, 48); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

592 
DrawWaves( 1, 75  WorldDx div 19,  cWaveHeight + offsetY div 45, 32); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

593 
DrawWaves(1, 100 + WorldDx div 14,  cWaveHeight + offsetY div 70, 24); 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

594 
end 
3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

595 
else 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

596 
DrawWaves(1, 100,  (cWaveHeight + (cWaveHeight shr 1)), 0); 
4  597 

3611  598 
DrawLand(WorldDx, WorldDy); 
1911  599 

3611  600 
DrawWater(255, 0); 
4  601 

1660  602 
// Attack bar 
3611  603 
if CurrentTeam <> nil then 
604 
case AttackBar of 

1660  605 
(* 1: begin 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

606 
r:= StuffPoz[sPowerBar]; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

607 
{$WARNINGS OFF} 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

608 
r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

609 
{$WARNINGS ON} 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

610 
DrawSpriteFromRect(r, cScreenWidth  272, cScreenHeight  48, 16, 0, Surface); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

611 
end;*) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

612 
2: with CurrentHedgehog^ do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

613 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

614 
tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

615 
tdy:=  Cos(Gear^.Angle * Pi / cMaxAngle); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

616 
for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

617 
DrawSprite(sprPower, 
3580  618 
hwRound(Gear^.X) + GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Gear^.dX), Gear^.Angle) + round(WorldDx + tdx * (24 + i * 2))  16, 
619 
hwRound(Gear^.Y) + GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Gear^.Angle) + round(WorldDy + tdy * (24 + i * 2))  16, 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

620 
i) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

621 
end 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

622 
end; 
1660  623 

3611  624 
DrawVisualGears(1); 
2713  625 

3611  626 
DrawGears; 
4  627 

3611  628 
DrawVisualGears(2); 
1045  629 

3611  630 
DrawWater(cWaterOpacity, 0); 
2269
00f5704f5f39
add extra semiopaque layer of water to discolour objects in the water.
nemo
parents:
2268
diff
changeset

631 

3611  632 
// Waves 
633 
DrawWaves( 1, 25  WorldDx div 9,  cWaveHeight, 12); 

3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

634 

3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

635 
if (cReducedQuality and rq2DWater) = 0 then 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

636 
begin 
3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

637 
//DrawWater(cWaterOpacity,  offsetY div 40); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

638 
DrawWaves(1, 50 + WorldDx div 6,  cWaveHeight  offsetY div 40, 8); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

639 
DrawWater(cWaterOpacity,  offsetY div 20); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

640 
DrawWaves( 1, 75  WorldDx div 4,  cWaveHeight  offsetY div 20, 2); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

641 
DrawWater(cWaterOpacity,  offsetY div 10); 
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3582
diff
changeset

642 
DrawWaves( 1, 25 + WorldDx div 3,  cWaveHeight  offsetY div 10, 0); 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

643 
end 
3611  644 
else 
645 
DrawWaves(1, 50,  (cWaveHeight shr 1), 0); 

2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

646 

0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

647 

2288  648 
{$WARNINGS OFF} 
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

649 
// Target 
3104  650 
if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then 
651 
begin 

652 
with PHedgehog(CurrentHedgehog)^ do 

653 
begin 

3110  654 
if (Ammo^[CurSlot, CurAmmo].AmmoType = amBee) then 
655 
DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) 

656 
else 

3104  657 
DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360); 
658 
end; 

659 
end; 

4  660 
{$WARNINGS ON} 
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

661 

3523  662 
// this scale is used to keep the various widgets at the same dimension at all zoom levels 
663 
SetScale(cDefaultZoomLevel); 

2724  664 

665 

666 
// Turn time 

2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset

667 
{$IFDEF IPHONEOS} 
3025  668 
offsetX:= cScreenHeight  13; 
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset

669 
{$ELSE} 
3025  670 
offsetX:= 48; 
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset

671 
{$ENDIF} 
3463  672 
offsetY:= cOffsetY; 
4  673 
if TurnTimeLeft <> 0 then 
674 
begin 

675 
i:= Succ(Pred(TurnTimeLeft) div 1000); 

676 
if i>99 then t:= 112 

677 
else if i>9 then t:= 96 

678 
else t:= 80; 

3463  679 
DrawSprite(sprFrame, (cScreenWidth shr 1) + t + offsetY, cScreenHeight  offsetX, 1); 
4  680 
while i > 0 do 
681 
begin 

682 
dec(t, 32); 

3463  683 
DrawSprite(sprBigDigit, (cScreenWidth shr 1) + t + offsetY, cScreenHeight  offsetX, i mod 10); 
4  684 
i:= i div 10 
685 
end; 

3463  686 
DrawSprite(sprFrame, (cScreenWidth shr 1) + t  4 + offsetY, cScreenHeight  offsetX, 0); 
4  687 
end; 
79  688 

2567  689 
{$IFNDEF IPHONEOS} 
2428  690 
// Timetrial 
691 
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

692 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

693 
if TimeTrialStopTime = 0 then i:= RealTicks  TimeTrialStartTime else i:= TimeTrialStopTime  TimeTrialStartTime; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

694 
t:= 272; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

695 
// right frame 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

696 
DrawSprite(sprFrame, cScreenWidth div 2 + t, 8, 1); 
2428  697 
dec(t, 32); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

698 
// 1 ms 
2428  699 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
700 
dec(t, 32); 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

701 
i:= i div 10; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

702 
// 10 ms 
2428  703 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
704 
dec(t, 32); 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

705 
i:= i div 10; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

706 
// 100 ms 
2428  707 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

708 
dec(t, 16); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

709 
// Point 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

710 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, 11); 
2428  711 
dec(t, 32); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

712 
i:= i div 10; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

713 
// 1 s 
2428  714 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
715 
dec(t, 32); 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

716 
i:= i div 10; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

717 
// 10s 
2428  718 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 6); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

719 
dec(t, 16); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

720 
// Point 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

721 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, 10); 
2428  722 
dec(t, 32); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

723 
i:= i div 6; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

724 
// 1 m 
2428  725 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
726 
dec(t, 32); 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

727 
i:= i div 10; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

728 
// 10 m 
2428  729 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

730 
// left frame 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

731 
DrawSprite(sprFrame, cScreenWidth div 2 + t  4, 8, 0); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

732 
end; 
2567  733 
{$ENDIF} 
734 

4  735 
// Captions 
2567  736 
{$IFDEF IPHONEOS} 
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset

737 
offset:= 40; 
2567  738 
{$ELSE} 
2724  739 
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48 
740 
else offset:= 8; 

2567  741 
{$ENDIF} 
2428  742 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

743 
for grp:= Low(TCapGroup) to High(TCapGroup) do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

744 
with Captions[grp] do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

745 
if Tex <> nil then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

746 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

747 
DrawCentered(0, offset, Tex); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

748 
inc(offset, Tex^.h + 2); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

749 
if EndTime <= RealTicks then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

750 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

751 
FreeTexture(Tex); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

752 
Tex:= nil; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

753 
EndTime:= 0 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

754 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

755 
end; 
4  756 

47  757 
// Teams Healths 
547  758 
for t:= 0 to Pred(TeamsCount) do 
759 
with TeamsArray[t]^ do 

47  760 
begin 
2839  761 
highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); 
762 

2747  763 
if highlight then 
3445  764 
Tint(Clan^.Color); 
2839  765 

766 
// draw name 

767 
DrawTexture(NameTagTex^.w  16, cScreenHeight + DrawHealthY, NameTagTex); 

768 

769 
// draw flag 

770 
DrawTexture(14, cScreenHeight + DrawHealthY, FlagTex); 

771 

772 
// draw health bar 

690  773 
r.x:= 0; 
774 
r.y:= 0; 

547  775 
r.w:= 2 + TeamHealthBarWidth; 
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset

776 
r.h:= HealthTex^.h; 
2747  777 
DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex); 
690  778 

2839  779 
// draw health bar's right border 
83  780 
inc(r.x, cTeamHealthWidth + 2); 
781 
r.w:= 3; 

2839  782 
DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex); 
783 
// if highlighted, draw flag and other contents again to keep their colors 

784 
// this approach should be faster than drawing all borders one by one tinted or not 

785 
if highlight then 

786 
begin 

3390  787 
Tint($FF, $FF, $FF, $FF); 
690  788 

2839  789 
// draw name 
2747  790 
r.x:= 2; 
791 
r.y:= 2; 

2839  792 
r.w:= NameTagTex^.w  4; 
793 
r.h:= NameTagTex^.h  4; 

794 
DrawFromRect(NameTagTex^.w  14, cScreenHeight + DrawHealthY + 2, @r, NameTagTex); 

795 
// draw flag 

2747  796 
r.w:= 22; 
797 
r.h:= 15; 

798 
DrawFromRect(12, cScreenHeight + DrawHealthY + 2, @r, FlagTex); 

2839  799 
// draw health bar 
800 
r.w:= TeamHealthBarWidth + 1; 

801 
r.h:= HealthTex^.h  4; 

802 
DrawFromRect(16, cScreenHeight + DrawHealthY + 2, @r, HealthTex); 

2747  803 
end; 
47  804 
end; 
805 

5  806 
// Lag alert 
2567  807 
if isInLag then DrawSprite(sprLag, 32  (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12); 
4  808 

5  809 
// Wind bar 
2567  810 
{$IFDEF IPHONEOS} 
3405  811 
offsetX:= cScreenHeight  13; 
812 
offsetY:= (cScreenWidth shr 1) + 74; 

2567  813 
{$ELSE} 
3405  814 
offsetX:= 30; 
815 
offsetY:= 180; 

2567  816 
{$ENDIF} 
3405  817 
DrawSprite(sprWindBar, (cScreenWidth shr 1)  offsetY, cScreenHeight  offsetX, 0); 
818 
if WindBarWidth > 0 then 

819 
begin 

820 
{$WARNINGS OFF} 

821 
r.x:= 8  (RealTicks shr 6) mod 8; 

822 
{$WARNINGS ON} 

823 
r.y:= 0; 

824 
r.w:= WindBarWidth; 

825 
r.h:= 13; 

826 
DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1)  offsetY + 77, cScreenHeight  offsetX + 2, 13, 0); 

827 
end 

828 
else 

829 
if WindBarWidth < 0 then 

830 
begin 

831 
{$WARNINGS OFF} 

3407  832 
r.x:= (Longword(WindBarWidth) + RealTicks shr 6) mod 8; 
3405  833 
{$WARNINGS ON} 
834 
r.y:= 0; 

835 
r.w:=  WindBarWidth; 

836 
r.h:= 13; 

837 
DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1)  offsetY + 74 + WindBarWidth, cScreenHeight  offsetX + 2, 13, 0); 

838 
end; 

5  839 

161  840 
// AmmoMenu 
3434  841 
if (AMxShift < AMWidth) or bShowAmmoMenu then ShowAmmoMenu; 
161  842 

2287  843 
// Cursor 
844 
if isCursorVisible and bShowAmmoMenu then 

845 
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight  CursorPoint.Y, (RealTicks shr 6) mod 8); 

942  846 

2287  847 
DrawChat; 
4  848 

2567  849 
if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture); 
850 
if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture); 

281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset

851 

3304  852 
if not isFirstFrame and ((missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm)) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

853 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

854 
if missionTimer > 0 then dec(missionTimer, Lag); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

855 
if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

856 
if missionTex <> nil then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

857 
DrawCentered(0, min((cScreenHeight shr 1) + 100, cScreenHeight  48  missionTex^.h), missionTex); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

858 
end; 
2786  859 

2724  860 
// fps 
861 
{$IFDEF IPHONEOS} 

3463  862 
offsetX:= 8; 
2724  863 
{$ELSE} 
3463  864 
offsetX:= 10; 
2724  865 
{$ENDIF} 
3463  866 
offsetY:= cOffsetY; 
4  867 
inc(Frames); 
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

868 

f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

869 
if cShowFPS or (GameType = gmtDemo) then inc(CountTicks, Lag); 
2851  870 
if (GameType = gmtDemo) and (CountTicks >= 1000) then 
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

871 
begin 
3407  872 
i:=GameTicks div 1000; 
873 
t:= i mod 60; 

874 
s:= inttostr(t); 

875 
if t < 10 then s:= '0' + s; 

876 
i:= i div 60; 

877 
t:= i mod 60; 

878 
s:= inttostr(t) + ':' + s; 

879 
if t < 10 then s:= '0' + s; 

880 
s:= inttostr(i div 60) + ':' + s; 

881 

3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

882 
if timeTexture <> nil then 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

883 
FreeTexture(timeTexture); 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

884 
timeTexture:= nil; 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

885 

2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

886 
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); 
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

887 
tmpSurface:= doSurfaceConversion(tmpSurface); 
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

888 
timeTexture:= Surface2Tex(tmpSurface, false); 
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

889 
SDL_FreeSurface(tmpSurface) 
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

890 
end; 
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

891 

f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

892 
if timeTexture <> nil then 
3463  893 
DrawTexture((cScreenWidth shr 1)  20  timeTexture^.w  offsetY, offsetX + timeTexture^.h+5, timeTexture); 
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

894 

298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

895 
if cShowFPS then 
4  896 
begin 
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

897 
if CountTicks >= 1000 then 
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

898 
begin 
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

899 
FPS:= Frames; 
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

900 
Frames:= 0; 
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

901 
CountTicks:= 0; 
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

902 
s:= inttostr(FPS) + ' fps'; 
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

903 
if fpsTexture <> nil then 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

904 
FreeTexture(fpsTexture); 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

905 
fpsTexture:= nil; 
2665
50b4e544c163
complete transition of longword>sdl_color for TTF bindings
koda
parents:
2630
diff
changeset

906 
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); 
2670  907 
tmpSurface:= doSurfaceConversion(tmpSurface); 
2290
bf87ca44782e
Selectively enable clamping  seeing if this helps avoid weird flake problems while still fixing vertical lines in waves and sky
nemo
parents:
2288
diff
changeset

908 
fpsTexture:= Surface2Tex(tmpSurface, false); 
759  909 
SDL_FreeSurface(tmpSurface) 
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset

910 
end; 
759  911 
if fpsTexture <> nil then 
3463  912 
DrawTexture((cScreenWidth shr 1)  60  offsetY, offsetX, fpsTexture); 
4  913 
end; 
174  914 

2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

915 
if CountTicks >= 1000 then CountTicks:= 0; 
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

916 

2724  917 
// lag warning (?) 
174  918 
inc(SoundTimerTicks, Lag); 
919 
if SoundTimerTicks >= 50 then 

920 
begin 

921 
SoundTimerTicks:= 0; 

922 
if cVolumeDelta <> 0 then 

923 
begin 

924 
str(ChangeVolume(cVolumeDelta), s); 

2619  925 
AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) 
174  926 
end 
756  927 
end; 
928 

2724  929 
if GameState = gsConfirm then 
3025  930 
DrawCentered(0, (cScreenHeight shr 1), ConfirmTexture); 
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

931 

3107  932 
if ScreenFade <> sfNone then 
933 
begin 

934 
if not isFirstFrame then 

935 
case ScreenFade of 

936 
sfToBlack, sfToWhite: if ScreenFadeValue + Lag * ScreenFadeSpeed < sfMax then 

937 
inc(ScreenFadeValue, Lag * ScreenFadeSpeed) 

938 
else 

3123  939 
ScreenFadeValue:= sfMax; 
3107  940 
sfFromBlack, sfFromWhite: if ScreenFadeValue  Lag * ScreenFadeSpeed > 0 then 
941 
dec(ScreenFadeValue, Lag * ScreenFadeSpeed) 

942 
else 

3123  943 
ScreenFadeValue:= 0; 
3107  944 
end; 
945 
if ScreenFade <> sfNone then 

946 
begin 

947 
case ScreenFade of 

3376  948 
sfToBlack, sfFromBlack: Tint(0, 0, 0, ScreenFadeValue * 255 div 1000); 
949 
sfToWhite, sfFromWhite: Tint($FF, $FF, $FF, ScreenFadeValue * 255 div 1000); 

3107  950 
end; 
3113  951 

952 
VertexBuffer[0].X:= cScreenWidth; 

953 
VertexBuffer[0].Y:= cScreenHeight; 

954 
VertexBuffer[1].X:= cScreenWidth; 

955 
VertexBuffer[1].Y:= 0; 

956 
VertexBuffer[2].X:= cScreenWidth; 

957 
VertexBuffer[2].Y:= 0; 

958 
VertexBuffer[3].X:= cScreenWidth; 

959 
VertexBuffer[3].Y:= cScreenHeight; 

960 

3376  961 
glDisable(GL_TEXTURE_2D); 
3113  962 
glEnableClientState(GL_VERTEX_ARRAY); 
963 
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); 

964 
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); 

965 
glDisableClientState(GL_VERTEX_ARRAY); 

3376  966 
glEnable(GL_TEXTURE_2D); 
3390  967 
Tint($FF, $FF, $FF, $FF); 
3123  968 
if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone 
3107  969 
end 
970 
end; 

971 

3123  972 
SetScale(zoom); 
973 

974 
// Cursor 

975 
if isCursorVisible then 

976 
begin 

977 
if not bShowAmmoMenu then 

3204  978 
begin 
3123  979 
with CurrentHedgehog^ do 
3582
4debed8656d7
fix segfault on HHgear being 0 (e.g. after drowning) in cursor/target selection mode, thanks "ivze" for the headsup!
sheepluva
parents:
3580
diff
changeset

980 
if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then 
3123  981 
begin 
982 
i:= Ammo^[CurSlot, CurAmmo].Pos; 

983 
with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do 

984 
if PosCount > 1 then 

3204  985 
DrawSprite(PosSprite, CursorPoint.X  (SpritesData[PosSprite].Width shr 1), cScreenHeight  CursorPoint.Y  (SpritesData[PosSprite].Height shr 1),i); 
3123  986 
end; 
3204  987 
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight  CursorPoint.Y, (RealTicks shr 6) mod 8) 
988 
end 

3123  989 
end; 
3107  990 
isFirstFrame:= false 
4  991 
end; 
992 

2905  993 
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); 
4  994 
begin 
2142  995 
//if Group in [capgrpGameState] then WriteLnToConsole(s); 
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

996 
if Captions[Group].Tex <> nil then 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

997 
FreeTexture(Captions[Group].Tex); 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

998 
Captions[Group].Tex:= nil; 
2142  999 

3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1000 
Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1001 

f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1002 
case Group of 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1003 
capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1004 
else 
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1005 
Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1006 
end; 
4  1007 
end; 
1008 

79  1009 
procedure MoveCamera; 
4  1010 
const PrevSentPointTime: LongWord = 0; 
2428  1011 
var EdgesDist, wdy: LongInt; 
4  1012 
begin 
3551  1013 
{$IFNDEF IPHONEOS} 
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset

1014 
if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then 
3551  1015 
begin 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1016 
SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1017 
CursorPoint.X:= CursorPoint.X  (cScreenWidth shr 1); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1018 
CursorPoint.Y:= cScreenHeight  CursorPoint.Y; 
3551  1019 
end; 
1020 
{$ENDIF} 

678  1021 

2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2747
diff
changeset

1022 
if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1023 
if abs(CursorPoint.X  prevPoint.X) + abs(CursorPoint.Y  prevpoint.Y) > 4 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1024 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1025 
FollowGear:= nil; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1026 
prevPoint:= CursorPoint; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1027 
exit 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1028 
end 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1029 
else begin 
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset

1030 
CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100 + WorldDx) div 8; 
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset

1031 
CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight  (hwRound(FollowGear^.Y) + WorldDy)) div 8; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1032 
end; 
4  1033 

2375  1034 
wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2  cWaterLine  cVisibleWater; 
1035 
if WorldDy < wdy then WorldDy:= wdy; 

1036 

2197  1037 
if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit; 
4  1038 

3434  1039 
if AMxShift < AMWidth then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1040 
begin 
3463  1041 
{$IFDEF IPHONEOS} 
3434  1042 
if CursorPoint.X < cScreenWidth div 2 + AMxShift  AMWidth then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMWidth; 
1043 
if CursorPoint.X > cScreenWidth div 2 + AMxShift  AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMxOffset; 

1044 
if CursorPoint.Y < cScreenHeight  AMyOffset  SlotsNum * AMSlotSize then CursorPoint.Y:= cScreenHeight  AMyOffset  SlotsNum * AMSlotSize; 

1045 
if CursorPoint.Y > cScreenHeight  AMyOffset then CursorPoint.Y:= cScreenHeight  AMyOffset; 

3463  1046 
{$ELSE} 
3434  1047 
if CursorPoint.X < cScreenWidth div 2 + AMxShift  AMWidth + AMSlotSize then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMWidth + AMSlotSize; 
1048 
if CursorPoint.X > cScreenWidth div 2 + AMxShift  AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMxOffset; 

1049 
if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize; 

1050 
if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize; 

3463  1051 
{$ENDIF} 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1052 
prevPoint:= CursorPoint; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1053 
if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight  CursorPoint.Y); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1054 
exit 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1055 
end; 
162  1056 

4  1057 
if isCursorVisible then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1058 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1059 
if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1060 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1061 
SendIPCXY('P', CursorPoint.X  WorldDx, cScreenHeight  CursorPoint.Y  WorldDy); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1062 
PrevSentPointTime:= GameTicks 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1063 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1064 
end; 
351  1065 

4  1066 
if isCursorVisible or (FollowGear <> nil) then 
1067 
begin 

284  1068 
if isCursorVisible then EdgesDist:= cCursorEdgesDist 
1069 
else EdgesDist:= cGearScrEdgesDist; 

2197  1070 
if CursorPoint.X <  cScreenWidth div 2 + EdgesDist then 
4  1071 
begin 
2197  1072 
WorldDx:= WorldDx  CursorPoint.X  cScreenWidth div 2 + EdgesDist; 
1073 
CursorPoint.X:=  cScreenWidth div 2 + EdgesDist 

4  1074 
end else 
2197  1075 
if CursorPoint.X > cScreenWidth div 2  EdgesDist then 
4  1076 
begin 
2197  1077 
WorldDx:= WorldDx  CursorPoint.X + cScreenWidth div 2  EdgesDist; 
2198  1078 
CursorPoint.X:= cScreenWidth div 2  EdgesDist 
4  1079 
end; 
284  1080 
if CursorPoint.Y < EdgesDist then 
4  1081 
begin 
2197  1082 
WorldDy:= WorldDy + CursorPoint.Y  EdgesDist; 
284  1083 
CursorPoint.Y:= EdgesDist 
4  1084 
end else 
284  1085 
if CursorPoint.Y > cScreenHeight  EdgesDist then 
4  1086 
begin 
2197  1087 
WorldDy:= WorldDy + CursorPoint.Y  cScreenHeight + EdgesDist; 
284  1088 
CursorPoint.Y:= cScreenHeight  EdgesDist 
4  1089 
end; 
1090 
end else 

308  1091 
if cHasFocus then 
1092 
begin 

70  1093 
WorldDx:= WorldDx  CursorPoint.X + prevPoint.X; 
2197  1094 
WorldDy:= WorldDy + CursorPoint.Y  prevPoint.Y; 
2162  1095 
CursorPoint.X:= 0; 
1096 
CursorPoint.Y:= cScreenHeight div 2; 

308  1097 
end; 
351  1098 

4  1099 
prevPoint:= CursorPoint; 
2567  1100 
if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight  CursorPoint.Y); 
1760  1101 
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; 
2375  1102 
if WorldDy < wdy then WorldDy:= wdy; 
2426  1103 
if WorldDx <  LAND_WIDTH  1024 then WorldDx:=  LAND_WIDTH  1024; 
1104 
if WorldDx > 1024 then WorldDx:= 1024; 

4  1105 
end; 
1106 

2905  1107 
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); 
2786  1108 
var r: TSDL_Rect; 
1109 
begin 

1110 
r.w:= 32; 

1111 
r.h:= 32; 

1112 

1113 
if time = 0 then time:= 5000; 

1114 
missionTimer:= time; 

3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1115 
if missionTex <> nil then 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1116 
FreeTexture(missionTex); 
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset

1117 
missionTex:= nil; 
2786  1118 

1119 
if icon > 1 then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1120 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1121 
r.x:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1122 
r.y:= icon * 32; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1123 
missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, MissionIcons, @r) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1124 
end 
2786  1125 
else 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1126 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1127 
r.x:= ((icon  1) shr 5) * 32; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1128 
r.y:= ((icon  1) mod 32) * 32; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1129 
missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, SpritesData[sprAMAmmos].Surface, @r) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1130 
end; 
2786  1131 
end; 
1132 

1133 
procedure HideMission; 

1134 
begin 

3045  1135 
missionTimer:= 0; 
1136 
if missionTex <> nil then FreeTexture(missionTex); 

2786  1137 
end; 
1138 

3032  1139 
procedure ShakeCamera(amount: LongWord); 
1140 
begin 

1141 
amount:= max(1, amount); 

1142 
WorldDx:= WorldDx  amount + LongInt(getRandom(1 + amount * 2)); 

1143 
WorldDy:= WorldDy  amount + LongInt(getRandom(1 + amount * 2)); 

1144 
end; 

1145 

3038  1146 
procedure initModule; 
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

1147 
begin 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1148 
fpsTexture:= nil; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1149 
FollowGear:= nil; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1150 
WindBarWidth:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1151 
bShowAmmoMenu:= false; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1152 
bSelected:= false; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1153 
bShowFinger:= false; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1154 
Frames:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1155 
WorldDx:= 512; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1156 
WorldDy:= 256; 
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

1157 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1158 
FPS:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1159 
CountTicks:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1160 
SoundTimerTicks:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1161 
prevPoint.X:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1162 
prevPoint.Y:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1163 
missionTimer:= 0; 
3240  1164 
missionTex:= nil; 
3463  1165 
cOffsetY:= 0; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1166 

3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1167 
FillChar(Captions, sizeof(Captions), 0) 
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset

1168 
end; 
4  1169 

3038  1170 
procedure freeModule; 
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

1171 
begin 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

1172 
end; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset

1173 

4  1174 
end. 