2
===========================================================================
3
Copyright (C) 1999-2005 Id Software, Inc.
5
This file is part of Quake III Arena source code.
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.
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.
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
===========================================================================
24
=======================================================================
28
=======================================================================
35
#define ART_FRAME "menu/art/cut_frame"
36
#define ART_ACCEPT0 "menu/art/accept_0"
37
#define ART_ACCEPT1 "menu/art/accept_1"
38
#define ART_BACK0 "menu/art/back_0"
39
#define ART_BACK1 "menu/art/back_1"
58
static cdkeyMenuInfo_t cdkeyMenuInfo;
66
static void UI_CDKeyMenu_Event( void *ptr, int event ) {
67
if( event != QM_ACTIVATED ) {
71
switch( ((menucommon_s*)ptr)->id ) {
73
if( cdkeyMenuInfo.cdkey.field.buffer[0] ) {
74
trap_SetCDKey( cdkeyMenuInfo.cdkey.field.buffer );
88
UI_CDKeyMenu_PreValidateKey
91
static int UI_CDKeyMenu_PreValidateKey( const char *key ) {
94
if( strlen( key ) != 16 ) {
98
while( ( ch = *key++ ) ) {
131
static void UI_CDKeyMenu_DrawKey( void *self ) {
140
f = (menufield_s *)self;
142
focus = (f->generic.parent->cursor == f->generic.menuPosition);
146
color = color_yellow;
149
color = color_orange;
152
x = 320 - 8 * BIGCHAR_WIDTH;
153
y = 240 - BIGCHAR_HEIGHT / 2;
154
UI_FillRect( x, y, 16 * BIGCHAR_WIDTH, BIGCHAR_HEIGHT, listbar_color );
155
UI_DrawString( x, y, f->field.buffer, style, color );
157
// draw cursor if we have focus
159
if ( trap_Key_GetOverstrikeMode() ) {
168
UI_DrawChar( x + f->field.cursor * BIGCHAR_WIDTH, y, c, style, color_white );
171
val = UI_CDKeyMenu_PreValidateKey( f->field.buffer );
173
UI_DrawProportionalString( 320, 376, "Please enter your CD Key", UI_CENTER|UI_SMALLFONT, color_yellow );
175
else if ( val == 0 ) {
176
UI_DrawProportionalString( 320, 376, "The CD Key appears to be valid, thank you", UI_CENTER|UI_SMALLFONT, color_white );
179
UI_DrawProportionalString( 320, 376, "The CD Key is not valid", UI_CENTER|UI_SMALLFONT, color_red );
189
static void UI_CDKeyMenu_Init( void ) {
190
trap_Cvar_Set( "ui_cdkeychecked", "1" );
192
UI_CDKeyMenu_Cache();
194
memset( &cdkeyMenuInfo, 0, sizeof(cdkeyMenuInfo) );
195
cdkeyMenuInfo.menu.wrapAround = qtrue;
196
cdkeyMenuInfo.menu.fullscreen = qtrue;
198
cdkeyMenuInfo.banner.generic.type = MTYPE_BTEXT;
199
cdkeyMenuInfo.banner.generic.x = 320;
200
cdkeyMenuInfo.banner.generic.y = 16;
201
cdkeyMenuInfo.banner.string = "CD KEY";
202
cdkeyMenuInfo.banner.color = color_white;
203
cdkeyMenuInfo.banner.style = UI_CENTER;
205
cdkeyMenuInfo.frame.generic.type = MTYPE_BITMAP;
206
cdkeyMenuInfo.frame.generic.name = ART_FRAME;
207
cdkeyMenuInfo.frame.generic.flags = QMF_INACTIVE;
208
cdkeyMenuInfo.frame.generic.x = 142;
209
cdkeyMenuInfo.frame.generic.y = 118;
210
cdkeyMenuInfo.frame.width = 359;
211
cdkeyMenuInfo.frame.height = 256;
213
cdkeyMenuInfo.cdkey.generic.type = MTYPE_FIELD;
214
cdkeyMenuInfo.cdkey.generic.name = "CD Key:";
215
cdkeyMenuInfo.cdkey.generic.flags = QMF_LOWERCASE;
216
cdkeyMenuInfo.cdkey.generic.x = 320 - BIGCHAR_WIDTH * 2.5;
217
cdkeyMenuInfo.cdkey.generic.y = 240 - BIGCHAR_HEIGHT / 2;
218
cdkeyMenuInfo.cdkey.field.widthInChars = 16;
219
cdkeyMenuInfo.cdkey.field.maxchars = 16;
220
cdkeyMenuInfo.cdkey.generic.ownerdraw = UI_CDKeyMenu_DrawKey;
222
cdkeyMenuInfo.accept.generic.type = MTYPE_BITMAP;
223
cdkeyMenuInfo.accept.generic.name = ART_ACCEPT0;
224
cdkeyMenuInfo.accept.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
225
cdkeyMenuInfo.accept.generic.id = ID_ACCEPT;
226
cdkeyMenuInfo.accept.generic.callback = UI_CDKeyMenu_Event;
227
cdkeyMenuInfo.accept.generic.x = 640;
228
cdkeyMenuInfo.accept.generic.y = 480-64;
229
cdkeyMenuInfo.accept.width = 128;
230
cdkeyMenuInfo.accept.height = 64;
231
cdkeyMenuInfo.accept.focuspic = ART_ACCEPT1;
233
cdkeyMenuInfo.back.generic.type = MTYPE_BITMAP;
234
cdkeyMenuInfo.back.generic.name = ART_BACK0;
235
cdkeyMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
236
cdkeyMenuInfo.back.generic.id = ID_BACK;
237
cdkeyMenuInfo.back.generic.callback = UI_CDKeyMenu_Event;
238
cdkeyMenuInfo.back.generic.x = 0;
239
cdkeyMenuInfo.back.generic.y = 480-64;
240
cdkeyMenuInfo.back.width = 128;
241
cdkeyMenuInfo.back.height = 64;
242
cdkeyMenuInfo.back.focuspic = ART_BACK1;
244
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.banner );
245
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.frame );
246
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.cdkey );
247
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.accept );
249
Menu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.back );
252
trap_GetCDKey( cdkeyMenuInfo.cdkey.field.buffer, cdkeyMenuInfo.cdkey.field.maxchars + 1 );
253
if( trap_VerifyCDKey( cdkeyMenuInfo.cdkey.field.buffer, NULL ) == qfalse ) {
254
cdkeyMenuInfo.cdkey.field.buffer[0] = 0;
264
void UI_CDKeyMenu_Cache( void ) {
265
trap_R_RegisterShaderNoMip( ART_ACCEPT0 );
266
trap_R_RegisterShaderNoMip( ART_ACCEPT1 );
267
trap_R_RegisterShaderNoMip( ART_BACK0 );
268
trap_R_RegisterShaderNoMip( ART_BACK1 );
269
trap_R_RegisterShaderNoMip( ART_FRAME );
278
void UI_CDKeyMenu( void ) {
280
UI_PushMenu( &cdkeyMenuInfo.menu );
289
void UI_CDKeyMenu_f( void ) {