author  koda 
Mon, 02 Aug 2010 12:24:06 +0200  
branch  experimental3D 
changeset 3692  bbec1275e46f 
parent 3690  c247dee9e1c0 
child 3696  6009d8378422 
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 

3692  25 
type TRenderMode = (rmDefault, rmLeftEye, rmRightEye); 
4  26 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3038  43 
procedure initModule; 
44 
procedure freeModule; 

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

45 

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

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

47 
procedure DrawWorld(Lag: LongInt); 
3692  48 
procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); 
2905  49 
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); 
50 
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); 

2786  51 
procedure HideMission; 
3032  52 
procedure ShakeCamera(amount: LongWord); 
3638
33ee433749ba
touch overlay reworked, improvements to zoom and confirmation
koda
parents:
3629
diff
changeset

53 
procedure MoveCamera; 
4  54 

55 
implementation 

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

4  58 
type TCaptionStr = record 
762  59 
Tex: PTexture; 
4  60 
EndTime: LongWord; 
61 
end; 

62 

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

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

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

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

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

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

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

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

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

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

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

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

75 
missionTimer: LongInt; 
3692  76 
stereoDepth: GLfloat = 0; 
77 

78 
const cStereo_Sky = 0.0750; 

79 
cStereo_Horizon = 0.0250; 

80 
cStereo_Water = 0.0125; 

4  81 

82 
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

83 
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

84 
cp: PClan; 
2863  85 
g: ansistring; 
86 

2904  87 
// helper functions to create the goal/game mode string 
2908  88 
function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; 
2905  89 
var t: ansistring; 
2904  90 
begin 
91 
if (GameFlags and gf) <> 0 then 

92 
begin 

93 
t:= inttostr(i); 

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

95 
end; 

96 
AddGoal:= s; 

97 
end; 

98 

2908  99 
function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring; 
2863  100 
begin 
2904  101 
if (GameFlags and gf) <> 0 then 
102 
s:= s + trgoal[si] + ''; 

2863  103 
AddGoal:= s; 
104 
end; 

4  105 
begin 
3405  106 
missionTimer:= 0; 
2786  107 

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

108 
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

109 
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

110 
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

111 
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

112 
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

113 
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

114 
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

115 
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

116 
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

117 
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

118 
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

119 
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

120 
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

121 
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

122 
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

123 
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

124 
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

125 
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

126 

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

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

132 

133 
// other important flags 

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

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

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

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

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

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

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

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

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

143 

2908  144 
// modified damage modificator? 
145 
if cDamagePercent <> 100 then 

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

146 
g:= AddGoal(g, gfAny, gidDamageModifier, cDamagePercent); 
2908  147 

3107  148 
// fade in 
149 
ScreenFade:= sfFromBlack; 

150 
ScreenFadeValue:= sfMax; 

151 
ScreenFadeSpeed:= 1; 

152 

2908  153 
// modified mine timers? 
154 
if cMinesTime <> 3000 then 

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

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

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

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

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

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

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

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

162 
end; 
2908  163 

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

166 

1825  167 
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

168 
//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

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

170 

284  171 
cGearScrEdgesDist:= Min(cScreenWidth div 2  100, cScreenHeight div 2  50); 
74  172 
SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); 
2197  173 
prevPoint.X:= 0; 
74  174 
prevPoint.Y:= cScreenHeight div 2; 
1760  175 
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

176 
WorldDy:=  (LAND_HEIGHT  (playHeight div 2)) + (cScreenHeight div 2); 
3434  177 
AMSlotSize:= 33; 
178 
{$IFDEF IPHONEOS} 

179 
AMxOffset:= 10; 

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

183 
AMxOffset:= 10; 

184 
AMyOffset:= 60; 

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

186 
{$ENDIF} 

187 
AMxShift:= AMWidth; 

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

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

189 
HorizontOffset:= 0; 
161  190 
end; 
191 

3405  192 

956  193 
procedure ShowAmmoMenu; 
161  194 
const MENUSPEED = 15; 
3434  195 
const BORDERSIZE = 2; 
196 
var x, y, i, t, g: LongInt; 

197 
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

198 
Ammo: PHHAmmo; 
161  199 
begin 
3434  200 
if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false; 
201 
if bShowAmmoMenu then 

202 
begin 

203 
FollowGear:= nil; 

204 
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

205 
if (cReducedQuality and rqSlowMenu) <> 0 then 
3434  206 
AMxShift:= 0 
207 
else 

208 
if AMxShift > MENUSPEED then 

209 
dec(AMxShift, MENUSPEED) 

