mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
Add hud_minimapnames
-Original code by alien bird/eternium. Thanks! -Removed names for self and other team -Default off due to black background on text
This commit is contained in:
parent
0e90cd5414
commit
97ea2a098c
5 changed files with 101 additions and 0 deletions
|
@ -221,6 +221,11 @@ void CHud :: Init( void )
|
||||||
|
|
||||||
CVAR_CREATE("cl_weaponswap", "2", FCVAR_ARCHIVE | FCVAR_USERINFO);
|
CVAR_CREATE("cl_weaponswap", "2", FCVAR_ARCHIVE | FCVAR_USERINFO);
|
||||||
CVAR_CREATE("hud_teamhealthalert", "95", FCVAR_ARCHIVE);
|
CVAR_CREATE("hud_teamhealthalert", "95", FCVAR_ARCHIVE);
|
||||||
|
CVAR_CREATE("hud_minimapnames", "0", FCVAR_ARCHIVE);
|
||||||
|
CVAR_CREATE("hud_minimapnamesComm", "0", FCVAR_ARCHIVE);
|
||||||
|
CVAR_CREATE("hud_minimapnamesRed", "255", FCVAR_ARCHIVE);
|
||||||
|
CVAR_CREATE("hud_minimapnamesGreen", "255", FCVAR_ARCHIVE);
|
||||||
|
CVAR_CREATE("hud_minimapnamesBlue", "255", FCVAR_ARCHIVE);
|
||||||
|
|
||||||
m_pSpriteList = NULL;
|
m_pSpriteList = NULL;
|
||||||
|
|
||||||
|
|
|
@ -192,4 +192,52 @@ int AvHFont::DrawStringReverse(int inX, int inY, const char* inString, int r, in
|
||||||
|
|
||||||
return theX;
|
return theX;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int AvHFont::DrawStringCustom(int inX, int inY, const char* inString, int r, int g, int b, int inRenderMode) const
|
||||||
|
{
|
||||||
|
|
||||||
|
int theX = inX;
|
||||||
|
int theY = inY;
|
||||||
|
|
||||||
|
int theCharHeight = GetStringHeight();
|
||||||
|
|
||||||
|
AvHSpriteBeginFrame();
|
||||||
|
|
||||||
|
//AvHSpriteSetVGUIOffset(0, 0);
|
||||||
|
|
||||||
|
AvHSpriteSetRenderMode(inRenderMode);
|
||||||
|
AvHSpriteSetColor(r / 256.0f, g / 256.0f, b / 256.0f);
|
||||||
|
|
||||||
|
int charWidth = mSpriteWidth / 16;
|
||||||
|
int charHeight = mSpriteHeight / 16;
|
||||||
|
|
||||||
|
for (int i = 0; inString[i] != 0 && inString[i] != '\n'; ++i)
|
||||||
|
{
|
||||||
|
|
||||||
|
unsigned char c = inString[i];
|
||||||
|
|
||||||
|
if (c < 32)
|
||||||
|
{
|
||||||
|
// Unprintable.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
theX += mCharWidth[c].a;
|
||||||
|
|
||||||
|
float theU = ((c % kNumCharsPerRow) * charWidth) / float(mSpriteWidth);
|
||||||
|
float theV = ((c / kNumCharsPerRow) * charHeight) / float(mSpriteHeight);
|
||||||
|
|
||||||
|
AvHSpriteDraw(mSprite, 0, theX, theY, theX + mCharWidth[c].b, theY + theCharHeight,
|
||||||
|
theU, theV, theU + mCharWidth[c].b / 256.0f, theV + theCharHeight / 256.0f);
|
||||||
|
|
||||||
|
theX += mCharWidth[c].b + mCharWidth[c].c;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AvHSpriteEndFrame();
|
||||||
|
AvHSpriteSetColor(1, 1, 1);
|
||||||
|
|
||||||
|
return theX;
|
||||||
|
|
||||||
}
|
}
|
|
@ -48,6 +48,8 @@ public:
|
||||||
*/
|
*/
|
||||||
int DrawStringReverse(int inX, int inY, const char* inString, int r, int g, int b, int inRenderMode = kRenderTransAdd) const;
|
int DrawStringReverse(int inX, int inY, const char* inString, int r, int g, int b, int inRenderMode = kRenderTransAdd) const;
|
||||||
|
|
||||||
|
int DrawStringCustom(int inX, int inY, const char* inString, int r, int g, int b, int inRenderMode = kRenderTransAdd) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AVHHSPRITE mSprite;
|
AVHHSPRITE mSprite;
|
||||||
|
|
|
@ -439,6 +439,51 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
||||||
AvHSpriteSetRenderMode(theRenderMode);
|
AvHSpriteSetRenderMode(theRenderMode);
|
||||||
AvHSpriteDraw(theSprite, theFrame, x, y, x + w, y + h, 0, 0, 1, 1);
|
AvHSpriteDraw(theSprite, theFrame, x, y, x + w, y + h, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
//alien's minimap names
|
||||||
|
//if (inEntity.mIsLocalPlayer)
|
||||||
|
if (CVAR_GET_FLOAT("hud_minimapnames") != 0 && ((mUser3 != AVH_USER3_COMMANDER_PLAYER) || CVAR_GET_FLOAT("hud_minimapnamesComm") != 0))
|
||||||
|
{
|
||||||
|
tFont.Load("sprites/nl/font_arial"); //font_arialsmall
|
||||||
|
//string theText;
|
||||||
|
char bufferb[1024];
|
||||||
|
|
||||||
|
|
||||||
|
if ((inEntity.mEntityNumber >= 1) && (inEntity.mEntityNumber <= gEngfuncs.GetMaxClients()))
|
||||||
|
{
|
||||||
|
hud_player_info_t thePlayerInfo;
|
||||||
|
gEngfuncs.pfnGetPlayerInfo(inEntity.mEntityNumber, &thePlayerInfo);
|
||||||
|
if (thePlayerInfo.name && !thePlayerInfo.thisplayer && inEntity.mTeam == this->mTeam)
|
||||||
|
{
|
||||||
|
//outEntityInfoString += thePlayerInfo.name;
|
||||||
|
//theText = thePlayerInfo.name;
|
||||||
|
//sprintf(bufferb, "%s", theText.c_str());
|
||||||
|
|
||||||
|
int tR = CVAR_GET_FLOAT("hud_minimapnamesRed");
|
||||||
|
int tG = CVAR_GET_FLOAT("hud_minimapnamesGreen");
|
||||||
|
int tB = CVAR_GET_FLOAT("hud_minimapnamesBlue");
|
||||||
|
|
||||||
|
sprintf(bufferb, "%s", thePlayerInfo.name);
|
||||||
|
|
||||||
|
if (bufferb) {
|
||||||
|
std::string text(bufferb);
|
||||||
|
|
||||||
|
if (CVAR_GET_FLOAT("hud_minimapnames") >= 2) { //3 letter max
|
||||||
|
//strcpy(rgDeathNoticeList[i].szVictim, killed_with.c_str() + 2);
|
||||||
|
//while (text.length() > 3) {
|
||||||
|
// text[3]
|
||||||
|
//}
|
||||||
|
//bufferb
|
||||||
|
text = text.substr(0, max((int)CVAR_GET_FLOAT("hud_minimapnames"), 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
tFont.DrawStringCustom(x + 12 - text.length() * 3, y - 18, text.c_str(), tR, tG, tB, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPlayer || theIsWaypoint)
|
if (isPlayer || theIsWaypoint)
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
void Draw(const DrawInfo& inDrawInfo);
|
void Draw(const DrawInfo& inDrawInfo);
|
||||||
|
|
||||||
int GetEntityAtWorldPosition(float inWorldX, float inWorldY, float inRadius) const;
|
int GetEntityAtWorldPosition(float inWorldX, float inWorldY, float inRadius) const;
|
||||||
|
AvHFont tFont;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void KillOldAlerts(float inCurrentTime);
|
void KillOldAlerts(float inCurrentTime);
|
||||||
|
|
Loading…
Reference in a new issue