int __MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf) { #ifdef ENGINE_DEBUG CONPRINT("## ResetHUD\n"); #endif return gHUD.MsgFunc_ResetHUD(pszName, iSize, pbuf ); }
// CHud destructor // cleans up memory allocated for m_rg* arrays CHud :: ~CHud() { #ifdef ENGINE_DEBUG CONPRINT("## CHud::destructor\n"); #endif delete [] m_rghSprites; delete [] m_rgrcRects; delete [] m_rgszSpriteNames; gMP3.Shutdown(); ResetRain(); //LRC - clear all shiny surfaces if (m_pShinySurface) { delete m_pShinySurface; m_pShinySurface = NULL; } if ( m_pHudList ) { HUDLIST *pList; while ( m_pHudList ) { pList = m_pHudList; m_pHudList = m_pHudList->pNext; free( pList ); } m_pHudList = NULL; } ServersShutdown(); }
int __MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf) { #ifdef ENGINE_DEBUG CONPRINT("## InitHUD\n"); #endif gHUD.MsgFunc_InitHUD( pszName, iSize, pbuf ); return 1; }
// CHud destructor // cleans up memory allocated for m_rg* arrays CHud :: ~CHud() { #ifdef ENGINE_DEBUG CONPRINT("## CHud::destructor\n"); #endif delete [] m_rghSprites; delete [] m_rgrcRects; delete [] m_rgszSpriteNames; if ( m_pHudList ) { HUDLIST *pList; while ( m_pHudList ) { pList = m_pHudList; m_pHudList = m_pHudList->pNext; free( pList ); } m_pHudList = NULL; } }
void CHud :: VidInit( void ) { #ifdef ENGINE_DEBUG CONPRINT("## CHud::VidInit\n"); #endif m_scrinfo.iSize = sizeof(m_scrinfo); GetScreenInfo(&m_scrinfo); // ---------- // Load Sprites // --------- // m_hsprFont = LoadSprite("sprites/%d_font.spr"); m_hsprLogo = 0; m_hsprCursor = 0; if (ScreenWidth < 640) m_iRes = 320; else m_iRes = 640; // Only load this once if ( !m_pSpriteList ) { // we need to load the hud.txt, and all sprites within m_pSpriteList = SPR_GetList("sprites/hud.txt", &m_iSpriteCountAllRes); if (m_pSpriteList) { int j; // count the number of sprites of the appropriate res m_iSpriteCount = 0; client_sprite_t *p = m_pSpriteList; for ( j = 0; j < m_iSpriteCountAllRes; j++ ) { if ( p->iRes == m_iRes ) m_iSpriteCount++; p++; } // allocated memory for sprite handle arrays m_rghSprites = new HSPRITE[m_iSpriteCount]; m_rgrcRects = new wrect_t[m_iSpriteCount]; m_rgszSpriteNames = new char[m_iSpriteCount * MAX_SPRITE_NAME_LENGTH]; p = m_pSpriteList; int index = 0; for ( j = 0; j < m_iSpriteCountAllRes; j++ ) { if ( p->iRes == m_iRes ) { char sz[256]; sprintf(sz, "sprites/%s.spr", p->szSprite); m_rghSprites[index] = SPR_Load(sz); m_rgrcRects[index] = p->rc; strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); index++; } p++; } } } else { // we have already have loaded the sprite reference from hud.txt, but // we need to make sure all the sprites have been loaded (we've gone through a transition, or loaded a save game) client_sprite_t *p = m_pSpriteList; int index = 0; for ( int j = 0; j < m_iSpriteCountAllRes; j++ ) { if ( p->iRes == m_iRes ) { char sz[256]; sprintf( sz, "sprites/%s.spr", p->szSprite ); m_rghSprites[index] = SPR_Load(sz); index++; } p++; } } // assumption: number_1, number_2, etc, are all listed and loaded sequentially m_HUD_number_0 = GetSpriteIndex( "number_0" ); m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top; m_Ammo.VidInit(); m_Health.VidInit(); m_Spectator.VidInit(); m_Geiger.VidInit(); m_Train.VidInit(); m_Battery.VidInit(); m_Flash.VidInit(); m_Message.VidInit(); m_StatusBar.VidInit(); m_DeathNotice.VidInit(); m_SayText.VidInit(); m_Menu.VidInit(); m_AmmoSecondary.VidInit(); m_TextMessage.VidInit(); m_StatusIcons.VidInit(); m_Particle.VidInit(); // (LRC) -- 30/08/02 November235: Particles to Order }
// This is called every time the DLL is loaded void CHud :: Init( void ) { #ifdef ENGINE_DEBUG CONPRINT("## CHud::Init\n"); #endif HOOK_MESSAGE( Logo ); HOOK_MESSAGE( ResetHUD ); HOOK_MESSAGE( GameMode ); HOOK_MESSAGE( InitHUD ); HOOK_MESSAGE( ViewMode ); HOOK_MESSAGE( SetFOV ); HOOK_MESSAGE( Concuss ); HOOK_MESSAGE( HUDColor ); //LRC HOOK_MESSAGE( SetFog ); //LRC HOOK_MESSAGE( KeyedDLight ); //LRC HOOK_MESSAGE( AddShine ); //LRC HOOK_MESSAGE( SetSky ); //LRC // TFFree CommandMenu HOOK_COMMAND( "+commandmenu", OpenCommandMenu ); HOOK_COMMAND( "-commandmenu", CloseCommandMenu ); HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu ); HOOK_COMMAND( "special", InputPlayerSpecial ); HOOK_COMMAND( "togglebrowser", ToggleServerBrowser ); HOOK_MESSAGE( ValClass ); HOOK_MESSAGE( TeamNames ); HOOK_MESSAGE( Feign ); HOOK_MESSAGE( Detpack ); HOOK_MESSAGE( MOTD ); HOOK_MESSAGE( BuildSt ); HOOK_MESSAGE( RandomPC ); HOOK_MESSAGE( ServerName ); HOOK_MESSAGE( ScoreInfo ); HOOK_MESSAGE( TeamScore ); HOOK_MESSAGE( TeamInfo ); HOOK_MESSAGE( Spectator ); HOOK_MESSAGE( AllowSpec ); // VGUI Menus HOOK_MESSAGE( VGUIMenu ); CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round m_iLogo = 0; m_iFOV = 0; m_iHUDColor = 0x00FFA000; //255,160,0 -- LRC CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 ); default_fov = CVAR_CREATE( "default_fov", "90", 0 ); m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE ); cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" ); m_pSpriteList = NULL; m_pShinySurface = NULL; //LRC // Clear any old HUD list if ( m_pHudList ) { HUDLIST *pList; while ( m_pHudList ) { pList = m_pHudList; m_pHudList = m_pHudList->pNext; free( pList ); } m_pHudList = NULL; } // In case we get messages before the first update -- time will be valid m_flTime = 1.0; m_Ammo.Init(); m_Health.Init(); m_SayText.Init(); m_Spectator.Init(); m_Geiger.Init(); m_Train.Init(); m_Battery.Init(); m_Flash.Init(); m_Message.Init(); m_StatusBar.Init(); m_DeathNotice.Init(); m_AmmoSecondary.Init(); m_TextMessage.Init(); m_StatusIcons.Init(); m_Particle.Init(); // (LRC) -- 30/08/02 November235: Particles to Order m_Menu.Init(); MsgFunc_ResetHUD(0, 0, NULL ); }
// This is called every time the DLL is loaded void CHud :: Init( void ) { #ifdef ENGINE_DEBUG CONPRINT("## CHud::Init\n"); #endif HOOK_MESSAGE( Logo ); HOOK_MESSAGE( ResetHUD ); HOOK_MESSAGE( GameMode ); HOOK_MESSAGE( InitHUD ); HOOK_MESSAGE( ViewMode ); HOOK_MESSAGE( SetFOV ); HOOK_MESSAGE( Concuss ); HOOK_MESSAGE( HUDColor ); //LRC HOOK_MESSAGE( SetFog ); //LRC HOOK_MESSAGE( KeyedDLight ); //LRC HOOK_MESSAGE( AddShine ); //LRC HOOK_MESSAGE( Test ); //LRC HOOK_MESSAGE( SetSky ); //LRC HOOK_MESSAGE( CamData );//G-Cont. for new camera style HOOK_MESSAGE( RainData );//G-Cont. for rain control HOOK_MESSAGE( Inventory ); //AJH Inventory system HOOK_MESSAGE( ClampView ); //LRC 1.8 //KILLAR: MP3 if(gMP3.Initialize()) { HOOK_MESSAGE( PlayMP3 ); HOOK_COMMAND( "stopaudio", StopMP3 ); } // TFFree CommandMenu HOOK_COMMAND( "+commandmenu", OpenCommandMenu ); HOOK_COMMAND( "-commandmenu", CloseCommandMenu ); HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu ); HOOK_COMMAND( "special", InputPlayerSpecial ); HOOK_COMMAND( "togglebrowser", ToggleServerBrowser ); HOOK_MESSAGE( ValClass ); HOOK_MESSAGE( TeamNames ); HOOK_MESSAGE( Feign ); HOOK_MESSAGE( Detpack ); HOOK_MESSAGE( MOTD ); HOOK_MESSAGE( BuildSt ); HOOK_MESSAGE( RandomPC ); HOOK_MESSAGE( ServerName ); HOOK_MESSAGE( ScoreInfo ); HOOK_MESSAGE( TeamScore ); HOOK_MESSAGE( TeamInfo ); HOOK_MESSAGE( Spectator ); HOOK_MESSAGE( AllowSpec ); // VGUI Menus HOOK_MESSAGE( VGUIMenu ); CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round CVAR_CREATE("r_glow", "2", FCVAR_ARCHIVE ); CVAR_CREATE("r_glowstrength", "1", FCVAR_ARCHIVE ); CVAR_CREATE("r_glowblur", "6", FCVAR_ARCHIVE ); CVAR_CREATE("r_glowdark", "10", FCVAR_ARCHIVE ); viewEntityIndex = 0; // trigger_viewset stuff viewFlags = 0; m_iLogo = 0; m_iFOV = 0; numMirrors = 0; m_iHUDColor = 0x00FFA000; //255,160,0 -- LRC CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 ); default_fov = CVAR_CREATE( "default_fov", "90", 0 ); m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE ); cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" ); RainInfo = gEngfuncs.pfnRegisterVariable( "cl_raininfo", "0", 0 ); m_pSpriteList = NULL; m_pShinySurface = NULL; //LRC // Clear any old HUD list if ( m_pHudList ) { HUDLIST *pList; while ( m_pHudList ) { pList = m_pHudList; m_pHudList = m_pHudList->pNext; free( pList ); } m_pHudList = NULL; } // In case we get messages before the first update -- time will be valid m_flTime = 1.0; m_Ammo.Init(); m_Health.Init(); m_SayText.Init(); m_Spectator.Init(); m_Geiger.Init(); m_Train.Init(); m_Battery.Init(); m_Flash.Init(); m_Message.Init(); m_StatusBar.Init(); m_DeathNotice.Init(); m_AmmoSecondary.Init(); m_TextMessage.Init(); m_StatusIcons.Init(); GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort); m_Particle.Init(); // (LRC) -- 30/08/02 November235: Particles to Order m_Lensflare.Init(); m_Menu.Init(); InitRain(); ServersInit(); MsgFunc_ResetHUD(0, 0, NULL ); }
// loads and parses the particle definition file bool CGrassParticleSystem::LoadParticleDefinition( particle_system_management *pSysDetails ) { // check we've set a file if(!m_sParticleFile) { CONPRINT("No Grass Particle definition file specified"); return false; } // load file checking it exists char *sFile = (char *)gEngfuncs.COM_LoadFile(m_sParticleFile, 5 , null); if(!sFile) { CONPRINT("Bad Grass Particle definition file specified %s\n", m_sParticleFile); return false; } char sSetting[256]; char sValue[256]; // pointer to the current system grass_particle_system *pSystem = NULL; // better than while(1) bool bLooping = true; while(bLooping) { // read the first chunk. it should be a setting sFile = gEngfuncs.COM_ParseFile(sFile, sSetting); // eof before a setting is fine if(!sFile) { break; } // not eof but no setting... !? if(!sSetting) { CONPRINT("Unexpected error in file after %sin %s", sValue, m_sParticleFile); gEngfuncs.COM_FreeFile(sFile); return false; } // we're finished with this particle, create a new particle and parse if((!_stricmp(sSetting, "new_particle"))) { pSystem = CreateDefaultParticleSystem(); pSystem->vDirection = pSysDetails->vDirection; pSystem->vAbsMax = pSysDetails->vAbsMax; pSystem->vAbsMin = pSysDetails->vAbsMin; pSystem->vPostion = pSysDetails->vPosition; // create the new gras type grass_particle_types *pGrassSystem = new grass_particle_types; pGrassSystem->pSystem = pSystem; pGrassSystem->pParticleTexture = NULL; m_cGrassTypes.push_back(pGrassSystem); continue; } // getting the value for this setting as setting and value's should be paired sFile = gEngfuncs.COM_ParseFile(sFile, sValue); // hitting eof is unaccpetable so no need to check for it and return true; if(!sValue) { CONPRINT("Unexpected error in file after %s in %s", sSetting, m_sParticleFile); gEngfuncs.COM_FreeFile(sFile); return false; } // first particle if(pSystem == NULL) { pSystem = CreateDefaultParticleSystem(); pSystem->vDirection = pSysDetails->vDirection; pSystem->vAbsMax = pSysDetails->vAbsMax; pSystem->vAbsMin = pSysDetails->vAbsMin; pSystem->vPostion = pSysDetails->vPosition; // create the new gras type grass_particle_types *pGrassSystem = new grass_particle_types; pGrassSystem->pSystem = pSystem; pGrassSystem->pParticleTexture = NULL; m_cGrassTypes.push_back(pGrassSystem); } // temp values so we don't have to keep converting when performing calcs on the inputted variables int iTemp = 0; // particle texture path if(!_stricmp(sSetting, "texture")) { _snprintf(pSystem->sParticleTexture, MAX_PARTICLE_PATH, "%s", sValue); } // size of texture * this value else if(!_stricmp(sSetting, "scale")) { pSystem->flSize = atof(sValue); } // the maximum amount this grass can lean else if(!_stricmp(sSetting, "leaning_max")) { pSystem->flLeaningMax = atof(sValue); } // the maximum amount this grass can lean else if(!_stricmp(sSetting, "leaning_min")) { pSystem->flLeaningMin = atof(sValue); } // how fast the wind is going else if(!_stricmp(sSetting, "wave_speed")) { pSystem->flWaveSpeed = atof(sValue); } // the number of particles in this system else if(!_stricmp(sSetting, "particles")) { pSystem->iCount = atoi(sValue); } // how transparent the particles are else if(!_stricmp(sSetting, "transparency")) { iTemp = atoi(sValue); // make sure it isn't out of range if(iTemp > 255 || iTemp < 0) pSystem->iTransparency = 255; else pSystem->iTransparency = iTemp; } // level of detail else if(!_stricmp(sSetting, "lod")) { pSystem->bLOD = (!!(atoi(sValue))); } // drop on ground ?? else if(!_stricmp(sSetting, "drop_on_ground")) { pSystem->bDropOnGround = (!!(atoi(sValue))); } // ignore_sort - Do not sort these particles with the rest ( saves cpu time ) else if(!_stricmp(sSetting, "ignore_sort")) { pSystem->bIgnoreSort = (!!(atoi(sValue))); } // randomize - set different scales based on iRandomVal's value else if(!_stricmp(sSetting, "randomize")) { pSystem->bUseRandom = (!!(atoi(sValue))); } // different scales values else if(!_stricmp(sSetting, "random_modifier")) { pSystem->fRandomVal = atof(sValue); } // catch all to accomodate for my spelling at first and then mapper's spelling later on else { CONPRINT("Unknown setting - %s in %s\n\0", sSetting, m_sParticleFile); } } return true; }
// draws this grass particle //extern void RenderFog ( void ); // Fograin92: Disabled void CGrassParticle::Draw( void ) { if (m_bIngoreParticle == true) return; if(sParticle.pTexture == NULL) { CONPRINT("Null texture in particle\n"); return; } Vector vForward, vRight, vUp, vDir; AngleVectors(v_angles, vForward, vRight, vUp ); vDir = ( sParticle.vPosition - flPlayerOrigin ).Normalize( ); if ( DotProduct ( vDir, vForward ) < 0 ) return; int iHealth = 0; // lets make sure transparency doesn't overflow or udnerflow if (sParticle.iTransparency > 255) sParticle.iTransparency = 255; if (sParticle.iTransparency < 0) sParticle.iTransparency = 0; iHealth = sParticle.iTransparency; if (pSys->bLOD) // fade out particles that are further away (LOD) { float flDistance = sqrt(sParticle.flSquareDistanceToPlayer); if ((flDistance > m_flLodMinDistance) && (flDistance < m_flLodMaxDistance)) { float flTransparencyFactor = 1 - ((flDistance - m_flLodMinDistance) / (m_flLodMaxDistance - m_flLodMinDistance)); if (flTransparencyFactor > 1) flTransparencyFactor = 1; if (flTransparencyFactor < 0) flTransparencyFactor = 0; iHealth *= flTransparencyFactor; } } vec3_t vPoint, vPosition; vec3_t vWaveForward, vWaveRight, vWaveUp; // We again copy part->origin into another vector to prevent us accidentally messing with it VectorCopy( sParticle.vPosition, vPosition ); AngleVectors(m_vNormal, vForward, vRight, vUp); AngleVectors(m_vWaveNormal, vWaveForward, vWaveRight, vWaveUp); glColor4ub(sParticle.iRed, sParticle.iGreen, sParticle.iBlue,iHealth); //RenderFog(); // Fograin92: Disabled // Finally, we draw the particle glBindTexture(GL_TEXTURE_2D, sParticle.pTexture->iID); glBegin(GL_QUADS); glTexCoord2f(0, 0.95f); VectorMA (sParticle.vPosition, sParticle.flSize, vWaveUp, vPoint); VectorMA (vPoint, -sParticle.flSize, vWaveRight, vPoint); glVertex3fv(vPoint); glTexCoord2f(0.95f, 0.95f); VectorMA (sParticle.vPosition, sParticle.flSize, vWaveUp, vPoint); VectorMA (vPoint, sParticle.flSize, vWaveRight, vPoint); glVertex3fv(vPoint); glTexCoord2f(0.95f, 0); VectorMA (sParticle.vPosition, -sParticle.flSize, vUp, vPoint); VectorMA (vPoint, sParticle.flSize, vRight, vPoint); glVertex3fv(vPoint); glTexCoord2f(0, 0); VectorMA (sParticle.vPosition, -sParticle.flSize, vUp, vPoint); VectorMA (vPoint, -sParticle.flSize, vRight, vPoint); glVertex3fv(vPoint); glEnd(); }