author  koda 
Sun, 20 Jun 2010 18:35:59 +0200  
changeset 3523  6592fbb969da 
parent 3513  f589230fa21b 
child 3537  8f5b3108f29c 
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; 

197 
if cReducedQuality then 

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; 

213 
if cReducedQuality then 

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); 
2426  489 
var i, w, sw: LongInt; 
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 
3405  494 
w:= SpritesData[spr].Width; 
495 
i:= Shift mod w; 

496 
if i > 0 then dec(i, w); 

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

498 
repeat 

499 
DrawSprite(spr, i, WorldDy + LAND_HEIGHT + OffsetY  SpritesData[spr].Height, 0); 

500 
inc(i, w) 

501 
until i > sw 

502 
end 

503 
else 

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

504 
begin 
3405  505 
w:= SpritesData[spr].Width; 
506 
dec(Shift, w div 2); 

507 
DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT + OffsetY  SpritesData[spr].Height, 0); 

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

508 

3405  509 
i:= Shift  SpritesData[sprL].Width; 
510 
while i >= sw  SpritesData[sprL].Width do 

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

511 
begin 
3405  512 
DrawSprite(sprL, i, WorldDy + LAND_HEIGHT + OffsetY  SpritesData[sprL].Height, 0); 
513 
dec(i, SpritesData[sprL].Width); 

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

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

515 

3405  516 
i:= Shift + w; 
517 
while i <= sw do 

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

518 
begin 
3405  519 
DrawSprite(sprR, i, WorldDy + LAND_HEIGHT + OffsetY  SpritesData[sprR].Height, 0); 
520 
inc(i, SpritesData[sprR].Width) 

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

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

522 
end 
2426  523 
end; 
524 

525 

956  526 
procedure DrawWorld(Lag: LongInt); 
371  527 
var i, t: LongInt; 
4  528 
r: TSDL_Rect; 
107  529 
tdx, tdy: Double; 
175  530 
grp: TCapGroup; 
174  531 
s: string[15]; 
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset

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

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

537 
begin 
3523  538 
if ZoomValue < zoom then 
3444  539 
begin 
3523  540 
zoom:= zoom  0.002 * Lag; 
541 
if ZoomValue > zoom then 

542 
zoom:= ZoomValue 

543 
end 

544 
else 

545 
if ZoomValue > zoom then 

3444  546 
begin 
3523  547 
zoom:= zoom + 0.002 * Lag; 
548 
if ZoomValue < zoom then 

549 
zoom:= ZoomValue 

3444  550 
end 
551 
end 

552 
else 

553 
ZoomValue:= zoom; 

2376  554 

770  555 
// Sky 
756  556 
glClear(GL_COLOR_BUFFER_BIT); 
777  557 
//glPushMatrix; 
558 
//glScalef(1.0, 1.0, 1.0); 

756  559 

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

560 
if not isPaused then MoveCamera; 
162  561 

1812  562 
if not cReducedQuality then 
563 
begin 

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

564 
// Offsets relative to camera  spare them to wimpier cpus, no bg or flakes for them anyway 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

565 
ScreenBottom:= (WorldDy  trunc(cScreenHeight/cScaleFactor)  (cScreenHeight div 2) + cWaterLine); 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

566 
offsetY:= 10 * min(0, 145  ScreenBottom); 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

567 
SkyOffset:= offsetY div 35 + cWaveHeight; 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

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

569 
if ScreenBottom > SkyOffset then 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

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

571 

1812  572 
// background 
3248  573 
DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset); 
574 
DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset); 

4  575 

1812  576 
DrawVisualGears(0); 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

577 

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

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

579 
DrawWater(255, SkyOffset); 
3376  580 
DrawWaves( 1, 0  WorldDx div 32,  cWaveHeight + offsetY div 35, 64); 
581 
DrawWaves( 1, 25 + WorldDx div 25,  cWaveHeight + offsetY div 38, 48); 