210 
else 

211 
AMxShift:= 0; 

212 
end else 

213 
begin 

214 
if AMxShift = 0 then 

215 
begin 

216 
CursorPoint.X:= cScreenWidth shr 1; 

217 
CursorPoint.Y:= cScreenHeight shr 1; 

218 
prevPoint:= CursorPoint; 

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

220 
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

221 
if (cReducedQuality and rqSlowMenu) <> 0 then 
3434  222 
AMxShift:= AMWidth 
223 
else 

224 
if AMxShift < (AMWidth  MENUSPEED) then 

225 
inc(AMxShift, MENUSPEED) 

226 
else 

227 
AMxShift:= AMWidth; 

228 
end; 

229 
Ammo:= nil; 

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

231 
Ammo:= CurrentHedgehog^.Ammo 

232 
else if (LocalAmmo <> 1) then 

233 
Ammo:= GetAmmoByNum(LocalAmmo); 

234 
Pos:= 1; 

235 
if Ammo = nil then 

2971  236 
begin 
3434  237 
bShowAmmoMenu:= false; 
238 
exit 

2971  239 
end; 
3434  240 
SlotsNum:= 0; 
241 
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

242 

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

243 
{$IFDEF IPHONEOS} 
3434  244 
Slot:= cMaxSlotIndex; 
3463  245 
x:= x  cOffsetY; 
3464  246 
y:= AMyOffset; 
3434  247 
dec(y, BORDERSIZE); 
248 
DrawSprite(sprAMCorners, x  BORDERSIZE, y, 0); 

249 
for i:= 0 to cMaxSlotAmmoIndex do 

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

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

252 
inc(y, BORDERSIZE); 

253 

254 
for i:= 0 to cMaxSlotIndex do 

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

256 
begin 

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

258 
inc(SlotsNum); 

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

260 
t:= 0; 

261 
g:= 0; 

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

263 
begin 

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

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

266 
begin 

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

268 

269 
if STurns >= 0 then 

270 
begin 

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

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

273 
end else 

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

275 
if (Slot = i) 

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

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

278 
begin 

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

280 
Pos:= t; 

281 
end; 

282 
inc(g) 

283 
end; 

284 
inc(t) 

285 
end; 

286 
for g:= g to cMaxSlotAmmoIndex do 

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

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

289 
inc(y, AMSlotSize); 

290 
end; 

291 

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

293 
for i:= 0 to cMaxSlotAmmoIndex do 

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

295 
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

296 
{$ELSE} 
3434  297 
Slot:= 0; 
298 
y:= cScreenHeight  AMyOffset; 

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

300 
for i:= 0 to cMaxSlotAmmoIndex + 1 do 

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

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

303 
dec(y, AMSlotSize); 

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

305 
for i:= 0 to cMaxSlotAmmoIndex do 

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

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

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

309 

310 
for i:= cMaxSlotIndex downto 0 do 

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

312 
begin 

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

314 
dec(y, AMSlotSize); 

315 
inc(SlotsNum); 

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

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

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

319 
t:= 0; 

320 
g:= 1; 

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

322 
begin 

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

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

325 
begin 

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

327 

328 
if STurns >= 0 then 

329 
begin 

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

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

332 
end else 

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

334 
if (Slot = i) 

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

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

337 
begin 

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

339 
Pos:= t; 

340 
end; 

341 
inc(g) 

342 
end; 

343 
inc(t) 

344 
end; 

345 
for g:= g to cMaxSlotAmmoIndex + 1 do 

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

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

348 
end; 

349 

350 
dec(y, BORDERSIZE); 

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

352 
for i:= 0 to cMaxSlotAmmoIndex + 1 do 

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

354 
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

