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

ui_teamorders.c File Reference

#include "ui_local.h"

Include dependency graph for ui_teamorders.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  teamOrdersMenuInfo_t

Defines

#define ART_BACK0   "menu/art/back_0"
#define ART_BACK1   "menu/art/back_1"
#define ART_FRAME   "menu/art/addbotframe"
#define ID_LIST_BOTS   10
#define ID_LIST_CTF_ORDERS   11
#define ID_LIST_TEAM_ORDERS   12
#define NUM_CTF_ORDERS   7
#define NUM_TEAM_ORDERS   6

Functions

void UI_TeamOrdersMenu (void)
void UI_TeamOrdersMenu_BackEvent (void *ptr, int event)
void UI_TeamOrdersMenu_BuildBotList (void)
void UI_TeamOrdersMenu_Cache (void)
void UI_TeamOrdersMenu_f (void)
void UI_TeamOrdersMenu_Init (void)
sfxHandle_t UI_TeamOrdersMenu_Key (int key)
void UI_TeamOrdersMenu_ListDraw (void *self)
void UI_TeamOrdersMenu_ListEvent (void *ptr, int event)
void UI_TeamOrdersMenu_SetList (int id)

Variables

const char * ctfMessages []
const char * ctfOrders []
const char * teamMessages []
const char * teamOrders []
teamOrdersMenuInfo_t teamOrdersMenuInfo


Define Documentation

#define ART_BACK0   "menu/art/back_0"
 

Definition at line 36 of file ui_teamorders.c.

#define ART_BACK1   "menu/art/back_1"
 

Definition at line 37 of file ui_teamorders.c.

#define ART_FRAME   "menu/art/addbotframe"
 

Definition at line 35 of file ui_teamorders.c.

#define ID_LIST_BOTS   10
 

Definition at line 39 of file ui_teamorders.c.

Referenced by UI_TeamOrdersMenu_Init(), and UI_TeamOrdersMenu_SetList().

#define ID_LIST_CTF_ORDERS   11
 

Definition at line 40 of file ui_teamorders.c.

Referenced by UI_TeamOrdersMenu_ListEvent(), and UI_TeamOrdersMenu_SetList().

#define ID_LIST_TEAM_ORDERS   12
 

Definition at line 41 of file ui_teamorders.c.

Referenced by UI_TeamOrdersMenu_ListEvent(), and UI_TeamOrdersMenu_SetList().

#define NUM_CTF_ORDERS   7
 

Definition at line 63 of file ui_teamorders.c.

#define NUM_TEAM_ORDERS   6
 

Definition at line 85 of file ui_teamorders.c.


Function Documentation

void UI_TeamOrdersMenu void   ) 
 

Definition at line 417 of file ui_teamorders.c.

References teamOrdersMenuInfo_t::menu, teamOrdersMenuInfo, UI_PushMenu(), and UI_TeamOrdersMenu_Init().