582 
DrawWaves( 1, 75  WorldDx div 19,  cWaveHeight + offsetY div 45, 32); 

583 
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

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

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

586 
DrawWaves(1, 100,  (cWaveHeight + (cWaveHeight shr 1)), 0); 
4  587 

762  588 
DrawLand(WorldDx, WorldDy); 
1911  589 

3104  590 
DrawWater(255, 0); 
4  591 

1660  592 
// Attack bar 
3483  593 
// TODO: Add weapon offset 
1660  594 
if CurrentTeam <> nil then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

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

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

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

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

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

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

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

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

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

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

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

607 
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

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

609 
hwRound(Gear^.X) + round(WorldDx + tdx * (24 + i * 2))  16, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

610 
hwRound(Gear^.Y) + round(WorldDy + tdy * (24 + i * 2))  12, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

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

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

613 
end; 
1660  614 

2713  615 
DrawVisualGears(1); 
616 

956  617 
DrawGears; 
4  618 

2713  619 
DrawVisualGears(2); 
1045  620 

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

622 

5  623 
// Waves 
3376  624 
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

625 

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

626 
if not cReducedQuality then 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

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

628 
//DrawWater(cWaterOpacity,  offsetY div 40); 
3376  629 
DrawWaves(1, 50 + WorldDx div 6,  cWaveHeight  offsetY div 40, 8); 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

630 
DrawWater(cWaterOpacity,  offsetY div 20); 
3376  631 
DrawWaves( 1, 75  WorldDx div 4,  cWaveHeight  offsetY div 20, 2); 
3265
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

632 
DrawWater(cWaterOpacity,  offsetY div 10); 
5fe62296fdea
 Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset

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

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

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

636 
DrawWaves(1, 50,  (cWaveHeight shr 1), 0); 
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset

637 

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

638 

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

640 
// Target 
3104  641 
if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then 
642 
begin 

643 
with PHedgehog(CurrentHedgehog)^ do 

644 
begin 

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

647 
else 

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

650 
end; 

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

652 

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

2724  655 

656 

657 
// Turn time 

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

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

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

662 
{$ENDIF} 
3463  663 
offsetY:= cOffsetY; 
4  664 
if TurnTimeLeft <> 0 then 
665 
begin 

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

667 
if i>99 then t:= 112 

668 
else if i>9 then t:= 96 

669 
else t:= 80; 

3463  670 
DrawSprite(sprFrame, (cScreenWidth shr 1) + t + offsetY, cScreenHeight  offsetX, 1); 
4  671 
while i > 0 do 
672 
begin 

673 
dec(t, 32); 

3463  674 
DrawSprite(sprBigDigit, (cScreenWidth shr 1) + t + offsetY, cScreenHeight  offsetX, i mod 10); 
4  675 
i:= i div 10 
676 
end; 

3463  677 
DrawSprite(sprFrame, (cScreenWidth shr 1) + t  4 + offsetY, cScreenHeight  offsetX, 0); 
4  678 
end; 
79  679 

2567  680 
{$IFNDEF IPHONEOS} 
2428  681 
// Timetrial 
682 
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

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

684 
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

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

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

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

689 
// 1 ms 
2428  690 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
691 
dec(t, 32); 

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

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

693 
// 10 ms 
2428  694 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
695 
dec(t, 32); 

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

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

697 
// 100 ms 
2428  698 
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

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

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

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

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

704 
// 1 s 
2428  705 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
706 
dec(t, 32); 

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

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

708 
// 10s 
2428  709 
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

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

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

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

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

715 
// 1 m 
2428  716 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
717 
dec(t, 32); 

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

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

719 
// 10 m 
2428  720 
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

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

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

723 
end; 
2567  724 
{$ENDIF} 
725 

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

728 
offset:= 40; 
2567  729 
{$ELSE} 
2724  730 
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48 
731 
else offset:= 8; 

2567  732 
{$ENDIF} 
2428  733 

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

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

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

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

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

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

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

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

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

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

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

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

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

746 
end; 
4  747 

