diff --git a/main/source/cl_dll/hud.cpp b/main/source/cl_dll/hud.cpp index 018589c4..1663e38f 100644 --- a/main/source/cl_dll/hud.cpp +++ b/main/source/cl_dll/hud.cpp @@ -221,6 +221,11 @@ void CHud :: Init( void ) CVAR_CREATE("cl_weaponswap", "2", FCVAR_ARCHIVE | FCVAR_USERINFO); 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; diff --git a/main/source/mod/AvHFont.cpp b/main/source/mod/AvHFont.cpp index 796d0ef0..be34b7ef 100644 --- a/main/source/mod/AvHFont.cpp +++ b/main/source/mod/AvHFont.cpp @@ -192,4 +192,52 @@ int AvHFont::DrawStringReverse(int inX, int inY, const char* inString, int r, in 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; + } \ No newline at end of file diff --git a/main/source/mod/AvHFont.h b/main/source/mod/AvHFont.h index 263ae88a..fba05054 100644 --- a/main/source/mod/AvHFont.h +++ b/main/source/mod/AvHFont.h @@ -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 DrawStringCustom(int inX, int inY, const char* inString, int r, int g, int b, int inRenderMode = kRenderTransAdd) const; + private: AVHHSPRITE mSprite; diff --git a/main/source/mod/AvHOverviewMap.cpp b/main/source/mod/AvHOverviewMap.cpp index 5a4953bf..7a3c33d2 100644 --- a/main/source/mod/AvHOverviewMap.cpp +++ b/main/source/mod/AvHOverviewMap.cpp @@ -439,6 +439,51 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl AvHSpriteSetRenderMode(theRenderMode); 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) diff --git a/main/source/mod/AvHOverviewMap.h b/main/source/mod/AvHOverviewMap.h index de6f3367..7130ffeb 100644 --- a/main/source/mod/AvHOverviewMap.h +++ b/main/source/mod/AvHOverviewMap.h @@ -67,6 +67,7 @@ public: void Draw(const DrawInfo& inDrawInfo); int GetEntityAtWorldPosition(float inWorldX, float inWorldY, float inRadius) const; + AvHFont tFont; protected: void KillOldAlerts(float inCurrentTime);