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