355 
{$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

356 

3434  357 
if (Pos >= 0) then 
358 
begin 

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

360 
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

361 
begin 
3434  362 
amSel:= Ammo^[Slot, Pos].AmmoType; 
363 
RenderWeaponTooltip(amSel) 

364 
end; 

365 

3629
86212d2b116a
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
koda
parents:
3611
diff
changeset

366 
{$IFDEF IPHONEOS} 
86212d2b116a
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
koda
parents:
3611
diff
changeset

367 
DrawTexture(cScreenWidth div 2  (AMWidth  10) + AMxShift, AMyOffset  25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); 
86212d2b116a
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
koda
parents:
3611
diff
changeset

368 

86212d2b116a
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
koda
parents:
3611
diff
changeset

369 
if Ammo^[Slot, Pos].Count < AMMO_INFINITE then 
86212d2b116a
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
koda
parents:
3611
diff
changeset

370 
DrawTexture(cScreenWidth div 2 + AMxOffset  45, AMyOffset  25, CountTexz[Ammo^[Slot, Pos].Count]); 
86212d2b116a
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
koda
parents:
3611
diff
changeset

371 
{$ELSE} 
3434  372 
DrawTexture(cScreenWidth div 2  (AMWidth  10) + AMxShift, cScreenHeight  AMyOffset  25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); 
3405  373 

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

3629
86212d2b116a
redo spinning wheel, redo fix for detail selection, redo ammo quantity and name in ammomenu
koda
parents:
3611
diff
changeset

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

377 

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

380 
bShowAmmoMenu:= false; 

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

382 
bSelected:= false; 

383 
FreeWeaponTooltip; 

384 
exit 

3405  385 
end; 
3434  386 
end 
387 
else 

388 
FreeWeaponTooltip; 

3663
8c28abf427f5
reduce the number of keywords used and switch to BMP format for screenshots
koda
parents:
3641
diff
changeset

389 
if (WeaponTooltipTex <> nil) and (AMxShift = 0) then 
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

390 
{$IFDEF IPHONEOS} 
3434  391 
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

392 
{$ELSE} 
3434  393 
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

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

395 

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

4  398 
end; 
399 

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

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

403 
lw, lh: GLfloat; 
1915  404 
begin 
3405  405 
WaterColorArray[0].a := Alpha; 
406 
WaterColorArray[1].a := Alpha; 

407 
WaterColorArray[2].a := Alpha; 

408 
WaterColorArray[3].a := Alpha; 

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

409 

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

3405  412 

413 
// Water 

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

3463  415 
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

416 
begin 
3405  417 
if r.y < 0 then 
418 
r.y:= 0; 

1915  419 

3405  420 
glDisable(GL_TEXTURE_2D); 
421 
VertexBuffer[0].X:= lw; 

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

423 
VertexBuffer[1].X:= lw; 

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

425 
VertexBuffer[2].X:= lw; 

426 
VertexBuffer[2].Y:= lh; 

427 
VertexBuffer[3].X:= lw; 

428 
VertexBuffer[3].Y:= lh; 

1915  429 

3641  430 
glDisableClientState(GL_TEXTURE_COORD_ARRAY); 
431 
glEnableClientState(GL_COLOR_ARRAY); 

3405  432 
glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); 
1915  433 

3405  434 
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

435 

3405  436 
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); 
1915  437 

3405  438 
glDisableClientState(GL_COLOR_ARRAY); 
3641  439 
glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
3407  440 
glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required 
3405  441 
glEnable(GL_TEXTURE_2D); 
442 
end; 

1915  443 
end; 
444 

3376  445 
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

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

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

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

451 

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

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

455 
255 

3089  456 
); 
457 

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

458 
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

459 

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

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

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

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

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

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

465 
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

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

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

468 

2374  469 
shift:=  lw / cWaveWidth; 
2495  470 
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

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

472 
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

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

474 
TextureBuffer[2].X:= TextureBuffer[1].X; 
2553  475 
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

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

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

478 

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

479 

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

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

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

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

483 

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

485 

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

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

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

488 
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

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

490 
0)} 
2288  491 
end; 
492 

3089  493 
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

494 
var i, w, h, lw, lh, rw, rh, sw: LongInt; 
2426  495 
begin 
3405  496 
sw:= round(cScreenWidth / cScaleFactor); 
497 
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

498 
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

499 
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

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

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

504 
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

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

508 
end 

509 
else 

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

510 
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

511 
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

512 
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

513 
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

514 
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

515 
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

516 
rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale; 
3405  517 
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

518 
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

519 

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

520 
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

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

522 
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

523 
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

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

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

526 

3405  527 
i:= Shift + w; 
528 
while i <= sw do 

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

529 
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

530 
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

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

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

533 
end 
2426  534 
end; 
535 

536 

956  537 
procedure DrawWorld(Lag: LongInt); 
3692  538 
var cc: array[0..3] of GLfloat; 
4  539 
begin 
3523  540 
if not isPaused then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2931
diff
changeset

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

546 
zoom:= ZoomValue 

547 
end 

548 
else 

549 
if ZoomValue > zoom then 

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

553 
zoom:= ZoomValue 

3611  554 
end 
3444  555 
end 
3611  556 
else 
557 
ZoomValue:= zoom; 

2376  558 

3611  559 
// Sky 
560 
glClear(GL_COLOR_BUFFER_BIT); 

