Debian Codegraph @

code/q3_ui/ui_team.c

raw symbols SCIP
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/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 /*
51 ===============
52 TeamMain_MenuEvent
53 ===============
54 */
55 static void TeamMain_MenuEvent( void* ptr, int event ) {
56 if( event != QM_ACTIVATED ) {
57 return;
58 }
59
60 switch( ((menucommon_s*)ptr)->id ) {
61 case ID_JOINRED:
62 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team red\n" );
63 UI_ForceMenuOff();
64 break;
65
66 case ID_JOINBLUE:
67 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team blue\n" );
68 UI_ForceMenuOff();
69 break;
70
71 case ID_JOINGAME:
72 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team free\n" );
73 UI_ForceMenuOff();
74 break;
75
76 case ID_SPECTATE:
77 trap_Cmd_ExecuteText( EXEC_APPEND, "cmd team spectator\n" );
78 UI_ForceMenuOff();
79 break;
80 }
81 }
82
83
84 /*
85 ===============
86 TeamMain_MenuInit
87 ===============
88 */
89 void TeamMain_MenuInit( void ) {
90 int y;
91 int gametype;
92 char info[MAX_INFO_STRING];
93
94 memset( &s_teammain, 0, sizeof(s_teammain) );
95
96 TeamMain_Cache();
97
98 s_teammain.menu.wrapAround = qtrue;
99 s_teammain.menu.fullscreen = qfalse;
100
101 s_teammain.frame.generic.type = MTYPE_BITMAP;
102 s_teammain.frame.generic.flags = QMF_INACTIVE;
103 s_teammain.frame.generic.name = TEAMMAIN_FRAME;
104 s_teammain.frame.generic.x = 142;
105 s_teammain.frame.generic.y = 118;
106 s_teammain.frame.width = 359;
107 s_teammain.frame.height = 256;
108
109 y = 194;
110
111 s_teammain.joinred.generic.type = MTYPE_PTEXT;
112 s_teammain.joinred.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
113 s_teammain.joinred.generic.id = ID_JOINRED;
114 s_teammain.joinred.generic.callback = TeamMain_MenuEvent;
115 s_teammain.joinred.generic.x = 320;
116 s_teammain.joinred.generic.y = y;
117 s_teammain.joinred.string = "JOIN RED";
118 s_teammain.joinred.style = UI_CENTER|UI_SMALLFONT;
119 s_teammain.joinred.color = colorRed;
120 y += 20;
121
122 s_teammain.joinblue.generic.type = MTYPE_PTEXT;
123 s_teammain.joinblue.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
124 s_teammain.joinblue.generic.id = ID_JOINBLUE;
125 s_teammain.joinblue.generic.callback = TeamMain_MenuEvent;
126 s_teammain.joinblue.generic.x = 320;
127 s_teammain.joinblue.generic.y = y;
128 s_teammain.joinblue.string = "JOIN BLUE";
129 s_teammain.joinblue.style = UI_CENTER|UI_SMALLFONT;
130 s_teammain.joinblue.color = colorRed;
131 y += 20;
132
133 s_teammain.joingame.generic.type = MTYPE_PTEXT;
134 s_teammain.joingame.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
135 s_teammain.joingame.generic.id = ID_JOINGAME;
136 s_teammain.joingame.generic.callback = TeamMain_MenuEvent;
137 s_teammain.joingame.generic.x = 320;
138 s_teammain.joingame.generic.y = y;
139 s_teammain.joingame.string = "JOIN GAME";
140 s_teammain.joingame.style = UI_CENTER|UI_SMALLFONT;
141 s_teammain.joingame.color = colorRed;
142 y += 20;
143
144 s_teammain.spectate.generic.type = MTYPE_PTEXT;
145 s_teammain.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
146 s_teammain.spectate.generic.id = ID_SPECTATE;
147 s_teammain.spectate.generic.callback = TeamMain_MenuEvent;
148 s_teammain.spectate.generic.x = 320;
149 s_teammain.spectate.generic.y = y;
150 s_teammain.spectate.string = "SPECTATE";
151 s_teammain.spectate.style = UI_CENTER|UI_SMALLFONT;
152 s_teammain.spectate.color = colorRed;
153
154 trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);
155 gametype = atoi( Info_ValueForKey( info,"g_gametype" ) );
156
157 // set initial states
158 switch( gametype ) {
159 case GT_SINGLE_PLAYER:
160 case GT_FFA:
161 case GT_TOURNAMENT:
162 s_teammain.joinred.generic.flags |= QMF_GRAYED;
163 s_teammain.joinblue.generic.flags |= QMF_GRAYED;
164 break;
165
166 default:
167 case GT_TEAM:
168 case GT_CTF:
169 s_teammain.joingame.generic.flags |= QMF_GRAYED;
170 break;
171 }
172
173 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.frame );
174 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinred );
175 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinblue );
176 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.joingame );
177 Menu_AddItem( &s_teammain.menu, (void*) &s_teammain.spectate );
178 }
179
180
181 /*
182 ===============
183 TeamMain_Cache
184 ===============
185 */
186 void TeamMain_Cache( void ) {
187 trap_R_RegisterShaderNoMip( TEAMMAIN_FRAME );
188 }
189
190
191 /*
192 ===============
193 UI_TeamMainMenu
194 ===============
195 */
196 void UI_TeamMainMenu( void ) {
197 TeamMain_MenuInit();
198 UI_PushMenu ( &s_teammain.menu );
199 }