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

ui_controls2.c File Reference

#include "ui_local.h"

Include dependency graph for ui_controls2.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  bind_t
struct  configcvar_t
struct  controls_t

Defines

#define ANIM_ATTACK   22
#define ANIM_BACK   3
#define ANIM_CHAT   25
#define ANIM_CROUCH   5
#define ANIM_DIE   24
#define ANIM_GESTURE   23
#define ANIM_IDLE   0
#define ANIM_JUMP   4
#define ANIM_LOOKDOWN   11
#define ANIM_LOOKUP   10
#define ANIM_RUN   1
#define ANIM_STEPLEFT   6
#define ANIM_STEPRIGHT   7
#define ANIM_TURNLEFT   8
#define ANIM_TURNRIGHT   9
#define ANIM_WALK   2
#define ANIM_WEAPON1   12
#define ANIM_WEAPON10   21
#define ANIM_WEAPON2   13
#define ANIM_WEAPON3   14
#define ANIM_WEAPON4   15
#define ANIM_WEAPON5   16
#define ANIM_WEAPON6   17
#define ANIM_WEAPON7   18
#define ANIM_WEAPON8   19
#define ANIM_WEAPON9   20
#define ART_BACK0   "menu/art/back_0"
#define ART_BACK1   "menu/art/back_1"
#define ART_FRAMEL   "menu/art/frame2_l"
#define ART_FRAMER   "menu/art/frame1_r"
#define C_LOOKING   1
#define C_MAX   4
#define C_MISC   3
#define C_MOVEMENT   0
#define C_WEAPONS   2
#define ID_ALWAYSRUN   36
#define ID_ATTACK   26
#define ID_AUTOSWITCH   37
#define ID_BACK   105
#define ID_BACKPEDAL   4
#define ID_CENTERVIEW   15
#define ID_CHAT   30
#define ID_CHAT2   31
#define ID_CHAT3   32
#define ID_CHAT4   33
#define ID_DEFAULTS   104
#define ID_EXIT   107
#define ID_FORWARD   3
#define ID_FREELOOK   34
#define ID_GESTURE   29
#define ID_INVERTMOUSE   35
#define ID_JOYENABLE   39
#define ID_JOYTHRESHOLD   40
#define ID_LEFT   9
#define ID_LOOKDOWN   13
#define ID_LOOKING   101
#define ID_LOOKUP   12
#define ID_MISC   103
#define ID_MOUSELOOK   14
#define ID_MOUSESPEED   38
#define ID_MOVEDOWN   8
#define ID_MOVELEFT   5
#define ID_MOVEMENT   100
#define ID_MOVERIGHT   6
#define ID_MOVEUP   7
#define ID_RIGHT   10
#define ID_SAVEANDEXIT   106
#define ID_SHOWSCORES   0
#define ID_SMOOTHMOUSE   41
#define ID_SPEED   2
#define ID_STRAFE   11
#define ID_USEITEM   1
#define ID_WEAPNEXT   28
#define ID_WEAPON1   17
#define ID_WEAPON2   18
#define ID_WEAPON3   19
#define ID_WEAPON4   20
#define ID_WEAPON5   21
#define ID_WEAPON6   22
#define ID_WEAPON7   23
#define ID_WEAPON8   24
#define ID_WEAPON9   25
#define ID_WEAPONS   102
#define ID_WEAPPREV   27
#define ID_ZOOMVIEW   16
#define SAVE_CANCEL   3
#define SAVE_NO   2
#define SAVE_NOOP   0
#define SAVE_YES   1

Functions

void Controls_ActionEvent (void *ptr, int event)
void Controls_Cache (void)
void Controls_DrawKeyBinding (void *self)
void Controls_DrawPlayer (void *self)
void Controls_GetConfig (void)
float Controls_GetCvarDefault (char *name)
float Controls_GetCvarValue (char *name)
void Controls_GetKeyAssignment (char *command, int *twokeys)
void Controls_InitCvars (void)
void Controls_InitModel (void)
void Controls_InitWeapons (void)
void Controls_MenuEvent (void *ptr, int event)
void Controls_MenuInit (void)
sfxHandle_t Controls_MenuKey (int key)
void Controls_ResetDefaults_Action (qboolean result)
void Controls_ResetDefaults_Draw (void)
void Controls_SetConfig (void)
void Controls_SetDefaults (void)
void Controls_StatusBar (void *self)
void Controls_Update (void)
void Controls_UpdateModel (int anim)
void UI_ControlsMenu (void)