00417                                {
00418     UI_TeamOrdersMenu_Init();
00419     UI_PushMenu( &teamOrdersMenuInfo.menu );
00420 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_BackEvent void *  ptr,
int  event
[static]
 

Definition at line 111 of file ui_teamorders.c.

References UI_PopMenu().

00111                                                                 {
00112     if( event != QM_ACTIVATED ) {
00113         return;
00114     }
00115     UI_PopMenu();
00116 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_BuildBotList void   )  [static]
 

Definition at line 293 of file ui_teamorders.c.

References atoi, teamOrdersMenuInfo_t::botNames, teamOrdersMenuInfo_t::bots, uiClientState_t::clientNum, CS_PLAYERS, CS_SERVERINFO, teamOrdersMenuInfo_t::gametype, Info_ValueForKey(), MAX_INFO_STRING, n, teamOrdersMenuInfo_t::numBots, Q_CleanStr(), Q_strncpyz(), teamOrdersMenuInfo, trap_GetClientState(), and trap_GetConfigString().

Referenced by UI_TeamOrdersMenu_Init().

00293                                                    {
00294     uiClientState_t cs;
00295     int     numPlayers;
00296     int     isBot;
00297     int     n;
00298     char    playerTeam;
00299     char    botTeam;
00300     char    info[MAX_INFO_STRING];
00301 
00302     for( n = 0; n < 9; n++ ) {
00303         teamOrdersMenuInfo.bots[n] = teamOrdersMenuInfo.botNames[n];
00304     }
00305 
00306     trap_GetClientState( &cs );
00307 
00308     Q_strncpyz( teamOrdersMenuInfo.botNames[0], "Everyone", 16 );
00309     teamOrdersMenuInfo.numBots = 1;
00310 
00311     trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
00312     numPlayers = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
00313     teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
00314 
00315     for( n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++ ) {
00316         trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );
00317 
00318         playerTeam = TEAM_SPECTATOR; // bk001204 = possible uninit use
00319 
00320         if( n == cs.clientNum ) {
00321             playerTeam = *Info_ValueForKey( info, "t" );
00322             continue;
00323         }
00324 
00325         isBot = atoi( Info_ValueForKey( info, "skill" ) );
00326         if( !isBot ) {
00327             continue;
00328         }
00329 
00330         botTeam = *Info_ValueForKey( info, "t" );
00331         if( botTeam != playerTeam ) {
00332             continue;
00333         }
00334 
00335         Q_strncpyz( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots], Info_ValueForKey( info, "n" ), 16 );
00336         Q_CleanStr( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots] );
00337         teamOrdersMenuInfo.numBots++;
00338     }
00339 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_Cache void   ) 
 

Definition at line 405 of file ui_teamorders.c.

References ART_BACK0, ART_BACK1, ART_FRAME, and trap_R_RegisterShaderNoMip().

00405                                      {
00406     trap_R_RegisterShaderNoMip( ART_FRAME );
00407     trap_R_RegisterShaderNoMip( ART_BACK0 );
00408     trap_R_RegisterShaderNoMip( ART_BACK1 );
00409 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_f void   ) 
 

Definition at line 428 of file ui_teamorders.c.

References atoi, uiClientState_t::clientNum, CS_PLAYERS, CS_SERVERINFO, teamOrdersMenuInfo_t::gametype, Info_ValueForKey(), MAX_INFO_STRING, teamOrdersMenuInfo, trap_GetClientState(), trap_GetConfigString(), and UI_TeamOrdersMenu().

00428                                  {
00429     uiClientState_t cs;
00430     char    info[MAX_INFO_STRING];
00431     int     team;
00432 
00433     // make sure it's a team game
00434     trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
00435     teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
00436     if( teamOrdersMenuInfo.gametype < GT_TEAM ) {
00437         return;
00438     }
00439 
00440     // not available to spectators
00441     trap_GetClientState( &cs );
00442     trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
00443     team = atoi( Info_ValueForKey( info, "t" ) );
00444     if( team == TEAM_SPECTATOR ) {
00445         return;
00446     }
00447 
00448     UI_TeamOrdersMenu();
00449 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_Init void   )  [static]
 

Definition at line 347 of file ui_teamorders.c.

References teamOrdersMenuInfo_t::back, teamOrdersMenuInfo_t::banner, menucommon_s::callback, menutext_s::color, menucommon_s::flags, menubitmap_s::focuspic, teamOrdersMenuInfo_t::frame, _tag_menuframework::fullscreen, menulist_s::generic, menubitmap_s::generic, menutext_s::generic, menubitmap_s::height, ID_LIST_BOTS, _tag_menuframework::key, menucommon_s::left, teamOrdersMenuInfo_t::list, memset(), teamOrdersMenuInfo_t::menu, Menu_AddItem(), menucommon_s::name, menucommon_s::ownerdraw, QMF_LEFT_JUSTIFY, menucommon_s::right, menutext_s::string, menutext_s::style, teamOrdersMenuInfo, menucommon_s::top, menucommon_s::type, UI_TeamOrdersMenu_BuildBotList(), UI_TeamOrdersMenu_Cache(), UI_TeamOrdersMenu_SetList(), menubitmap_s::width, menucommon_s::x, and menucommon_s::y.

Referenced by UI_TeamOrdersMenu().

