MCPcopy Create free account
hub / github.com/ddnet/ddnet / RenderSpeedupOverlay

Method RenderSpeedupOverlay

src/game/map/render_map.cpp:811–896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

809}
810
811void CRenderMap::RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, float Scale, int OverlayRenderFlag, float Alpha)
812{
813 float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
814 Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
815
816 int StartY = (int)(ScreenY0 / Scale) - 1;
817 int StartX = (int)(ScreenX0 / Scale) - 1;
818 int EndY = (int)(ScreenY1 / Scale) + 1;
819 int EndX = (int)(ScreenX1 / Scale) + 1;
820
821 if(EndX - StartX > Graphics()->ScreenWidth() / g_Config.m_GfxTextOverlay || EndY - StartY > Graphics()->ScreenHeight() / g_Config.m_GfxTextOverlay)
822 return; // its useless to render text at this distance
823
824 float Size = g_Config.m_ClTextEntitiesSize / 100.f;
825 float ToCenterOffset = (1 - Size) / 2.f;
826 char aBuf[16];
827
828 TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
829 for(int y = StartY; y < EndY; y++)
830 {
831 for(int x = StartX; x < EndX; x++)
832 {
833 int mx = x;
834 int my = y;
835
836 if(mx < 0)
837 continue; // mx = 0;
838 if(mx >= w)
839 continue; // mx = w-1;
840 if(my < 0)
841 continue; // my = 0;
842 if(my >= h)
843 continue; // my = h-1;
844
845 int c = mx + my * w;
846
847 int Force = (int)pSpeedup[c].m_Force;
848 int MaxSpeed = (int)pSpeedup[c].m_MaxSpeed;
849 int Type = (int)pSpeedup[c].m_Type;
850 int Angle = (int)pSpeedup[c].m_Angle;
851 if((Force && Type == TILE_SPEED_BOOST_OLD) || ((Force || MaxSpeed) && Type == TILE_SPEED_BOOST) || (OverlayRenderFlag & OVERLAYRENDERFLAG_EDITOR && (Type || Force || MaxSpeed || Angle)))
852 {
853 if(IsValidSpeedupTile(Type))
854 {
855 // draw arrow
856 Graphics()->TextureSet(g_pData->m_aImages[IMAGE_SPEEDUP_ARROW].m_Id);
857 Graphics()->QuadsBegin();
858 Graphics()->SetColor(1.0f, 1.0f, 1.0f, Alpha);
859 Graphics()->SelectSprite(SPRITE_SPEEDUP_ARROW);
860 Graphics()->QuadsSetRotation(pSpeedup[c].m_Angle * (pi / 180.0f));
861 Graphics()->DrawSprite(mx * Scale + 16, my * Scale + 16, 35.0f);
862 Graphics()->QuadsEnd();
863
864 // draw force and max speed
865 if(OverlayRenderFlag & OVERLAYRENDERFLAG_TEXT)
866 {
867 str_format(aBuf, sizeof(aBuf), "%d", Force);
868 TextRender()->Text(mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf);

Callers 2

RenderMethod · 0.80

Calls 15

GraphicsFunction · 0.85
TextRenderFunction · 0.85
IsValidSpeedupTileFunction · 0.85
str_formatFunction · 0.85
GetScreenMethod · 0.80
ScreenWidthMethod · 0.80
ScreenHeightMethod · 0.80
TextColorMethod · 0.80
TextureSetMethod · 0.80
QuadsBeginMethod · 0.80
SelectSpriteMethod · 0.80
QuadsSetRotationMethod · 0.80

Tested by

no test coverage detected