mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
commit
28f92559df
|
@ -396,6 +396,11 @@ container.sprites.Add(Sprite("pickup_ninja", set_game, 2,10,8,2))
|
||||||
container.sprites.Add(Sprite("flag_blue", set_game, 12,8,4,8))
|
container.sprites.Add(Sprite("flag_blue", set_game, 12,8,4,8))
|
||||||
container.sprites.Add(Sprite("flag_red", set_game, 16,8,4,8))
|
container.sprites.Add(Sprite("flag_red", set_game, 16,8,4,8))
|
||||||
|
|
||||||
|
container.sprites.Add(Sprite("ninja_bar_full_left", set_game, 21,4,1,2))
|
||||||
|
container.sprites.Add(Sprite("ninja_bar_full", set_game, 22,4,1,2))
|
||||||
|
container.sprites.Add(Sprite("ninja_bar_empty", set_game, 23,4,1,2))
|
||||||
|
container.sprites.Add(Sprite("ninja_bar_empty_right", set_game, 24,4,1,2))
|
||||||
|
|
||||||
container.sprites.Add(Sprite("tee_body_outline", set_tee_body, 0,0,1,1))
|
container.sprites.Add(Sprite("tee_body_outline", set_tee_body, 0,0,1,1))
|
||||||
container.sprites.Add(Sprite("tee_body", set_tee_body, 1,0,1,1))
|
container.sprites.Add(Sprite("tee_body", set_tee_body, 1,0,1,1))
|
||||||
container.sprites.Add(Sprite("tee_body_shadow", set_tee_body, 0,1,1,1))
|
container.sprites.Add(Sprite("tee_body_shadow", set_tee_body, 0,1,1,1))
|
||||||
|
|
|
@ -462,6 +462,75 @@ void CHud::RenderCursor()
|
||||||
Graphics()->QuadsEnd();
|
Graphics()->QuadsEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHud::RenderNinjaBar(float x, float y, float Progress)
|
||||||
|
{
|
||||||
|
Progress = clamp(Progress, 0.0f, 1.0f);
|
||||||
|
const float EndWidth = 6.0f;
|
||||||
|
const float BarHeight = 12.0f;
|
||||||
|
const float WholeBarWidth = 120.f;
|
||||||
|
const float MiddleBarWidth = WholeBarWidth - (EndWidth * 2.0f);
|
||||||
|
|
||||||
|
IGraphics::CQuadItem QuadStartFull(x, y, EndWidth, BarHeight);
|
||||||
|
RenderTools()->SelectSprite(&g_pData->m_aSprites[SPRITE_NINJA_BAR_FULL_LEFT]);
|
||||||
|
Graphics()->QuadsDrawTL(&QuadStartFull, 1);
|
||||||
|
x += EndWidth;
|
||||||
|
|
||||||
|
const float FullBarWidth = MiddleBarWidth * Progress;
|
||||||
|
const float EmptyBarWidth = MiddleBarWidth - FullBarWidth;
|
||||||
|
|
||||||
|
// full bar
|
||||||
|
IGraphics::CQuadItem QuadFull(x, y, FullBarWidth, BarHeight);
|
||||||
|
|
||||||
|
CDataSprite SpriteBarFull = g_pData->m_aSprites[SPRITE_NINJA_BAR_FULL];
|
||||||
|
// prevent pixel puree, select only a small slice
|
||||||
|
if(Progress < 0.1f)
|
||||||
|
{
|
||||||
|
int spx = SpriteBarFull.m_X;
|
||||||
|
int spy = SpriteBarFull.m_Y;
|
||||||
|
float w = SpriteBarFull.m_W * 0.1f; // magic here
|
||||||
|
int h = SpriteBarFull.m_H;
|
||||||
|
int cx = SpriteBarFull.m_pSet->m_Gridx;
|
||||||
|
int cy = SpriteBarFull.m_pSet->m_Gridy;
|
||||||
|
float x1 = spx/(float)cx;
|
||||||
|
float x2 = (spx+w-1/32.0f)/(float)cx;
|
||||||
|
float y1 = spy/(float)cy;
|
||||||
|
float y2 = (spy+h-1/32.0f)/(float)cy;
|
||||||
|
|
||||||
|
Graphics()->QuadsSetSubset(x1, y1, x2, y2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
RenderTools()->SelectSprite(&SpriteBarFull);
|
||||||
|
|
||||||
|
Graphics()->QuadsDrawTL(&QuadFull, 1);
|
||||||
|
|
||||||
|
// empty bar
|
||||||
|
// select the middle portion of the sprite so we don't get edge bleeding
|
||||||
|
const CDataSprite SpriteBarEmpty = g_pData->m_aSprites[SPRITE_NINJA_BAR_EMPTY];
|
||||||
|
{
|
||||||
|
float spx = SpriteBarEmpty.m_X + 0.1f;
|
||||||
|
float spy = SpriteBarEmpty.m_Y;
|
||||||
|
float w = SpriteBarEmpty.m_W * 0.5f;
|
||||||
|
int h = SpriteBarEmpty.m_H;
|
||||||
|
int cx = SpriteBarEmpty.m_pSet->m_Gridx;
|
||||||
|
int cy = SpriteBarEmpty.m_pSet->m_Gridy;
|
||||||
|
float x1 = spx/(float)cx;
|
||||||
|
float x2 = (spx+w-1/32.0f)/(float)cx;
|
||||||
|
float y1 = spy/(float)cy;
|
||||||
|
float y2 = (spy+h-1/32.0f)/(float)cy;
|
||||||
|
|
||||||
|
Graphics()->QuadsSetSubset(x1, y1, x2, y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
IGraphics::CQuadItem QuadEmpty(x + FullBarWidth, y, EmptyBarWidth, BarHeight);
|
||||||
|
Graphics()->QuadsDrawTL(&QuadEmpty, 1);
|
||||||
|
|
||||||
|
x += MiddleBarWidth;
|
||||||
|
|
||||||
|
IGraphics::CQuadItem QuadEndEmpty(x, y, EndWidth, BarHeight);
|
||||||
|
RenderTools()->SelectSprite(&g_pData->m_aSprites[SPRITE_NINJA_BAR_EMPTY_RIGHT]);
|
||||||
|
Graphics()->QuadsDrawTL(&QuadEndEmpty, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
||||||
{
|
{
|
||||||
if(!pCharacter)
|
if(!pCharacter)
|
||||||
|
@ -472,30 +541,21 @@ void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
||||||
int i;
|
int i;
|
||||||
IGraphics::CQuadItem Array[10];
|
IGraphics::CQuadItem Array[10];
|
||||||
|
|
||||||
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
||||||
|
Graphics()->WrapClamp();
|
||||||
|
|
||||||
|
Graphics()->QuadsBegin();
|
||||||
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
// render ammo
|
// render ammo
|
||||||
if(pCharacter->m_Weapon == WEAPON_NINJA)
|
if(pCharacter->m_Weapon == WEAPON_NINJA)
|
||||||
{
|
{
|
||||||
CUIRect Rect = {x, y+24.0f, 118.0f, 10.0f};
|
const int Max = g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000;
|
||||||
RenderTools()->DrawUIRect(&Rect, vec4(0.8f, 0.8f, 0.8f, 0.5f), 0, 0.0f);
|
float NinjaProgress = clamp(pCharacter->m_AmmoCount-Client()->GameTick(), 0, Max) / (float)Max;
|
||||||
|
RenderNinjaBar(x, y+24.f, NinjaProgress);
|
||||||
int Max = g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000;
|
|
||||||
Rect.x = x+1.0f;
|
|
||||||
Rect.y = y+25.0f;
|
|
||||||
Rect.w = 116.0f * clamp(pCharacter->m_AmmoCount-Client()->GameTick(), 0, Max) / Max;
|
|
||||||
Rect.h = 8.0f;
|
|
||||||
RenderTools()->DrawUIRect(&Rect, vec4(0.9f, 0.2f, 0.2f, 0.85f), 0, 0.0f);
|
|
||||||
|
|
||||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
|
||||||
Graphics()->QuadsBegin();
|
|
||||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[WEAPON_NINJA].m_pSpriteBody);
|
|
||||||
Array[0] = IGraphics::CQuadItem(x+40.0f,y+25, 32.0f, 8.0f);
|
|
||||||
Graphics()->QuadsDrawTL(Array, 1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
|
||||||
Graphics()->QuadsBegin();
|
|
||||||
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[pCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteProj);
|
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[pCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteProj);
|
||||||
if(pCharacter->m_Weapon == WEAPON_GRENADE)
|
if(pCharacter->m_Weapon == WEAPON_GRENADE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@ class CHud : public CComponent
|
||||||
void RenderConnectionWarning();
|
void RenderConnectionWarning();
|
||||||
void RenderTeambalanceWarning();
|
void RenderTeambalanceWarning();
|
||||||
void RenderVoting();
|
void RenderVoting();
|
||||||
|
void RenderNinjaBar(float x, float y, float Progress);
|
||||||
void RenderHealthAndAmmo(const CNetObj_Character *pCharacter);
|
void RenderHealthAndAmmo(const CNetObj_Character *pCharacter);
|
||||||
void RenderGameTimer();
|
void RenderGameTimer();
|
||||||
void RenderPauseTimer();
|
void RenderPauseTimer();
|
||||||
|
|
Loading…
Reference in a new issue