Variables

vec4_t controls_binding_color = {1.00f, 0.43f, 0.00f, 1.00f}
bind_t g_bindings []
configcvar_t g_configcvars []
menucommon_s ** g_controls []
menucommon_sg_looking_controls []
menucommon_sg_misc_controls []
menucommon_sg_movement_controls []
menucommon_sg_weapons_controls []
controls_t s_controls


Define Documentation

#define ANIM_ATTACK   22
 

Definition at line 147 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_BACK   3
 

Definition at line 128 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_CHAT   25
 

Definition at line 150 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_CROUCH   5
 

Definition at line 130 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_DIE   24
 

Definition at line 149 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_GESTURE   23
 

Definition at line 148 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_IDLE   0
 

Definition at line 125 of file ui_controls2.c.

Referenced by Controls_ActionEvent(), Controls_DrawPlayer(), and Controls_InitModel().

#define ANIM_JUMP   4
 

Definition at line 129 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_LOOKDOWN   11
 

Definition at line 136 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_LOOKUP   10
 

Definition at line 135 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_RUN   1
 

Definition at line 126 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_STEPLEFT   6
 

Definition at line 131 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_STEPRIGHT   7
 

Definition at line 132 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_TURNLEFT   8
 

Definition at line 133 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_TURNRIGHT   9
 

Definition at line 134 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WALK   2
 

Definition at line 127 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON1   12
 

Definition at line 137 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON10   21
 

Definition at line 146 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON2   13
 

Definition at line 138 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON3   14
 

Definition at line 139 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON4   15
 

Definition at line 140 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON5   16
 

Definition at line 141 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON6   17
 

Definition at line 142 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON7   18
 

Definition at line 143 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON8   19
 

Definition at line 144 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ANIM_WEAPON9   20
 

Definition at line 145 of file ui_controls2.c.

Referenced by Controls_UpdateModel().

#define ART_BACK0   "menu/art/back_0"
 

Definition at line 34 of file ui_controls2.c.

#define ART_BACK1   "menu/art/back_1"
 

Definition at line 35 of file ui_controls2.c.

#define ART_FRAMEL   "menu/art/frame2_l"
 

Definition at line 36 of file ui_controls2.c.

#define ART_FRAMER   "menu/art/frame1_r"
 

Definition at line 37 of file ui_controls2.c.

#define C_LOOKING   1
 

Definition at line 65 of file ui_controls2.c.

Referenced by Controls_Update().

#define C_MAX   4
 

Definition at line 68 of file ui_controls2.c.

#define C_MISC   3
 

Definition at line 67 of file ui_controls2.c.

Referenced by Controls_Update().

#define C_MOVEMENT   0
 

Definition at line 64 of file ui_controls2.c.

Referenced by Controls_Update().

#define C_WEAPONS   2
 

Definition at line 66 of file ui_controls2.c.

Referenced by Controls_Update().

#define ID_ALWAYSRUN   36
 

Definition at line 118 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_ATTACK   26
 

Definition at line 106 of file ui_controls2.c.

#define ID_AUTOSWITCH   37
 

Definition at line 119 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_BACK   105
 

Definition at line 75 of file ui_controls2.c.

#define ID_BACKPEDAL   4
 

Definition at line 84 of file ui_controls2.c.

#define ID_CENTERVIEW   15
 

Definition at line 95 of file ui_controls2.c.

#define ID_CHAT   30
 

Definition at line 110 of file ui_controls2.c.

#define ID_CHAT2   31
 

Definition at line 111 of file ui_controls2.c.

#define ID_CHAT3   32
 

Definition at line 112 of file ui_controls2.c.

#define ID_CHAT4   33
 

Definition at line 113 of file ui_controls2.c.

#define ID_DEFAULTS   104
 