561 
//glPushMatrix; 

562 
//glScalef(1.0, 1.0, 1.0); 

756  563 

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

564 
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

565 
MoveCamera; 
162  566 

3692  567 
if not isStereoEnabled then 
568 
begin 

569 
glClear(GL_COLOR_BUFFER_BIT); 

570 
DrawWorldStereo(Lag, rmDefault) 

571 
end 

572 
else 

573 
begin 

574 
// create left fb 

575 
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel); 

576 
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); 

577 
DrawWorldStereo(Lag, rmLeftEye); 

578 

579 
// create right fb 

580 
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer); 

581 
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); 

582 
DrawWorldStereo(0, rmRightEye); 

583 

584 
// detatch drawing from fbs 

585 
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 

586 
glGetFloatv(GL_COLOR_CLEAR_VALUE, @cc); 

587 
glClearColor(0, 0, 0, 0); 

588 
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); 

589 
glClearColor(cc[0], cc[1], cc[2], cc[3]); 

590 
SetScale(cDefaultZoomLevel); 

591 

592 
// enable gl stuff 

593 
glEnable(GL_TEXTURE_2D); 

594 
glEnable(GL_BLEND); 

595 
glBlendFunc(GL_ONE, GL_ONE); 

596 

597 
// draw left frame 

598 
glBindTexture(GL_TEXTURE_2D, texl); 

599 
glColor3f(0.0, 1.0, 1.0); 

600 
glBegin(GL_QUADS); 

601 
glTexCoord2f(0.0, 0.0); 

602 
glVertex2d(cScreenWidth / 2, cScreenHeight); 

603 
glTexCoord2f(1.0, 0.0); 

604 
glVertex2d(cScreenWidth / 2, cScreenHeight); 

605 
glTexCoord2f(1.0, 1.0); 

606 
glVertex2d(cScreenWidth / 2, 0); 

607 
glTexCoord2f(0.0, 1.0); 

608 
glVertex2d(cScreenWidth / 2, 0); 

609 
glEnd(); 

610 

611 
// draw right frame 

612 
glBindTexture(GL_TEXTURE_2D, texr); 

613 
glColor3f(1.0, 0.0, 0.0); 

614 
glBegin(GL_QUADS); 

615 
glTexCoord2f(0.0, 0.0); 

616 
glVertex2d(cScreenWidth / 2, cScreenHeight); 

617 
glTexCoord2f(1.0, 0.0); 

618 
glVertex2d(cScreenWidth / 2, cScreenHeight); 

619 
glTexCoord2f(1.0, 1.0); 

620 
glVertex2d(cScreenWidth / 2, 0); 

621 
glTexCoord2f(0.0, 1.0); 

622 
glVertex2d(cScreenWidth / 2, 0); 

623 
glEnd(); 

624 

625 
// reset 

626 
glColor3f(1.0, 1.0, 1.0); 

627 
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 

628 
SetScale(zoom); 

629 
end 

630 
end; 

631 

632 
procedure ChangeDepth(rm: TRenderMode; d: GLfloat); 

633 
begin 

634 
if rm = rmDefault then exit 

635 
else if rm = rmRightEye then d:= d; 

636 
stereoDepth:= stereoDepth + d; 

637 
glMatrixMode(GL_PROJECTION); 

638 
glTranslatef(d, 0, 0); 

639 
glMatrixMode(GL_MODELVIEW) 

640 
end; 

641 

642 
procedure ResetDepth(rm: TRenderMode); 

643 
begin 

644 
if rm = rmDefault then exit; 

645 
glMatrixMode(GL_PROJECTION); 

646 
glTranslatef(stereoDepth, 0, 0); 

647 
glMatrixMode(GL_MODELVIEW); 

648 
stereoDepth:= 0; 

649 
end; 

650 

651 
procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); 

652 
var i, t: LongInt; 

653 
r: TSDL_Rect; 

654 
tdx, tdy: Double; 

655 
grp: TCapGroup; 

656 
s: string[15]; 

657 
highlight: Boolean; 

658 
offset, offsetX, offsetY, screenBottom: LongInt; 

659 
scale: GLfloat; 

660 
VertexBuffer: array [0..3] of TVertex2f; 

661 
begin 

3611  662 
if (cReducedQuality and rqNoBackground) = 0 then 
1812  663 
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

664 
// 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

665 
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

666 
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

667 
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

668 
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

669 
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

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

671 

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

672 
// background 
3688  673 
ChangeDepth(RM, cStereo_Sky); 
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

