stvoy-mp-sdk/Code-DM/ui/ui_team.c
2000-12-11 00:00:00 +00:00

272 lines
8.3 KiB
C

// Copyright (C) 1999-2000 Id Software, Inc.
//
//
// ui_team.c
//
#include "ui_local.h"
#define ID_INGAMEMENU 50
#define ID_JOINRED 100
#define ID_JOINBLUE 101
#define ID_JOINGAME 102
#define ID_SPECTATE 103
typedef struct
{
menuframework_s menu;
menubitmap_s ingamemenu;
menubitmap_s joinred;
menubitmap_s joinblue;
menubitmap_s joingame;
menubitmap_s spectate;
} teammain_t;
static teammain_t s_teammain;
static menuframework_s s_teammain_menu;
static menuaction_s s_teammain_orders;
static menuaction_s s_teammain_voice;
static menuaction_s s_teammain_joinred;
static menuaction_s s_teammain_joinblue;
static menuaction_s s_teammain_joingame;
static menuaction_s s_teammain_spectate;
/*
===============
TeamMain_MenuEvent
===============
*/
static void TeamMain_MenuEvent( void* ptr, int event )
{
if( event != QM_ACTIVATED )
{
return;
}
switch( ((menucommon_s*)ptr)->id )
{
case ID_INGAMEMENU:
UI_PopMenu();
break;
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;
}
}
/*
=================
UI_TeamMainMenu_Draw
=================
*/
static void UI_TeamMainMenu_Draw( void )
{
UI_MenuFrame(&s_teammain.menu);
trap_R_SetColor( colorTable[CT_LTBROWN1]);
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]);
UI_DrawHandlePic(s_teammain.joinred.generic.x - 14, s_teammain.joinred.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd);
UI_DrawHandlePic(s_teammain.joinblue.generic.x - 14, s_teammain.joinblue.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd);
UI_DrawHandlePic(s_teammain.joingame.generic.x - 14, s_teammain.joingame.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd);
UI_DrawHandlePic(s_teammain.spectate.generic.x - 14, s_teammain.spectate.generic.y,
MENU_BUTTON_MED_HEIGHT, MENU_BUTTON_MED_HEIGHT, uis.graphicButtonLeftEnd);
// standard menu drawing
Menu_Draw( &s_teammain.menu );
}
/*
===============
TeamMain_MenuInit
===============
*/
void TeamMain_MenuInit( void )
{
int y,pad,x;
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 = qtrue;
s_teammain.menu.descX = MENU_DESC_X;
s_teammain.menu.descY = MENU_DESC_Y;
s_teammain.menu.draw = UI_TeamMainMenu_Draw;
s_teammain.menu.titleX = MENU_TITLE_X;
s_teammain.menu.titleY = MENU_TITLE_Y;
s_teammain.menu.titleI = MNT_TEAMMENU_TITLE;
s_teammain.menu.footNoteEnum = MNT_TEAM_MENU;
s_teammain.ingamemenu.generic.type = MTYPE_BITMAP;
s_teammain.ingamemenu.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_teammain.ingamemenu.generic.x = 482;
s_teammain.ingamemenu.generic.y = 136;
s_teammain.ingamemenu.generic.name = BUTTON_GRAPHIC_LONGRIGHT;
s_teammain.ingamemenu.generic.id = ID_INGAMEMENU;
s_teammain.ingamemenu.generic.callback = TeamMain_MenuEvent;
s_teammain.ingamemenu.width = MENU_BUTTON_MED_WIDTH;
s_teammain.ingamemenu.height = MENU_BUTTON_MED_HEIGHT;
s_teammain.ingamemenu.color = CT_DKPURPLE1;
s_teammain.ingamemenu.color2 = CT_LTPURPLE1;
s_teammain.ingamemenu.textX = 5;
s_teammain.ingamemenu.textY = 2;
s_teammain.ingamemenu.textEnum = MBT_INGAMEMENU;
s_teammain.ingamemenu.textcolor = CT_BLACK;
s_teammain.ingamemenu.textcolor2 = CT_WHITE;
y = 220;
x = 290;
s_teammain.joinred.generic.type = MTYPE_BITMAP;
s_teammain.joinred.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_teammain.joinred.generic.x = x;
s_teammain.joinred.generic.y = y;
s_teammain.joinred.generic.name = GRAPHIC_SQUARE;
s_teammain.joinred.generic.id = ID_JOINRED;
s_teammain.joinred.generic.callback = TeamMain_MenuEvent;
s_teammain.joinred.width = MENU_BUTTON_MED_WIDTH;
s_teammain.joinred.height = MENU_BUTTON_MED_HEIGHT;
s_teammain.joinred.color = CT_DKPURPLE1;
s_teammain.joinred.color2 = CT_LTPURPLE1;
s_teammain.joinred.textX = MENU_BUTTON_TEXT_X;
s_teammain.joinred.textY = MENU_BUTTON_TEXT_Y;
s_teammain.joinred.textEnum = MBT_REDTEAM;
s_teammain.joinred.textcolor = CT_BLACK;
s_teammain.joinred.textcolor2 = CT_WHITE;
pad = 40;
y += pad;
s_teammain.joinblue.generic.type = MTYPE_BITMAP;
s_teammain.joinblue.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_teammain.joinblue.generic.x = x;
s_teammain.joinblue.generic.y = y;
s_teammain.joinblue.generic.name = GRAPHIC_SQUARE;
s_teammain.joinblue.generic.id = ID_JOINBLUE;
s_teammain.joinblue.generic.callback = TeamMain_MenuEvent;
s_teammain.joinblue.width = MENU_BUTTON_MED_WIDTH;
s_teammain.joinblue.height = MENU_BUTTON_MED_HEIGHT;
s_teammain.joinblue.color = CT_DKPURPLE1;
s_teammain.joinblue.color2 = CT_LTPURPLE1;
s_teammain.joinblue.textX = MENU_BUTTON_TEXT_X;
s_teammain.joinblue.textY = MENU_BUTTON_TEXT_Y;
s_teammain.joinblue.textEnum = MBT_BLUETEAM;
s_teammain.joinblue.textcolor = CT_BLACK;
s_teammain.joinblue.textcolor2 = CT_WHITE;
y += pad;
s_teammain.joingame.generic.type = MTYPE_BITMAP;
s_teammain.joingame.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_teammain.joingame.generic.x = x;
s_teammain.joingame.generic.y = y;
s_teammain.joingame.generic.id = ID_JOINGAME;
s_teammain.joingame.generic.name = GRAPHIC_SQUARE;
s_teammain.joingame.generic.callback = TeamMain_MenuEvent;
s_teammain.joingame.width = MENU_BUTTON_MED_WIDTH;
s_teammain.joingame.height = MENU_BUTTON_MED_HEIGHT;
s_teammain.joingame.color = CT_DKPURPLE1;
s_teammain.joingame.color2 = CT_LTPURPLE1;
s_teammain.joingame.textX = MENU_BUTTON_TEXT_X;
s_teammain.joingame.textY = MENU_BUTTON_TEXT_Y;
s_teammain.joingame.textEnum = MBT_JOINMATCH;
s_teammain.joingame.textcolor = CT_BLACK;
s_teammain.joingame.textcolor2 = CT_WHITE;
y += pad;
s_teammain.spectate.generic.type = MTYPE_BITMAP;
s_teammain.spectate.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_teammain.spectate.generic.x = x;
s_teammain.spectate.generic.y = y;
s_teammain.spectate.generic.id = ID_SPECTATE;
s_teammain.spectate.generic.name = GRAPHIC_SQUARE;
s_teammain.spectate.generic.callback = TeamMain_MenuEvent;
s_teammain.spectate.width = MENU_BUTTON_MED_WIDTH;
s_teammain.spectate.height = MENU_BUTTON_MED_HEIGHT;
s_teammain.spectate.color = CT_DKPURPLE1;
s_teammain.spectate.color2 = CT_LTPURPLE1;
s_teammain.spectate.textX = MENU_BUTTON_TEXT_X;
s_teammain.spectate.textY = MENU_BUTTON_TEXT_Y;
s_teammain.spectate.textEnum = MBT_OBSERVER;
s_teammain.spectate.textcolor = CT_BLACK;
s_teammain.spectate.textcolor2 = CT_WHITE;
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.ingamemenu );
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 )
{
}
/*
===============
UI_TeamMainMenu
===============
*/
void UI_TeamMainMenu( void )
{
TeamMain_MenuInit();
UI_PushMenu ( &s_teammain.menu );
}