Definition at line 74 of file ui_controls2.c.

Referenced by Controls_MenuEvent(), and UI_SetupMenu_Event().

#define ID_EXIT   107
 

Definition at line 77 of file ui_controls2.c.

Referenced by Controls_MenuEvent(), and Main_MenuEvent().

#define ID_FORWARD   3
 

Definition at line 83 of file ui_controls2.c.

#define ID_FREELOOK   34
 

Definition at line 116 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_GESTURE   29
 

Definition at line 109 of file ui_controls2.c.

#define ID_INVERTMOUSE   35
 

Definition at line 117 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_JOYENABLE   39
 

Definition at line 121 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_JOYTHRESHOLD   40
 

Definition at line 122 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_LEFT   9
 

Definition at line 89 of file ui_controls2.c.

Referenced by Demos_MenuEvent(), and LoadConfig_MenuEvent().

#define ID_LOOKDOWN   13
 

Definition at line 93 of file ui_controls2.c.

#define ID_LOOKING   101
 

Definition at line 71 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_LOOKUP   12
 

Definition at line 92 of file ui_controls2.c.

#define ID_MISC   103
 

Definition at line 73 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_MOUSELOOK   14
 

Definition at line 94 of file ui_controls2.c.

#define ID_MOUSESPEED   38
 

Definition at line 120 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_MOVEDOWN   8
 

Definition at line 88 of file ui_controls2.c.

#define ID_MOVELEFT   5
 

Definition at line 85 of file ui_controls2.c.

#define ID_MOVEMENT   100
 

Definition at line 70 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_MOVERIGHT   6
 

Definition at line 86 of file ui_controls2.c.

#define ID_MOVEUP   7
 

Definition at line 87 of file ui_controls2.c.

#define ID_RIGHT   10
 

Definition at line 90 of file ui_controls2.c.

Referenced by Demos_MenuEvent(), and LoadConfig_MenuEvent().

#define ID_SAVEANDEXIT   106
 

Definition at line 76 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_SHOWSCORES   0
 

Definition at line 80 of file ui_controls2.c.

#define ID_SMOOTHMOUSE   41
 

Definition at line 123 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_SPEED   2
 

Definition at line 82 of file ui_controls2.c.

#define ID_STRAFE   11
 

Definition at line 91 of file ui_controls2.c.

#define ID_USEITEM   1
 

Definition at line 81 of file ui_controls2.c.

#define ID_WEAPNEXT   28
 

Definition at line 108 of file ui_controls2.c.

#define ID_WEAPON1   17
 

Definition at line 97 of file ui_controls2.c.

#define ID_WEAPON2   18
 

Definition at line 98 of file ui_controls2.c.

#define ID_WEAPON3   19
 

Definition at line 99 of file ui_controls2.c.

#define ID_WEAPON4   20
 

Definition at line 100 of file ui_controls2.c.

#define ID_WEAPON5   21
 

Definition at line 101 of file ui_controls2.c.

#define ID_WEAPON6   22
 

Definition at line 102 of file ui_controls2.c.

#define ID_WEAPON7   23
 

Definition at line 103 of file ui_controls2.c.

#define ID_WEAPON8   24
 

Definition at line 104 of file ui_controls2.c.

#define ID_WEAPON9   25
 

Definition at line 105 of file ui_controls2.c.

#define ID_WEAPONS   102
 

Definition at line 72 of file ui_controls2.c.

Referenced by Controls_MenuEvent().

#define ID_WEAPPREV   27
 

Definition at line 107 of file ui_controls2.c.

#define ID_ZOOMVIEW   16
 

Definition at line 96 of file ui_controls2.c.

#define SAVE_CANCEL   3
 

Definition at line 61 of file ui_controls2.c.

#define SAVE_NO   2
 

Definition at line 60 of file ui_controls2.c.

#define SAVE_NOOP   0
 

Definition at line 58 of file ui_controls2.c.

#define SAVE_YES   1
 

Definition at line 59 of file ui_controls2.c.


Function Documentation

void Controls_ActionEvent void *  ptr,
int  event
[static]
 

Definition at line 1136 of file ui_controls2.c.

