More work on admin UI

I had some issues with the standalone Welcome Page so I modified the Login Page to include this and moved the Admin-Check there as well.
I altered the Defines in ui_admin.c and updated on other positions where required so far (I'll adapt the remainder as time comes)
I enabled subfolders for the Music-UI (I don't see why this is a problem at all)
I the Ingame menu I completely disabled the HC-Butttons.
Added Logout-Ability for userlogion (adapted from adminlogin)

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2013-03-20 11:33:29 +01:00
parent 6694f3845f
commit c9a8d31f3d
4 changed files with 134 additions and 191 deletions

View file

@ -7242,7 +7242,15 @@ static void Cmd_SqlLogin_f(gentity_t *ent) {
if(!sql_use.integer || !ent || !ent->client) return;
if(trap_Argc() < 2) {
//logout if no argument and player is loged in
if(!uName[0] && !pwd[0] && ent->client->uid) {
ent->client->uid = 0;
trap_SendServerCommand( ent-g_entities, va("print \"You are now logged out.\n\"") );
G_Client_UserinfoChanged( ent-g_entities );
return;
}
else if ( !uName[0] && !pwd[0] ) { //if user added no args (ie wanted the parameters)
trap_SendServerCommand( ent-g_entities, va("print \"\nUsage: Allows a player to login via the User-DB\nCommand: userlogin <User Name> <User Password>\nEntering userlogin without password will log you out if you are loged in\n\" ") );
return;
}

View file

@ -12,42 +12,83 @@ ingame.
*/
#include "ui_local.h"
#define ID_MAINMENU 15
#define ID_ADMIN_MAIN 16
#define ID_ADMIN_CLIENTS 17
#define ID_ADMIN_AUDIO 18
#define ID_GOD 20
#define ID_NOCLIP 21
#define ID_CLOAK 22
#define ID_FLIGHT 23
#define ID_GIVE 24
#define ID_REVIVE 25
#define ID_MESSAGE 26
#define ID_ENTITY 27
#define ID_BEAM_LOC 28
#define ID_BEAM_PLAYER 29
#define ID_FXGUNLIST 30
#define ID_FXGUN 31
#define ID_SPAWNCHAR 32
#define ID_REMOVECHAR 33
#define ID_BIND_SPAWN 40
#define ID_BIND_USEENT 41
#define ID_BIND_KICK 42
#define ID_CLIENT_SELECT 43
#define ID_CLIENT_KICK 44
#define ID_CLIENT_FORCE 45
// Defines
//general
#define PIC_ARROW_UP "menu/common/arrow_up_16.tga"
#define PIC_ARROW_DOWN "menu/common/arrow_dn_16.tga"
// Head Menu (also includes pro forma defines)
#define ID_MAINMENU 10
#define ID_ADMIN_MAIN 11
#define ID_ADMIN_CLIENTS 12
#define ID_ADMIN_AUDIO 13
#define ID_LOGIN_MENU 14
//admin Main
#define ID_GOD 1111
#define ID_NOCLIP 1112
#define ID_CLOAK 1113
#define ID_FLIGHT 1114
#define ID_GIVE 1121
#define ID_REVIVE 1122
#define ID_MESSAGE 1123
#define ID_ENTITY 1124
#define ID_BEAM_LOC 1131
#define ID_BEAM_PLAYER 1132
#define ID_FXGUNLIST 1141
#define ID_FXGUN 1142
#define ID_SPAWNCHAR 1151
#define ID_REMOVECHAR 1152
#define ID_BIND_SPAWN 1161
#define ID_BIND_USEENT 1162
#define ID_BIND_KICK 1163
// admin client
#define ID_CLIENT_SELECT 1211
#define ID_CLIENT_KICK 1212
#define ID_CLIENT_FORCE 1213
// admin audio
#define MAX_SONGS 2048
#define MAX_SOUNDS_ 1024
#define MAX_BUTTONS 7
#define MAX_AUDIO_LOCATIONS 32
/* menu choices defines */
#define ID_SONGBUTTON0 13100
#define ID_SONGBUTTON1 13101
#define ID_SONGBUTTON2 13102
#define ID_SONGBUTTON3 13103
#define ID_SONGBUTTON4 13104
#define ID_SONGBUTTON5 13105
#define ID_SONGBUTTON6 13106
#define ID_PLAYSONG 1311
#define ID_STOPSONG 1312
#define ID_SONGUP 1313
#define ID_SONGDN 1314
#define ID_SNDBUTTON0 13200
#define ID_SNDBUTTON1 13201
#define ID_SNDBUTTON2 13202
#define ID_SNDBUTTON3 13203
#define ID_SNDBUTTON4 13204
#define ID_SNDBUTTON5 13205
#define ID_SNDBUTTON6 13206
#define ID_PLAYSND 1321
#define ID_SNDUP 1322
#define ID_SNDDN 1323
//Login Menu
#define ID_ADMIN 1411
#define ID_SQL 1412
static void AdminMenu_Event( void* ptr, int event );
void UI_ClientAdminMenu( void );
void UI_AdminAudioMenu( void );
@ -733,7 +774,7 @@ static sfxHandle_t AdminMenu_KeyEvent( int key ) {
else {
/* unbind the current key */
if ( s->id >= ID_BIND_SPAWN && s->id <= ID_BIND_KICK ) {
int id = s->id - 40;
int id = s->id - 1161;
switch ( key ) {
case K_BACKSPACE:
@ -1966,37 +2007,6 @@ void UI_ClientAdminMenu( void ) {
/*****************************************************************************************/
/* TiM - Admin Audio Menu */
#define MAX_SONGS 2048
#define MAX_SOUNDS_ 1024
#define MAX_BUTTONS 7
#define MAX_AUDIO_LOCATIONS 32
/* menu choices defines */
#define ID_SONGBUTTON0 100
#define ID_SONGBUTTON1 101
#define ID_SONGBUTTON2 102
#define ID_SONGBUTTON3 103
#define ID_SONGBUTTON4 104
#define ID_SONGBUTTON5 105
#define ID_SONGBUTTON6 106
#define ID_PLAYSONG 1
#define ID_STOPSONG 2
#define ID_SONGUP 3
#define ID_SONGDN 4
#define ID_SNDBUTTON0 200
#define ID_SNDBUTTON1 201
#define ID_SNDBUTTON2 202
#define ID_SNDBUTTON3 203
#define ID_SNDBUTTON4 204
#define ID_SNDBUTTON5 205
#define ID_SNDBUTTON6 206
#define ID_PLAYSND 5
#define ID_SNDUP 6
#define ID_SNDDN 7
typedef enum
{
TYPE_WAV,
@ -2226,13 +2236,14 @@ static void AdminAudio_InitFilesList ( void )
/*
* the API returns files in subfolders too
* but we're not interested in that here
*/
//Why not?
if ( strchr( strPtr, '/' ) != NULL )
{
strPtr += strLen + 1;
j++;
continue;
}
}*/
if ( !Q_stricmp( strPtr + strLen - 4, ".mp3" ) )
{
@ -2313,13 +2324,13 @@ static void AdminAudio_InitFilesList ( void )
strLen = strlen( strPtr );
/* no hierarchical files here */
/* no hierarchical files here
if ( strchr( strPtr, '/' ) != NULL )
{
strPtr += strLen + 1;
j++;
continue;
}
}*/
if ( !Q_stricmp( strPtr + strLen - 4, ".wav" ) )
{
@ -2366,7 +2377,7 @@ static void AdminAudio_Event( void *ptr, int event )
if ( s_adminAudio.selectedSong < 0 )
s_adminAudio.playSong.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_adminAudio.selectedSong = s_adminAudio.songOffset + ( ((menucommon_s *)ptr)->id - 100 );
s_adminAudio.selectedSong = s_adminAudio.songOffset + ( ((menucommon_s *)ptr)->id - 13100 );
}
break;
@ -2399,7 +2410,7 @@ static void AdminAudio_Event( void *ptr, int event )
if ( s_adminAudio.selectedSound < 0 )
s_adminAudio.playSound.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_adminAudio.selectedSound = s_adminAudio.soundOffset + ( ((menucommon_s *)ptr)->id - 200 );
s_adminAudio.selectedSound = s_adminAudio.soundOffset + ( ((menucommon_s *)ptr)->id - 13200 );
}
break;
case ID_SNDUP:
@ -2783,6 +2794,8 @@ void UI_AdminAudioMenu( void )
**********************************************************************/
static byte sqlkey;
uiClientState_t cs;
char info[MAX_INFO_STRING];
typedef struct {
menuframework_s menu;
@ -2794,16 +2807,12 @@ typedef struct {
menufield_s username;
menufield_s password;
qboolean fromConsole;
qboolean isAdmin;
int isSQL;
} login_t;
login_t s_login;
#define ID_COMPUTERVOICE 6
#define ID_ADMIN 100001
#define ID_SQL 100002
/*
=================
UI_LoginSetSqlkey
@ -2859,6 +2868,14 @@ static void LoginMenu_Draw(void) {
AdminMenu_DrawCommon();
UI_MenuFrame2( &s_login.menu );
if( s_login.isAdmin || s_login.isSQL > 0){
length = UI_ProportionalStringWidth( "WELCOME TO",UI_BIGFONT);
UI_DrawProportionalString( 360 - ( length / 2 ), 130, "WELCOME TO", UI_BIGFONT, colorTable[CT_WHITE]); ;
length = UI_ProportionalStringWidth( "LCARS ODN BACKEND PROCESSING",UI_BIGFONT);
UI_DrawProportionalString( 360 - ( length / 2 ), 160, "LCARS ODN BACKEND PROCESSING", UI_BIGFONT, colorTable[CT_WHITE]);
length = UI_ProportionalStringWidth( "ACCESS GRANTED",UI_BIGFONT);
UI_DrawProportionalString( 360 - ( length / 2 ), 190, "ACCESS GRANTED", UI_BIGFONT, colorTable[CT_GREEN]);
}else{
length = UI_ProportionalStringWidth( "LCARS ODN BACKEND PROCESSING",UI_BIGFONT);
UI_DrawProportionalString( 360 - ( length / 2 ), 130, "LCARS ODN BACKEND PROCESSING", UI_BIGFONT, colorTable[CT_WHITE]);
length = UI_ProportionalStringWidth( "ACCESS DENIED",UI_BIGFONT);
@ -2869,6 +2886,8 @@ static void LoginMenu_Draw(void) {
vec_t* color = colorTable[CT_LTORANGE];
AdminMenu_DrawLCARSBox( 190, 268, 340, 70, color, MNT_BROADCAST_CMDS ); /* Admin Login */
AdminMenu_DrawLCARSBox( 190, 342, 340, 91, color, MNT_BROADCAST_CMDS ); /* SQL Login */
}
Menu_Draw(&s_login.menu);
}
@ -2878,9 +2897,22 @@ LoginMenu_Init
===============
*/
void LoginMenu_Init(void) {
/*int y, pad, x;
int i, width;*/
if( s_login.isAdmin || s_login.isSQL > 0){
UI_AdminMenu_Cache();
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;
AdminMenu_InitButtons( &s_login.menu );
}else{
UI_AdminMenu_Cache();
s_login.menu.wrapAround = qtrue;
@ -2960,8 +2992,7 @@ void LoginMenu_Init(void) {
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 );
@ -2969,6 +3000,10 @@ void LoginMenu_Init(void) {
Menu_AddItem( &s_login.menu, &s_login.username );
Menu_AddItem( &s_login.menu, &s_login.password );
Menu_AddItem( &s_login.menu, &s_login.sql );
AdminMenu_InitButtons( &s_login.menu );
}
}
/*
@ -2983,6 +3018,10 @@ void UI_LoginMenu(qboolean fromConsole) {
ingameFlag = qtrue;
trap_GetClientState( &cs );
trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
s_login.isAdmin = atoi( Info_ValueForKey( info, "admin" ));
s_login.isSQL = atoi( Info_ValueForKey( info, "uid" ));
s_login.fromConsole = fromConsole;
Mouse_Show();
@ -2992,95 +3031,4 @@ void UI_LoginMenu(qboolean fromConsole) {
UI_PushMenu(&s_login.menu);
Menu_AdjustCursor(&s_login.menu, 1);
}
/**********************************************************************
UI_AdminWelcomeMenu
User inferface for user login (sql)
**********************************************************************/
typedef struct {
menuframework_s menu;
qboolean fromConsole;
} AWM_t;
AWM_t s_AWM;
/*
=================
AdminWelcomeMenu_Key
=================
*/
sfxHandle_t AdminWelcomeMenu_Key(int key) {
return (Menu_DefaultKey(&s_login.menu, key));
}
/*
===============
AdminWelcomeMenu_Draw
===============
*/
static void AdminWelcomeMenu_Draw(void) {
int length;
AdminMenu_DrawCommon();
UI_MenuFrame2( &s_AWM.menu );
length = UI_ProportionalStringWidth( "WELCOME TO",UI_BIGFONT);
UI_DrawProportionalString( 360 - ( length / 2 ), 130, "WELCOME TO", UI_BIGFONT, colorTable[CT_WHITE]); ;
length = UI_ProportionalStringWidth( "LCARS ODN BACKEND PROCESSING",UI_BIGFONT);
UI_DrawProportionalString( 360 - ( length / 2 ), 160, "LCARS ODN BACKEND PROCESSING", UI_BIGFONT, colorTable[CT_WHITE]);
length = UI_ProportionalStringWidth( "ACCESS GRANTED",UI_BIGFONT);
UI_DrawProportionalString( 360 - ( length / 2 ), 190, "ACCESS GRANTED", UI_BIGFONT, colorTable[CT_GREEN]);
Menu_Draw(&s_AWM.menu);
}
/*
===============
AdminWelcomeMenu_Init
===============
*/
void AdminWelcomeMenu_Init(void) {
/*int y, pad, x;
int i, width;*/
UI_AdminMenu_Cache();
s_AWM.menu.wrapAround = qtrue;
s_AWM.menu.fullscreen = qtrue;
s_AWM.menu.draw = AdminWelcomeMenu_Draw;
s_AWM.menu.descX = MENU_DESC_X;
s_AWM.menu.descY = MENU_DESC_Y;
s_AWM.menu.titleX = MENU_TITLE_X;
s_AWM.menu.titleY = MENU_TITLE_Y;
s_AWM.menu.footNoteEnum = MNT_ADMIN;
s_AWM.menu.titleI = MNT_ADMIN_MENU;
s_AWM.menu.key = AdminWelcomeMenu_Key;
AdminMenu_InitButtons( &s_AWM.menu );
}
/*
===============
UI_AdminWelcomeMenu
===============
*/
void UI_AdminWelcomeMenu(qboolean fromConsole) {
memset(&s_AWM, 0, sizeof(s_AWM));
uis.menusp = 0;
ingameFlag = qtrue;
s_AWM.fromConsole = fromConsole;
Mouse_Show();
AdminWelcomeMenu_Init();
UI_PushMenu(&s_AWM.menu);
Menu_AdjustCursor(&s_AWM.menu, 1);
}

View file

@ -308,11 +308,7 @@ void InGame_Event( void *ptr, int notification )
break;
case ID_ADMIN:
if ( s_ingame.isAdmin || s_ingame.isSQL > 0 ) {
UI_AdminWelcomeMenu(qfalse);
} else {
UI_LoginMenu(qfalse);
}
UI_LoginMenu(qfalse);
break;
case ID_MOTD: // RPG-X | Marcin | 03/01/2008
@ -387,7 +383,7 @@ static void UI_InGameMenu_Draw( void )
UI_DrawHandlePic(30,203, 47, 186, uis.whiteShader); // Long left column square on bottom 3rd
// Left rounded ends for buttons
trap_R_SetColor( colorTable[CT_DKPURPLE1]);
trap_R_SetColor( colorTable[CT_MDGREY]);
/*UI_DrawHandlePic(s_ingame.team.generic.x - 14, s_ingame.team.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd);*/
@ -398,6 +394,7 @@ static void UI_InGameMenu_Draw( void )
UI_DrawHandlePic(s_ingame.removebots.generic.x - 14, s_ingame.removebots.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd);
trap_R_SetColor( colorTable[CT_DKPURPLE1]);
// UI_DrawHandlePic(s_ingame.teamorders.generic.x - 14, s_ingame.teamorders.generic.y,
// MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd);
@ -627,8 +624,6 @@ 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 );
@ -672,7 +667,7 @@ void InGame_MenuInit( void )
// y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.addbots.generic.type = MTYPE_BITMAP;
s_ingame.addbots.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_ingame.addbots.generic.flags = QMF_GRAYED | QMF_INACTIVE;
s_ingame.addbots.generic.x = x;
s_ingame.addbots.generic.y = y;
s_ingame.addbots.generic.id = ID_ADDBOTS;
@ -687,14 +682,10 @@ void InGame_MenuInit( void )
s_ingame.addbots.textEnum = MBT_INGAMEADDSIMULANTS;
s_ingame.addbots.textcolor = CT_BLACK;
s_ingame.addbots.textcolor2 = CT_WHITE;
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER))
{
s_ingame.addbots.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.removebots.generic.type = MTYPE_BITMAP;
s_ingame.removebots.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_ingame.removebots.generic.flags = QMF_GRAYED | QMF_INACTIVE;
s_ingame.removebots.generic.x = x;
s_ingame.removebots.generic.y = y;
s_ingame.removebots.generic.id = ID_REMOVEBOTS;
@ -709,9 +700,6 @@ void InGame_MenuInit( void )
s_ingame.removebots.textEnum = MBT_INGAMEREMOVESIMULANTS;
s_ingame.removebots.textcolor = CT_BLACK;
s_ingame.removebots.textcolor2 = CT_WHITE;
if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
s_ingame.removebots.generic.flags |= QMF_GRAYED;
}
y += INGAME_MENU_VERTICAL_SPACING;
s_ingame.respawn.generic.type = MTYPE_BITMAP;

View file

@ -1850,7 +1850,6 @@ extern void HoloDataReceived(const char *data);
extern void UI_AdminMenu( qboolean fromConsole );
extern void UI_AdminMenu_Cache( void );
extern void UI_LoginMenu( qboolean fromConsole );
extern void UI_AdminWelcomeMenu( qboolean fromConsole );
//
// ui_msd.c