CGame Source Code Changes

In order to make the scripted Hud work with the modified menu script code avalible on this site we must add some code to the CGame module. This must be done regardless of which method you use to implement the Hud code. These code changes will make the Hud scripts more versatile and also make them compatible with your menu scripts.

Most code changes take place in the cg_main.c file with the rest in the cg_newdraw.c file . All line numbers are approximate and will vary depending on the source code version you are using and how much the file has been modified.

cg_main.h

In the CG_Asset_Parse function at about line 1375 add this code :

 cgDC.Assets.shadowFadeClamp = cgDC.Assets.shadowColor[3];
continue;
}
// Changed RD SCRIPTHUD
if (Q_stricmp(token.string, "scrollbarSize") == 0) {
if (!PC_Float_Parse(handle, &cgDC.Assets.scrollbarsize)) {
return qfalse;
}
continue;
}
 if (Q_stricmp(token.string, "sliderWidth") == 0) {
   if (!PC_Float_Parse(handle, &cgDC.Assets.sliderwidth)) {
       return qfalse;
   }
   continue;
 }
 if (Q_stricmp(token.string, "sliderHeight") == 0) {
   if (!PC_Float_Parse(handle, &cgDC.Assets.sliderheight)) {
       return qfalse;
   }
   continue;
 }
 if (Q_stricmp(token.string, "sliderthumbWidth") == 0) {
   if (!PC_Float_Parse(handle, &cgDC.Assets.sliderthumbwidth)) {
       return qfalse;
   }
   continue;
 }
 if (Q_stricmp(token.string, "sliderthumbHeight") == 0) {
   if (!PC_Float_Parse(handle, &cgDC.Assets.sliderthumbheight)) {
       return qfalse;
   }
   continue;
 }
 if (Q_stricmp(token.string, "sliderBar") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "sliderThumb") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
        return qfalse;
   }
   cgDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "sliderThumbSel") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.sliderThumb_sel = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "scrollBarHorz") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.scrollBarHorz = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "scrollBarVert") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.scrollBarVert = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "scrollBarThumb") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "scrollBarArrowUp") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "scrollBarArrowDown") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "scrollBarArrowLeft") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "scrollBarArrowRight") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxBase") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxRed") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxYellow") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxGreen") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxTeal") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxBlue") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxCyan") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
 if (Q_stricmp(token.string, "fxWhite") == 0) {
   if (!PC_String_Parse(handle, &tempStr)) {
       return qfalse;
   }
   cgDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( tempStr);
   continue;
 }
   // end changed RD SCRIPTHUD
}
   return qfalse; // bk001204 - why not?
}

In the CG_AssetCache function at about line 2010 replace the entire function with the following :

void CG_AssetCache( void ) {
// Changed RD SCRIPTHUD
cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR );
cgDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE );
cgDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED );
cgDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW );
cgDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN );
cgDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL );
cgDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE );
cgDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN );
cgDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE );
cgDC.Assets.scrollBarHorz = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );
cgDC.Assets.scrollBarVert = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );
cgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );
cgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );
cgDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );
cgDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );
cgDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );
cgDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR );
cgDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB );
cgDC.Assets.sliderThumb_sel = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB_SEL );
cgDC.Assets.scrollbarsize = SCROLLBAR_SIZE;
cgDC.Assets.sliderwidth = SLIDER_WIDTH;
cgDC.Assets.sliderheight = SLIDER_HEIGHT;
cgDC.Assets.sliderthumbwidth = SLIDER_THUMB_WIDTH;
cgDC.Assets.sliderthumbheight = SLIDER_THUMB_HEIGHT;
// end changed RD SCRIPTHUD

}
#endif

These changes add some new commands to the assetGlobalDef section and make some changes to the assets that are loaded by default. This makes the Hud scripts identical to the menu scripts in this regard.

cg_newdraw.h

In the CG_SelectNextPlayer function about line 142 change the code to the following :

void CG_SelectNextPlayer( void ) {
CG_CheckOrderPending();
cg_currentSelectedPlayer.integer +=1;
if (cg_currentSelectedPlayer.integer > numSortedTeamPlayers)
cg_currentSelectedPlayer.integer = 0;
CG_SetSelectedPlayerName();

}

And in the CG_SelectPrevPlayer function about line 152 change the code to the following :

void CG_SelectPrevPlayer( void ) {
CG_CheckOrderPending();
cg_currentSelectedPlayer.integer -=1;
if (cg_currentSelectedPlayer.integer < 0)
cg_currentSelectedPlayer.integer = numSortedTeamPlayers;
CG_SetSelectedPlayerName();

}


This fixes a problem with cycling through the team members that caused it not to wrap around at the end of the list.

          
Return to Home Page