47  748 
// Teams Healths 
547  749 
for t:= 0 to Pred(TeamsCount) do 
750 
with TeamsArray[t]^ do 

47  751 
begin 
2839  752 
highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); 
753 

2747  754 
if highlight then 
3445  755 
Tint(Clan^.Color); 
2839  756 

757 
// draw name 

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

759 

760 
// draw flag 

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

762 

763 
// draw health bar 

690  764 
r.x:= 0; 
765 
r.y:= 0; 

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

767 
r.h:= HealthTex^.h; 
2747  768 
DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex); 
690  769 

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

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

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

776 
if highlight then 

777 
begin 

3390  778 
Tint($FF, $FF, $FF, $FF); 
690  779 

2839  780 
// draw name 
2747  781 
r.x:= 2; 
782 
r.y:= 2; 

2839  783 
r.w:= NameTagTex^.w  4; 
784 
r.h:= NameTagTex^.h  4; 

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

786 
// draw flag 

2747  787 
r.w:= 22; 
788 
r.h:= 15; 

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

2839  790 
// draw health bar 
791 
r.w:= TeamHealthBarWidth + 1; 

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

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

2747  794 
end; 
47  795 
end; 
796 

5  797 
// Lag alert 
2567  798 
if isInLag then DrawSprite(sprLag, 32  (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12); 
4  799 

5  800 
// Wind bar 
2567  801 
{$IFDEF IPHONEOS} 
3405  802 
offsetX:= cScreenHeight  13; 
803 
offsetY:= (cScreenWidth shr 1) + 74; 

2567  804 
{$ELSE} 
3405  805 
offsetX:= 30; 
806 
offsetY:= 180; 

2567  807 
{$ENDIF} 
3405  808 
DrawSprite(sprWindBar, (cScreenWidth shr 1)  offsetY, cScreenHeight  offsetX, 0); 
809 
if WindBarWidth > 0 then 

810 
begin 

811 
{$WARNINGS OFF} 

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

813 
{$WARNINGS ON} 

814 
r.y:= 0; 

815 
r.w:= WindBarWidth; 

816 
r.h:= 13; 

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

818 
end 

819 
else 

820 
if WindBarWidth < 0 then 

821 
begin 

822 
{$WARNINGS OFF} 

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

826 
r.w:=  WindBarWidth; 

827 
r.h:= 13; 

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

829 
end; 

5  830 

161  831 
// AmmoMenu 
3434  832 
if (AMxShift < AMWidth) or bShowAmmoMenu then ShowAmmoMenu; 
161  833 

2287  834 
// Cursor 
835 
if isCursorVisible and bShowAmmoMenu then 

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

942  837 

2287  838 
DrawChat; 
4  839 

2567  840 
if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture); 
841 
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

842 

3304  843 
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

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

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

846 
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

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

848 
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

849 
end; 
2786  850 

2724  851 
// fps 
852 
{$IFDEF IPHONEOS} 

3463  853 
offsetX:= 8; 
2724  854 
{$ELSE} 
3463  855 
offsetX:= 10; 
2724  856 
{$ENDIF} 
3463  857 
offsetY:= cOffsetY; 
4  858 
inc(Frames); 
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset

859 

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

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

862 
begin 
3407  863 
i:=GameTicks div 1000; 
864 
t:= i mod 60; 

865 
s:= inttostr(t); 

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

867 
i:= i div 60; 

868 
t:= i mod 60; 

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

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

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

872 

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

873 
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

874 
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

875 
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

876 

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

877 
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

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

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

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

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

882 

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

883 
if timeTexture <> nil then 
3463  884 
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

885 

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

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

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

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

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

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

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

893 
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

894 
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

895 
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

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

897 
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); 
2670  898 
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

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

901 
end; 
759  902 
if fpsTexture <> nil then 
3463  903 
DrawTexture((cScreenWidth shr 1)  60  offsetY, offsetX, fpsTexture); 
4  904 
end; 
174  905 

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

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

907 

