First series of mods to Admin UI

Implementet the Relaod-Callvote in Ingame
Build a rudimentary Login system

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2013-03-18 14:36:06 +01:00
parent cdcd259913
commit 18e3921d4f
5 changed files with 3015 additions and 151 deletions

View file

@ -2776,3 +2776,226 @@ void UI_AdminAudioMenu( void )
UI_PushMenu( &s_adminAudio.menu );
}
/**********************************************************************
UI_LOGIN.C
User inferface for user login (sql)
**********************************************************************/
#include "ui_local.h"
static byte sqlkey;
typedef struct {
menuframework_s menu;
sfxHandle_t openingVoice;
menuaction_s admin;
menuaction_s sql;
menubitmap_s quit;
menufield_s apassword;
menufield_s username;
menufield_s password;
} login_t;
login_t s_login;
#define ID_COMPUTERVOICE 6
#define ID_ADMIN 100001
#define ID_SQL 100002
void UI_LoginMenu_Cache (void);
/*
=================
UI_LoginSetSqlkey
=================
*/
void UI_LoginSetSqlkey(int key) {
sqlkey = (byte)key;
}
/*
=================
M_Login_Event
=================
*/
static void M_Login_Event(void* ptr, int notification) {
int id;
id = ((menucommon_s*)ptr)->id;
switch(id) {
case ID_SQL:
if(notification == QM_ACTIVATED) {
trap_Cmd_ExecuteText( EXEC_APPEND, va( "userlogin %s %s\n", s_login.username.field.buffer, s_login.password.field.buffer ));
UI_PopMenu();
}
break;
case ID_ADMIN:
if(notification == QM_ACTIVATED) {
trap_Cmd_ExecuteText( EXEC_APPEND, va( "adminlogin %s\n", s_login.apassword.field.buffer ));
UI_PopMenu();
}
break;
}
}
/*
=================
LoginMenu_Key
=================
*/
sfxHandle_t LoginMenu_Key(int key) {
return (Menu_DefaultKey(&s_login.menu, key));
}
extern qhandle_t leftRound;
extern qhandle_t corner_ul_24_60;
extern qhandle_t corner_ll_12_60;
/*
===============
LoginMenu_Draw
===============
*/
static void LoginMenu_Draw(void) {
AdminMenu_DrawCommon();
vec_t* color = colorTable[CT_LTORANGE];
AdminMenu_DrawLCARSBox( 81, 194, 339, 70, color, MNT_BROADCAST_CMDS ); /* Admin Login */
AdminMenu_DrawLCARSBox( 81, 268, 339, 91, color, MNT_BROADCAST_CMDS ); /* SQL Login */
Menu_Draw(&s_login.menu);
}
/*
===============
UI_LoginMenu_Cache
===============
*/
void UI_LoginMenu_Cache(void) {
leftRound = trap_R_RegisterShaderNoMip("menu/common/halfroundl_24.tga");
corner_ul_24_60 = trap_R_RegisterShaderNoMip("menu/common/corner_ul_24_60.tga");
corner_ll_12_60 = trap_R_RegisterShaderNoMip("menu/common/corner_ll_12_60.tga");
}
/*
===============
LoginMenu_Init
===============
*/
void LoginMenu_Init(void) {
/*int y, pad, x;
int i, width;*/
s_login.menu.wrapAround = qtrue;
s_login.menu.fullscreen = qtrue;
s_login.menu.draw = LoginMenu_Draw;
s_login.menu.descX = MENU_DESC_X;
s_login.menu.descY = MENU_DESC_Y;
s_login.menu.titleX = MENU_TITLE_X;
s_login.menu.titleY = MENU_TITLE_Y;
s_login.menu.footNoteEnum = MNT_ADMIN;
s_login.menu.titleI = MNT_ADMIN_MENU;
s_login.menu.key = LoginMenu_Key;
s_login.apassword.generic.type = MTYPE_FIELD;
s_login.apassword.field.widthInChars = 30;
s_login.apassword.field.maxchars = MAX_TOKEN_CHARS; /* Freeking hell this is long... who coded this admin thing? O_O */
s_login.apassword.generic.x = 90 + 5 + UI_ProportionalStringWidth( menu_button_text[MBT_ADMIN_MESSAGE][0], UI_SMALLFONT ); /* 159; */
s_login.apassword.generic.y = 217;
s_login.apassword.field.style = UI_SMALLFONT;
s_login.apassword.field.titleEnum = MBT_ADMIN_MESSAGE;
s_login.apassword.field.titlecolor = CT_WHITE;
s_login.apassword.field.textcolor = CT_DKGOLD1;
s_login.apassword.field.textcolor2 = CT_LTGOLD1;
s_login.admin.generic.type = MTYPE_ACTION;
s_login.admin.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_login.admin.generic.callback = M_Login_Event;
s_login.admin.generic.ownerdraw = AdminMenu_DrawButton;
s_login.admin.generic.id = ID_ADMIN;
s_login.admin.generic.x = 90;
s_login.admin.generic.y = 238;
s_login.admin.textX = 9;
s_login.admin.textY = 1;
s_login.admin.textEnum = MBT_ADMIN_EXECUTE;
s_login.admin.color = CT_DKPURPLE1;
s_login.admin.color2 = CT_LTPURPLE1;
s_login.admin.textcolor = CT_BLACK;
s_login.admin.textcolor2 = CT_WHITE;
s_login.admin.width = 100;
s_login.admin.height = 18;
s_login.username.generic.type = MTYPE_FIELD;
s_login.username.field.widthInChars = 30;
s_login.username.field.maxchars = MAX_TOKEN_CHARS; /* Freeking hell this is long... who coded this admin thing? O_O */
s_login.username.generic.x = 90 + 5 + UI_ProportionalStringWidth( menu_button_text[MBT_ADMIN_MESSAGE][0], UI_SMALLFONT ); /* 159; */
s_login.username.generic.y = 290;
s_login.username.field.style = UI_SMALLFONT;
s_login.username.field.titleEnum = MBT_ADMIN_MESSAGE;
s_login.username.field.titlecolor = CT_WHITE;
s_login.username.field.textcolor = CT_DKGOLD1;
s_login.username.field.textcolor2 = CT_LTGOLD1;
s_login.password.generic.type = MTYPE_FIELD;
s_login.password.field.widthInChars = 30;
s_login.password.field.maxchars = MAX_TOKEN_CHARS; /* Freeking hell this is long... who coded this admin thing? O_O */
s_login.password.generic.x = 90 + 5 + UI_ProportionalStringWidth( menu_button_text[MBT_ADMIN_MESSAGE][0], UI_SMALLFONT ); /* 159; */
s_login.password.generic.y = 312;
s_login.password.field.style = UI_SMALLFONT;
s_login.password.field.titleEnum = MBT_ADMIN_MESSAGE;
s_login.password.field.titlecolor = CT_WHITE;
s_login.password.field.textcolor = CT_DKGOLD1;
s_login.password.field.textcolor2 = CT_LTGOLD1;
s_login.sql.generic.type = MTYPE_ACTION;
s_login.sql.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_login.sql.generic.callback = M_Login_Event;
s_login.sql.generic.ownerdraw = AdminMenu_DrawButton;
s_login.sql.generic.id = ID_SQL;
s_login.sql.generic.x = 90;
s_login.sql.generic.y = 334;
s_login.sql.textX = 9;
s_login.sql.textY = 1;
s_login.sql.textEnum = MBT_ADMIN_EXECUTE;
s_login.sql.color = CT_DKPURPLE1;
s_login.sql.color2 = CT_LTPURPLE1;
s_login.sql.textcolor = CT_BLACK;
s_login.sql.textcolor2 = CT_WHITE;
s_login.sql.width = 100;
s_login.sql.height = 18;
AdminMenu_InitButtons( &s_login.menu );
Menu_AddItem( &s_login.menu, &s_login.apassword);
Menu_AddItem( &s_login.menu, &s_login.admin );
Menu_AddItem( &s_login.menu, &s_login.username );
Menu_AddItem( &s_login.menu, &s_login.password );
Menu_AddItem( &s_login.menu, &s_login.sql );
}
/*
===============
UI_LoginMenu
===============
*/
void UI_LoginMenu(void) {
memset(&s_login, 0, sizeof(s_login));
uis.menusp = 0;
ingameFlag = qtrue;
Mouse_Show();
UI_LoginMenu_Cache();
LoginMenu_Init();
UI_PushMenu(&s_login.menu);
Menu_AdjustCursor(&s_login.menu, 1);
}

