DEADSOFTWARE

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