References ANIM_IDLE, Controls_Update(), Controls_UpdateModel(), g_bindings, ptr(), s_controls, and controls_t::waitingforkey.

01137 {
01138     if (event == QM_LOSTFOCUS)
01139     {
01140         Controls_UpdateModel( ANIM_IDLE );
01141     }
01142     else if (event == QM_GOTFOCUS)
01143     {
01144         Controls_UpdateModel( g_bindings[((menucommon_s*)ptr)->id].anim );
01145     }
01146     else if ((event == QM_ACTIVATED) && !s_controls.waitingforkey)
01147     {
01148         s_controls.waitingforkey = 1;
01149         Controls_Update();
01150     }
01151 }

Here is the call graph for this function:

void Controls_Cache void   ) 
 

Definition at line 1651 of file ui_controls2.c.

References ART_BACK0, ART_BACK1, ART_FRAMEL, ART_FRAMER, and trap_R_RegisterShaderNoMip().

Referenced by Controls_MenuInit(), and UI_Cache_f().

01651                             {
01652     trap_R_RegisterShaderNoMip( ART_BACK0 );
01653     trap_R_RegisterShaderNoMip( ART_BACK1 );
01654     trap_R_RegisterShaderNoMip( ART_FRAMEL );
01655     trap_R_RegisterShaderNoMip( ART_FRAMER );
01656 }

Here is the call graph for this function:

void Controls_DrawKeyBinding void *  self  )  [static]
 

Definition at line 651 of file ui_controls2.c.

References a, bind_t::bind1, bind_t::bind2, menucommon_s::bottom, c, colorWhite, controls_binding_color, menucommon_s::flags, g_bindings, menuaction_s::generic, menucommon_s::id, menucommon_s::left, listbar_color, Menu_ItemAtCursor(), name, menucommon_s::parent, Q_strupr(), qboolean, menucommon_s::right, s_controls, SCREEN_HEIGHT, SCREEN_WIDTH, SMALLCHAR_WIDTH, strcat(), strcpy(), text_color_disabled, text_color_highlight, menucommon_s::top, trap_Key_KeynumToStringBuf(), UI_BLINK, UI_CENTER, UI_DrawChar(), UI_DrawString(), UI_FillRect(), UI_LEFT, UI_PULSE, UI_RIGHT, UI_SMALLFONT, controls_t::waitingforkey, menucommon_s::x, x, menucommon_s::y, and y.

00652 {
00653     menuaction_s*   a;
00654     int             x;
00655     int             y;
00656     int             b1;
00657     int             b2;
00658     qboolean        c;
00659     char            name[32];
00660     char            name2[32];
00661 
00662     a = (menuaction_s*) self;
00663 
00664     x = a->generic.x;
00665     y = a->generic.y;
00666 
00667     c = (Menu_ItemAtCursor( a->generic.parent ) == a);
00668 
00669     b1 = g_bindings[a->generic.id].bind1;
00670     if (b1 == -1)
00671         strcpy(name,"???");
00672     else
00673     {
00674         trap_Key_KeynumToStringBuf( b1, name, 32 );
00675         Q_strupr(name);
00676 
00677         b2 = g_bindings[a->generic.id].bind2;
00678         if (b2 != -1)
00679         {
00680             trap_Key_KeynumToStringBuf( b2, name2, 32 );
00681             Q_strupr(name2);
00682 
00683             strcat( name, " or " );
00684             strcat( name, name2 );
00685         }
00686     }
00687 
00688     if (c)
00689     {
00690         UI_FillRect( a->generic.left, a->generic.top, a->generic.right-a->generic.left+1, a->generic.bottom-a->generic.top+1, listbar_color ); 
00691 
00692         UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_highlight );
00693         UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT|UI_PULSE, text_color_highlight );
00694 
00695         if (s_controls.waitingforkey)
00696         {
00697             UI_DrawChar( x, y, '=', UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight);
00698             UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.80, "Waiting for new key ... ESCAPE to cancel", UI_SMALLFONT|UI_CENTER|UI_PULSE, colorWhite );
00699         }
00700         else
00701         {
00702             UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight);
00703             UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.78, "Press ENTER or CLICK to change", UI_SMALLFONT|UI_CENTER, colorWhite );
00704             UI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.82, "Press BACKSPACE to clear", UI_SMALLFONT|UI_CENTER, colorWhite );
00705         }
00706     }
00707     else
00708     {
00709         if (a->generic.flags & QMF_GRAYED)
00710         {
00711             UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_disabled );
00712             UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, text_color_disabled );
00713         }
00714         else
00715         {
00716             UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, controls_binding_color );
00717             UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, controls_binding_color );
00718         }
00719     }
00720 }

