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
;
38 {$INCLUDE ../nogl/noGLuses.inc}
39 {$IFDEF ENABLE_HOLMES}
42 SysUtils
, Classes
, Math
,
45 MAPDEF
, xprofiler
, utils
, wadreader
,
47 g_language
, g_console
, g_menu
, g_triggers
, g_player
, g_options
, g_monsters
, g_map
, g_panel
,
48 g_items
, g_weapons
, g_gfx
, g_phys
, g_net
, g_gui
, g_netmaster
,
49 g_game
, r_console
, r_gfx
, r_items
, r_map
, r_monsters
, r_weapons
, r_netmaster
, r_player
, r_textures
,
54 profileFrameDraw
: TProfiler
= nil;
61 BackID
: DWORD
= DWORD(-1);
64 procedure r_Game_Load
;
72 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+ ':TEXTURES\TITLE', gTextureFilter
);
73 g_Texture_CreateWADEx('INTER', GameWAD
+ ':TEXTURES\INTER', gTextureFilter
);
74 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+ ':TEXTURES\ENDGAME_EN', gTextureFilter
);
75 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+ ':TEXTURES\ENDGAME_RU', gTextureFilter
);
76 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
77 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
78 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
80 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+ ':TEXTURES\NOTEXTURE');
81 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+ ':TEXTURES\HUD');
82 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+ ':TEXTURES\AIRBAR');
83 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+ ':TEXTURES\JETBAR');
84 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+ ':TEXTURES\HUDBG');
85 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+ ':TEXTURES\ARMORHUD');
86 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+ ':TEXTURES\FLAGHUD_R_BASE');
87 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+ ':TEXTURES\FLAGHUD_R_STOLEN');
88 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+ ':TEXTURES\FLAGHUD_R_DROP');
89 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+ ':TEXTURES\FLAGHUD_B_BASE');
90 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+ ':TEXTURES\FLAGHUD_B_STOLEN');
91 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+ ':TEXTURES\FLAGHUD_B_DROP');
92 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+ ':TEXTURES\TALKBUBBLE');
93 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+ ':TEXTURES\PENTA');
94 g_Texture_CreateWADEx('TEXTURE_PLAYER_INDICATOR', GameWAD
+ ':TEXTURES\PLRIND');
97 if not g_Texture_CreateWADEx('UI_GFX_PBAR_LEFT', GameWAD
+':TEXTURES\LLEFT') then hasPBarGfx
:= false;
98 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MARKER', GameWAD
+':TEXTURES\LMARKER') then hasPBarGfx
:= false;
99 if not g_Texture_CreateWADEx('UI_GFX_PBAR_MIDDLE', GameWAD
+':TEXTURES\LMIDDLE') then hasPBarGfx
:= false;
100 if not g_Texture_CreateWADEx('UI_GFX_PBAR_RIGHT', GameWAD
+':TEXTURES\LRIGHT') then hasPBarGfx
:= false;
103 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
104 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
105 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
106 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
107 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
116 procedure r_Game_Free
;
118 g_Texture_Delete('NOTEXTURE');
119 g_Texture_Delete('TEXTURE_PLAYER_HUD');
120 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
121 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
122 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
123 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
124 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
125 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
126 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
127 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
128 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
129 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
132 procedure r_Game_SetupScreenSize
;
134 RES_FACTOR
= 4.0 / 3.0;
140 // Размер экранов игроков:
141 gPlayerScreenSize
.X
:= gScreenWidth
-196;
142 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
143 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
145 gPlayerScreenSize
.Y
:= gScreenHeight
;
147 // Размер заднего плана:
148 if BackID
<> DWORD(-1) then
151 if (gScreenWidth
*s
> gMapInfo
.Width
) or
152 (gScreenHeight
*s
> gMapInfo
.Height
) then
154 gBackSize
.X
:= gScreenWidth
;
155 gBackSize
.Y
:= gScreenHeight
;
159 e_GetTextureSize(BackID
, @bw
, @bh
);
160 rf
:= Single(bw
) / Single(bh
);
161 if (rf
> RES_FACTOR
) then bw
:= Round(Single(bh
) * RES_FACTOR
)
162 else if (rf
< RES_FACTOR
) then bh
:= Round(Single(bw
) / RES_FACTOR
);
163 s
:= Max(gScreenWidth
/ bw
, gScreenHeight
/ bh
);
164 if (s
< 1.0) then s
:= 1.0;
165 gBackSize
.X
:= Round(bw
*s
);
166 gBackSize
.Y
:= Round(bh
*s
);
171 procedure r_Game_LoadTextures
;
173 g_Texture_CreateWADEx('TEXTURE_endpic', EndPicPath
, gTextureFilter
);
174 if gMapInfo
.SkyFullName
<> '' then
175 g_Texture_CreateWAD(BackID
, gMapInfo
.SkyFullName
, gTextureFilter
);
176 r_Game_SetupScreenSize
;
179 procedure r_Game_FreeTextures
;
181 g_Texture_Delete('TEXTURE_endpic');
182 if BackID
<> DWORD(-1) then
186 e_DeleteTexture(BackID
);
191 procedure r_Map_DrawBack(dx
, dy
: Integer);
193 if gDrawBackGround
and (BackID
<> DWORD(-1)) then
194 e_DrawSize(BackID
, dx
, dy
, 0, False, False, gBackSize
.X
, gBackSize
.Y
)
196 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
199 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
206 if gPlayers
= nil then
208 for a
:= Low(gPlayers
) to High(gPlayers
) do
209 if IsActivePlayer(gPlayers
[a
]) then
211 if gPlayers
[a
].UID
<> ID
then
213 Result
:= gPlayers
[a
];
218 function calcProfilesHeight (prof
: TProfiler
): Integer;
221 if (prof
= nil) then exit
;
222 if (length(prof
.bars
) = 0) then exit
;
223 result
:= length(prof
.bars
)*(16+2);
227 function drawProfiles (x
, y
: Integer; prof
: TProfiler
): Integer;
234 if (prof
= nil) then exit
;
236 if (length(prof
.bars
) = 0) then exit
;
238 hgt
:= calcProfilesHeight(prof
);
239 if (x
< 0) then x
:= gScreenWidth
-(wdt
-1)+x
;
240 if (y
< 0) then y
:= gScreenHeight
-(hgt
-1)+y
;
242 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
243 //e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 20, 20, 20, 0, B_NONE);
244 e_DarkenQuadWH(x
, y
, wdt
, hgt
, 150);
247 for ii
:= 0 to High(prof
.bars
) do
249 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);
255 procedure drawTime(X
, Y
: Integer); inline;
257 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
);
260 procedure DrawStat();
262 pc
, x
, y
, w
, h
: Integer;
263 w1
, w2
, w3
, w4
: Integer;
265 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
268 stat
: TPlayerStatArray
;
276 pc
:= g_Player_GetCount
;
277 e_TextureFontGetSize(gStdFont
, cw
, ch
);
279 w
:= gScreenWidth
-(gScreenWidth
div 5);
280 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
283 h
:= 40+ch
*5+(ch
+8)*pc
;
284 x
:= (gScreenWidth
div 2)-(w
div 2);
285 y
:= (gScreenHeight
div 2)-(h
div 2);
287 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
288 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
290 drawTime(x
+w
-78, y
+8);
292 wad
:= g_ExtractWadNameNoPath(gMapInfo
.Map
);
293 map
:= g_ExtractFileName(gMapInfo
.Map
);
294 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
296 case gGameSettings
.GameMode
of
299 if gGameSettings
.MaxLives
= 0 then
302 s1
:= _lc
[I_GAME_LMS
];
303 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
304 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
309 if gGameSettings
.MaxLives
= 0 then
310 s1
:= _lc
[I_GAME_TDM
]
312 s1
:= _lc
[I_GAME_TLMS
];
313 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
314 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
319 s1
:= _lc
[I_GAME_CTF
];
320 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
321 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
326 if gGameSettings
.MaxLives
= 0 then
327 s1
:= _lc
[I_GAME_COOP
]
329 s1
:= _lc
[I_GAME_SURV
];
330 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
331 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
341 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
343 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
345 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
347 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
348 gStdFont
, 200, 200, 200, 1);
350 if NetMode
= NET_SERVER
then
351 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
353 if NetMode
= NET_CLIENT
then
354 e_TextureFontPrintEx(x
+8, y
+ 8,
355 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
359 stat
:= g_Player_GetStats();
362 w2
:= (w
-16) div 6 + 48; // ширина 2 столбца
363 w3
:= (w
-16) div 6; // ширина 3 и 4 столбцов
365 w1
:= w
-16-w2
-w3
-w4
; // оставшееся пространство - для цвета и имени игрока
367 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
371 for a
:= TEAM_RED
to TEAM_BLUE
do
375 s1
:= _lc
[I_GAME_TEAM_RED
];
382 s1
:= _lc
[I_GAME_TEAM_BLUE
];
388 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
389 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
390 gStdFont
, r
, g
, b
, 1);
392 _y
:= _y
+ch
+(ch
div 4);
393 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
396 for aa
:= 0 to High(stat
) do
397 if stat
[aa
].Team
= a
then
413 namestr
:= Format('[%5d] %s', [UID
, Name
])
417 e_TextureFontPrintEx(x
+16, _y
, namestr
, gStdFont
, rr
, gg
, bb
, 1);
419 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
421 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
423 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
430 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
433 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
434 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
435 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
436 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
439 for aa
:= 0 to High(stat
) do
453 namestr
:= Format('[%5d] %s', [UID
, Name
])
457 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
458 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
460 e_TextureFontPrintEx(x
+16+16+8, _y
+4, namestr
, gStdFont
, r
, g
, 0, 1);
462 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
464 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
466 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
472 procedure DrawCustomStat();
478 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
479 s1
, s2
, topstr
: String;
481 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
485 if g_Console_Action(ACTION_SCORES
) then
487 if not gStatsPressed
then
489 gStatsOff
:= not gStatsOff
;
490 gStatsPressed
:= True;
494 gStatsPressed
:= False;
498 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
499 w
:= (Length(s1
) * ww2
) div 2;
500 x
:= gScreenWidth
div 2 - w
;
502 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
506 if (gGameSettings
.GameMode
= GM_COOP
) then
508 if gMissionFailed
then
509 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
511 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
514 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
516 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
517 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
521 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
522 if not gChatShow
then
523 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
524 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
527 if g_Game_IsClient
then
528 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
530 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
531 if not gChatShow
then
532 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
533 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
538 w
:= gScreenWidth
-x
*2;
544 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
545 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
547 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
549 case CustomStat
.GameMode
of
552 if gGameSettings
.MaxLives
= 0 then
555 s1
:= _lc
[I_GAME_LMS
];
559 if gGameSettings
.MaxLives
= 0 then
560 s1
:= _lc
[I_GAME_TDM
]
562 s1
:= _lc
[I_GAME_TLMS
];
564 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
567 if gGameSettings
.MaxLives
= 0 then
568 s1
:= _lc
[I_GAME_COOP
]
570 s1
:= _lc
[I_GAME_SURV
];
576 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
580 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
581 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
584 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
585 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
586 (CustomStat
.GameTime
div 1000 div 60) mod 60,
587 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
589 pc
:= Length(CustomStat
.PlayerStat
);
592 if CustomStat
.GameMode
= GM_COOP
then
594 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
596 s2
:= _lc
[I_GAME_MONSTERS
];
597 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
598 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
600 s2
:= _lc
[I_GAME_SECRETS
];
601 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
602 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
605 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
607 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
608 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
609 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
611 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
612 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
613 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
617 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
622 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
623 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
624 else s1
:= _lc
[I_GAME_WIN_DRAW
];
626 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
629 for t
:= TEAM_RED
to TEAM_BLUE
do
633 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
634 gStdFont
, 255, 0, 0, 1);
635 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
636 gStdFont
, 255, 0, 0, 1);
643 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
644 gStdFont
, 0, 0, 255, 1);
645 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
646 gStdFont
, 0, 0, 255, 1);
652 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
655 for p
:= 0 to High(CustomStat
.PlayerStat
) do
656 if CustomStat
.PlayerStat
[p
].Team
= t
then
657 with CustomStat
.PlayerStat
[p
] do
671 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
672 e_TextureFontPrintEx(x
+16, _y
, Name
+ ' *', gStdFont
, rr
, gg
, bb
, 1)
674 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
675 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
676 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
683 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
686 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
687 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
688 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
691 for p
:= 0 to High(CustomStat
.PlayerStat
) do
692 with CustomStat
.PlayerStat
[p
] do
694 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
701 if (gPlayers
[Num
] <> nil) and (gPlayers
[Num
].FReady
) then
702 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
+ ' *', gStdFont
, r
, r
, r
, 1, True)
704 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
705 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
706 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
711 // HACK: take stats screenshot immediately after the first frame of the stats showing
712 if gScreenshotStats
and (not StatShotDone
) and (Length(CustomStat
.PlayerStat
) > 1) then
714 g_TakeScreenShot('stats/' + StatFilename
);
715 StatShotDone
:= True;
719 procedure DrawSingleStat();
721 tm
, key_x
, val_x
, y
: Integer;
725 procedure player_stat(n
: Integer);
731 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
732 s2
:= Format(' %d', [gTotalMonsters
]);
734 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
735 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
736 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
737 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
739 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
740 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
742 // "Kills-per-minute: ##.#":
743 s1
:= _lc
[I_MENU_INTER_KPM
];
745 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
747 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
748 s2
:= Format(' %.1f', [kpm
]);
750 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
751 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
753 // "Secrets found: # / #":
754 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
755 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
757 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
758 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
759 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
760 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
762 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
763 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
768 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
769 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
771 // Определяем координаты выравнивания по самой длинной строке:
772 s1
:= _lc
[I_MENU_INTER_KPM
];
773 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
776 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
778 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
782 tm
:= SingleStat
.GameTime
div 1000;
783 s1
:= _lc
[I_MENU_INTER_TIME
];
784 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
786 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
787 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
789 if SingleStat
.TwoPlayers
then
792 s1
:= _lc
[I_MENU_PLAYER_1
];
793 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
794 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
796 // Статистика первого игрока:
801 s1
:= _lc
[I_MENU_PLAYER_2
];
802 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
803 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
805 // Статистика второго игрока:
811 // Статистика первого игрока:
817 procedure r_Game_DrawLoadingStat
;
818 procedure drawRect (x
, y
, w
, h
: Integer);
820 if (w
< 1) or (h
< 1) then exit
;
822 glVertex2f(x
+0.375, y
+0.375);
823 glVertex2f(x
+w
+0.375, y
+0.375);
824 glVertex2f(x
+w
+0.375, y
+h
+0.375);
825 glVertex2f(x
+0.375, y
+h
+0.375);
829 function drawPBar (cur
, total
: Integer; washere
: Boolean): Boolean;
831 rectW
, rectH
: Integer;
838 idl
, idr
, idb
, idm
: LongWord;
842 if (total
< 1) then exit
;
843 if (cur
< 1) then exit
; // don't blink
844 if (not washere
) and (cur
>= total
) then exit
; // don't blink
845 //if (cur < 0) then cur := 0;
846 //if (cur > total) then cur := total;
851 g_Texture_Get('UI_GFX_PBAR_LEFT', idl
);
852 g_Texture_GetSize('UI_GFX_PBAR_LEFT', wl
, hl
);
853 g_Texture_Get('UI_GFX_PBAR_RIGHT', idr
);
854 g_Texture_GetSize('UI_GFX_PBAR_RIGHT', wr
, hr
);
855 g_Texture_Get('UI_GFX_PBAR_MIDDLE', idb
);
856 g_Texture_GetSize('UI_GFX_PBAR_MIDDLE', wb
, hb
);
857 g_Texture_Get('UI_GFX_PBAR_MARKER', idm
);
858 g_Texture_GetSize('UI_GFX_PBAR_MARKER', wm
, hm
);
860 //rectW := gScreenWidth-360;
861 rectW
:= trunc(624.0*gScreenWidth
/1024.0);
864 x0
:= (gScreenWidth
-rectW
) div 2;
865 y0
:= gScreenHeight
-rectH
-64;
866 if (y0
< 2) then y0
:= 2;
868 glEnable(GL_SCISSOR_TEST
);
871 glScissor(x0
, gScreenHeight
-y0
-rectH
, rectW
, rectH
);
872 e_DrawSize(idl
, x0
, y0
, 0, true, false, wl
, hl
);
873 e_DrawSize(idr
, x0
+rectW
-wr
, y0
, 0, true, false, wr
, hr
);
876 glScissor(x0
+wl
, gScreenHeight
-y0
-rectH
, rectW
-wl
-wr
, rectH
);
878 while (f
< x0
+rectW
) do
880 e_DrawSize(idb
, f
, y0
, 0, true, false, wb
, hb
);
885 wdt
:= (rectW
-wl
-wr
)*cur
div total
;
886 if (wdt
> rectW
-wl
-wr
) then wdt
:= rectW
-wr
-wr
;
889 my
:= y0
; // don't be so smart, ketmar: +(rectH-wm) div 2;
890 glScissor(x0
+wl
, gScreenHeight
-my
-rectH
, wdt
, hm
);
894 e_DrawSize(idm
, f
, y0
, 0, true, false, wm
, hm
);
900 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
904 rectW
:= gScreenWidth
-64;
907 x0
:= (gScreenWidth
-rectW
) div 2;
908 y0
:= gScreenHeight
-rectH
-64;
909 if (y0
< 2) then y0
:= 2;
912 glDisable(GL_TEXTURE_2D
);
914 //glClearColor(0, 0, 0, 0);
915 //glClear(GL_COLOR_BUFFER_BIT);
917 glColor4ub(127, 127, 127, 255);
918 drawRect(x0
-2, y0
-2, rectW
+4, rectH
+4);
920 glColor4ub(0, 0, 0, 255);
921 drawRect(x0
-1, y0
-1, rectW
+2, rectH
+2);
923 glColor4ub(127, 127, 127, 255);
924 wdt
:= rectW
*cur
div total
;
925 if (wdt
> rectW
) then wdt
:= rectW
;
926 drawRect(x0
, y0
, wdt
, rectH
);
935 if (Length(LoadingStat
.Msgs
) = 0) then exit
;
937 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
938 yy
:= (gScreenHeight
div 3);
939 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
940 xx
:= (gScreenWidth
div 3);
944 for i
:= 0 to NextMsg
-1 do
946 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
947 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
951 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
952 yy
:= yy
+ LOADING_INTERLINE
;
953 PBarWasHere
:= drawPBar(CurValue
, MaxValue
, PBarWasHere
);
958 procedure r_Game_DrawMenuBackground (tex
: AnsiString);
964 if g_Texture_Get(tex
, ID
) then
966 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
967 e_GetTextureSize(ID
, @w
, @h
);
969 w
:= round(w
* 1.333 * (gScreenHeight
/ h
))
971 w
:= trunc(w
* (gScreenHeight
/ h
));
972 e_DrawSize(ID
, (gScreenWidth
- w
) div 2, 0, 0, False, False, w
, gScreenHeight
);
974 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
977 procedure DrawMinimap(p
: TPlayer
; RenderRect
: TRect
);
979 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
981 function monDraw (mon
: TMonster
): Boolean;
983 result
:= false; // don't stop
988 // Левый верхний угол
989 aX
:= Obj
.X
div ScaleSz
+ 1;
990 aY
:= Obj
.Y
div ScaleSz
+ 1;
992 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
993 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
994 // Правый нижний угол
997 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
1003 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
1004 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
1007 // Сколько пикселов карты в 1 пикселе мини-карты:
1008 ScaleSz
:= 16 div Scale
;
1009 // Размеры мини-карты:
1010 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
1011 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
1013 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
1015 if gWalls
<> nil then
1018 for a
:= 0 to High(gWalls
) do
1020 if PanelType
<> 0 then
1022 // Левый верхний угол:
1023 aX
:= X
div ScaleSz
;
1024 aY
:= Y
div ScaleSz
;
1026 aX2
:= max(Width
div ScaleSz
, 1);
1027 aY2
:= max(Height
div ScaleSz
, 1);
1028 // Правый нижний угол:
1029 aX2
:= aX
+ aX2
- 1;
1030 aY2
:= aY
+ aY2
- 1;
1033 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
1034 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
1035 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
1039 if gSteps
<> nil then
1042 for a
:= 0 to High(gSteps
) do
1044 if PanelType
<> 0 then
1046 // Левый верхний угол:
1047 aX
:= X
div ScaleSz
;
1048 aY
:= Y
div ScaleSz
;
1050 aX2
:= max(Width
div ScaleSz
, 1);
1051 aY2
:= max(Height
div ScaleSz
, 1);
1052 // Правый нижний угол:
1053 aX2
:= aX
+ aX2
- 1;
1054 aY2
:= aY
+ aY2
- 1;
1056 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
1059 if gLifts
<> nil then
1062 for a
:= 0 to High(gLifts
) do
1064 if PanelType
<> 0 then
1066 // Левый верхний угол:
1067 aX
:= X
div ScaleSz
;
1068 aY
:= Y
div ScaleSz
;
1070 aX2
:= max(Width
div ScaleSz
, 1);
1071 aY2
:= max(Height
div ScaleSz
, 1);
1072 // Правый нижний угол:
1073 aX2
:= aX
+ aX2
- 1;
1074 aY2
:= aY
+ aY2
- 1;
1077 LIFTTYPE_UP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
1078 LIFTTYPE_DOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
1079 LIFTTYPE_LEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
1080 LIFTTYPE_RIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
1084 if gWater
<> nil then
1087 for a
:= 0 to High(gWater
) do
1089 if PanelType
<> 0 then
1091 // Левый верхний угол:
1092 aX
:= X
div ScaleSz
;
1093 aY
:= Y
div ScaleSz
;
1095 aX2
:= max(Width
div ScaleSz
, 1);
1096 aY2
:= max(Height
div ScaleSz
, 1);
1097 // Правый нижний угол:
1098 aX2
:= aX
+ aX2
- 1;
1099 aY2
:= aY
+ aY2
- 1;
1101 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
1104 if gAcid1
<> nil then
1106 // Рисуем кислоту 1:
1107 for a
:= 0 to High(gAcid1
) do
1109 if PanelType
<> 0 then
1111 // Левый верхний угол:
1112 aX
:= X
div ScaleSz
;
1113 aY
:= Y
div ScaleSz
;
1115 aX2
:= max(Width
div ScaleSz
, 1);
1116 aY2
:= max(Height
div ScaleSz
, 1);
1117 // Правый нижний угол:
1118 aX2
:= aX
+ aX2
- 1;
1119 aY2
:= aY
+ aY2
- 1;
1121 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
1124 if gAcid2
<> nil then
1126 // Рисуем кислоту 2:
1127 for a
:= 0 to High(gAcid2
) do
1129 if PanelType
<> 0 then
1131 // Левый верхний угол:
1132 aX
:= X
div ScaleSz
;
1133 aY
:= Y
div ScaleSz
;
1135 aX2
:= max(Width
div ScaleSz
, 1);
1136 aY2
:= max(Height
div ScaleSz
, 1);
1137 // Правый нижний угол:
1138 aX2
:= aX
+ aX2
- 1;
1139 aY2
:= aY
+ aY2
- 1;
1141 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
1144 if gPlayers
<> nil then
1147 for a
:= 0 to High(gPlayers
) do
1148 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
1150 // Левый верхний угол:
1151 aX
:= Obj
.X
div ScaleSz
+ 1;
1152 aY
:= Obj
.Y
div ScaleSz
+ 1;
1154 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
1155 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
1156 // Правый нижний угол:
1157 aX2
:= aX
+ aX2
- 1;
1158 aY2
:= aY
+ aY2
- 1;
1160 if gPlayers
[a
] = p
then
1161 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
1164 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
1165 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
1166 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
1171 g_Mons_ForEach(monDraw
);
1176 procedure renderAmbientQuad (hasAmbient
: Boolean; constref ambColor
: TDFColor
);
1178 if not hasAmbient
then exit
;
1179 e_AmbientQuad(sX
, sY
, sWidth
, sHeight
, ambColor
.r
, ambColor
.g
, ambColor
.b
, ambColor
.a
);
1182 // ////////////////////////////////////////////////////////////////////////// //
1186 function g_Texture_Light (): Integer;
1188 Radius
: Integer = 128;
1196 GetMem(tex
, (Radius
*2)*(Radius
*2)*4);
1198 for y
:= 0 to Radius
*2-1 do
1200 for x
:= 0 to Radius
*2-1 do
1202 dist
:= 1.0-sqrt((x
-Radius
)*(x
-Radius
)+(y
-Radius
)*(y
-Radius
))/Radius
;
1205 tpp
^ := 0; Inc(tpp
);
1206 tpp
^ := 0; Inc(tpp
);
1207 tpp
^ := 0; Inc(tpp
);
1208 tpp
^ := 0; Inc(tpp
);
1212 //tc.setPixel(x, y, Color(cast(int)(dist*255), cast(int)(dist*255), cast(int)(dist*255)));
1213 if (dist
> 0.5) then dist
:= 0.5;
1214 a
:= round(dist
*255);
1215 if (a
< 0) then a
:= 0 else if (a
> 255) then a
:= 255;
1216 tpp
^ := 255; Inc(tpp
);
1217 tpp
^ := 255; Inc(tpp
);
1218 tpp
^ := 255; Inc(tpp
);
1219 tpp
^ := Byte(a
); Inc(tpp
);
1224 glGenTextures(1, @ltexid
);
1225 //if (tid == 0) assert(0, "VGL: can't create screen texture");
1227 glBindTexture(GL_TEXTURE_2D
, ltexid
);
1228 glTexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_REPEAT
);
1229 glTexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_REPEAT
);
1230 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
1231 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
1233 //GLfloat[4] bclr = 0.0;
1234 //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
1236 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, Radius
*2, Radius
*2, 0, GL_RGBA
{gltt}, GL_UNSIGNED_BYTE
, tex
);
1242 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
1243 //FIXME: broken for splitscreen mode
1244 procedure renderDynLightsInternal ();
1246 //hasAmbient: Boolean;
1247 //ambColor: TDFColor;
1249 lx
, ly
, lrad
: Integer;
1250 scxywh
: array[0..3] of GLint
;
1253 if e_NoGraphics
then exit
;
1255 //TODO: lights should be in separate grid, i think
1256 // but on the other side: grid may be slower for dynlights, as their lifetime is short
1257 if (not gwin_k8_enable_light_experiments
) or (not gwin_has_stencil
) or (g_dynLightCount
< 1) then exit
;
1260 //ambColor := gCurrentMap['light_ambient'].rgba;
1261 //hasAmbient := (not ambColor.isOpaque) or (not ambColor.isBlack);
1263 { // this will multiply incoming color to alpha from framebuffer
1265 glBlendFunc(GL_DST_ALPHA, GL_ONE);
1269 * light rendering: (INVALID!)
1270 * glStencilFunc(GL_EQUAL, 0, $ff);
1272 * glClear(GL_STENCIL_BUFFER_BIT);
1273 * glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
1274 * draw shadow volume into stencil buffer
1275 * glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
1276 * glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // don't modify stencil buffer
1278 * draw color-less quad with light alpha (WARNING! don't touch color!)
1279 * glEnable(GL_BLEND);
1280 * glBlendFunc(GL_DST_ALPHA, GL_ONE);
1281 * draw all geometry up to and including walls (with alpha-testing, probably) -- this does lighting
1283 wassc
:= (glIsEnabled(GL_SCISSOR_TEST
) <> 0);
1284 if wassc
then glGetIntegerv(GL_SCISSOR_BOX
, @scxywh
[0]) else glGetIntegerv(GL_VIEWPORT
, @scxywh
[0]);
1286 // setup OpenGL parameters
1287 glStencilMask($FFFFFFFF);
1288 glStencilFunc(GL_ALWAYS
, 0, $FFFFFFFF);
1289 glEnable(GL_STENCIL_TEST
);
1290 glEnable(GL_SCISSOR_TEST
);
1291 glClear(GL_STENCIL_BUFFER_BIT
);
1292 glStencilFunc(GL_EQUAL
, 0, $ff);
1294 for lln
:= 0 to g_dynLightCount
-1 do
1296 lx
:= g_dynLights
[lln
].x
;
1297 ly
:= g_dynLights
[lln
].y
;
1298 lrad
:= g_dynLights
[lln
].radius
;
1299 if (lrad
< 3) then continue
;
1301 if (lx
-sX
+lrad
< 0) then continue
;
1302 if (ly
-sY
+lrad
< 0) then continue
;
1303 if (lx
-sX
-lrad
>= gPlayerScreenSize
.X
) then continue
;
1304 if (ly
-sY
-lrad
>= gPlayerScreenSize
.Y
) then continue
;
1306 // set scissor to optimize drawing
1307 if (g_dbg_scale
= 1.0) then
1309 glScissor((lx
-sX
)-lrad
+2, gPlayerScreenSize
.Y
-(ly
-sY
)-lrad
-1+2, lrad
*2-4, lrad
*2-4);
1313 glScissor(0, 0, gScreenWidth
, gScreenHeight
);
1315 // no need to clear stencil buffer, light blitting will do it for us... but only for normal scale
1316 if (g_dbg_scale
<> 1.0) then glClear(GL_STENCIL_BUFFER_BIT
);
1317 glStencilOp(GL_KEEP
, GL_KEEP
, GL_INCR
);
1318 // draw extruded panels
1319 glDisable(GL_TEXTURE_2D
);
1320 glDisable(GL_BLEND
);
1321 glColorMask(GL_FALSE
, GL_FALSE
, GL_FALSE
, GL_FALSE
); // no need to modify color buffer
1322 if (lrad
> 4) then r_Map_DrawPanelShadowVolumes(lx
, ly
, lrad
);
1323 // render light texture
1324 glColorMask(GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
); // modify color buffer
1325 glStencilOp(GL_ZERO
, GL_ZERO
, GL_ZERO
); // draw light, and clear stencil buffer
1328 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1329 glEnable(GL_TEXTURE_2D
);
1330 // color and opacity
1331 glColor4f(g_dynLights
[lln
].r
, g_dynLights
[lln
].g
, g_dynLights
[lln
].b
, g_dynLights
[lln
].a
);
1332 glBindTexture(GL_TEXTURE_2D
, g_Texture_Light());
1334 glTexCoord2f(0.0, 0.0); glVertex2i(lx
-lrad
, ly
-lrad
); // top-left
1335 glTexCoord2f(1.0, 0.0); glVertex2i(lx
+lrad
, ly
-lrad
); // top-right
1336 glTexCoord2f(1.0, 1.0); glVertex2i(lx
+lrad
, ly
+lrad
); // bottom-right
1337 glTexCoord2f(0.0, 1.0); glVertex2i(lx
-lrad
, ly
+lrad
); // bottom-left
1342 glDisable(GL_STENCIL_TEST
);
1343 glDisable(GL_BLEND
);
1344 glDisable(GL_SCISSOR_TEST
);
1345 //glScissor(0, 0, sWidth, sHeight);
1347 glScissor(scxywh
[0], scxywh
[1], scxywh
[2], scxywh
[3]);
1348 if wassc
then glEnable(GL_SCISSOR_TEST
) else glDisable(GL_SCISSOR_TEST
);
1352 function fixViewportForScale (): Boolean;
1354 nx0
, ny0
, nw
, nh
: Integer;
1357 if (g_dbg_scale
<> 1.0) then
1360 nx0
:= round(sX
-(gPlayerScreenSize
.X
-(sWidth
*g_dbg_scale
))/2/g_dbg_scale
);
1361 ny0
:= round(sY
-(gPlayerScreenSize
.Y
-(sHeight
*g_dbg_scale
))/2/g_dbg_scale
);
1362 nw
:= round(sWidth
/g_dbg_scale
);
1363 nh
:= round(sHeight
/g_dbg_scale
);
1372 // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this!
1373 // WARNING! this WILL CALL `glTranslatef()`, but won't restore matrices!
1374 procedure renderMapInternal (backXOfs
, backYOfs
: Integer; setTransMatrix
: Boolean);
1376 TDrawCB
= procedure ();
1379 hasAmbient
: Boolean;
1381 doAmbient
: Boolean = false;
1383 procedure drawPanelType (profname
: AnsiString; panType
: DWord
; doDraw
: Boolean);
1388 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
1389 if gdbg_map_use_accel_render
then
1391 tagmask
:= panelTypeToTag(panType
);
1392 while (gDrawPanelList
.count
> 0) do
1394 pan
:= TPanel(gDrawPanelList
.front());
1395 if ((pan
.tag
and tagmask
) = 0) then break
;
1396 if doDraw
then r_Panel_Draw(pan
, doAmbient
, ambColor
);
1397 gDrawPanelList
.popFront();
1402 if doDraw
then r_Map_DrawPanels(panType
, hasAmbient
, ambColor
);
1404 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1407 procedure drawOther (profname
: AnsiString; cb
: TDrawCB
);
1409 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin(profname
);
1410 if assigned(cb
) then cb();
1411 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1415 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('total');
1417 // our accelerated renderer will collect all panels to gDrawPanelList
1418 // we can use panel tag to render level parts (see GridTagXXX in g_map.pas)
1419 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('collect');
1420 if gdbg_map_use_accel_render
then
1422 r_Map_CollectDrawPanels(sX
, sY
, sWidth
, sHeight
);
1424 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1426 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionBegin('skyback');
1427 r_Map_DrawBack(backXOfs
, backYOfs
);
1428 if (profileFrameDraw
<> nil) then profileFrameDraw
.sectionEnd();
1430 if setTransMatrix
then
1432 //if (g_dbg_scale <> 1.0) then glTranslatef(0.0, -0.375/2, 0);
1433 glScalef(g_dbg_scale
, g_dbg_scale
, 1.0);
1434 glTranslatef(-sX
, -sY
, 0);
1438 ambColor
:= gCurrentMap
['light_ambient'].rgba
;
1439 hasAmbient
:= (not ambColor
.isOpaque
) or (not ambColor
.isBlack
);
1444 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
1445 glColor4ub(ambColor.r, ambColor.g, ambColor.b, ambColor.a);
1446 glClear(GL_COLOR_BUFFER_BIT);
1449 //writeln('color: (', ambColor.r, ',', ambColor.g, ',', ambColor.b, ',', ambColor.a, ')');
1452 drawPanelType('*back', PANEL_BACK
, g_rlayer_back
);
1453 drawPanelType('*step', PANEL_STEP
, g_rlayer_step
);
1454 drawOther('items', @r_Items_Draw
);
1455 drawOther('weapons', @r_Weapon_Draw
);
1456 drawOther('shells', @r_Player_DrawShells
);
1457 drawOther('drawall', @r_Player_DrawAll
);
1458 drawOther('gibs', @r_PlayerModel_DrawGibs
);
1459 drawOther('corpses', @r_Player_DrawCorpses
);
1460 drawPanelType('*wall', PANEL_WALL
, g_rlayer_wall
);
1461 drawOther('monsters', @r_Monsters_Draw
);
1462 drawOther('itemdrop', @r_Items_DrawDrop
);
1463 drawPanelType('*door', PANEL_CLOSEDOOR
, g_rlayer_door
);
1464 drawOther('gfx', @r_GFX_Draw
);
1465 drawOther('flags', @r_Map_DrawFlags
);
1466 drawPanelType('*acid1', PANEL_ACID1
, g_rlayer_acid1
);
1467 drawPanelType('*acid2', PANEL_ACID2
, g_rlayer_acid2
);
1468 drawPanelType('*water', PANEL_WATER
, g_rlayer_water
);
1469 drawOther('dynlights', @renderDynLightsInternal
);
1471 if hasAmbient
{and ((not g_playerLight) or (not gwin_has_stencil) or (g_dynLightCount < 1))} then
1473 renderAmbientQuad(hasAmbient
, ambColor
);
1477 drawPanelType('*fore', PANEL_FORE
, g_rlayer_fore
);
1480 if g_debug_HealthBar
then
1482 r_Monsters_DrawHealth();
1483 r_Player_DrawHealth();
1486 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainEnd(); // map rendering
1490 procedure DrawMapView(x
, y
, w
, h
: Integer);
1497 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
1498 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
1505 fixViewportForScale();
1506 renderMapInternal(-bx
, -by
, true);
1512 procedure DrawPlayer(p
: TPlayer
);
1514 px
, py
, a
, b
, c
, d
, i
, fX
, fY
: Integer;
1518 if (p
= nil) or (p
.FDummy
) then
1521 r_Map_DrawBack(0, 0);
1526 if (profileFrameDraw
= nil) then profileFrameDraw
:= TProfiler
.Create('RENDER', g_profile_history_size
);
1527 if (profileFrameDraw
<> nil) then profileFrameDraw
.mainBegin(g_profile_frame_draw
);
1533 camObj
:= p
.getCameraObj();
1534 camObj
.lerp(gLerpFactor
, fX
, fY
);
1535 px
:= fX
+ PLAYER_RECT_CX
;
1536 py
:= fY
+ PLAYER_RECT_CY
+nlerp(p
.SlopeOld
, camObj
.slopeUpLeft
, gLerpFactor
);
1538 if (g_dbg_scale
= 1.0) and (not g_dbg_ignore_bounds
) then
1540 if (px
> (gPlayerScreenSize
.X
div 2)) then a
:= -px
+(gPlayerScreenSize
.X
div 2) else a
:= 0;
1541 if (py
> (gPlayerScreenSize
.Y
div 2)) then b
:= -py
+(gPlayerScreenSize
.Y
div 2) else b
:= 0;
1543 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then a
:= -gMapInfo
.Width
+gPlayerScreenSize
.X
;
1544 if (py
> gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then b
:= -gMapInfo
.Height
+gPlayerScreenSize
.Y
;
1546 if (gMapInfo
.Width
= gPlayerScreenSize
.X
) then a
:= 0
1547 else if (gMapInfo
.Width
< gPlayerScreenSize
.X
) then
1550 a
:= (gPlayerScreenSize
.X
-gMapInfo
.Width
) div 2;
1553 if (gMapInfo
.Height
= gPlayerScreenSize
.Y
) then b
:= 0
1554 else if (gMapInfo
.Height
< gPlayerScreenSize
.Y
) then
1557 b
:= (gPlayerScreenSize
.Y
-gMapInfo
.Height
) div 2;
1562 // scaled, ignore level bounds
1563 a
:= -px
+(gPlayerScreenSize
.X
div 2);
1564 b
:= -py
+(gPlayerScreenSize
.Y
div 2);
1569 sWidth
:= gPlayerScreenSize
.X
;
1570 sHeight
:= gPlayerScreenSize
.Y
;
1571 fixViewportForScale();
1573 i
:= py
- (sY
+ sHeight
div 2);
1574 if (p
.IncCam
> 0) then
1576 // clamp to level bounds
1577 if (sY
- p
.IncCam
< 0) then
1578 p
.IncCam
:= nclamp(sY
, 0, 120);
1579 // clamp around player position
1581 p
.IncCam
:= nclamp(p
.IncCam
, 0, max(0, 120 - i
));
1583 else if (p
.IncCam
< 0) then
1585 // clamp to level bounds
1586 if (sY
+ sHeight
- p
.IncCam
> gMapInfo
.Height
) then
1587 p
.IncCam
:= nclamp(sY
+ sHeight
- gMapInfo
.Height
, -120, 0);
1588 // clamp around player position
1590 p
.IncCam
:= nclamp(p
.IncCam
, min(0, -120 - i
), 0);
1593 sY
:= sY
- nlerp(p
.IncCamOld
, p
.IncCam
, gLerpFactor
);
1595 if (not g_dbg_ignore_bounds
) then
1597 if (sX
+sWidth
> gMapInfo
.Width
) then sX
:= gMapInfo
.Width
-sWidth
;
1598 if (sY
+sHeight
> gMapInfo
.Height
) then sY
:= gMapInfo
.Height
-sHeight
;
1599 if (sX
< 0) then sX
:= 0;
1600 if (sY
< 0) then sY
:= 0;
1603 if (gBackSize
.X
<= gPlayerScreenSize
.X
) or (gMapInfo
.Width
<= sWidth
) then c
:= 0 else c
:= trunc((gBackSize
.X
-gPlayerScreenSize
.X
)*sX
/(gMapInfo
.Width
-sWidth
));
1604 if (gBackSize
.Y
<= gPlayerScreenSize
.Y
) or (gMapInfo
.Height
<= sHeight
) then d
:= 0 else d
:= trunc((gBackSize
.Y
-gPlayerScreenSize
.Y
)*sY
/(gMapInfo
.Height
-sHeight
));
1606 //r_smallmap_h: 0: left; 1: center; 2: right
1607 //r_smallmap_v: 0: top; 1: center; 2: bottom
1609 if (gMapInfo
.Width
= sWidth
) then
1613 else if (gMapInfo
.Width
< sWidth
) then
1615 case r_smallmap_h
of
1616 1: sX
:= -((sWidth
-gMapInfo
.Width
) div 2); // center
1617 2: sX
:= -(sWidth
-gMapInfo
.Width
); // right
1618 else sX
:= 0; // left
1622 if (gMapInfo
.Height
= sHeight
) then
1626 else if (gMapInfo
.Height
< sHeight
) then
1628 case r_smallmap_v
of
1629 1: sY
:= -((sHeight
-gMapInfo
.Height
) div 2); // center
1630 2: sY
:= -(sHeight
-gMapInfo
.Height
); // bottom
1631 else sY
:= 0; // top
1637 p
.viewPortW
:= sWidth
;
1638 p
.viewPortH
:= sHeight
;
1640 {$IFDEF ENABLE_HOLMES}
1641 if (p
= gPlayer1
) then
1643 g_Holmes_plrViewPos(sX
, sY
);
1644 g_Holmes_plrViewSize(sWidth
, sHeight
);
1648 renderMapInternal(-c
, -d
, true);
1650 if (gGameSettings
.GameMode
<> GM_SINGLE
) and (gPlayerIndicator
> 0) then
1651 case gPlayerIndicator
of
1653 r_Player_DrawIndicator(p
, _RGB(255, 255, 255));
1656 for i
:= 0 to High(gPlayers
) do
1657 if gPlayers
[i
] <> nil then
1658 if gPlayers
[i
] = p
then
1659 r_Player_DrawIndicator(p
, _RGB(255, 255, 255))
1660 else if (gPlayers
[i
].Team
= p
.Team
) and (gPlayers
[i
].Team
<> TEAM_NONE
) then
1661 if gPlayerIndicatorStyle
= 1 then
1662 r_Player_DrawIndicator(gPlayers
[i
], _RGB(192, 192, 192))
1664 r_Player_DrawIndicator(gPlayers
[i
], gPlayers
[i
].GetColor
);
1668 for a := 0 to High(gCollideMap) do
1669 for b := 0 to High(gCollideMap[a]) do
1672 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
1674 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
1678 1: e_DrawPoint(1, b, a, 200, 200, 200);
1679 2: e_DrawPoint(1, b, a, 64, 64, 255);
1680 3: e_DrawPoint(1, b, a, 255, 0, 255);
1687 r_Player_DrawPain(p
);
1688 r_Player_DrawPickup(p
);
1689 r_Player_DrawRulez(p
);
1690 if gShowMap
then DrawMinimap(p
, _TRect(0, 0, 128, 128));
1691 if g_Debug_Player
then
1692 r_Player_DrawDebug(p
);
1693 r_Player_DrawGUI(p
);
1696 procedure drawProfilers ();
1701 if g_profile_frame_draw
and (profileFrameDraw
<> nil) then px
:= px
-drawProfiles(px
, py
, profileFrameDraw
);
1702 if g_profile_collision
and (profMapCollision
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMapCollision
); py
-= calcProfilesHeight(profMonsLOS
); end;
1703 if g_profile_los
and (profMonsLOS
<> nil) then begin px
:= px
-drawProfiles(px
, py
, profMonsLOS
); py
-= calcProfilesHeight(profMonsLOS
); end;
1706 procedure r_Game_Draw();
1713 plView1
, plView2
: TPlayer
;
1716 if gExit
= EXIT_QUIT
then Exit
;
1718 Time
:= GetTickCount64() {div 1000};
1719 FPSCounter
:= FPSCounter
+1;
1720 if Time
- FPSTime
>= 1000 then
1727 e_SetRendertarget(True);
1728 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
1730 if gGameOn
or (gState
= STATE_FOLD
) then
1732 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
1734 gSpectMode
:= SPECT_NONE
;
1735 if not gRevertPlayers
then
1737 plView1
:= gPlayer1
;
1738 plView2
:= gPlayer2
;
1742 plView1
:= gPlayer2
;
1743 plView2
:= gPlayer1
;
1747 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
1749 gSpectMode
:= SPECT_NONE
;
1750 if gPlayer2
= nil then
1753 plView1
:= gPlayer2
;
1762 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
1763 gSpectMode
:= SPECT_STATS
;
1765 if gSpectMode
= SPECT_PLAYERS
then
1766 if gPlayers
<> nil then
1768 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
1769 if plView1
= nil then
1771 gSpectPID1
:= GetActivePlayerID_Next();
1772 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
1774 if gSpectViewTwo
then
1776 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
1777 if plView2
= nil then
1779 gSpectPID2
:= GetActivePlayerID_Next();
1780 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
1785 if gSpectMode
= SPECT_MAPVIEW
then
1787 // Режим просмотра карты
1789 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
1790 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
1791 gHearPoint1
.Active
:= True;
1792 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
1793 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
1794 gHearPoint2
.Active
:= False;
1798 Split
:= (plView1
<> nil) and (plView2
<> nil);
1800 // Точки слуха игроков
1801 if plView1
<> nil then
1803 gHearPoint1
.Active
:= True;
1804 gHearPoint1
.Coords
.X
:= plView1
.GameX
+ PLAYER_RECT
.Width
;
1805 gHearPoint1
.Coords
.Y
:= plView1
.GameY
+ PLAYER_RECT
.Height
DIV 2;
1807 gHearPoint1
.Active
:= False;
1808 if plView2
<> nil then
1810 gHearPoint2
.Active
:= True;
1811 gHearPoint2
.Coords
.X
:= plView2
.GameX
+ PLAYER_RECT
.Width
;
1812 gHearPoint2
.Coords
.Y
:= plView2
.GameY
+ PLAYER_RECT
.Height
DIV 2;
1814 gHearPoint2
.Active
:= False;
1816 // Размер экранов игроков:
1817 gPlayerScreenSize
.X
:= gScreenWidth
-196;
1820 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
1821 if gScreenHeight
mod 2 = 0 then
1822 Dec(gPlayerScreenSize
.Y
);
1825 gPlayerScreenSize
.Y
:= gScreenHeight
;
1828 if gScreenHeight
mod 2 = 0 then
1829 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
1831 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
1833 DrawPlayer(plView1
);
1834 gPlayer1ScreenCoord
.X
:= sX
;
1835 gPlayer1ScreenCoord
.Y
:= sY
;
1839 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
1841 DrawPlayer(plView2
);
1842 gPlayer2ScreenCoord
.X
:= sX
;
1843 gPlayer2ScreenCoord
.Y
:= sY
;
1846 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
1849 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
1852 {$IFDEF ENABLE_HOLMES}
1854 if (g_holmes_enabled
) then g_Holmes_Draw();
1857 if MessageText
<> '' then
1861 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
1863 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
1864 (gScreenHeight
div 2)-(h
div 2), MessageText
)
1866 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
1867 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
1870 if IsDrawStat
or (gSpectMode
= SPECT_STATS
) then
1873 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) and (not gSpectAuto
) then
1875 // Draw spectator GUI
1878 e_TextureFontGetSize(gStdFont
, ww
, hh
);
1881 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
1883 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
1885 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
1887 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
1888 if gSpectMode
= SPECT_STATS
then
1890 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2)*2, 'Autoview', gStdFont
, 255, 255, 255, 1);
1891 e_TextureFontPrintEx(16*ww
, gScreenHeight
- (hh
+2), '< fire >', gStdFont
, 255, 255, 255, 1);
1893 if gSpectMode
= SPECT_MAPVIEW
then
1895 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
1896 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
1897 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
1898 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
1899 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
1901 if gSpectMode
= SPECT_PLAYERS
then
1903 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
1904 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
1905 if gSpectViewTwo
then
1907 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
1908 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
1909 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
1910 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
1914 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
1915 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
1921 if gPauseMain
and gGameOn
and (g_ActiveWindow
= nil) then
1923 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
1924 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
1926 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
1927 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
1928 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
1933 if (gState
= STATE_MENU
) then
1935 if (g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '') then r_Game_DrawMenuBackground('MENU_BACKGROUND');
1936 // F3 at menu will show game loading dialog
1937 if e_KeyPressed(IK_F3
) then g_Menu_Show_LoadMenu(true);
1938 if (g_ActiveWindow
<> nil) then
1940 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
1941 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
1945 // F3 at titlepic will show game loading dialog
1946 if e_KeyPressed(IK_F3
) then
1948 g_Menu_Show_LoadMenu(true);
1949 if (g_ActiveWindow
<> nil) then e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
1954 if gState
= STATE_FOLD
then
1956 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
1959 if gState
= STATE_INTERCUSTOM
then
1961 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1963 back
:= 'TEXTURE_endpic';
1964 if not g_Texture_Get(back
, ID
) then
1965 back
:= _lc
[I_TEXTURE_ENDPIC
];
1970 r_Game_DrawMenuBackground(back
);
1974 if g_ActiveWindow
<> nil then
1976 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
1977 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
1981 if gState
= STATE_INTERSINGLE
then
1983 if EndingGameCounter
> 0 then
1985 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
1991 r_Game_DrawMenuBackground(back
);
1995 if g_ActiveWindow
<> nil then
1997 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
1998 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2003 if gState
= STATE_ENDPIC
then
2006 if g_Texture_Get('TEXTURE_endpic', ID
) then r_Game_DrawMenuBackground('TEXTURE_endpic')
2007 else r_Game_DrawMenuBackground(_lc
[I_TEXTURE_ENDPIC
]);
2009 if g_ActiveWindow
<> nil then
2011 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2012 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2016 if gState
= STATE_SLIST
then
2018 // if g_Texture_Get('MENU_BACKGROUND', ID) then
2020 // e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
2021 // //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2023 r_Game_DrawMenuBackground('MENU_BACKGROUND');
2024 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2025 r_Serverlist_Draw(slCurrent
, slTable
);
2029 if g_ActiveWindow
<> nil then
2033 //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
2034 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
2036 g_ActiveWindow
.Draw();
2043 if g_debug_Sounds
and gGameOn
then
2045 for w
:= 0 to High(e_SoundsArray
) do
2046 for h
:= 0 to e_SoundsArray
[w
].nRefs
do
2047 e_DrawPoint(1, w
+100, h
+100, 255, 0, 0);
2052 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
2053 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
2056 if gGameOn
and gShowTime
then
2057 drawTime(gScreenWidth
-72, gScreenHeight
-16);
2059 if gGameOn
then drawProfilers();
2061 // TODO: draw this after the FBO and remap mouse click coordinates
2063 {$IFDEF ENABLE_HOLMES}
2067 // blit framebuffer to screen
2069 e_SetRendertarget(False);
2070 e_SetViewPort(0, 0, gWinSizeX
, gWinSizeY
);
2071 e_BlitFramebuffer(gWinSizeX
, gWinSizeY
);
2073 // draw the overlay stuff on top of it