00347                                            {
00348     UI_TeamOrdersMenu_Cache();
00349 
00350     memset( &teamOrdersMenuInfo, 0, sizeof(teamOrdersMenuInfo) );
00351     teamOrdersMenuInfo.menu.fullscreen = qfalse;
00352     teamOrdersMenuInfo.menu.key = UI_TeamOrdersMenu_Key;
00353 
00354     UI_TeamOrdersMenu_BuildBotList();
00355 
00356     teamOrdersMenuInfo.banner.generic.type      = MTYPE_BTEXT;
00357     teamOrdersMenuInfo.banner.generic.x         = 320;
00358     teamOrdersMenuInfo.banner.generic.y         = 16;
00359     teamOrdersMenuInfo.banner.string            = "TEAM ORDERS";
00360     teamOrdersMenuInfo.banner.color             = color_white;
00361     teamOrdersMenuInfo.banner.style             = UI_CENTER;
00362 
00363     teamOrdersMenuInfo.frame.generic.type       = MTYPE_BITMAP;
00364     teamOrdersMenuInfo.frame.generic.flags      = QMF_INACTIVE;
00365     teamOrdersMenuInfo.frame.generic.name       = ART_FRAME;
00366     teamOrdersMenuInfo.frame.generic.x          = 320-233;
00367     teamOrdersMenuInfo.frame.generic.y          = 240-166;
00368     teamOrdersMenuInfo.frame.width              = 466;
00369     teamOrdersMenuInfo.frame.height             = 332;
00370 
00371     teamOrdersMenuInfo.list.generic.type        = MTYPE_SCROLLLIST;
00372     teamOrdersMenuInfo.list.generic.flags       = QMF_PULSEIFFOCUS;
00373     teamOrdersMenuInfo.list.generic.ownerdraw   = UI_TeamOrdersMenu_ListDraw;
00374     teamOrdersMenuInfo.list.generic.callback    = UI_TeamOrdersMenu_ListEvent;
00375     teamOrdersMenuInfo.list.generic.x           = 320-64;
00376     teamOrdersMenuInfo.list.generic.y           = 120;
00377 
00378     teamOrdersMenuInfo.back.generic.type        = MTYPE_BITMAP;
00379     teamOrdersMenuInfo.back.generic.name        = ART_BACK0;
00380     teamOrdersMenuInfo.back.generic.flags       = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
00381     teamOrdersMenuInfo.back.generic.callback    = UI_TeamOrdersMenu_BackEvent;
00382     teamOrdersMenuInfo.back.generic.x           = 0;
00383     teamOrdersMenuInfo.back.generic.y           = 480-64;
00384     teamOrdersMenuInfo.back.width               = 128;
00385     teamOrdersMenuInfo.back.height              = 64;
00386     teamOrdersMenuInfo.back.focuspic            = ART_BACK1;
00387 
00388     Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.banner );
00389     Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.frame );
00390     Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.list );
00391     Menu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.back );
00392 
00393     teamOrdersMenuInfo.list.generic.left = 220;
00394     teamOrdersMenuInfo.list.generic.top = teamOrdersMenuInfo.list.generic.y;
00395     teamOrdersMenuInfo.list.generic.right = 420;
00396     UI_TeamOrdersMenu_SetList( ID_LIST_BOTS );
00397 }

Here is the call graph for this function:

sfxHandle_t UI_TeamOrdersMenu_Key int  key  ) 
 

Definition at line 155 of file ui_teamorders.c.

References menucommon_s::bottom, menucommon_s::callback, uiStatic_t::cursory, menulist_s::curvalue, menulist_s::generic, K_DOWNARROW, K_KP_DOWNARROW, K_KP_UPARROW, K_MOUSE1, K_UPARROW, l, menucommon_s::left, teamOrdersMenuInfo_t::list, teamOrdersMenuInfo_t::menu, Menu_DefaultKey(), Menu_ItemAtCursor(), menulist_s::numitems, menulist_s::oldvalue, QM_ACTIVATED, menucommon_s::right, sfxHandle_t, teamOrdersMenuInfo, menucommon_s::top, UI_CursorInRect(), uis, x, and y.