2778
code/ui/ui_admin_orig.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -80,6 +80,7 @@ typedef struct
menubitmap_s emotes;
menubitmap_s admin;
menubitmap_s login;
menubitmap_s motd;
menubitmap_s respawn;
@ -92,6 +93,7 @@ typedef struct
int prevMenu;
qboolean isAdmin;
int isSQL;
} ingamemenu_t;
@ -186,7 +188,7 @@ static void InGame_RestartAction( qboolean result )
}
UI_PopMenu();
trap_Cmd_ExecuteText( EXEC_APPEND, "map_restart 0\n" );
trap_Cmd_ExecuteText( EXEC_APPEND, "callvote map_restart 0\n" );
}
/*
@ -306,7 +308,11 @@ void InGame_Event( void *ptr, int notification )
break;
case ID_ADMIN:
UI_AdminMenu(qfalse);
if ( s_ingame.isAdmin || s_ingame.isSQL ) {
UI_AdminMenu(qfalse);
} else {
UI_LoginMenu();
}
break;
case ID_MOTD: // RPG-X | Marcin | 03/01/2008
@ -416,11 +422,9 @@ static void UI_InGameMenu_Draw( void )
UI_DrawHandlePic( s_ingame.respawn.generic.x - 14, s_ingame.respawn.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd );
if ( s_ingame.isAdmin/*s_ingame.pclass == PC_ADMIN*/ ) {
UI_DrawHandlePic( s_ingame.admin.generic.x - 14, s_ingame.admin.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd );
}
UI_DrawHandlePic( s_ingame.admin.generic.x - 14, s_ingame.admin.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd );
trap_R_SetColor( colorTable[CT_VDKRED1] );
UI_DrawHandlePic(s_ingame.leave.generic.x - 14, s_ingame.leave.generic.y,
@ -624,6 +628,7 @@ void InGame_MenuInit( void )
//TiM - Store current class
s_ingame.pclass = atoi( Info_ValueForKey( info, "p" ) );
s_ingame.isAdmin = atoi( Info_ValueForKey( info, "admin" ));
s_ingame.isSQL = atoi( Info_ValueForKey( info, "uid" ));
//TiM: flush the ranks data
trap_GetConfigString( CS_SERVERINFO, info_server, MAX_INFO_STRING );
@ -763,10 +768,6 @@ void InGame_MenuInit( void )
s_ingame.admin.textcolor = CT_BLACK;
s_ingame.admin.textcolor2 = CT_WHITE;
if ( !s_ingame.isAdmin/*s_ingame.pclass != PC_ADMIN*/ ) {
s_ingame.admin.generic.flags |= (QMF_HIDDEN|QMF_INACTIVE|QMF_GRAYED);
}
/*y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.teamorders.generic.type = MTYPE_BITMAP;
s_ingame.teamorders.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
@ -895,7 +896,7 @@ void InGame_MenuInit( void )
s_ingame.restart.textEnum = MBT_INGAMERESTART;
s_ingame.restart.textcolor = CT_BLACK;
s_ingame.restart.textcolor2 = CT_WHITE;
if( !trap_Cvar_VariableValue( "sv_running" ) )
if( !trap_Cvar_VariableValue( "g_allowVote" ) )
{
s_ingame.restart.generic.flags |= QMF_GRAYED;
}

View file

@ -1864,7 +1864,7 @@ extern void TransDataReceived(const char *data);
//
// ui_login.c
//
/* nothing for now */
void UI_LoginMenu(void);
//
// ui_demo2.c

View file

@ -1,138 +0,0 @@
/**********************************************************************
UI_LOGIN.C
User inferface for user login (sql)
**********************************************************************/
#include "ui_local.h"
static byte sqlkey;
typedef struct {
menuframework_s menu;
sfxHandle_t openingVoice;
menubitmap_s cancel;
menubitmap_s login;
menufield_s username;
menufield_s password;
} login_t;
login_t s_login;
#define ID_COMPUTERVOICE 6
#define ID_CANCEL 10
#define ID_LOGIN 100
void UI_LoginMenu_Cache (void);
/*
=================
UI_LoginSetSqlkey
=================
*/
void UI_LoginSetSqlkey(int key) {
sqlkey = (byte)key;
}
/*
=================
M_Login_Event
=================
*/
static void M_Login_Event(void* ptr, int notification) {
int id;
id = ((menucommon_s*)ptr)->id;
switch(id) {
case ID_QUIT:
if(notification == QM_ACTIVATED)
UI_PopMenu();
break;
case ID_LOGIN:
if(notification == QM_ACTIVATED) {
// do login
}
break;
}
}
/*
=================
LoginMenu_Key
=================
*/
sfxHandle_t LoginMenu_Key(int key) {
return (Menu_DefaultKey(&s_login.menu, key));
}
extern qhandle_t leftRound;
extern qhandle_t corner_ul_24_60;
extern qhandle_t corner_ll_12_60;
/*
=================
M_LoginMenu_Graphics
=================
*/
static void M_LoginMenu_Graphics(void) {
// do graphic here
}
/*
===============
LoginMenu_Draw
===============
*/
static void LoginMenu_Draw(void) {
M_LoginMenu_Graphics();
Menu_Draw(&s_login.menu);
}
/*
===============
UI_LoginMenu_Cache
===============
*/
void UI_LoginMenu_Cache(void) {
leftRound = trap_R_RegisterShaderNoMip("menu/common/halfroundl_24.tga");
corner_ul_24_60 = trap_R_RegisterShaderNoMip("menu/common/corner_ul_24_60.tga");
corner_ll_12_60 = trap_R_RegisterShaderNoMip("menu/common/corner_ll_12_60.tga");
}
/*
===============
LoginMenu_Init
===============
*/
void LoginMenu_Init(void) {
int y, pad, x;
int i, width;
//init menu
}
/*
===============
UI_LoginMenu
===============
*/
void UI_LoginMenu(void) {
memset(&s_login, 0, sizeof(s_login));
uis.menusp = 0;
ingameFlag = qtrue;
Mouse_Show();
UI_LoginMenu_Cache();
LoginMenu_Init();
UI_PushMenu(&s_login.menu);
Menu_AdjustCursor(&s_login.menu, 1);
}