1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../../shared/a_modes.inc}
20 procedure r_Game_Load
;
21 procedure r_Game_Free
;
23 procedure r_Game_LoadTextures
;
24 procedure r_Game_FreeTextures
;
26 procedure r_Game_Draw
;
27 procedure r_Game_DrawLoadingStat
;
28 procedure r_Game_DrawMenuBackground (tex
: AnsiString);
30 procedure r_Game_SetupScreenSize
;
35 gMenuSmallFont
: DWORD
;
40 {$INCLUDE ../nogl/noGLuses.inc}
41 {$IFDEF ENABLE_HOLMES}
50 {$IFDEF ENABLE_CORPSES}
53 SysUtils
, Classes
, Math
,
54 g_base
, g_basic
, r_graphics
,
56 MAPDEF
, xprofiler
, utils
, wadreader
, CONFIG
,
58 g_language
, g_console
, g_triggers
, g_player
, g_options
, g_monsters
, g_map
, g_panel
,
59 g_items
, g_weapons
, g_phys
, g_net
, g_netmaster
,
60 g_game
, r_console
, r_items
, r_map
, r_monsters
, r_weapons
, r_netmaster
, r_player
, r_textures
,
65 profileFrameDraw
: TProfiler
= nil;
72 BackID
: DWORD
= DWORD(-1);
75 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
87 wad
:= TWADFile
.Create
;
88 if wad
.ReadFile(GameWAD
) then
89 wad
.GetResource('FONTS/'+cfgres
, cfgdata
, cfglen
);
94 g_Texture_CreateWADEx('FONT_STD', GameWAD
+':FONTS\'+texture
);
96 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
97 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
98 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
99 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
101 if g_Texture_Get('FONT_STD', ID
) then
102 e_TextureFontBuild(ID
, FontID
, cwdt
, chgt
, spc
);
107 if cfglen
<> 0 then FreeMem(cfgdata
);
110 procedure LoadFont(txtres
, fntres
: string; var FontID
: DWORD
);
116 cfgdata
, fntdata
: Pointer;
117 cfglen
, fntlen
: Integer;
125 wad
:= TWADFile
.Create
;
126 if wad
.ReadFile(GameWAD
) then
128 wad
.GetResource('FONTS/'+txtres
, cfgdata
, cfglen
);
129 wad
.GetResource('FONTS/'+fntres
, fntdata
, fntlen
);
135 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
136 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
137 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
139 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
140 FontID
:= e_CharFont_Create(spc
);
144 chrwidth
:= config
.ReadInt(IntToStr(a
), 'Width', 0);
145 if chrwidth
= 0 then Continue
;
147 if e_CreateTextureMemEx(fntdata
, fntlen
, CharID
, cwdt
*(a
mod 16), chgt
*(a
div 16),
149 e_CharFont_AddChar(FontID
, CharID
, Chr(a
), chrwidth
);
155 if cfglen
<> 0 then FreeMem(cfgdata
);
156 if fntlen
<> 0 then FreeMem(fntdata
);
159 procedure r_Game_Load
;
167 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+ ':TEXTURES\TITLE', gTextureFilter
);
168 g_Texture_CreateWADEx('INTER', GameWAD
+ ':TEXTURES\INTER', gTextureFilter
);
169 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+ ':TEXTURES\ENDGAME_EN', gTextureFilter
);
170 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+ ':TEXTURES\ENDGAME_RU', gTextureFilter
);
171 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
172 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
173 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
175 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+ ':TEXTURES\NOTEXTURE');
176 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+ ':TEXTURES\HUD');
177 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+ ':TEXTURES\AIRBAR');
178 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+ ':TEXTURES\JETBAR');
179 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+ ':TEXTURES\HUDBG');
180 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+ ':TEXTURES\ARMORHUD');
181 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+ ':TEXTURES\FLAGHUD_R_BASE');
182 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+ ':TEXTURES\FLAGHUD_R_STOLEN');
183 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+ ':TEXTURES\FLAGHUD_R_DROP');
184 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+ ':TEXTURES\FLAGHUD_B_BASE');
185 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+ ':TEXTURES\FLAGHUD_B_STOLEN');
186 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+ ':TEXTURES\FLAGHUD_B_DROP');
187 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+ ':TEXTURES\TALKBUBBLE');
188 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+ ':TEXTURES\PENTA');
189 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+ ':TEXTURES\PLRIND');
192 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
193 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
194 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
195 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
198 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
199 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
200 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
201 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
202 if (wl
> 0) and (hl
> 0) and (wr
> 0) and (hr
= hl
) and (wb
> 0) and (hb
= hl
) and (wm
> 0) and (hm
> 0) and (hm
<= hl
) then
211 procedure r_Game_Free
;
213 g_Texture_Delete('NOTEXTURE');
214 g_Texture_Delete('TEXTURE_PLAYER_HUD');
215 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
216 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
217 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
218 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
219 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
220 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
221 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
222 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
223 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
224 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
227 procedure r_Game_SetupScreenSize
;
229 RES_FACTOR
= 4.0 / 3.0;
235 // Размер экранов игроков:
236 gPlayerScreenSize
.X
:= gScreenWidth
-196;
237 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
238 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
240 gPlayerScreenSize
.Y
:= gScreenHeight
;
242 // Размер заднего плана:
243 if BackID
<> DWORD(-1) then
246 if (gScreenWidth
*s
> gMapInfo
.Width
) or
247 (gScreenHeight
*s
> gMapInfo
.Height
) then
249 gBackSize
.X
:= gScreenWidth
;
250 gBackSize
.Y
:= gScreenHeight
;
254 e_GetTextureSize(BackID
, @bw
, @bh
);
255 rf
:= Single(bw
) / Single(bh
);
256 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
257 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
258 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
259 if (s
< 1.0) then s
:= 1.0;
260 gBackSize
.X
:= Round(bw
*s
);
261 gBackSize
.Y
:= Round(bh
*s
);
266 procedure r_Game_LoadTextures
;
268 g_Texture_CreateWADEx('TEXTURE_endpic', EndPicPath
, gTextureFilter
);
269 if gMapInfo
.SkyFullName
<> '' then
270 g_Texture_CreateWAD(BackID
, gMapInfo
.SkyFullName
, gTextureFilter
);
271 r_Game_SetupScreenSize
;
274 procedure r_Game_FreeTextures
;
276 g_Texture_Delete('TEXTURE_endpic');
277 if BackID
<> DWORD(-1) then
281 e_DeleteTexture(BackID
);
286 procedure r_Map_DrawBack(dx
, dy
: Integer);
288 if gDrawBackGround
and (BackID
<> DWORD(-1)) then
289 e_DrawSize(BackID
, dx
, dy
, 0, False, False, gBackSize
.X
, gBackSize
.Y
)
291 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
294 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
301 if gPlayers
= nil then
303 for a
:= Low(gPlayers
) to High(gPlayers
) do
304 if IsActivePlayer(gPlayers
[a
]) then
306 if gPlayers
[a
].UID
<> ID
then
308 Result
:= gPlayers
[a
];
313 function calcProfilesHeight (prof
: TProfiler
): Integer;
316 if (prof
= nil) then exit
;
317 if (length(prof
.bars
) = 0) then exit
;
318 result
:= length(prof
.bars
)*(16+2);
322 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
329 if (prof
= nil) then exit
;
331 if (length(prof
.bars
) = 0) then exit
;
333 hgt
:= calcProfilesHeight(prof
);
334 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
335 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
337 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
338 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
339 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
342 for ii
:= 0 to High(prof
.bars
) do
344 e_TextureFontPrintEx(x
+2+4*prof
.bars
[ii
].level
, yy
, Format('%s: %d', [prof
.bars
[ii
].name
, prof
.bars
[ii
].value
]), gStdFont
, 255, 255, 0, 1, false);
350 procedure drawTime(X
, Y
: Integer); inline;
352 e_TextureFontPrint(x
, y
, Format('%d:%.2d:%.2d', [gTime
div 1000 div 3600, (gTime
div 1000 div 60) mod 60, gTime
div 1000 mod 60]), gStdFont
);
355 procedure DrawStat();
357 pc
, x
, y
, w
, h
: Integer;
358 w1
, w2
, w3
, w4
: Integer;
360 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
363 stat
: TPlayerStatArray
;
371 pc
:= g_Player_GetCount
;
372 e_TextureFontGetSize(gStdFont
, cw
, ch
);
374 w
:= gScreenWidth
-(gScreenWidth
div 5);
375 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
378 h
:= 40+ch
*5+(ch
+8)*pc
;
379 x
:= (gScreenWidth
div 2)-(w
div 2);
380 y
:= (gScreenHeight
div 2)-(h
div 2);
382 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
383 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
385 drawTime(x
+w
-78, y
+8);
387 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
388 map
:= g_ExtractFileName(gMapInfo
.Map
);
389 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
391 case gGameSettings
.GameMode
of
394 if gGameSettings
.MaxLives
= 0 then
397 s1
:= _lc
[I_GAME_LMS
];
398 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
399 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
404 if gGameSettings
.MaxLives
= 0 then
405 s1
:= _lc
[I_GAME_TDM
]
407 s1
:= _lc
[I_GAME_TLMS
];
408 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.ScoreLimit
]);
409 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
414 s1
:= _lc
[I_GAME_CTF
];
415 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.ScoreLimit
]);
416 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
421 if gGameSettings
.MaxLives
= 0 then
422 s1
:= _lc
[I_GAME_COOP
]
424 s1
:= _lc
[I_GAME_SURV
];
425 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
426 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
436 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
438 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
440 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
442 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
443 gStdFont
, 200, 200, 200, 1);
445 if NetMode
= NET_SERVER
then
446 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
448 if NetMode
= NET_CLIENT
then
449 e_TextureFontPrintEx(x
+8, y
+ 8,
450 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
454 stat
:= g_Player_GetStats();
457 w2
:= (w
-16) div 6 + 48; // ширина 2 столбца
458 w3
:= (w
-16) div 6; // ширина 3 и 4 столбцов
460 w1
:= w
-16-w2
-w3
-w4
; // оставшееся пространство - для цвета и имени игрока
462 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
466 for a
:= TEAM_RED
to TEAM_BLUE
do
470 s1
:= _lc
[I_GAME_TEAM_RED
];
477 s1
:= _lc
[I_GAME_TEAM_BLUE
];
483 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
484 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Score
),
485 gStdFont
, r
, g
, b
, 1);
487 _y
:= _y
+ch
+(ch
div 4);
488 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
491 for aa
:= 0 to High(stat
) do
492 if stat
[aa
].Team
= a
then
508 namestr
:= Format('[%5d] %s', [UID
, Name
])
512 e_TextureFontPrintEx(x
+16, _y
, namestr
, gStdFont
, rr
, gg
, bb
, 1);
514 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
516 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
518 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
525 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
528 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
529 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
530 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
531 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
534 for aa
:= 0 to High(stat
) do
548 namestr
:= Format('[%5d] %s', [UID
, Name
])
552 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
553 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
555 e_TextureFontPrintEx(x
+16+16+8, _y
+4, namestr
, gStdFont
, r
, g
, 0, 1);
557 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
559 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
561 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
567 procedure DrawCustomStat();
573 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
574 s1
, s2
, topstr
: String;
576 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
580 if g_Console_Action(ACTION_SCORES
) then
582 if not gStatsPressed
then
584 gStatsOff
:= not gStatsOff
;
585 gStatsPressed
:= True;
589 gStatsPressed
:= False;
593 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
594 w
:= (Length(s1
) * ww2
) div 2;
595 x
:= gScreenWidth
div 2 - w
;
597 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
601 if (gGameSettings
.GameMode
= GM_COOP
) then
603 if gMissionFailed
then
604 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
606 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
609 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
611 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
612 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
616 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
617 if not gChatShow
then
618 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
619 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
622 if g_Game_IsClient
then
623 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
625 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
626 if not gChatShow
then
627 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
628 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
633 w
:= gScreenWidth
-x
*2;
639 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
640 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
642 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
644 case CustomStat
.GameMode
of
647 if gGameSettings
.MaxLives
= 0 then
650 s1
:= _lc
[I_GAME_LMS
];
654 if gGameSettings
.MaxLives
= 0 then
655 s1
:= _lc
[I_GAME_TDM
]
657 s1
:= _lc
[I_GAME_TLMS
];
659 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
662 if gGameSettings
.MaxLives
= 0 then
663 s1
:= _lc
[I_GAME_COOP
]
665 s1
:= _lc
[I_GAME_SURV
];
671 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
675 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
676 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
679 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
680 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
681 (CustomStat
.GameTime
div 1000 div 60) mod 60,
682 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
684 pc
:= Length(CustomStat
.PlayerStat
);
687 if CustomStat
.GameMode
= GM_COOP
then
689 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
691 s2
:= _lc
[I_GAME_MONSTERS
];
692 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
693 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
695 s2
:= _lc
[I_GAME_SECRETS
];
696 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
697 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
700 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
702 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
703 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
704 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
706 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
707 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
708 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
712 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
717 if TeamStat
[TEAM_RED
].Score
> TeamStat
[TEAM_BLUE
].Score
then s1
:= _lc
[I_GAME_WIN_RED
]
718 else if TeamStat
[TEAM_BLUE
].Score
> TeamStat
[TEAM_RED
].Score
then s1
:= _lc
[I_GAME_WIN_BLUE
]
719 else s1
:= _lc
[I_GAME_WIN_DRAW
];
721 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
724 for t
:= TEAM_RED
to TEAM_BLUE
do
728 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
729 gStdFont
, 255, 0, 0, 1);
730 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Score
),
731 gStdFont
, 255, 0, 0, 1);
738 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
739 gStdFont
, 0, 0, 255, 1);
740 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Score
),
741 gStdFont
, 0, 0, 255, 1);
747 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
750 for p
:= 0 to High(CustomStat
.PlayerStat
) do
751 if CustomStat
.PlayerStat
[p
].Team
= t
then
752 with CustomStat
.PlayerStat
[p
] do
766 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
767 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
769 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
770 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
771 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
778 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
781 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
782 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
783 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
786 for p
:= 0 to High(CustomStat
.PlayerStat
) do
787 with CustomStat
.PlayerStat
[p
] do
789 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
796 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
797 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
799 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
800 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
801 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
806 // HACK: take stats screenshot immediately after the first frame of the stats showing
807 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
810 g_TakeScreenShot('stats/' + StatFilename
);
812 StatShotDone
:= True;
816 procedure DrawSingleStat();
818 tm
, key_x
, val_x
, y
: Integer;
822 procedure player_stat(n
: Integer);
828 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
829 s2
:= Format(' %d', [gTotalMonsters
]);
831 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
832 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
833 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
834 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
836 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
837 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
839 // "Kills-per-minute: ##.#":
840 s1
:= _lc
[I_MENU_INTER_KPM
];
842 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
844 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
845 s2
:= Format(' %.1f', [kpm
]);
847 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
848 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
850 // "Secrets found: # / #":
851 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
852 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
854 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
855 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
856 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
857 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
859 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
860 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
865 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
866 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
868 // Определяем координаты выравнивания по самой длинной строке:
869 s1
:= _lc
[I_MENU_INTER_KPM
];
870 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
873 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
875 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
879 tm
:= SingleStat
.GameTime
div 1000;
880 s1
:= _lc
[I_MENU_INTER_TIME
];
881 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
883 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
884 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
886 if SingleStat
.TwoPlayers
then
889 s1
:= _lc
[I_MENU_PLAYER_1
];
890 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
891 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
893 // Статистика первого игрока:
898 s1
:= _lc
[I_MENU_PLAYER_2
];
899 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
900 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
902 // Статистика второго игрока:
908 // Статистика первого игрока:
914 procedure r_Game_DrawLoadingStat
;
915 procedure drawRect (x
, y
, w
, h
: Integer);
917 if (w
< 1) or (h
< 1) then exit
;
919 glVertex2f(x
+0.375, y
+0.375);
920 glVertex2f(x
+w
+0.375, y
+0.375);
921 glVertex2f(x
+w
+0.375, y
+h
+0.375);
922 glVertex2f(x
+0.375, y
+h
+0.375);
926 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
928 rectW
, rectH
: Integer;
935 idl
, idr
, idb
, idm
: LongWord;
939 if (total
< 1) then exit
;
940 if (cur
< 1) then exit
; // don't blink
941 if (not washere
) and (cur
>= total
) then exit
; // don't blink
942 //if (cur < 0) then cur := 0;
943 //if (cur > total) then cur := total;
948 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
949 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
950 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
951 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
952 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
953 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
954 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
955 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
957 //rectW := gScreenWidth-360;
958 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
961 x0
:= (gScreenWidth
-rectW
) div 2;
962 y0
:= gScreenHeight
-rectH
-64;
963 if (y0
< 2) then y0
:= 2;
965 glEnable(GL_SCISSOR_TEST
);
968 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
969 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
970 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
973 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
975 while (f
< x0
+rectW
) do
977 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
982 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
983 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
986 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
987 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
991 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
997 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
1001 rectW
:= gScreenWidth
-64;
1004 x0
:= (gScreenWidth
-rectW
) div 2;
1005 y0
:= gScreenHeight
-rectH
-64;
1006 if (y0
< 2) then y0
:= 2;
1008 glDisable(GL_BLEND
);
1009 glDisable(GL_TEXTURE_2D
);
1011 //glClearColor(0, 0, 0, 0);
1012 //glClear(GL_COLOR_BUFFER_BIT);
1014 glColor4ub(127, 127, 127, 255);
1015 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
1017 glColor4ub(0, 0, 0, 255);
1018 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
1020 glColor4ub(127, 127, 127, 255);
1021 wdt
:= rectW
*cur
div total
;
1022 if (wdt
> rectW
) then wdt
:= rectW
;
1023 drawRect(x0
, y0
, wdt
, rectH
);
1032 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
1034 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
1035 yy
:= (gScreenHeight
div 3);
1036 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
1037 xx
:= (gScreenWidth
div 3);
1041 for i
:= 0 to NextMsg
-1 do
1043 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
1044 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
1048 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
1049 yy
:= yy
+ LOADING_INTERLINE
;
1050 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
1055 procedure r_Game_DrawMenuBackground (tex
: AnsiString);
1061 if g_Texture_Get(tex
, ID
) then
1063 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
1064 e_GetTextureSize(ID
, @w
, @h
);
1066 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
1068 w
:= trunc(w
* (gScreenHeight
/ h
));
1069 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
1071 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
1074 procedure DrawMinimap(p
: TPlayer
; RenderRect
: TRect
);
1076 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
1078 function monDraw (mon
: TMonster
): Boolean;
1080 result
:= false; // don't stop
1085 // Левый верхний угол
1086 aX
:= Obj
.X
div ScaleSz
+ 1;
1087 aY
:= Obj
.Y
div ScaleSz
+ 1;
1089 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
1090 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
1091 // Правый нижний угол
1092 aX2
:= aX
+ aX2
- 1;
1093 aY2
:= aY
+ aY2
- 1;
1094 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
1100 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
1101 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
1104 // Сколько пикселов карты в 1 пикселе мини-карты:
1105 ScaleSz
:= 16 div Scale
;
1106 // Размеры мини-карты:
1107 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
1108 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
1110 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
1112 if gWalls
<> nil then
1115 for a
:= 0 to High(gWalls
) do
1117 if PanelType
<> 0 then
1119 // Левый верхний угол:
1120 aX
:= X
div ScaleSz
;
1121 aY
:= Y
div ScaleSz
;
1123 aX2
:= max(Width
div ScaleSz
, 1);
1124 aY2
:= max(Height
div ScaleSz
, 1);
1125 // Правый нижний угол:
1126 aX2
:= aX
+ aX2
- 1;
1127 aY2
:= aY
+ aY2
- 1;
1130 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
1131 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
1132 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
1136 if gSteps
<> nil then
1139 for a
:= 0 to High(gSteps
) do
1141 if PanelType
<> 0 then
1143 // Левый верхний угол:
1144 aX
:= X
div ScaleSz
;
1145 aY
:= Y
div ScaleSz
;
1147 aX2
:= max(Width
div ScaleSz
, 1);
1148 aY2
:= max(Height
div ScaleSz
, 1);
1149 // Правый нижний угол:
1150 aX2
:= aX
+ aX2
- 1;
1151 aY2
:= aY
+ aY2
- 1;
1153 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
1156 if gLifts
<> nil then
1159 for a
:= 0 to High(gLifts
) do
1161 if PanelType
<> 0 then
1163 // Левый верхний угол:
1164 aX
:= X
div ScaleSz
;
1165 aY
:= Y
div ScaleSz
;
1167 aX2
:= max(Width
div ScaleSz
, 1);
1168 aY2
:= max(Height
div ScaleSz
, 1);
1169 // Правый нижний угол:
1170 aX2
:= aX
+ aX2
- 1;
1171 aY2
:= aY
+ aY2
- 1;
1174 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
1175 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
1176 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
1177 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
1181 if gWater
<> nil then
1184 for a
:= 0 to High(gWater
) do
1186 if PanelType
<> 0 then
1188 // Левый верхний угол:
1189 aX
:= X
div ScaleSz
;
1190 aY
:= Y
div ScaleSz
;
1192 aX2
:= max(Width
div ScaleSz
, 1);
1193 aY2
:= max(Height
div ScaleSz
, 1);
1194 // Правый нижний угол:
1195 aX2
:= aX
+ aX2
- 1;
1196 aY2
:= aY
+ aY2
- 1;
1198 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
1201 if gAcid1
<> nil then
1203 // Рисуем кислоту 1:
1204 for a
:= 0 to High(gAcid1
) do
1206 if PanelType
<> 0 then
1208 // Левый верхний угол:
1209 aX
:= X
div ScaleSz
;
1210 aY
:= Y
div ScaleSz
;
1212 aX2
:= max(Width
div ScaleSz
, 1);
1213 aY2
:= max(Height
div ScaleSz
, 1);
1214 // Правый нижний угол:
1215 aX2
:= aX
+ aX2
- 1;
1216 aY2
:= aY
+ aY2
- 1;
1218 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
1221 if gAcid2
<> nil then
1223 // Рисуем кислоту 2:
1224 for a
:= 0 to High(gAcid2
) do
1226 if PanelType
<> 0 then
1228 // Левый верхний угол:
1229 aX
:= X
div ScaleSz
;
1230 aY
:= Y
div ScaleSz
;
1232 aX2
:= max(Width
div ScaleSz
, 1);
1233 aY2
:= max(Height
div ScaleSz
, 1);
1234 // Правый нижний угол:
1235 aX2
:= aX
+ aX2
- 1;
1236 aY2
:= aY
+ aY2
- 1;
1238 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
1241 if gPlayers
<> nil then
1244 for a
:= 0 to High(gPlayers
) do
1245 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
1247 // Левый верхний угол:
1248 aX
:= Obj
.X
div ScaleSz
+ 1;
1249 aY
:= Obj
.Y
div ScaleSz
+ 1;
1251 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
1252 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
1253 // Правый нижний угол:
1254 aX2
:= aX
+ aX2
- 1;
1255 aY2
:= aY
+ aY2
- 1;
1257 if gPlayers
[a
] = p
then
1258 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
1261 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
1262 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
1263 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
1268 g_Mons_ForEach(monDraw
);
1273 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
1275 if not hasAmbient
then exit
;
1276 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
1279 // ////////////////////////////////////////////////////////////////////////// //
1283 function g_Texture_Light (): Integer;
1285 Radius
: Integer = 128;
1293 GetMem(tex
, (Radius
*2)*(Radius
*2)*4);
1295 for y
:= 0 to Radius
*2-1 do
1297 for x
:= 0 to Radius
*2-1 do
1299 dist
:= 1.0-sqrt((x
-Radius
)*(x
-Radius
)+(y
-Radius
)*(y
-Radius
))/Radius
;
1302 tpp
^ := 0; Inc(tpp
);
1303 tpp
^ := 0; Inc(tpp
);
1304 tpp
^ := 0; Inc(tpp
);
1305 tpp
^ := 0; Inc(tpp
);
1309 //tc.setPixel(x, y, Color(cast(int)(dist*255), cast(int)(dist*255), cast(int)(dist*255)));
1310 if (dist
> 0.5) then dist
:= 0.5;
1311 a
:= round(dist
*255);
1312 if (a
< 0) then a
:= 0 else if (a
> 255) then a
:= 255;
1313 tpp
^ := 255; Inc(tpp
);
1314 tpp
^ := 255; Inc(tpp
);
1315 tpp
^ := 255; Inc(tpp
);
1316 tpp
^ := Byte(a
); Inc(tpp
);
1321 glGenTextures(1, @ltexid
);
1322 //if (tid == 0) assert(0, "VGL: can't create screen texture");
1324 glBindTexture(GL_TEXTURE_2D
, ltexid
);
1325 glTexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_REPEAT
);
1326 glTexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_REPEAT
);
1327 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
1328 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
1330 //GLfloat[4] bclr = 0.0;
1331 //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
1333 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, Radius
*2, Radius
*2, 0, GL_RGBA
{gltt}, GL_UNSIGNED_BYTE
, tex
);
1339 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
1340 //FIXME: broken for splitscreen mode
1341 procedure renderDynLightsInternal ();
1343 //hasAmbient: Boolean;
1344 //ambColor: TDFColor;
1346 lx
, ly
, lrad
: Integer;
1347 scxywh
: array[0..3] of GLint
;
1350 if e_NoGraphics
then exit
;
1352 //TODO: lights should be in separate grid, i think
1353 // but on the other side: grid may be slower for dynlights, as their lifetime is short
1354 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
1357 //ambColor := gCurrentMap['light_ambient'].rgba;
1358 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
1360 { // this will multiply incoming color to alpha from framebuffer
1362 glBlendFunc(GL_DST_ALPHA, GL_ONE);
1366 * light rendering: (INVALID!)
1367 * glStencilFunc(GL_EQUAL, 0, $ff);
1369 * glClear(GL_STENCIL_BUFFER_BIT);
1370 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
1371 * draw shadow volume into stencil buffer
1372 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
1373 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
1375 * draw color-less quad with light alpha (WARNING! don't touch color!)
1376 * glEnable(GL_BLEND);
1377 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
1378 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
1380 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
1381 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
1383 // setup OpenGL parameters
1384 glStencilMask($FFFFFFFF);
1385 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
1386 glEnable(GL_STENCIL_TEST
);
1387 glEnable(GL_SCISSOR_TEST
);
1388 glClear(GL_STENCIL_BUFFER_BIT
);
1389 glStencilFunc(GL_EQUAL
, 0, $ff);
1391 for lln
:= 0 to g_dynLightCount
-1 do
1393 lx
:= g_dynLights
[lln
].x
;
1394 ly
:= g_dynLights
[lln
].y
;
1395 lrad
:= g_dynLights
[lln
].radius
;
1396 if (lrad
< 3) then continue
;
1398 if (lx
-sX
+lrad
< 0) then continue
;
1399 if (ly
-sY
+lrad
< 0) then continue
;
1400 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
1401 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
1403 // set scissor to optimize drawing
1404 if (g_dbg_scale
= 1.0) then
1406 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
1410 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
1412 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
1413 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
1414 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
1415 // draw extruded panels
1416 glDisable(GL_TEXTURE_2D
);
1417 glDisable(GL_BLEND
);
1418 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
1419 if (lrad
> 4) then r_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
1420 // render light texture
1421 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
1422 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
1425 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1426 glEnable(GL_TEXTURE_2D
);
1427 // color and opacity
1428 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
1429 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
1431 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
1432 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
1433 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
1434 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
1439 glDisable(GL_STENCIL_TEST
);
1440 glDisable(GL_BLEND
);
1441 glDisable(GL_SCISSOR_TEST
);
1442 //glScissor(0, 0, sWidth, sHeight);
1444 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
1445 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
1449 function fixViewportForScale (): Boolean;
1451 nx0
, ny0
, nw
, nh
: Integer;
1454 if (g_dbg_scale
<> 1.0) then
1457 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
1458 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
1459 nw
:= round(sWidth
/g_dbg_scale
);
1460 nh
:= round(sHeight
/g_dbg_scale
);
1469 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
1470 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
1471 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
1473 TDrawCB
= procedure ();
1476 hasAmbient
: Boolean;
1478 doAmbient
: Boolean = false;
1480 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
1485 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
1486 if gdbg_map_use_accel_render
then
1488 tagmask
:= panelTypeToTag(panType
);
1489 while (gDrawPanelList
.count
> 0) do
1491 pan
:= TPanel(gDrawPanelList
.front());
1492 if ((pan
.tag
and tagmask
) = 0) then break
;
1493 if doDraw
then r_Panel_Draw(pan
, doAmbient
, ambColor
);
1494 gDrawPanelList
.popFront();
1499 if doDraw
then r_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
1501 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1504 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
1506 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
1507 if assigned(cb
) then cb();
1508 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1512 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
1514 // our accelerated renderer will collect all panels to gDrawPanelList
1515 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
1516 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
1517 if gdbg_map_use_accel_render
then
1519 r_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
1521 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1523 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
1524 r_Map_DrawBack(backXOfs
, backYOfs
);
1525 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1527 if setTransMatrix
then
1529 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
1530 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
1531 glTranslatef(-sX
, -sY
, 0);
1535 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
1536 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
1541 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
1542 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
1543 glClear(GL_COLOR_BUFFER_BIT);
1546 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
1549 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
1550 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
1551 drawOther('items', @r_Items_Draw
);
1552 drawOther('weapons', @r_Weapon_Draw
);
1553 {$IFDEF ENABLE_SHELLS}
1554 drawOther('shells', @r_Player_DrawShells
);
1556 drawOther('drawall', @r_Player_DrawAll
);
1557 {$IFDEF ENABLE_GIBS}
1558 drawOther('gibs', @r_PlayerModel_DrawGibs
);
1560 {$IFDEF ENABLE_CORPSES}
1561 drawOther('corpses', @r_Player_DrawCorpses
);
1563 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
1564 drawOther('monsters', @r_Monsters_Draw
);
1565 drawOther('itemdrop', @r_Items_DrawDrop
);
1566 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
1568 drawOther('gfx', @r_GFX_Draw
);
1570 drawOther('flags', @r_Map_DrawFlags
);
1571 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
1572 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
1573 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
1574 drawOther('dynlights', @renderDynLightsInternal
);
1576 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
1578 renderAmbientQuad(hasAmbient
, ambColor
);
1582 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
1585 if g_debug_HealthBar
then
1587 r_Monsters_DrawHealth();
1588 r_Player_DrawHealth();
1591 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
1595 procedure DrawMapView(x
, y
, w
, h
: Integer);
1602 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
1603 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
1610 fixViewportForScale();
1611 renderMapInternal(-bx
, -by
, true);
1617 procedure DrawPlayer(p
: TPlayer
);
1619 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
1623 if (p
= nil) or (p
.FDummy
) then
1626 r_Map_DrawBack(0, 0);
1631 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
1632 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
1638 {$IFDEF ENABLE_CORPSES}
1639 camObj
:= g_Corpses_GetCameraObj(p
);
1644 camObj
.lerp(gLerpFactor
, fX
, fY
);
1645 px
:= fX
+ PLAYER_RECT_CX
;
1646 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
1648 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
1650 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
1651 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
1653 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
1654 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
1656 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
1657 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
1660 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
1663 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
1664 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
1667 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
1672 // scaled, ignore level bounds
1673 a
:= -px
+(gPlayerScreenSize
.X
div 2);
1674 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
1679 sWidth
:= gPlayerScreenSize
.X
;
1680 sHeight
:= gPlayerScreenSize
.Y
;
1681 fixViewportForScale();
1683 i
:= py
- (sY
+ sHeight
div 2);
1684 if (p
.IncCam
> 0) then
1686 // clamp to level bounds
1687 if (sY
- p
.IncCam
< 0) then
1688 p
.IncCam
:= nclamp(sY
, 0, 120);
1689 // clamp around player position
1691 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
1693 else if (p
.IncCam
< 0) then
1695 // clamp to level bounds
1696 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
1697 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
1698 // clamp around player position
1700 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
1703 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
1705 if (not g_dbg_ignore_bounds
) then
1707 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
1708 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
1709 if (sX
< 0) then sX
:= 0;
1710 if (sY
< 0) then sY
:= 0;
1713 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
1714 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
1716 //r_smallmap_h: 0: left; 1: center; 2: right
1717 //r_smallmap_v: 0: top; 1: center; 2: bottom
1719 if (gMapInfo
.Width
= sWidth
) then
1723 else if (gMapInfo
.Width
< sWidth
) then
1725 case r_smallmap_h
of
1726 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
1727 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
1728 else sX
:= 0; // left
1732 if (gMapInfo
.Height
= sHeight
) then
1736 else if (gMapInfo
.Height
< sHeight
) then
1738 case r_smallmap_v
of
1739 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
1740 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
1741 else sY
:= 0; // top
1747 p
.viewPortW
:= sWidth
;
1748 p
.viewPortH
:= sHeight
;
1750 {$IFDEF ENABLE_HOLMES}
1751 if (p
= gPlayer1
) then
1753 g_Holmes_plrViewPos(sX
, sY
);
1754 g_Holmes_plrViewSize(sWidth
, sHeight
);
1758 renderMapInternal(-c
, -d
, true);
1760 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
1761 case gPlayerIndicator
of
1763 r_Player_DrawIndicator(p
, _RGB(255, 255, 255));
1766 for i
:= 0 to High(gPlayers
) do
1767 if gPlayers
[i
] <> nil then
1768 if gPlayers
[i
] = p
then
1769 r_Player_DrawIndicator(p
, _RGB(255, 255, 255))
1770 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
1771 if gPlayerIndicatorStyle
= 1 then
1772 r_Player_DrawIndicator(gPlayers
[i
], _RGB(192, 192, 192))
1774 r_Player_DrawIndicator(gPlayers
[i
], gPlayers
[i
].GetColor
);
1778 for a := 0 to High(gCollideMap) do
1779 for b := 0 to High(gCollideMap[a]) do
1782 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
1784 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
1788 1: e_DrawPoint(1, b, a, 200, 200, 200);
1789 2: e_DrawPoint(1, b, a, 64, 64, 255);
1790 3: e_DrawPoint(1, b, a, 255, 0, 255);
1797 r_Player_DrawPain(p
);
1798 r_Player_DrawPickup(p
);
1799 r_Player_DrawRulez(p
);
1800 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
1801 if g_Debug_Player
then
1802 r_Player_DrawDebug(p
);
1803 r_Player_DrawGUI(p
);
1806 procedure drawProfilers ();
1811 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
1812 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
1813 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
1816 procedure r_Game_Draw();
1823 plView1
, plView2
: TPlayer
;
1825 MsgLineLength
: Integer;
1828 if gExit
= EXIT_QUIT
then Exit
;
1830 Time
:= GetTickCount64() {div 1000};
1831 FPSCounter
:= FPSCounter
+1;
1832 if Time
- FPSTime
>= 1000 then
1839 e_SetRendertarget(True);
1840 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
1842 if gGameOn
or (gState
= STATE_FOLD
) then
1844 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
1846 gSpectMode
:= SPECT_NONE
;
1847 if not gRevertPlayers
then
1849 plView1
:= gPlayer1
;
1850 plView2
:= gPlayer2
;
1854 plView1
:= gPlayer2
;
1855 plView2
:= gPlayer1
;
1859 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
1861 gSpectMode
:= SPECT_NONE
;
1862 if gPlayer2
= nil then
1865 plView1
:= gPlayer2
;
1874 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
1875 gSpectMode
:= SPECT_STATS
;
1877 if gSpectMode
= SPECT_PLAYERS
then
1878 if gPlayers
<> nil then
1880 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
1881 if plView1
= nil then
1883 gSpectPID1
:= GetActivePlayerID_Next();
1884 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
1886 if gSpectViewTwo
then
1888 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
1889 if plView2
= nil then
1891 gSpectPID2
:= GetActivePlayerID_Next();
1892 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
1897 if gSpectMode
= SPECT_MAPVIEW
then
1899 // Режим просмотра карты
1901 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
1902 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
1903 gHearPoint1
.Active
:= True;
1904 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
1905 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
1906 gHearPoint2
.Active
:= False;
1910 Split
:= (plView1
<> nil) and (plView2
<> nil);
1912 // Точки слуха игроков
1913 if plView1
<> nil then
1915 gHearPoint1
.Active
:= True;
1916 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
1917 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
1919 gHearPoint1
.Active
:= False;
1920 if plView2
<> nil then
1922 gHearPoint2
.Active
:= True;
1923 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
1924 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
1926 gHearPoint2
.Active
:= False;
1928 // Размер экранов игроков:
1929 gPlayerScreenSize
.X
:= gScreenWidth
-196;
1932 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
1933 if gScreenHeight
mod 2 = 0 then
1934 Dec(gPlayerScreenSize
.Y
);
1937 gPlayerScreenSize
.Y
:= gScreenHeight
;
1940 if gScreenHeight
mod 2 = 0 then
1941 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
1943 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
1945 DrawPlayer(plView1
);
1946 gPlayer1ScreenCoord
.X
:= sX
;
1947 gPlayer1ScreenCoord
.Y
:= sY
;
1951 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
1953 DrawPlayer(plView2
);
1954 gPlayer2ScreenCoord
.X
:= sX
;
1955 gPlayer2ScreenCoord
.Y
:= sY
;
1958 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
1961 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
1964 {$IFDEF ENABLE_HOLMES}
1966 if (g_holmes_enabled
) then g_Holmes_Draw();
1969 if MessageText
<> '' then
1973 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
1974 MsgLineLength
:= (gScreenWidth
- 204) div e_CharFont_GetMaxWidth(gMenuFont
);
1975 MsgText
:= b_Text_Wrap(b_Text_Format(MessageText
), MsgLineLength
);
1977 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
1978 (gScreenHeight
div 2)-(h
div 2), MsgText
)
1980 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
1981 Round(gScreenHeight
/ 2.75)-(h
div 2), MsgText
);
1984 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
1987 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
1989 // Draw spectator GUI
1992 e_TextureFontGetSize(gStdFont
, ww
, hh
);
1995 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
1997 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
1999 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
2001 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
2002 if gSpectMode
= SPECT_STATS
then
2004 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
2005 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
2007 if gSpectMode
= SPECT_MAPVIEW
then
2009 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
2010 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
2011 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
2012 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
2013 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
2015 if gSpectMode
= SPECT_PLAYERS
then
2017 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
2018 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
2019 if gSpectViewTwo
then
2021 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
2022 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
2023 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2024 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2028 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2029 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2035 {$IFDEF ENABLE_MENU}
2036 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
2038 if gPauseMain
and gGameOn
then
2041 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2042 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2044 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
2045 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2046 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
2051 {$IFDEF ENABLE_MENU}
2052 if (gState
= STATE_MENU
) then
2054 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then r_Game_DrawMenuBackground('MENU_BACKGROUND');
2055 // F3 at menu will show game loading dialog
2056 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
2057 if (g_ActiveWindow
<> nil) then
2059 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2060 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2064 // F3 at titlepic will show game loading dialog
2065 if e_KeyPressed(IK_F3
) then
2067 g_Menu_Show_LoadMenu(true);
2068 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2073 r_Game_DrawMenuBackground('MENU_BACKGROUND');
2076 if gState
= STATE_FOLD
then
2078 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
2081 if gState
= STATE_INTERCUSTOM
then
2083 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
2085 back
:= 'TEXTURE_endpic';
2086 if not g_Texture_Get(back
, ID
) then
2087 back
:= _lc
[I_TEXTURE_ENDPIC
];
2092 r_Game_DrawMenuBackground(back
);
2096 {$IFDEF ENABLE_MENU}
2097 if g_ActiveWindow
<> nil then
2099 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2100 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2105 if gState
= STATE_INTERSINGLE
then
2107 if EndingGameCounter
> 0 then
2109 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
2115 r_Game_DrawMenuBackground(back
);
2119 {$IFDEF ENABLE_MENU}
2120 if g_ActiveWindow
<> nil then
2122 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2123 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2129 if gState
= STATE_ENDPIC
then
2132 if g_Texture_Get('TEXTURE_endpic', ID
) then r_Game_DrawMenuBackground('TEXTURE_endpic')
2133 else r_Game_DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
2135 {$IFDEF ENABLE_MENU}
2136 if g_ActiveWindow
<> nil then
2138 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2139 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2144 if gState
= STATE_SLIST
then
2146 // if g_Texture_Get('MENU_BACKGROUND', ID) then
2148 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
2149 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2151 r_Game_DrawMenuBackground('MENU_BACKGROUND');
2152 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2153 r_Serverlist_Draw(slCurrent
, slTable
);
2157 {$IFDEF ENABLE_MENU}
2158 if g_ActiveWindow
<> nil then
2162 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2163 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2165 g_ActiveWindow
.Draw();
2173 if g_debug_Sounds
and gGameOn
then
2175 for w
:= 0 to High(e_SoundsArray
) do
2176 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
2177 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
2182 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
2183 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
2186 if gGameOn
and gShowTime
then
2187 drawTime(gScreenWidth
-72, gScreenHeight
-16);
2189 if gGameOn
then drawProfilers();
2191 // TODO: draw this after the FBO and remap mouse click coordinates
2193 {$IFDEF ENABLE_HOLMES}
2197 // blit framebuffer to screen
2199 e_SetRendertarget(False);
2200 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
2201 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);