2724  908 
// lag warning (?) 
174  909 
inc(SoundTimerTicks, Lag); 
910 
if SoundTimerTicks >= 50 then 

911 
begin 

912 
SoundTimerTicks:= 0; 

913 
if cVolumeDelta <> 0 then 

914 
begin 

915 
str(ChangeVolume(cVolumeDelta), s); 

2619  916 
AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) 
174  917 
end 
756  918 
end; 
919 

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

922 

3107  923 
if ScreenFade <> sfNone then 
924 
begin 

925 
if not isFirstFrame then 

926 
case ScreenFade of 

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

928 
inc(ScreenFadeValue, Lag * ScreenFadeSpeed) 

929 
else 

3123  930 
ScreenFadeValue:= sfMax; 
3107  931 
sfFromBlack, sfFromWhite: if ScreenFadeValue  Lag * ScreenFadeSpeed > 0 then 
932 
dec(ScreenFadeValue, Lag * ScreenFadeSpeed) 

933 
else 

3123  934 
ScreenFadeValue:= 0; 
3107  935 
end; 
936 
if ScreenFade <> sfNone then 

937 
begin 

938 
case ScreenFade of 

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

3107  941 
end; 
3113  942 

943 
VertexBuffer[0].X:= cScreenWidth; 

944 
VertexBuffer[0].Y:= cScreenHeight; 

945 
VertexBuffer[1].X:= cScreenWidth; 

946 
VertexBuffer[1].Y:= 0; 

947 
VertexBuffer[2].X:= cScreenWidth; 

948 
VertexBuffer[2].Y:= 0; 

949 
VertexBuffer[3].X:= cScreenWidth; 

950 
VertexBuffer[3].Y:= cScreenHeight; 

951 

3376  952 
glDisable(GL_TEXTURE_2D); 
3113  953 
glEnableClientState(GL_VERTEX_ARRAY); 
954 
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); 

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

956 
glDisableClientState(GL_VERTEX_ARRAY); 

3376  957 
glEnable(GL_TEXTURE_2D); 
3390  958 
Tint($FF, $FF, $FF, $FF); 
3123  959 
if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone 
3107  960 
end 
961 
end; 

962 

3123  963 
SetScale(zoom); 
964 

965 
// Cursor 

966 
if isCursorVisible then 

967 
begin 

968 
if not bShowAmmoMenu then 

3204  969 
begin 
3123  970 
with CurrentHedgehog^ do 
971 
if (Gear^.State and gstHHChooseTarget) <> 0 then 

972 
begin 

973 
i:= Ammo^[CurSlot, CurAmmo].Pos; 

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

975 
if PosCount > 1 then 

3204  976 
DrawSprite(PosSprite, CursorPoint.X  (SpritesData[PosSprite].Width shr 1), cScreenHeight  CursorPoint.Y  (SpritesData[PosSprite].Height shr 1),i); 
3123  977 
end; 
3204  978 
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight  CursorPoint.Y, (RealTicks shr 6) mod 8) 
979 
end 

3123  980 
end; 
3107  981 
isFirstFrame:= false 
4  982 
end; 
983 

2905  984 
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); 
4  985 
begin 
2142  986 
//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

987 
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

988 
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

989 
Captions[Group].Tex:= nil; 
2142  990 

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

991 
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

992 

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

993 
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

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

995 
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

996 
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

997 
end; 
4  998 
end; 
999 

79  1000 
procedure MoveCamera; 
4  1001 
const PrevSentPointTime: LongWord = 0; 
2428  1002 
var EdgesDist, wdy: LongInt; 
4  1003 
begin 
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset

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

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

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

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

1008 
CursorPoint.Y:= cScreenHeight  CursorPoint.Y; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

1009 
end; 
678  1010 

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

1011 
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

1012 
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

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

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

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

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

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

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

1019 
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

1020 
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

1021 
end; 
4  1022 

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

1025 

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

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

