5c03ef31c16a70021d246e1dfcd88d2240e9d4e9
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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.
6 *
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.
11 *
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/>.
14 *)
15 {$INCLUDE ../../../shared/a_modes.inc}
18 interface
20 uses
21 {$IFDEF ENABLE_MENU}
22 g_gui,
23 {$ENDIF}
24 g_base // TRectWH
25 ;
27 (* render startup *)
31 (* load globally used textures *)
35 (* load map specific textures *)
47 {$IFDEF ENABLE_GIBS}
49 {$ENDIF}
51 {$IFDEF ENABLE_GFX}
53 {$ENDIF}
55 {$IFDEF ENABLE_TOUCH}
56 // touch screen button location and size
58 {$ENDIF}
60 {$IFDEF ENABLE_MENU}
65 {$ENDIF}
69 implementation
71 uses
72 {$IFDEF USE_GLES1}
73 GLES11,
74 {$ELSE}
76 {$ENDIF}
77 {$IFDEF ENABLE_MENU}
78 r_gui,
79 {$ENDIF}
80 {$IFDEF ENABLE_SYSTEM}
81 g_system,
82 {$ENDIF}
85 g_basic,
89 ;
91 type
92 TBasePoint = (
96 );
98 var
112 begin
113 r_Map_LoadTextures;
117 begin
118 r_Map_FreeTextures;
122 const
123 WeapName: array [0..WP_LAST] of AnsiString = ('KASTET', 'SAW', 'PISTOL', 'SHOTGUN1', 'SHOTGUN2', 'MGUN', 'RLAUNCHER', 'PGUN', 'BFG', 'SPULEMET', 'FLAMETHROWER');
124 var
126 begin
127 r_Common_Load;
147 r_Console_Load;
148 r_Map_Load;
149 {$IFDEF ENABLE_MENU}
150 r_GUI_Load;
151 {$ENDIF}
156 begin
157 {$IFDEF ENABLE_MENU}
158 r_GUI_Free;
159 {$ENDIF}
160 r_Map_Free;
161 r_Console_Free;
174 begin
185 r_Common_Free;
188 {$IFDEF ENABLE_SYSTEM}
191 begin
203 {$ENDIF}
206 begin
207 {$IFDEF ENABLE_SYSTEM}
211 {$ENDIF}
212 r_Textures_Initialize;
213 r_Console_Initialize;
214 r_Map_Initialize;
218 begin
219 r_Map_Finalize;
220 r_Console_Finalize;
221 r_Textures_Finalize;
225 begin
226 r_Console_Update;
227 r_Map_Update;
231 begin
244 procedure r_Render_DrawText (const text: AnsiString; x, y: Integer; r, g, b, a: Byte; f: TGLFont; p: TBasePoint);
246 begin
248 begin
256 begin
263 begin
266 // hud area is 196 x 240 pixels
274 r_Render_DrawText(IntToStr(MAX(0, p.health)), x + 174, y + 56, 255, 0, 0, 255, menufont, TBasePoint.BP_RIGHT);
275 r_Render_DrawText(IntToStr(MAX(0, p.armor)), x + 174, y + 84, 255, 0, 0, 255, menufont, TBasePoint.BP_RIGHT);
284 begin
297 begin
300 r_Draw_FillRect(x + 14, y + 116 + 4, x + 14 + 168 * p.air div AIR_MAX, y + 116 + 4 + 4, 0, 0, 196, 255);
302 r_Draw_FillRect(x + 14, y + 126 + 4, x + 14 + 168 * p.JetFuel div JET_MAX, y + 126 + 4 + 4, 208, 0, 0, 255);
303 end
304 else
305 begin
308 r_Draw_FillRect(x + 14, y + 124 + 4, x + 14 + 168 * p.air div AIR_MAX, y + 124 + 4 + 4, 0, 0, 196, 255);
314 begin
321 begin
327 begin
328 r_Render_DrawText(_lc[I_PLAYER_SPECT], x + 4, y + 242, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
329 r_Render_DrawText(_lc[I_PLAYER_SPECT2], x + 4, y + 258, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
330 r_Render_DrawText(_lc[I_PLAYER_SPECT1], x + 4, y + 274, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
332 r_Render_DrawText(_lc[I_PLAYER_SPECT1S], x + 4, y + 290, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
337 var fw, i, maxFrags, top, totalPlayers: Integer; sign: Char; stat: TPlayerStatArray; f: TGLTexture;
338 begin
342 begin
343 (* RED TEAM GOALS *)
346 begin
353 begin
355 r_Render_DrawTexture(f, x + w - 16, y + 240 - 72 - 4, f.width, f.height, TBasePoint.BP_RIGHTUP);
358 r_Render_DrawText(IntToStr(gTeamStat[TEAM_RED].Score), x + w - 16 - fw, y + 240 - 72 - 4, TEAMCOLOR[TEAM_RED].R, TEAMCOLOR[TEAM_RED].G, TEAMCOLOR[TEAM_RED].B, 255, menufont, TBasePoint.BP_RIGHTUP);
360 (* BLUE TEAM GOALS *)
363 begin
370 begin
372 r_Render_DrawTexture(f, x + w - 16, y + 240 - 32 - 4, f.width, f.height, TBasePoint.BP_RIGHTUP);
375 r_Render_DrawText(IntToStr(gTeamStat[TEAM_BLUE].Score), x + w - 16 - fw, y + 240 - 32 - 4, TEAMCOLOR[TEAM_RED].R, TEAMCOLOR[TEAM_RED].G, TEAMCOLOR[TEAM_RED].B, 255, menufont, TBasePoint.BP_RIGHTUP);
379 begin
381 begin
382 r_Render_DrawText(IntToStr(p.Frags), x + w - 16, y, 255, 0, 0, 255, menufont, TBasePoint.BP_RIGHTUP);
389 begin
392 begin
394 begin
402 r_Render_DrawText(IntToStr(top) + ' / ' + IntToStr(totalPlayers) + ' ' + sign + IntToStr(ABS(p.Frags - maxFrags)), x + w - 16, y + 32, 255, 0, 0, 255, smallfont, TBasePoint.BP_RIGHTUP);
406 begin
407 r_Render_DrawText(_lc[I_GAME_WARMUP], x + w - 16 - 64, y + h, 0, 255, 0, 255, menufont, TBasePoint.BP_RIGHTDOWN);
408 r_Render_DrawText(': ' + IntToStr((gLMSRespawnTime - gTime) div 1000), x + w - 16 - 64, y + h, 0, 255, 0, 255, menufont, TBasePoint.BP_LEFTDOWN);
409 end
411 begin
412 r_Render_DrawText(IntToStr(p.Lives), x + w - 16, y + h, 0, 255, 0, 255, menufont, TBasePoint.BP_RIGHTDOWN);
419 begin
424 begin
428 r_Render_DrawText(_lc[I_PLAYER_SPECT4], x div 2 + w div 2, y div 2 + h div 2, 255, 255, 255, 255, stdfont, TBasePoint.BP_CENTER);
429 end
430 else
431 begin
440 begin
450 begin
452 begin
454 if img.width = img.height then fw := img.width * 4 div 3 else fw := img.width; // fix aspect 4:3
457 end
461 begin
467 var ip: AnsiString; ww, hh, cw, ch, mw, mh, motdh, scrx, scry, i, mx, y: Integer; msg: SSArray; Srv: TNetServer;
468 begin
473 r_Render_DrawText(_lc[I_NET_SLIST], gScreenWidth div 2, 16, 255, 255, 255, 255, menufont, TBasePoint.BP_UP);
481 r_Render_DrawText(_lc[I_NET_SLIST_HELP], gScreenWidth div 2, gScreenHeight - 8, 255, 255, 255, 255, stdfont, TBasePoint.BP_DOWN);
484 begin
489 r_Render_DrawText(msg[i], 20, motdh + 3 + ch * i, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
493 begin
498 r_Render_DrawText(_lc[I_NET_SLIST_URGENT], scrx, scry - 58, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
501 r_Render_DrawText(msg[i], scrx - 253, scry - 38 + ch * i, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
502 r_Render_DrawText(_lc[I_NET_SLIST_URGENT_CONT], scrx, scry + 41, 255, 255, 255, 255, stdfont, TBasePoint.BP_UP);
504 end
506 begin
510 end
511 else
512 begin
515 begin
545 begin
551 r_Render_DrawText('<1' + _lc[I_NET_SLIST_PING_MS], mx - 68, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP)
553 r_Render_DrawText(IntToStr(Srv.Ping) + _lc[I_NET_SLIST_PING_MS], mx - 68, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP)
554 else
555 r_Render_DrawText(_lc[I_NET_SLIST_NO_ACCESS], mx - 68, y, 255, 0, 0, 255, stdfont, TBasePoint.BP_LEFTUP);
557 r_Render_DrawText('<' + IntToStr(Length(ST[I].Indices)) + '>', mx - 68, y + 16, 210, 210, 210, 255, stdfont, TBasePoint.BP_LEFTUP);
559 r_Render_DrawText(g_Game_ModeToText(Srv.GameMode), mx + 2, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
561 r_Render_DrawText(IntToStr(Srv.Players) + '/' + IntToStr(Srv.MaxPlayers), mx + 54, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
562 r_Render_DrawText(IntToStr(Srv.LocalPl) + '+' + IntToStr(Srv.Bots), mx + 54, y + 16, 210, 210, 210, 255, stdfont, TBasePoint.BP_LEFTUP);
564 r_Render_DrawText(IntToStr(Srv.Protocol), mx + 106, y, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
570 r_Render_DrawText(IntToStr(Length(ST)) + _lc[I_NET_SLIST_SERVERS], gScreenWidth - 48, motdh - 20 + 3, 255, 255, 255, 255, stdfont, TBasePoint.BP_RIGHTUP);
575 begin
577 exit;
588 //e_LogWritefln('r_render_draw: %sx%s', [gScreenWidth, gScreenHeight]);
591 begin
592 // TODO setup sectator mode
593 // TODO setup player hear point
596 begin
598 r_Render_DrawPlayerView(0, gScreenHeight div 2 + 2, gScreenWidth, gScreenHeight div 2, gPlayer2);
599 end
600 else
601 begin
605 // TODO draw holmes inspector
607 // TODO draw messages
608 // TODO draw stats (?)
609 // TODO draw spectator hud
613 begin
614 // TODO draw pause screen
618 begin
622 STATE_FOLD:
623 begin
625 r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter, 0), 255));
627 STATE_INTERCUSTOM:
628 begin
632 else
634 else
636 // TODO draw custom stata
637 {$IFDEF ENABLE_MENU}
640 {$ENDIF}
643 begin
645 begin
646 r_Draw_FillRect(0, 0, gScreenWidth - 1, gScreenHeight - 1, 0, 0, 0, MIN(MAX(255 - EndingGameCounter, 0), 255));
647 end
648 else
649 begin
651 // TODO darw single stats
652 {$IFDEF ENABLE_MENU}
655 {$ENDIF}
658 STATE_ENDPIC:
659 begin
662 else
664 {$IFDEF ENABLE_MENU}
667 {$ENDIF}
669 STATE_SLIST:
670 begin
678 {$IFDEF ENABLE_MENU}
680 begin
685 {$ENDIF}
689 // TODO draw holmes interface
693 sys_Repaint;
697 begin
707 begin
708 {$IFDEF ENABLE_SYSTEM}
711 else
714 {$ENDIF}
718 begin
722 {$IFDEF ENABLE_GIBS}
724 begin
727 {$ENDIF}
729 {$IFDEF ENABLE_GFX}
731 begin
734 {$ENDIF}
736 {$IFDEF ENABLE_TOUCH}
738 begin
741 {$ENDIF}
743 {$IFDEF ENABLE_MENU}
745 begin
750 begin
755 begin
760 begin
763 {$ENDIF}
766 begin
767 // TODO draw loading screen