00155                                              {
00156     menulist_s  *l;
00157     int x;
00158     int y;
00159     int index;
00160 
00161     l = (menulist_s *)Menu_ItemAtCursor( &teamOrdersMenuInfo.menu );
00162     if( l != &teamOrdersMenuInfo.list ) {
00163         return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );
00164     }
00165 
00166     switch( key ) {
00167         case K_MOUSE1:
00168             x = l->generic.left;
00169             y = l->generic.top;
00170             if( UI_CursorInRect( x, y, l->generic.right - x, l->generic.bottom - y ) ) {
00171                 index = (uis.cursory - y) / PROP_HEIGHT;
00172                 l->oldvalue = l->curvalue;
00173                 l->curvalue = index;
00174 
00175                 if( l->generic.callback ) {
00176                     l->generic.callback( l, QM_ACTIVATED );
00177                     return menu_move_sound;
00178                 }
00179             }
00180             return menu_null_sound;
00181 
00182         case K_KP_UPARROW:
00183         case K_UPARROW:
00184             l->oldvalue = l->curvalue;
00185 
00186             if( l->curvalue == 0 ) {
00187                 l->curvalue = l->numitems - 1;
00188             }
00189             else {
00190                 l->curvalue--;
00191             }
00192             return menu_move_sound;
00193 
00194         case K_KP_DOWNARROW:
00195         case K_DOWNARROW:
00196             l->oldvalue = l->curvalue;
00197 
00198             if( l->curvalue == l->numitems - 1 ) {
00199                 l->curvalue = 0;;
00200             }
00201             else {
00202                 l->curvalue++;
00203             }
00204             return menu_move_sound;
00205     }
00206 
00207     return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );
00208 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_ListDraw void *  self  )  [static]
 

Definition at line 216 of file ui_teamorders.c.

References _tag_menuframework::cursor, menulist_s::curvalue, menulist_s::generic, i, menulist_s::itemnames, l, menucommon_s::menuPosition, menulist_s::numitems, menucommon_s::parent, qboolean, UI_DrawProportionalString(), UI_LEFT, UI_SMALLFONT, x, menucommon_s::y, and y.

00216                                                      {
00217     menulist_s  *l;
00218     int         x;
00219     int         y;
00220     int         i;
00221     float       *color;
00222     qboolean    hasfocus;
00223     int         style;
00224 
00225     l = (menulist_s *)self;
00226 
00227     hasfocus = (l->generic.parent->cursor == l->generic.menuPosition);
00228 
00229     x = 320;//l->generic.x;
00230     y = l->generic.y;
00231     for( i = 0; i < l->numitems; i++ ) {
00232         style = UI_LEFT|UI_SMALLFONT|UI_CENTER;
00233         if( i == l->curvalue ) {
00234             color = color_yellow;
00235             if( hasfocus ) {
00236                 style |= UI_PULSE;
00237             }
00238         }
00239         else {
00240             color = color_orange;
00241         }
00242 
00243         UI_DrawProportionalString( x, y, l->itemnames[i], style, color );
00244         y += PROP_HEIGHT;
00245     }
00246 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_ListEvent void *  ptr,
int  event
[static]
 

Definition at line 254 of file ui_teamorders.c.

References teamOrdersMenuInfo_t::botNames, Com_sprintf(), ctfMessages, EXEC_APPEND, teamOrdersMenuInfo_t::gametype, menucommon_s::id, ID_LIST_CTF_ORDERS, ID_LIST_TEAM_ORDERS, teamOrdersMenuInfo_t::selectedBot, teamMessages, teamOrdersMenuInfo, trap_Cmd_ExecuteText(), UI_PopMenu(), UI_TeamOrdersMenu_SetList(), and va().

00254                                                                 {
00255     int     id;
00256     int     selection;
00257     char    message[256];
00258 
00259     if (event != QM_ACTIVATED)
00260         return;
00261 
00262     id = ((menulist_s *)ptr)->generic.id;
00263     selection = ((menulist_s *)ptr)->curvalue;
00264 
00265     if( id == ID_LIST_BOTS ) {
00266         teamOrdersMenuInfo.selectedBot = selection;
00267         if( teamOrdersMenuInfo.gametype == GT_CTF ) {
00268             UI_TeamOrdersMenu_SetList( ID_LIST_CTF_ORDERS );
00269         }
00270         else {
00271             UI_TeamOrdersMenu_SetList( ID_LIST_TEAM_ORDERS );
00272         }
00273         return;
00274     }
00275 
00276     if( id == ID_LIST_CTF_ORDERS ) {
00277         Com_sprintf( message, sizeof(message), ctfMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );
00278     }
00279     else {
00280         Com_sprintf( message, sizeof(message), teamMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );
00281     }
00282 
00283     trap_Cmd_ExecuteText( EXEC_APPEND, va( "say_team \"%s\"\n", message ) );
00284     UI_PopMenu();
00285 }

Here is the call graph for this function:

void UI_TeamOrdersMenu_SetList int  id  )  [static]
 

