Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ui_login.c

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 //
00023 //
00024 // ui_login.c
00025 //
00026 
00027 #include "ui_local.h"
00028 
00029 
00030 #define LOGIN_FRAME     "menu/art/cut_frame"
00031 
00032 #define ID_NAME         100
00033 #define ID_NAME_BOX     101
00034 #define ID_PASSWORD     102
00035 #define ID_PASSWORD_BOX 103
00036 #define ID_LOGIN        104
00037 #define ID_CANCEL       105
00038 
00039 
00040 typedef struct
00041 {
00042     menuframework_s menu;
00043     menubitmap_s    frame;
00044     menutext_s      name;
00045     menufield_s     name_box;
00046     menutext_s      password;
00047     menufield_s     password_box;
00048     menutext_s      login;
00049     menutext_s      cancel;
00050 } login_t;
00051 
00052 static login_t  s_login;
00053 
00054 static menuframework_s  s_login_menu;
00055 static menuaction_s     s_login_login;
00056 static menuaction_s     s_login_cancel;
00057 
00058 static vec4_t s_login_color_prompt  = {1.00, 0.43, 0.00, 1.00};
00059 
00060 /*
00061 ===============
00062 Login_MenuEvent
00063 ===============
00064 */
00065 static void Login_MenuEvent( void* ptr, int event ) {
00066     if( event != QM_ACTIVATED ) {
00067         return;
00068     }
00069 
00070     switch( ((menucommon_s*)ptr)->id ) {
00071     case ID_LOGIN:
00072         // set name                             ``
00073         //trap_Cvar_Set( "name", s_login.name_box.field.buffer );
00074         /*
00075         trap_Cvar_Set( "rank_name", s_login.name_box.field.buffer );
00076         trap_Cvar_Set( "rank_pwd", s_login.password_box.field.buffer );
00077         */
00078 
00079         // login
00080         trap_CL_UI_RankUserLogin(
00081             s_login.name_box.field.buffer, 
00082             s_login.password_box.field.buffer );
00083 
00084         UI_ForceMenuOff();
00085         break;
00086         
00087     case ID_CANCEL:
00088         UI_PopMenu();
00089         break;
00090     }
00091 }
00092 
00093 
00094 /*
00095 ===============
00096 Login_MenuInit
00097 ===============
00098 */
00099 void Login_MenuInit( void ) {
00100     int             y;
00101 
00102     memset( &s_login, 0, sizeof(s_login) );
00103 
00104     Login_Cache();
00105 
00106     s_login.menu.wrapAround = qtrue;
00107     s_login.menu.fullscreen = qfalse;
00108 
00109     s_login.frame.generic.type          = MTYPE_BITMAP;
00110     s_login.frame.generic.flags         = QMF_INACTIVE;
00111     s_login.frame.generic.name          = LOGIN_FRAME;
00112     s_login.frame.generic.x             = 142; //320-233;
00113     s_login.frame.generic.y             = 118; //240-166;
00114     s_login.frame.width                 = 359; //466;
00115     s_login.frame.height                = 256; //332;
00116 
00117     y = 214;
00118 
00119     s_login.name.generic.type           = MTYPE_PTEXT;
00120     s_login.name.generic.flags          = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
00121     s_login.name.generic.id             = ID_NAME;
00122     s_login.name.generic.x              = 310;
00123     s_login.name.generic.y              = y;
00124     s_login.name.string                 = "NAME";
00125     s_login.name.style                  = UI_RIGHT|UI_SMALLFONT;
00126     s_login.name.color                  = s_login_color_prompt;
00127 
00128     s_login.name_box.generic.type       = MTYPE_FIELD;
00129     s_login.name_box.generic.ownerdraw  = Rankings_DrawName;
00130     s_login.name_box.generic.name       = "";
00131     s_login.name_box.generic.flags      = 0;
00132     s_login.name_box.generic.x          = 330;
00133     s_login.name_box.generic.y          = y;
00134     s_login.name_box.field.widthInChars = 16;
00135     s_login.name_box.field.maxchars     = 16;
00136     y += 20;
00137     
00138     s_login.password.generic.type       = MTYPE_PTEXT;
00139     s_login.password.generic.flags      = QMF_RIGHT_JUSTIFY|QMF_INACTIVE;
00140     s_login.password.generic.id         = ID_PASSWORD;
00141     s_login.password.generic.x          = 310;
00142     s_login.password.generic.y          = y;
00143     s_login.password.string             = "PASSWORD";
00144     s_login.password.style              = UI_RIGHT|UI_SMALLFONT;
00145     s_login.password.color              = s_login_color_prompt;
00146 
00147     s_login.password_box.generic.type       = MTYPE_FIELD;
00148     s_login.password_box.generic.ownerdraw  = Rankings_DrawPassword;
00149     s_login.password_box.generic.name       = "";
00150     s_login.password_box.generic.flags      = 0;
00151     s_login.password_box.generic.x          = 330;
00152     s_login.password_box.generic.y          = y;
00153     s_login.password_box.field.widthInChars = 16;
00154     s_login.password_box.field.maxchars     = 16;
00155     y += 40;
00156 
00157     s_login.login.generic.type              = MTYPE_PTEXT;
00158     s_login.login.generic.flags             = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
00159     s_login.login.generic.id                = ID_LOGIN;
00160     s_login.login.generic.callback          = Login_MenuEvent;
00161     s_login.login.generic.x                 = 310;
00162     s_login.login.generic.y                 = y;
00163     s_login.login.string                    = "LOGIN";
00164     s_login.login.style                     = UI_RIGHT|UI_SMALLFONT;
00165     s_login.login.color                     = colorRed;
00166 
00167     s_login.cancel.generic.type             = MTYPE_PTEXT;
00168     s_login.cancel.generic.flags            = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
00169     s_login.cancel.generic.id               = ID_CANCEL;
00170     s_login.cancel.generic.callback         = Login_MenuEvent;
00171     s_login.cancel.generic.x                = 330;
00172     s_login.cancel.generic.y                = y;
00173     s_login.cancel.string                   = "CANCEL";
00174     s_login.cancel.style                    = UI_LEFT|UI_SMALLFONT;
00175     s_login.cancel.color                    = colorRed;
00176     y += 20;
00177 
00178     Menu_AddItem( &s_login.menu, (void*) &s_login.frame );
00179     Menu_AddItem( &s_login.menu, (void*) &s_login.name );
00180     Menu_AddItem( &s_login.menu, (void*) &s_login.name_box );
00181     Menu_AddItem( &s_login.menu, (void*) &s_login.password );
00182     Menu_AddItem( &s_login.menu, (void*) &s_login.password_box );
00183     Menu_AddItem( &s_login.menu, (void*) &s_login.login );
00184     Menu_AddItem( &s_login.menu, (void*) &s_login.cancel );
00185 }
00186 
00187 
00188 /*
00189 ===============
00190 Login_Cache
00191 ===============
00192 */
00193 void Login_Cache( void ) {
00194     trap_R_RegisterShaderNoMip( LOGIN_FRAME );
00195 }
00196 
00197 
00198 /*
00199 ===============
00200 UI_LoginMenu
00201 ===============
00202 */
00203 void UI_LoginMenu( void ) {
00204     Login_MenuInit();
00205     UI_PushMenu ( &s_login.menu );
00206 }
00207 
00208 

Generated on Thu Aug 25 12:37:41 2005 for Quake III Arena by  doxygen 1.3.9.1