DEADSOFTWARE

render: use TAnimationState for projectiles
[d2df-sdl.git] / src / game / opengl / r_netmaster.pas
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}
16 unit r_netmaster;
18 interface
20 uses g_netmaster;
22 procedure r_Serverlist_Draw (var SL: TNetServerList; var ST: TNetServerTable);
24 implementation
26 uses
27 SysUtils, Classes, Math,
28 r_graphics,
29 g_basic, g_language, g_game, g_menu
30 ;
32 procedure r_Serverlist_Draw (var SL: TNetServerList; var ST: TNetServerTable);
33 var
34 Srv: TNetServer;
35 sy, i, y, mw, mx, l, motdh: Integer;
36 cw: Byte = 0;
37 ch: Byte = 0;
38 ww: Word = 0;
39 hh: Word = 0;
40 ip: AnsiString;
41 begin
42 ip := '';
43 sy := 0;
45 e_CharFont_GetSize(gMenuFont, _lc[I_NET_SLIST], ww, hh);
46 e_CharFont_Print(gMenuFont, (gScreenWidth div 2) - (ww div 2), 16, _lc[I_NET_SLIST]);
48 e_TextureFontGetSize(gStdFont, cw, ch);
50 ip := _lc[I_NET_SLIST_HELP];
51 mw := (Length(ip) * cw) div 2;
53 motdh := gScreenHeight - 49 - ch * b_Text_LineCount(slMOTD);
55 e_DrawFillQuad(16, 64, gScreenWidth-16, motdh, 64, 64, 64, 110);
56 e_DrawQuad(16, 64, gScreenWidth-16, motdh, 255, 127, 0);
58 e_TextureFontPrintEx(gScreenWidth div 2 - mw, gScreenHeight-24, ip, gStdFont, 225, 225, 225, 1);
60 // MOTD
61 if slMOTD <> '' then
62 begin
63 e_DrawFillQuad(16, motdh, gScreenWidth-16, gScreenHeight-44, 64, 64, 64, 110);
64 e_DrawQuad(16, motdh, gScreenWidth-16, gScreenHeight-44, 255, 127, 0);
65 e_TextureFontPrintFmt(20, motdh + 3, slMOTD, gStdFont, False, True);
66 end;
68 // Urgent message
69 if not slReadUrgent and (slUrgent <> '') then
70 begin
71 e_DrawFillQuad(17, 65, gScreenWidth-17, motdh-1, 64, 64, 64, 128);
72 e_DrawFillQuad(gScreenWidth div 2 - 256, gScreenHeight div 2 - 60,
73 gScreenWidth div 2 + 256, gScreenHeight div 2 + 60, 64, 64, 64, 128);
74 e_DrawQuad(gScreenWidth div 2 - 256, gScreenHeight div 2 - 60,
75 gScreenWidth div 2 + 256, gScreenHeight div 2 + 60, 255, 127, 0);
76 e_DrawLine(1, gScreenWidth div 2 - 256, gScreenHeight div 2 - 40,
77 gScreenWidth div 2 + 256, gScreenHeight div 2 - 40, 255, 127, 0);
78 l := Length(_lc[I_NET_SLIST_URGENT]) div 2;
79 e_TextureFontPrint(gScreenWidth div 2 - cw * l, gScreenHeight div 2 - 58,
80 _lc[I_NET_SLIST_URGENT], gStdFont);
81 l := Length(slUrgent) div 2;
82 e_TextureFontPrintFmt(gScreenWidth div 2 - 253, gScreenHeight div 2 - 38,
83 slUrgent, gStdFont, False, True);
84 l := Length(_lc[I_NET_SLIST_URGENT_CONT]) div 2;
85 e_TextureFontPrint(gScreenWidth div 2 - cw * l, gScreenHeight div 2 + 41,
86 _lc[I_NET_SLIST_URGENT_CONT], gStdFont);
87 e_DrawLine(1, gScreenWidth div 2 - 256, gScreenHeight div 2 + 40,
88 gScreenWidth div 2 + 256, gScreenHeight div 2 + 40, 255, 127, 0);
89 Exit;
90 end;
92 if SL = nil then
93 begin
94 l := Length(slWaitStr) div 2;
95 e_DrawFillQuad(17, 65, gScreenWidth-17, motdh-1, 64, 64, 64, 128);
96 e_DrawQuad(gScreenWidth div 2 - 192, gScreenHeight div 2 - 10,
97 gScreenWidth div 2 + 192, gScreenHeight div 2 + 11, 255, 127, 0);
98 e_TextureFontPrint(gScreenWidth div 2 - cw * l, gScreenHeight div 2 - ch div 2,
99 slWaitStr, gStdFont);
100 Exit;
101 end;
103 y := 90;
104 if (slSelection < Length(ST)) then
105 begin
106 I := slSelection;
107 sy := y + 42 * I - 4;
108 Srv := GetServerFromTable(I, SL, ST);
109 ip := _lc[I_NET_ADDRESS] + ' ' + Srv.IP + ':' + IntToStr(Srv.Port);
110 if Srv.Password then
111 ip := ip + ' ' + _lc[I_NET_SERVER_PASSWORD] + ' ' + _lc[I_MENU_YES]
112 else
113 ip := ip + ' ' + _lc[I_NET_SERVER_PASSWORD] + ' ' + _lc[I_MENU_NO];
114 end else
115 if Length(ST) > 0 then
116 slSelection := 0;
118 mw := (gScreenWidth - 188);
119 mx := 16 + mw;
121 e_DrawFillQuad(16 + 1, sy, gScreenWidth - 16 - 1, sy + 40, 64, 64, 64, 0);
122 e_DrawLine(1, 16 + 1, sy, gScreenWidth - 16 - 1, sy, 205, 205, 205);
123 e_DrawLine(1, 16 + 1, sy + 41, gScreenWidth - 16 - 1, sy + 41, 255, 255, 255);
125 e_DrawLine(1, 16, 85, gScreenWidth - 16, 85, 255, 127, 0);
126 e_DrawLine(1, 16, motdh-20, gScreenWidth-16, motdh-20, 255, 127, 0);
128 e_DrawLine(1, mx - 70, 64, mx - 70, motdh, 255, 127, 0);
129 e_DrawLine(1, mx, 64, mx, motdh-20, 255, 127, 0);
130 e_DrawLine(1, mx + 52, 64, mx + 52, motdh-20, 255, 127, 0);
131 e_DrawLine(1, mx + 104, 64, mx + 104, motdh-20, 255, 127, 0);
133 e_TextureFontPrintEx(18, 68, 'NAME/MAP', gStdFont, 255, 127, 0, 1);
134 e_TextureFontPrintEx(mx - 68, 68, 'PING', gStdFont, 255, 127, 0, 1);
135 e_TextureFontPrintEx(mx + 2, 68, 'MODE', gStdFont, 255, 127, 0, 1);
136 e_TextureFontPrintEx(mx + 54, 68, 'PLRS', gStdFont, 255, 127, 0, 1);
137 e_TextureFontPrintEx(mx + 106, 68, 'VER', gStdFont, 255, 127, 0, 1);
139 y := 90;
140 for I := 0 to High(ST) do
141 begin
142 Srv := GetServerFromTable(I, SL, ST);
143 // Name and map
144 e_TextureFontPrintEx(18, y, Srv.Name, gStdFont, 255, 255, 255, 1);
145 e_TextureFontPrintEx(18, y + 16, Srv.Map, gStdFont, 210, 210, 210, 1);
147 // Ping and similar count
148 if (Srv.Ping < 0) or (Srv.Ping > 999) then
149 e_TextureFontPrintEx(mx - 68, y, _lc[I_NET_SLIST_NO_ACCESS], gStdFont, 255, 0, 0, 1)
150 else
151 if Srv.Ping = 0 then
152 e_TextureFontPrintEx(mx - 68, y, '<1' + _lc[I_NET_SLIST_PING_MS], gStdFont, 255, 255, 255, 1)
153 else
154 e_TextureFontPrintEx(mx - 68, y, IntToStr(Srv.Ping) + _lc[I_NET_SLIST_PING_MS], gStdFont, 255, 255, 255, 1);
156 if Length(ST[I].Indices) > 1 then
157 e_TextureFontPrintEx(mx - 68, y + 16, '< ' + IntToStr(Length(ST[I].Indices)) + ' >', gStdFont, 210, 210, 210, 1);
159 // Game mode
160 e_TextureFontPrintEx(mx + 2, y, g_Game_ModeToText(Srv.GameMode), gStdFont, 255, 255, 255, 1);
162 // Players
163 e_TextureFontPrintEx(mx + 54, y, IntToStr(Srv.Players) + '/' + IntToStr(Srv.MaxPlayers), gStdFont, 255, 255, 255, 1);
164 e_TextureFontPrintEx(mx + 54, y + 16, IntToStr(Srv.LocalPl) + '+' + IntToStr(Srv.Bots), gStdFont, 210, 210, 210, 1);
166 // Version
167 e_TextureFontPrintEx(mx + 106, y, IntToStr(Srv.Protocol), gStdFont, 255, 255, 255, 1);
169 y := y + 42;
170 end;
172 e_TextureFontPrintEx(20, motdh-20+3, ip, gStdFont, 205, 205, 205, 1);
173 ip := IntToStr(Length(ST)) + _lc[I_NET_SLIST_SERVERS];
174 e_TextureFontPrintEx(gScreenWidth - 48 - (Length(ip) + 1)*cw,
175 motdh-20+3, ip, gStdFont, 205, 205, 205, 1);
176 end;
178 end.