1029 
begin 
3463  1030 
{$IFDEF IPHONEOS} 
3434  1031 
if CursorPoint.X < cScreenWidth div 2 + AMxShift  AMWidth then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMWidth; 
1032 
if CursorPoint.X > cScreenWidth div 2 + AMxShift  AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMxOffset; 

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

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

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

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

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

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

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

1042 
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

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

1044 
end; 
162  1045 

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

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

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

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

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

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

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

1053 
end; 
351  1054 

4  1055 
if isCursorVisible or (FollowGear <> nil) then 
1056 
begin 

284  1057 
if isCursorVisible then EdgesDist:= cCursorEdgesDist 
1058 
else EdgesDist:= cGearScrEdgesDist; 

2197  1059 
if CursorPoint.X <  cScreenWidth div 2 + EdgesDist then 
4  1060 
begin 
2197  1061 
WorldDx:= WorldDx  CursorPoint.X  cScreenWidth div 2 + EdgesDist; 
1062 
CursorPoint.X:=  cScreenWidth div 2 + EdgesDist 

4  1063 
end else 
2197  1064 
if CursorPoint.X > cScreenWidth div 2  EdgesDist then 
4  1065 
begin 
2197  1066 
WorldDx:= WorldDx  CursorPoint.X + cScreenWidth div 2  EdgesDist; 
2198  1067 
CursorPoint.X:= cScreenWidth div 2  EdgesDist 
4  1068 
end; 
284  1069 
if CursorPoint.Y < EdgesDist then 
4  1070 
begin 
2197  1071 
WorldDy:= WorldDy + CursorPoint.Y  EdgesDist; 
284  1072 
CursorPoint.Y:= EdgesDist 
4  1073 
end else 
284  1074 
if CursorPoint.Y > cScreenHeight  EdgesDist then 
4  1075 
begin 
2197  1076 
WorldDy:= WorldDy + CursorPoint.Y  cScreenHeight + EdgesDist; 
284  1077 
CursorPoint.Y:= cScreenHeight  EdgesDist 
4  1078 
end; 
1079 
end else 

308  1080 
if cHasFocus then 
1081 
begin 

70  1082 
WorldDx:= WorldDx  CursorPoint.X + prevPoint.X; 
2197  1083 
WorldDy:= WorldDy + CursorPoint.Y  prevPoint.Y; 
2162  1084 
CursorPoint.X:= 0; 
1085 
CursorPoint.Y:= cScreenHeight div 2; 

308  1086 
end; 
351  1087 

4  1088 
prevPoint:= CursorPoint; 
2567  1089 
if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight  CursorPoint.Y); 
1760  1090 
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; 
2375  1091 
if WorldDy < wdy then WorldDy:= wdy; 
2426  1092 
if WorldDx <  LAND_WIDTH  1024 then WorldDx:=  LAND_WIDTH  1024; 
1093 
if WorldDx > 1024 then WorldDx:= 1024; 

4  1094 
end; 
1095 

2905  1096 
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); 
2786  1097 
var r: TSDL_Rect; 
1098 
begin 

1099 
r.w:= 32; 

1100 
r.h:= 32; 

1101 

1102 
if time = 0 then time:= 5000; 

1103 
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

1104 
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

1105 
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

1106 
missionTex:= nil; 
2786  1107 

1108 
if icon > 1 then 

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

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

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

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

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

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

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

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

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

1118 
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

1119 
end; 
2786  1120 
end; 
1121 

1122 
procedure HideMission; 

1123 
begin 

3045  1124 
missionTimer:= 0; 
1125 
if missionTex <> nil then FreeTexture(missionTex); 

2786  1126 
end; 
1127 

3032  1128 
procedure ShakeCamera(amount: LongWord); 
1129 
begin 

1130 
amount:= max(1, amount); 

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

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

1133 
end; 

1134 

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

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

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

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

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

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

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

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

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

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

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

1146 

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

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

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

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

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

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

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

1155 

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

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

1157 
end; 
4  1158 

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

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

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

1162 

4  1163 
end. 