diff options
Diffstat (limited to 'src/ui_playerconfig.c')
-rw-r--r-- | src/ui_playerconfig.c | 141 |
1 files changed, 75 insertions, 66 deletions
diff --git a/src/ui_playerconfig.c b/src/ui_playerconfig.c index ac41268..1b22a89 100644 --- a/src/ui_playerconfig.c +++ b/src/ui_playerconfig.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -57,45 +57,48 @@ static const char *handedness[] = { 0 }; -static void ReloadMedia( void ) { +static void ReloadMedia(void) +{ char scratch[MAX_QPATH]; char *model = uis.pmi[m_player.model.curvalue].directory; char *skin = uis.pmi[m_player.model.curvalue].skindisplaynames[m_player.skin.curvalue]; - Q_concat( scratch, sizeof( scratch ), "players/", model, "/tris.md2", NULL ); - m_player.entities[0].model = R_RegisterModel( scratch ); + Q_concat(scratch, sizeof(scratch), "players/", model, "/tris.md2", NULL); + m_player.entities[0].model = R_RegisterModel(scratch); - Q_concat( scratch, sizeof( scratch ), "players/", model, "/", skin, ".pcx", NULL ); - m_player.entities[0].skin = R_RegisterSkin( scratch ); + Q_concat(scratch, sizeof(scratch), "players/", model, "/", skin, ".pcx", NULL); + m_player.entities[0].skin = R_RegisterSkin(scratch); - if( uis.weaponModel[0] ) { - Q_concat( scratch, sizeof( scratch ), "players/", model, "/", uis.weaponModel, NULL ); - m_player.entities[1].model = R_RegisterModel( scratch ); + if (uis.weaponModel[0]) { + Q_concat(scratch, sizeof(scratch), "players/", model, "/", uis.weaponModel, NULL); + m_player.entities[1].model = R_RegisterModel(scratch); } } -static void RunFrame( void ) { +static void RunFrame(void) +{ int frame; int i; - if( m_player.time < uis.realtime ) { + if (m_player.time < uis.realtime) { m_player.oldTime = m_player.time; m_player.time += 120; - if( m_player.time < uis.realtime ) { + if (m_player.time < uis.realtime) { m_player.time = uis.realtime; } - frame = ( m_player.time / 120 ) % 40; + frame = (m_player.time / 120) % 40; - for( i = 0; i < m_player.refdef.num_entities; i++ ) { + for (i = 0; i < m_player.refdef.num_entities; i++) { m_player.entities[i].oldframe = m_player.entities[i].frame; m_player.entities[i].frame = frame; } } } -static void Draw( menuFrameWork_t *self ) { +static void Draw(menuFrameWork_t *self) +{ float backlerp; int i; @@ -103,23 +106,24 @@ static void Draw( menuFrameWork_t *self ) { RunFrame(); - if( m_player.time == m_player.oldTime ) { + if (m_player.time == m_player.oldTime) { backlerp = 0; } else { - backlerp = 1 - ( float )( uis.realtime - m_player.oldTime ) / - ( float )( m_player.time - m_player.oldTime ); + backlerp = 1 - (float)(uis.realtime - m_player.oldTime) / + (float)(m_player.time - m_player.oldTime); } - for( i = 0; i < m_player.refdef.num_entities; i++ ) { + for (i = 0; i < m_player.refdef.num_entities; i++) { m_player.entities[i].backlerp = backlerp; } - Menu_Draw( self ); + Menu_Draw(self); - R_RenderFrame( &m_player.refdef ); + R_RenderFrame(&m_player.refdef); } -static void Size( menuFrameWork_t *self ) { +static void Size(menuFrameWork_t *self) +{ int x = uis.width / 2 - 130; int y = uis.height / 2 - 97; @@ -129,8 +133,8 @@ static void Size( menuFrameWork_t *self ) { m_player.refdef.height = uis.height / uis.scale - 122; m_player.refdef.fov_x = 40; - m_player.refdef.fov_y = V_CalcFov( m_player.refdef.fov_x, - m_player.refdef.width, m_player.refdef.height ); + m_player.refdef.fov_y = V_CalcFov(m_player.refdef.fov_x, + m_player.refdef.width, m_player.refdef.height); m_player.name.generic.x = x; m_player.name.generic.y = y; @@ -148,13 +152,14 @@ static void Size( menuFrameWork_t *self ) { m_player.hand.generic.y = y; } -static menuSound_t Change( menuCommon_t *self ) { - switch( self->id ) { +static menuSound_t Change(menuCommon_t *self) +{ + switch (self->id) { case ID_MODEL: m_player.skin.itemnames = uis.pmi[m_player.model.curvalue].skindisplaynames; m_player.skin.curvalue = 0; - SpinControl_Init( &m_player.skin ); + SpinControl_Init(&m_player.skin); // fall through case ID_SKIN: ReloadMedia(); @@ -165,21 +170,23 @@ static menuSound_t Change( menuCommon_t *self ) { return QMS_MOVE; } -static void Pop( menuFrameWork_t *self ) { +static void Pop(menuFrameWork_t *self) +{ char scratch[MAX_OSPATH]; - Cvar_SetEx( "name", m_player.name.field.text, FROM_CONSOLE ); + Cvar_SetEx("name", m_player.name.field.text, FROM_CONSOLE); - Q_concat( scratch, sizeof( scratch ), - uis.pmi[m_player.model.curvalue].directory, "/", - uis.pmi[m_player.model.curvalue].skindisplaynames[m_player.skin.curvalue], NULL ); + Q_concat(scratch, sizeof(scratch), + uis.pmi[m_player.model.curvalue].directory, "/", + uis.pmi[m_player.model.curvalue].skindisplaynames[m_player.skin.curvalue], NULL); - Cvar_SetEx( "skin", scratch, FROM_CONSOLE ); + Cvar_SetEx("skin", scratch, FROM_CONSOLE); - Cvar_SetEx( "hand", va( "%d", m_player.hand.curvalue ), FROM_CONSOLE ); + Cvar_SetEx("hand", va("%d", m_player.hand.curvalue), FROM_CONSOLE); } -static qboolean Push( menuFrameWork_t *self ) { +static qboolean Push(menuFrameWork_t *self) +{ char currentdirectory[MAX_QPATH]; char currentskin[MAX_QPATH]; int i, j; @@ -188,30 +195,30 @@ static qboolean Push( menuFrameWork_t *self ) { char *p; // find and register all player models - if( !uis.numPlayerModels ) { + if (!uis.numPlayerModels) { PlayerModel_Load(); - if( !uis.numPlayerModels ) { + if (!uis.numPlayerModels) { return qfalse; } } - Cvar_VariableStringBuffer( "skin", currentdirectory, sizeof( currentdirectory ) ); + Cvar_VariableStringBuffer("skin", currentdirectory, sizeof(currentdirectory)); - if( ( p = strchr( currentdirectory, '/' ) ) || ( p = strchr( currentdirectory, '\\' ) ) ) { + if ((p = strchr(currentdirectory, '/')) || (p = strchr(currentdirectory, '\\'))) { *p++ = 0; - Q_strlcpy( currentskin, p, sizeof( currentskin ) ); + Q_strlcpy(currentskin, p, sizeof(currentskin)); } else { - strcpy( currentdirectory, "male" ); - strcpy( currentskin, "grunt" ); + strcpy(currentdirectory, "male"); + strcpy(currentskin, "grunt"); } - for( i = 0 ; i < uis.numPlayerModels ; i++ ) { + for (i = 0; i < uis.numPlayerModels; i++) { m_player.pmnames[i] = uis.pmi[i].directory; - if( Q_stricmp( uis.pmi[i].directory, currentdirectory ) == 0 ) { + if (Q_stricmp(uis.pmi[i].directory, currentdirectory) == 0) { currentdirectoryindex = i; - for( j = 0 ; j < uis.pmi[i].nskins ; j++ ) { - if( Q_stricmp( uis.pmi[i].skindisplaynames[j], currentskin ) == 0 ) { + for (j = 0; j < uis.pmi[i].nskins; j++) { + if (Q_stricmp(uis.pmi[i].skindisplaynames[j], currentskin) == 0) { currentskinindex = j; break; } @@ -219,8 +226,8 @@ static qboolean Push( menuFrameWork_t *self ) { } } - IF_Init( &m_player.name.field, 15, 15 ); - IF_Replace( &m_player.name.field, Cvar_VariableString( "name" ) ); + IF_Init(&m_player.name.field, 15, 15); + IF_Replace(&m_player.name.field, Cvar_VariableString("name")); m_player.model.curvalue = currentdirectoryindex; m_player.model.itemnames = m_player.pmnames; @@ -228,8 +235,8 @@ static qboolean Push( menuFrameWork_t *self ) { m_player.skin.curvalue = currentskinindex; m_player.skin.itemnames = uis.pmi[currentdirectoryindex].skindisplaynames; - m_player.hand.curvalue = Cvar_VariableInteger( "hand" ); - clamp( m_player.hand.curvalue, 0, 2 ); + m_player.hand.curvalue = Cvar_VariableInteger("hand"); + clamp(m_player.hand.curvalue, 0, 2); ReloadMedia(); @@ -241,11 +248,13 @@ static qboolean Push( menuFrameWork_t *self ) { return qtrue; } -static void Free( menuFrameWork_t *self ) { - memset( &m_player, 0, sizeof( m_player ) ); +static void Free(menuFrameWork_t *self) +{ + memset(&m_player, 0, sizeof(m_player)); } -void M_Menu_PlayerConfig( void ) { +void M_Menu_PlayerConfig(void) +{ static const vec3_t origin = { 80.0f, 5.0f, 0.0f }; static const vec3_t angles = { 0.0f, 260.0f, 0.0f }; @@ -260,17 +269,17 @@ void M_Menu_PlayerConfig( void ) { m_player.menu.color.u32 = uis.color.background.u32; m_player.entities[0].flags = RF_FULLBRIGHT; - VectorCopy( angles, m_player.entities[0].angles ); - VectorCopy( origin, m_player.entities[0].origin ); - VectorCopy( origin, m_player.entities[0].oldorigin ); + VectorCopy(angles, m_player.entities[0].angles); + VectorCopy(origin, m_player.entities[0].origin); + VectorCopy(origin, m_player.entities[0].oldorigin); m_player.entities[1].flags = RF_FULLBRIGHT; - VectorCopy( angles, m_player.entities[1].angles ); - VectorCopy( origin, m_player.entities[1].origin ); - VectorCopy( origin, m_player.entities[1].oldorigin ); + VectorCopy(angles, m_player.entities[1].angles); + VectorCopy(origin, m_player.entities[1].origin); + VectorCopy(origin, m_player.entities[1].oldorigin); m_player.refdef.num_entities = 1; - if( uis.weaponModel[0] ) { + if (uis.weaponModel[0]) { m_player.refdef.num_entities++; } @@ -293,13 +302,13 @@ void M_Menu_PlayerConfig( void ) { m_player.hand.generic.type = MTYPE_SPINCONTROL; m_player.hand.generic.name = "handedness"; - m_player.hand.itemnames = ( char ** )handedness; + m_player.hand.itemnames = (char **)handedness; - Menu_AddItem( &m_player.menu, &m_player.name ); - Menu_AddItem( &m_player.menu, &m_player.model ); - Menu_AddItem( &m_player.menu, &m_player.skin ); - Menu_AddItem( &m_player.menu, &m_player.hand ); + Menu_AddItem(&m_player.menu, &m_player.name); + Menu_AddItem(&m_player.menu, &m_player.model); + Menu_AddItem(&m_player.menu, &m_player.skin); + Menu_AddItem(&m_player.menu, &m_player.hand); - List_Append( &ui_menus, &m_player.menu.entry ); + List_Append(&ui_menus, &m_player.menu.entry); } |