Definition at line 124 of file ui_teamorders.c.

References teamOrdersMenuInfo_t::bots, menucommon_s::bottom, menulist_s::generic, menucommon_s::id, ID_LIST_BOTS, ID_LIST_CTF_ORDERS, ID_LIST_TEAM_ORDERS, menulist_s::itemnames, teamOrdersMenuInfo_t::list, teamOrdersMenuInfo_t::numBots, menulist_s::numitems, teamOrdersMenuInfo, and menucommon_s::top.

Referenced by UI_TeamOrdersMenu_Init(), and UI_TeamOrdersMenu_ListEvent().

00124                                                 {
00125     switch( id ) {
00126     default:
00127     case ID_LIST_BOTS:
00128         teamOrdersMenuInfo.list.generic.id = id;
00129         teamOrdersMenuInfo.list.numitems = teamOrdersMenuInfo.numBots;
00130         teamOrdersMenuInfo.list.itemnames = (const char **)teamOrdersMenuInfo.bots;
00131          break;
00132 
00133     case ID_LIST_CTF_ORDERS:
00134         teamOrdersMenuInfo.list.generic.id = id;
00135         teamOrdersMenuInfo.list.numitems = NUM_CTF_ORDERS;
00136         teamOrdersMenuInfo.list.itemnames = ctfOrders;
00137         break;
00138 
00139     case ID_LIST_TEAM_ORDERS:
00140         teamOrdersMenuInfo.list.generic.id = id;
00141         teamOrdersMenuInfo.list.numitems = NUM_TEAM_ORDERS;
00142         teamOrdersMenuInfo.list.itemnames = teamOrders;
00143         break;
00144     }
00145 
00146     teamOrdersMenuInfo.list.generic.bottom = teamOrdersMenuInfo.list.generic.top + teamOrdersMenuInfo.list.numitems * PROP_HEIGHT;
00147 }


Variable Documentation

const char* ctfMessages[] [static]
 

Initial value:

 {
    "i am the leader",
    "%s defend the base",
    "%s follow me",
    "%s get enemy flag",
    "%s camp here",
    "%s report",
    "i stop being the leader",
    NULL
}

Definition at line 74 of file ui_teamorders.c.

Referenced by UI_TeamOrdersMenu_ListEvent().

const char* ctfOrders[] [static]
 

Initial value:

 {
    "I Am the Leader",
    "Defend the Base",
    "Follow Me",
    "Get Enemy Flag",
    "Camp Here",
    "Report",
    "I Relinquish Command",
    NULL
}

Definition at line 64 of file ui_teamorders.c.

const char* teamMessages[] [static]
 

Initial value:

 {
    "i am the leader",
    "%s follow me",
    "%s roam",
    "%s camp here",
    "%s report",
    "i stop being the leader",
    NULL
}

Definition at line 95 of file ui_teamorders.c.

Referenced by UI_TeamOrdersMenu_ListEvent().

const char* teamOrders[] [static]
 

Initial value:

 {
    "I Am the Leader",
    "Follow Me",
    "Roam",
    "Camp Here",
    "Report",
    "I Relinquish Command",
    NULL
}

Definition at line 86 of file ui_teamorders.c.

teamOrdersMenuInfo_t teamOrdersMenuInfo [static]
 

Definition at line 61 of file ui_teamorders.c.

Referenced by UI_TeamOrdersMenu(), UI_TeamOrdersMenu_BuildBotList(), UI_TeamOrdersMenu_f(), UI_TeamOrdersMenu_Init(), UI_TeamOrdersMenu_Key(), UI_TeamOrdersMenu_ListEvent(), and UI_TeamOrdersMenu_SetList().


Generated on Thu Aug 25 14:35:55 2005 for Quake III Arena by  doxygen 1.3.9.1