674 
DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset); 
3688  675 
ChangeDepth(RM, cStereo_Horizon); 
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

676 
DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset); 
3611  677 
end; 
4  678 

3611  679 
DrawVisualGears(0); 
680 

681 
if (cReducedQuality and rq2DWater) = 0 then 

682 
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

683 
// 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

684 
DrawWater(255, SkyOffset); 
3688  685 
ChangeDepth(RM, cStereo_Water); 
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

686 
DrawWaves( 1, 0  WorldDx div 32,  cWaveHeight + offsetY div 35, 64); 
3688  687 
ChangeDepth(RM, cStereo_Water); 
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

688 
DrawWaves( 1, 25 + WorldDx div 25,  cWaveHeight + offsetY div 38, 48); 
3688  689 
ChangeDepth(RM, cStereo_Water); 
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

690 
DrawWaves( 1, 75  WorldDx div 19,  cWaveHeight + offsetY div 45, 32); 
3688  691 
ChangeDepth(RM, cStereo_Water); 
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

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

694 
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

695 
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

696 
DrawWaves(1, 100,  (cWaveHeight + (cWaveHeight shr 1)), 0); 
4  697 

3611  698 
DrawLand(WorldDx, WorldDy); 
1911  699 

3611  700 
DrawWater(255, 0); 
4  701 

1660  702 
// Attack bar 
3611  703 
if CurrentTeam <> nil then 
704 
case AttackBar of 

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

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

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

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

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

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

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

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

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

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

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

716 
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

717 
DrawSprite(sprPower, 
3580  718 
hwRound(Gear^.X) + GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Gear^.dX), Gear^.Angle) + round(WorldDx + tdx * (24 + i * 2))  16, 
719 
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

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

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

722 
end; 
1660  723 

3611  724 
DrawVisualGears(1); 
2713  725 

3611  726 
DrawGears; 
4  727 

3611  728 
DrawVisualGears(2); 
1045  729 

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

731 

3611  732 
// Waves 
3688  733 
ChangeDepth(RM, cStereo_Water); 
3611  734 
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

735 

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

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

737 
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

738 
//DrawWater(cWaterOpacity,  offsetY div 40); 
3688  739 
ChangeDepth(RM, cStereo_Water); 
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

740 
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

741 
DrawWater(cWaterOpacity,  offsetY div 20); 
3688  742 
ChangeDepth(RM, cStereo_Water); 
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

743 
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

744 
DrawWater(cWaterOpacity,  offsetY div 10); 
3688  745 
ChangeDepth(RM, cStereo_Water); 
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

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

748 
end 
3611  749 
else 
750 
DrawWaves(1, 50,  (cWaveHeight shr 1), 0); 

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

751 

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

752 

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

754 
// Target 
3104  755 
if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then 
756 
begin 

757 
with PHedgehog(CurrentHedgehog)^ do 

758 
begin 

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

761 
else 

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

764 
end; 

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

766 

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

2724  769 

770 

771 
// Turn time 

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

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

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

776 
{$ENDIF} 
3463  777 
offsetY:= cOffsetY; 
4  778 
if TurnTimeLeft <> 0 then 
779 
begin 

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

781 
if i>99 then t:= 112 

782 
else if i>9 then t:= 96 

783 
else t:= 80; 

3463  784 
DrawSprite(sprFrame, (cScreenWidth shr 1) + t + offsetY, cScreenHeight  offsetX, 1); 
4  785 
while i > 0 do 
786 
begin 

787 
dec(t, 32); 

3463  788 
DrawSprite(sprBigDigit, (cScreenWidth shr 1) + t + offsetY, cScreenHeight  offsetX, i mod 10); 
4  789 
i:= i div 10 
790 
end; 

3463  791 
DrawSprite(sprFrame, (cScreenWidth shr 1) + t  4 + offsetY, cScreenHeight  offsetX, 0); 
4  792 
end; 
79  793 

2567  794 
{$IFNDEF IPHONEOS} 
2428  795 
// Timetrial 
796 
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

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

798 
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

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

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

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

803 
// 1 ms 
2428  804 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
805 
dec(t, 32); 

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

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

807 
// 10 ms 
2428  808 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
809 
dec(t, 32); 

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

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

811 
// 100 ms 
2428  812 
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

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

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

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

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

818 
// 1 s 
2428  819 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
820 
dec(t, 32); 

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

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

822 
// 10s 
2428  823 
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

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

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

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

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

829 
// 1 m 
2428  830 
DrawSprite(sprBigDigit, cScreenWidth div 2 + t, 8, i mod 10); 
831 
dec(t, 32); 

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

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

