Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 08-26-2009, 09:23 AM   #1
DuckSauce01
 
Join Date: Apr 2008
Reputation: 35
Posts: 923
Multiple Icons on screen part of one HUD element possible?

Got me a HUD element that will display an icon over a players head, only one can be shown at a time atm, however now I want to increase the usefull of it by showing at least 3 icons at once.

Everything works fine with the one, however I'm unsure if it's possible with just the one hud element.

Currently done all the messing around I could regarding that in the code for the HUD element itself, to do more I would have to mess with logic of selecting who to show the icon on which is in hl2mp_player.cpp, I can easily replace an old backup of the hud file if needed but if I do it for hl2mp_player I might be losing other progress.

So is this possible with one HUD element or would I need to make one HUD element for each "target" player that an icon has to be shown for?

Right now I've just tried a simple for loop and making an array of my handle that takes care of fetching the coördinates from the targetted player, this didn't seem to work though and I'd like to know for sure if it's possible before digging in deeper.
DuckSauce01 is offline  
Reply With Quote
Old 08-26-2009, 09:37 AM   #2
Biohazard_90
 
 
 
Join Date: Jun 2008
Reputation: 351
Posts: 1,804
You could create a panel for every client playerclass spawned (I did this with sunflares for every env_sun used, so it will work).

But in this case it might be more efficient to prepare structarrays (with information about the position and if they are supposed to draw) and then draw them, if a player exists and if he's onscreen.
Biohazard_90 is offline   Reply With Quote
Old 08-26-2009, 11:20 AM   #3
B_Andrews
 
 
 
Guest
Posts: n/a
lol..
Just use one hud element... looping through all the clients.
Here's some old code (before i moved onto editing the voice thing instead - search for DoD style player icons to find the post)

Code:
void CSDKPlayerIcons::Paint()
{
	C_SDKPlayer *pLocalPlayer = C_SDKPlayer::GetLocalSDKPlayer();

	if ( !pLocalPlayer )
		return;
	int xpos(0), ypos(0);


	surface()->DrawSetColor( SDKGameResources()->GetTeamColor( pLocalPlayer->GetTeamNumber() )/*m_CPProgressColor*/ );
	surface()->DrawSetTextFont(m_hFont);

	for( int iClient = 1; iClient <= gpGlobals->maxClients; ++iClient )
	{
		
		C_BasePlayer *pPlayer = UTIL_PlayerByIndex( iClient );
		if (pPlayer && (pPlayer->GetTeamNumber() == pLocalPlayer->GetTeamNumber()) && pPlayer->IsAlive() )
		{
			Vector vecPos(pPlayer->WorldSpaceCenter());
			vecPos.z += (pPlayer->GetViewOffset().z / 2);
			//vecPos.z += 40.0f;
			GetVectorInScreenSpace( vecPos, xpos, ypos );
			surface()->DrawSetTextPos(xpos, ypos);
			surface()->DrawSetColor( SDKGameResources()->GetTeamColor( pPlayer->GetTeamNumber() ) );
			if (pPlayer->IsDowned() )
			{
				Vector vecPos(pPlayer->WorldSpaceCenter());
				GetVectorInScreenSpace( vecPos, xpos, ypos );
				surface()->DrawSetTextPos(xpos, ypos);
				surface()->DrawPrintText(L"+", wcslen(L"+"));
			}
			else
				surface()->DrawPrintText(L"C", wcslen(L"C"));
		}
	}//for each client in our PVS

}
  Reply With Quote
Old 08-26-2009, 12:01 PM   #4
DuckSauce01
 
Join Date: Apr 2008
Reputation: 35
Posts: 923
Quote:
Originally Posted by B_Andrews View Post
lol..
Just use one hud element... looping through all the clients.
Good to know
Shouldn't have any problems with it so consider this thread done
DuckSauce01 is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 12:08 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.