Here is the call graph for this function:

void Controls_DrawPlayer void *  self  )  [static]
 

Definition at line 738 of file ui_controls2.c.

References ANIM_IDLE, b, Controls_UpdateModel(), menubitmap_s::generic, menubitmap_s::height, controls_t::playerinfo, controls_t::playerModel, uiStatic_t::realtime, s_controls, strcmp(), strcpy(), trap_Cvar_VariableStringBuffer(), UI_DrawPlayer(), UI_PlayerInfo_SetModel(), uis, menubitmap_s::width, menucommon_s::x, and menucommon_s::y.

00738                                               {
00739     menubitmap_s    *b;
00740     char            buf[MAX_QPATH];
00741 
00742     trap_Cvar_VariableStringBuffer( "model", buf, sizeof( buf ) );
00743     if ( strcmp( buf, s_controls.playerModel ) != 0 ) {
00744         UI_PlayerInfo_SetModel( &s_controls.playerinfo, buf );
00745         strcpy( s_controls.playerModel, buf );
00746         Controls_UpdateModel( ANIM_IDLE );
00747     }
00748 
00749     b = (menubitmap_s*) self;
00750     UI_DrawPlayer( b->generic.x, b->generic.y, b->width, b->height, &s_controls.playerinfo, uis.realtime/2 );
00751 }

Here is the call graph for this function:

void Controls_GetConfig void   )  [static]
 

Definition at line 788 of file ui_controls2.c.

References controls_t::alwaysrun, controls_t::autoswitch, bind_t::bind1, bind_t::bind2, bind_t::command, Controls_GetCvarValue(), Controls_GetKeyAssignment(), menuslider_s::curvalue, menuradiobutton_s::curvalue, f, controls_t::freelook, i, controls_t::invertmouse, controls_t::joyenable, controls_t::joythreshold, bind_t::label, s_controls, controls_t::sensitivity, controls_t::smoothmouse, and UI_ClampCvar().

Referenced by Controls_MenuInit(), String_Init(), and UI_RunMenuScript().

00789 {
00790     int     i;
00791     int     twokeys[2];
00792     bind_t* bindptr;
00793 
00794     // put the bindings into a local store
00795     bindptr = g_bindings;
00796 
00797     // iterate each command, get its numeric binding
00798     for (i=0; ;i++,bindptr++)
00799     {
00800         if (!bindptr->label)
00801             break;
00802 
00803         Controls_GetKeyAssignment(bindptr->command, twokeys);
00804 
00805         bindptr->bind1 = twokeys[0];
00806         bindptr->bind2 = twokeys[1];
00807     }
00808 
00809     s_controls.invertmouse.curvalue  = Controls_GetCvarValue( "m_pitch" ) < 0;
00810     s_controls.smoothmouse.curvalue  = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "m_filter" ) );
00811     s_controls.alwaysrun.curvalue    = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cl_run" ) );
00812     s_controls.autoswitch.curvalue   = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cg_autoswitch" ) );
00813     s_controls.sensitivity.curvalue  = UI_ClampCvar( 2, 30, Controls_GetCvarValue( "sensitivity" ) );
00814     s_controls.joyenable.curvalue    = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "in_joystick" ) );
00815     s_controls.joythreshold.curvalue = UI_ClampCvar( 0.05f, 0.75f, Controls_GetCvarValue( "joy_threshold" ) );
00816     s_controls.freelook.curvalue     = UI_ClampCvar( 0, 1, Controls_GetCvarValue( "cl_freelook" ) );
00817 }

Here is the call graph for this function:

float Controls_GetCvarDefault char *  name  )  [static]