833 
// 10 m 
2428  834 
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

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

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

837 
end; 
2567  838 
{$ENDIF} 
839 

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

842 
offset:= 40; 
2567  843 
{$ELSE} 
2724  844 
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48 
845 
else offset:= 8; 

2567  846 
{$ENDIF} 
2428  847 

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

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

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

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

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

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

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

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

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

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

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

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

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

860 
end; 
4  861 

47  862 
// Teams Healths 
547  863 
for t:= 0 to Pred(TeamsCount) do 
864 
with TeamsArray[t]^ do 

47  865 
begin 
2839  866 
highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); 
867 

2747  868 
if highlight then 
3445  869 
Tint(Clan^.Color); 
2839  870 

871 
// draw name 

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

873 

874 
// draw flag 

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

876 

877 
// draw health bar 

690  878 
r.x:= 0; 
879 
r.y:= 0; 

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

881 
r.h:= HealthTex^.h; 
2747  882 
DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex); 
690  883 

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

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

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

890 
if highlight then 

891 
begin 

3390  892 
Tint($FF, $FF, $FF, $FF); 
690  893 

2839  894 
// draw name 
2747  895 
r.x:= 2; 
896 
r.y:= 2; 

2839  897 
r.w:= NameTagTex^.w  4; 
898 
r.h:= NameTagTex^.h  4; 

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

900 
// draw flag 

2747  901 
r.w:= 22; 
902 
r.h:= 15; 

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

2839  904 
// draw health bar 
905 
r.w:= TeamHealthBarWidth + 1; 

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

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

2747  908 
end; 
47  909 
end; 
910 

5  911 
// Lag alert 
2567  912 
if isInLag then DrawSprite(sprLag, 32  (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12); 
4  913 

5  914 
// Wind bar 
2567  915 
{$IFDEF IPHONEOS} 
3405  916 
offsetX:= cScreenHeight  13; 
917 
offsetY:= (cScreenWidth shr 1) + 74; 

2567  918 
{$ELSE} 
3405  919 
offsetX:= 30; 
920 
offsetY:= 180; 

2567  921 
{$ENDIF} 
3405  922 
DrawSprite(sprWindBar, (cScreenWidth shr 1)  offsetY, cScreenHeight  offsetX, 0); 
923 
if WindBarWidth > 0 then 

924 
begin 

925 
{$WARNINGS OFF} 

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

927 
{$WARNINGS ON} 

928 
r.y:= 0; 

929 
r.w:= WindBarWidth; 

930 
r.h:= 13; 

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

932 
end 

933 
else 

934 
if WindBarWidth < 0 then 

935 
begin 

936 
{$WARNINGS OFF} 

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

940 
r.w:=  WindBarWidth; 

941 
r.h:= 13; 

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

943 
end; 

5  944 

161  945 
// AmmoMenu 
3434  946 
if (AMxShift < AMWidth) or bShowAmmoMenu then ShowAmmoMenu; 
161  947 

2287  948 
// Cursor 
949 
if isCursorVisible and bShowAmmoMenu then 

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

942  951 

2287  952 
DrawChat; 
4  953 

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

956 

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

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

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

960 
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

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

962 
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

963 
end; 
2786  964 

2724  965 
// fps 
966 
{$IFDEF IPHONEOS} 

3463  967 
offsetX:= 8; 
2724  968 
{$ELSE} 
3463  969 
offsetX:= 10; 
2724  970 
{$ENDIF} 
3463  971 
offsetY:= cOffsetY; 
3692  972 

973 
// don't increment fps when drawing the right frame 

974 
if (RM = rmDefault) or (RM = rmLeftEye) then 

975 
begin 

976 
inc(Frames); 

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

977 

3692  978 
if cShowFPS or (GameType = gmtDemo) then 
979 
inc(CountTicks, Lag); 

980 
if (GameType = gmtDemo) and (CountTicks >= 1000) then 

981 
begin 

982 
i:=GameTicks div 1000; 

983 
t:= i mod 60; 

984 
s:= inttostr(t); 

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

986 
i:= i div 60; 

987 
t:= i mod 60; 

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

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

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

3407  991 

3692  992 
if timeTexture <> nil then 
993 
FreeTexture(timeTexture); 

994 
timeTexture:= nil; 

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

995 

3692  996 
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); 
997 
tmpSurface:= doSurfaceConversion(tmpSurface); 

998 
timeTexture:= Surface2Tex(tmpSurface, false); 

999 
SDL_FreeSurface(tmpSurface) 

