Debian Codegraph @

code/q3_ui/ui_team.c

raw
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23 //
24 // ui_team.c
25 //
26
27 #include "ui_local.h"
28
29
30 #define TEAMMAIN_FRAME "menu/art_blueish/cut_frame"
31
32 #define ID_JOINRED 100
33 #define ID_JOINBLUE 101
34 #define ID_JOINGAME 102
35 #define ID_SPECTATE 103
36
37
38 typedef struct
39 {
40 menuframework_s menu;
41 menubitmap_s frame;
42 menutext_s joinred;
43 menutext_s joinblue;
44 menutext_s joingame;
45 menutext_s spectate;
46 } teammain_t;
47
48 static teammain_t s_teammain;
49
50 // bk001204 - unused
51 //static menuframework_s s_teammain_menu;
52 //static menuaction_s s_teammain_orders;
53 //static menuaction_s s_teammain_voice;
54 //static menuaction_s s_teammain_joinred;
55 //static menuaction_s s_teammain_joinblue;
56 //static menuaction_s s_teammain_joingame;
57 //static menuaction_s s_teammain_spectate;
58
59
60 /*
61 ===============
62 TeamMain_MenuEvent
63 ===============
64 */
65 static void TeamMain_MenuEvent( void* ptr, int event ) {
66 if( event != QM_ACTIVATED ) {
67 return;
68 }
69
70 switch( ((menucommon_s*)ptr)->id ) {
71 case ID_JOINRED:
72 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team red\n" );
73 UI_ForceMenuOff();
74 break;
75
76 case ID_JOINBLUE:
77 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team blue\n" );
78 UI_ForceMenuOff();
79 break;
80
81 case ID_JOINGAME:
82 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team free\n" );
83 UI_ForceMenuOff();
84 break;
85
86 case ID_SPECTATE:
87 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team spectator\n" );
88 UI_ForceMenuOff();
89 break;
90 }
91 }
92
93
94 /*
95 ===============
96 TeamMain_MenuInit
97 ===============
98 */
99 void TeamMain_MenuInit( void ) {
100 int y;
101 int gametype;
102 char info[MAX_INFO_STRING];
103
104 memset( &s_teammain, 0, sizeof(s_teammain) );
105
106 TeamMain_Cache();
107
108 s_teammain.menu.wrapAround = qtrue;
109 s_teammain.menu.fullscreen = qfalse;
110
111 s_teammain.frame.generic.type = MTYPE_BITMAP;
112 s_teammain.frame.generic.flags = QMF_INACTIVE;
113 s_teammain.frame.generic.name = TEAMMAIN_FRAME;
114 s_teammain.frame.generic.x = 142;
115 s_teammain.frame.generic.y = 118;
116 s_teammain.frame.width = 359;
117 s_teammain.frame.height = 256;
118
119 y = 194;
120
121 s_teammain.joinred.generic.type = MTYPE_PTEXT;
122 s_teammain.joinred.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
123 s_teammain.joinred.generic.id = ID_JOINRED;
124 s_teammain.joinred.generic.callback = TeamMain_MenuEvent;
125 s_teammain.joinred.generic.x = 320;
126 s_teammain.joinred.generic.y = y;
127 s_teammain.joinred.string = "JOIN RED";
128 s_teammain.joinred.style = UI_CENTER|UI_SMALLFONT;
129 s_teammain.joinred.color = colorRed;
130 y += 20;
131
132 s_teammain.joinblue.generic.type = MTYPE_PTEXT;
133 s_teammain.joinblue.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
134 s_teammain.joinblue.generic.id = ID_JOINBLUE;
135 s_teammain.joinblue.generic.callback = TeamMain_MenuEvent;
136 s_teammain.joinblue.generic.x = 320;
137 s_teammain.joinblue.generic.y = y;
138 s_teammain.joinblue.string = "JOIN BLUE";
139 s_teammain.joinblue.style = UI_CENTER|UI_SMALLFONT;
140 s_teammain.joinblue.color = colorRed;
141 y += 20;
142
143 s_teammain.joingame.generic.type = MTYPE_PTEXT;
144 s_teammain.joingame.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
145 s_teammain.joingame.generic.id = ID_JOINGAME;
146 s_teammain.joingame.generic.callback = TeamMain_MenuEvent;
147 s_teammain.joingame.generic.x = 320;
148 s_teammain.joingame.generic.y = y;
149 s_teammain.joingame.string = "JOIN GAME";
150 s_teammain.joingame.style = UI_CENTER|UI_SMALLFONT;
151 s_teammain.joingame.color = colorRed;
152 y += 20;
153
154 s_teammain.spectate.generic.type = MTYPE_PTEXT;
155 s_teammain.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
156 s_teammain.spectate.generic.id = ID_SPECTATE;
157 s_teammain.spectate.generic.callback = TeamMain_MenuEvent;
158 s_teammain.spectate.generic.x = 320;
159 s_teammain.spectate.generic.y = y;
160 s_teammain.spectate.string = "SPECTATE";
161 s_teammain.spectate.style = UI_CENTER|UI_SMALLFONT;
162 s_teammain.spectate.color = colorRed;
163 y += 20;
164
165 trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);
166 gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
167
168 // set initial states
169 switch( gametype ) {
170 case GT_SINGLE_PLAYER:
171 case GT_FFA:
172 case GT_LMS:
173 case GT_TOURNAMENT:
174 s_teammain.joinred.generic.flags |= QMF_GRAYED;
175 s_teammain.joinblue.generic.flags |= QMF_GRAYED;
176 break;
177
178 default:
179 case GT_TEAM:
180 case GT_CTF:
181 case GT_ELIMINATION:
182 case GT_CTF_ELIMINATION:
183 //s_teammain.joingame.generic.flags |= QMF_GRAYED;
184 s_teammain.joingame.string = "AUTO JOIN GAME";
185 break;
186 }
187
188 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.frame );
189 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinred );
190 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinblue );
191 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joingame );
192 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.spectate );
193 }
194
195
196 /*
197 ===============
198 TeamMain_Cache
199 ===============
200 */
201 void TeamMain_Cache( void ) {
202 trap_R_RegisterShaderNoMip( TEAMMAIN_FRAME );
203 }
204
205
206 /*
207 ===============
208 UI_TeamMainMenu
209 ===============
210 */
211 void UI_TeamMainMenu( void ) {
212 TeamMain_MenuInit();
213 UI_PushMenu ( &s_teammain.menu );
214 }