1000 
end; 

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

1001 

3692  1002 
if timeTexture <> nil then 
1003 
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

1004 

3692  1005 
if cShowFPS then 
1006 
begin 

1007 
if CountTicks >= 1000 then 

1008 
begin 

1009 
FPS:= Frames; 

1010 
Frames:= 0; 

1011 
CountTicks:= 0; 

1012 
s:= inttostr(FPS) + ' fps'; 

1013 
if fpsTexture <> nil then 

1014 
FreeTexture(fpsTexture); 

1015 
fpsTexture:= nil; 

1016 
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); 

1017 
tmpSurface:= doSurfaceConversion(tmpSurface); 

1018 
fpsTexture:= Surface2Tex(tmpSurface, false); 

1019 
SDL_FreeSurface(tmpSurface) 

1020 
end; 

1021 
if fpsTexture <> nil then 

1022 
DrawTexture((cScreenWidth shr 1)  60  offsetY, offsetX, fpsTexture); 

1023 
end; 

174  1024 

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

1026 

3692  1027 
// lag warning (?) 
1028 
inc(SoundTimerTicks, Lag); 

1029 
end; 

1030 

174  1031 
if SoundTimerTicks >= 50 then 
1032 
begin 

1033 
SoundTimerTicks:= 0; 

1034 
if cVolumeDelta <> 0 then 

1035 
begin 

1036 
str(ChangeVolume(cVolumeDelta), s); 

2619  1037 
AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) 
174  1038 
end 
756  1039 
end; 
1040 

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

1043 

3107  1044 
if ScreenFade <> sfNone then 
1045 
begin 

1046 
if not isFirstFrame then 

1047 
case ScreenFade of 

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

1049 
inc(ScreenFadeValue, Lag * ScreenFadeSpeed) 

1050 
else 

3123  1051 
ScreenFadeValue:= sfMax; 
3107  1052 
sfFromBlack, sfFromWhite: if ScreenFadeValue  Lag * ScreenFadeSpeed > 0 then 
1053 
dec(ScreenFadeValue, Lag * ScreenFadeSpeed) 

1054 
else 

3123  1055 
ScreenFadeValue:= 0; 
3107  1056 
end; 
1057 
if ScreenFade <> sfNone then 

1058 
begin 

1059 
case ScreenFade of 

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

3107  1062 
end; 
3113  1063 

1064 
VertexBuffer[0].X:= cScreenWidth; 

1065 
VertexBuffer[0].Y:= cScreenHeight; 

1066 
VertexBuffer[1].X:= cScreenWidth; 

1067 
VertexBuffer[1].Y:= 0; 

1068 
VertexBuffer[2].X:= cScreenWidth; 

1069 
VertexBuffer[2].Y:= 0; 

1070 
VertexBuffer[3].X:= cScreenWidth; 

1071 
VertexBuffer[3].Y:= cScreenHeight; 

1072 

3376  1073 
glDisable(GL_TEXTURE_2D); 
3641  1074 

3113  1075 
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); 
1076 
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); 

3641  1077 

3376  1078 
glEnable(GL_TEXTURE_2D); 
3390  1079 
Tint($FF, $FF, $FF, $FF); 
3123  1080 
if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone 
3107  1081 
end 
1082 
end; 

1083 

3123  1084 
SetScale(zoom); 
1085 

1086 
// Cursor 

1087 
if isCursorVisible then 

1088 
begin 

1089 
if not bShowAmmoMenu then 

3204  1090 
begin 
3123  1091 
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

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

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

1096 
if PosCount > 1 then 

3204  1097 
DrawSprite(PosSprite, CursorPoint.X  (SpritesData[PosSprite].Width shr 1), cScreenHeight  CursorPoint.Y  (SpritesData[PosSprite].Height shr 1),i); 
3123  1098 
end; 
3204  1099 
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight  CursorPoint.Y, (RealTicks shr 6) mod 8) 
1100 
end 

3123  1101 
end; 
3107  1102 
isFirstFrame:= false 
4  1103 
end; 
1104 

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

1108 
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

1109 
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

1110 
Captions[Group].Tex:= nil; 
2142  1111 

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

1112 
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

1113 

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

1114 
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

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

1116 
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

1117 
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

1118 
end; 
4  1119 
end; 
1120 

79  1121 
procedure MoveCamera; 
2428  1122 
var EdgesDist, wdy: LongInt; 
3638
33ee433749ba
touch overlay reworked, improvements to zoom and confirmation
koda
parents:
3629
diff
changeset

1123 
PrevSentPointTime: LongWord = 0; 
4  1124 
begin 
3551  1125 
{$IFNDEF IPHONEOS} 
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset

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

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

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

1130 
CursorPoint.Y:= cScreenHeight  CursorPoint.Y; 
3551  1131 
end; 
1132 
{$ENDIF} 

678  1133 

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

1134 
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

1135 
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

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

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

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

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

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

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

1142 
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

1143 
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

1144 
end; 
4  1145 

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

1148 

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

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

1152 
begin 
3463  1153 
{$IFDEF IPHONEOS} 
3434  1154 
if CursorPoint.X < cScreenWidth div 2 + AMxShift  AMWidth then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMWidth; 
1155 
if CursorPoint.X > cScreenWidth div 2 + AMxShift  AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift  AMxOffset; 

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

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

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

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

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

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

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

1165 
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

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

1167 
end; 
162  1168 

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

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

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

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

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

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

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

1176 
end; 
351  1177 

4  1178 
if isCursorVisible or (FollowGear <> nil) then 
1179 
begin 

284  1180 
if isCursorVisible then EdgesDist:= cCursorEdgesDist 
1181 
else EdgesDist:= cGearScrEdgesDist; 

2197  1182 
if CursorPoint.X <  cScreenWidth div 2 + EdgesDist then 
4  1183 
begin 
2197  1184 
WorldDx:= WorldDx  CursorPoint.X  cScreenWidth div 2 + EdgesDist; 
1185 
CursorPoint.X:=  cScreenWidth div 2 + EdgesDist 

4  1186 
end else 
2197  1187 
if CursorPoint.X > cScreenWidth div 2  EdgesDist then 
4  1188 
begin 
2197  1189 
WorldDx:= WorldDx  CursorPoint.X + cScreenWidth div 2  EdgesDist; 
2198  1190 
CursorPoint.X:= cScreenWidth div 2  EdgesDist 
4  1191 
end; 
284  1192 
if CursorPoint.Y < EdgesDist then 
4  1193 
begin 
2197  1194 
WorldDy:= WorldDy + CursorPoint.Y  EdgesDist; 
284  1195 
CursorPoint.Y:= EdgesDist 
4  1196 
end else 
284  1197 
if CursorPoint.Y > cScreenHeight  EdgesDist then 
4  1198 
begin 
2197  1199 
WorldDy:= WorldDy + CursorPoint.Y  cScreenHeight + EdgesDist; 
284  1200 
CursorPoint.Y:= cScreenHeight  EdgesDist 
4  1201 
end; 
1202 
end else 

308  1203 
if cHasFocus then 
1204 
begin 

70  1205 
WorldDx:= WorldDx  CursorPoint.X + prevPoint.X; 
2197  1206 
WorldDy:= WorldDy + CursorPoint.Y  prevPoint.Y; 
2162  1207 
CursorPoint.X:= 0; 
1208 
CursorPoint.Y:= cScreenHeight div 2; 

308  1209 
end; 
351  1210 

4  1211 
prevPoint:= CursorPoint; 
2567  1212 
if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight  CursorPoint.Y); 
1760  1213 
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; 
2375  1214 
if WorldDy < wdy then WorldDy:= wdy; 
2426  1215 
if WorldDx <  LAND_WIDTH  1024 then WorldDx:=  LAND_WIDTH  1024; 
1216 
if WorldDx > 1024 then WorldDx:= 1024; 

4  1217 
end; 
1218 

2905  1219 
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); 
2786  1220 
var r: TSDL_Rect; 
1221 
begin 

1222 
r.w:= 32; 

1223 
r.h:= 32; 

1224 

1225 
if time = 0 then time:= 5000; 

1226 
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

1227 
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

1228 
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

1229 
missionTex:= nil; 
2786  1230 

1231 
if icon > 1 then 

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

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

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

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

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

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

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

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

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

1241 
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

1242 
end; 
2786  1243 
end; 
1244 

1245 
procedure HideMission; 

1246 
begin 

3045  1247 
missionTimer:= 0; 
1248 
if missionTex <> nil then FreeTexture(missionTex); 

2786  1249 
end; 
1250 

3032  1251 
procedure ShakeCamera(amount: LongWord); 
1252 
begin 

1253 
amount:= max(1, amount); 

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

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

1256 
end; 

1257 

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

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

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

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

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

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

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

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

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

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

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

1269 

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

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

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

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

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

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

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

1278 

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

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

1280 
end; 
4  1281 

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

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

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

1285 

4  1286 
end. 