mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Move MapScreenToGroup from 3 classes to render.cpp; Rename MapscreenToWorld to MapScreenToWorld
This commit is contained in:
parent
b751a2e098
commit
87893ceca7
|
@ -519,14 +519,6 @@ void CHud::RenderWarmupTimer()
|
|||
}
|
||||
}
|
||||
|
||||
void CHud::MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
|
||||
{
|
||||
float Points[4];
|
||||
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX, pGroup->m_ParallaxY,
|
||||
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), 1.0f, Points);
|
||||
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
|
||||
}
|
||||
|
||||
void CHud::RenderTextInfo()
|
||||
{
|
||||
if(g_Config.m_ClShowfps)
|
||||
|
@ -660,7 +652,7 @@ void CHud::RenderCursor()
|
|||
if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||
return;
|
||||
|
||||
MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
|
||||
RenderTools()->MapScreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
|
||||
|
||||
// render cursor
|
||||
int CurWeapon = m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS;
|
||||
|
|
|
@ -65,10 +65,7 @@ class CHud : public CComponent
|
|||
void RenderWarmupTimer();
|
||||
void RenderLocalTime(float x);
|
||||
|
||||
void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup);
|
||||
|
||||
static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f;
|
||||
|
||||
public:
|
||||
CHud();
|
||||
virtual int Sizeof() const override { return sizeof(*this); }
|
||||
|
|
|
@ -55,14 +55,6 @@ void CMapLayers::EnvelopeUpdate()
|
|||
}
|
||||
}
|
||||
|
||||
void CMapLayers::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom)
|
||||
{
|
||||
float Points[4];
|
||||
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX, pGroup->m_ParallaxY,
|
||||
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), Zoom, Points);
|
||||
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
|
||||
}
|
||||
|
||||
void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, float *pChannels, void *pUser)
|
||||
{
|
||||
CMapLayers *pThis = (CMapLayers *)pUser;
|
||||
|
@ -1567,7 +1559,7 @@ void CMapLayers::OnRender()
|
|||
{
|
||||
// set clipping
|
||||
float Points[4];
|
||||
MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup(), GetCurCamera()->m_Zoom);
|
||||
RenderTools()->MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup(), GetCurCamera()->m_Zoom);
|
||||
Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);
|
||||
float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2] - Points[0]);
|
||||
float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3] - Points[1]);
|
||||
|
@ -1587,10 +1579,10 @@ void CMapLayers::OnRender()
|
|||
|
||||
if((!g_Config.m_ClZoomBackgroundLayers || m_Type == TYPE_FULL_DESIGN) && !pGroup->m_ParallaxX && !pGroup->m_ParallaxY)
|
||||
{
|
||||
MapScreenToGroup(Center.x, Center.y, pGroup, 1.0f);
|
||||
RenderTools()->MapScreenToGroup(Center.x, Center.y, pGroup, 1.0f);
|
||||
}
|
||||
else
|
||||
MapScreenToGroup(Center.x, Center.y, pGroup, GetCurCamera()->m_Zoom);
|
||||
RenderTools()->MapScreenToGroup(Center.x, Center.y, pGroup, GetCurCamera()->m_Zoom);
|
||||
|
||||
for(int l = 0; l < pGroup->m_NumLayers; l++)
|
||||
{
|
||||
|
|
|
@ -35,8 +35,6 @@ class CMapLayers : public CComponent
|
|||
|
||||
bool m_OnlineOnly;
|
||||
|
||||
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom = 1.0f);
|
||||
|
||||
struct STileLayerVisuals
|
||||
{
|
||||
STileLayerVisuals() :
|
||||
|
|
|
@ -14,13 +14,6 @@
|
|||
|
||||
#include "players.h"
|
||||
|
||||
void CNamePlates::MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
|
||||
{
|
||||
float Points[4];
|
||||
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX, pGroup->m_ParallaxY, pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), 1.0f, Points);
|
||||
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
|
||||
}
|
||||
|
||||
void CNamePlates::RenderNameplate(
|
||||
const CNetObj_Character *pPrevChar,
|
||||
const CNetObj_Character *pPlayerChar,
|
||||
|
@ -109,7 +102,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
|
|||
// create nameplates at standard zoom
|
||||
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
|
||||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
|
||||
RenderTools()->MapScreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
|
||||
|
||||
m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(0, FontSize, pName, -1, -1.0f);
|
||||
|
||||
|
@ -135,7 +128,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
|
|||
// create nameplates at standard zoom
|
||||
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
|
||||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
|
||||
RenderTools()->MapScreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
|
||||
|
||||
m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(0, FontSizeClan, pClan, -1, -1.0f);
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ struct SPlayerNamePlate
|
|||
|
||||
class CNamePlates : public CComponent
|
||||
{
|
||||
void MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup);
|
||||
|
||||
void RenderNameplate(
|
||||
const CNetObj_Character *pPrevChar,
|
||||
const CNetObj_Character *pPlayerChar,
|
||||
|
|
|
@ -752,7 +752,7 @@ void CRenderTools::CalcScreenParams(float Aspect, float Zoom, float *w, float *h
|
|||
*h *= Zoom;
|
||||
}
|
||||
|
||||
void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
|
||||
void CRenderTools::MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
|
||||
float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints)
|
||||
{
|
||||
float Width, Height;
|
||||
|
@ -764,3 +764,11 @@ void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float Parallax
|
|||
pPoints[2] = pPoints[0] + Width;
|
||||
pPoints[3] = pPoints[1] + Height;
|
||||
}
|
||||
|
||||
void CRenderTools::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom)
|
||||
{
|
||||
float Points[4];
|
||||
MapScreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX, pGroup->m_ParallaxY,
|
||||
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), Zoom, Points);
|
||||
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
|
||||
}
|
||||
|
|
|
@ -119,8 +119,9 @@ public:
|
|||
|
||||
// helpers
|
||||
void CalcScreenParams(float Aspect, float Zoom, float *w, float *h);
|
||||
void MapscreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
|
||||
void MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
|
||||
float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints);
|
||||
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom = 1.0f);
|
||||
|
||||
// DDRace
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ void CLayerGroup::Convert(CUIRect *pRect)
|
|||
|
||||
void CLayerGroup::Mapping(float *pPoints)
|
||||
{
|
||||
m_pMap->m_pEditor->RenderTools()->MapscreenToWorld(
|
||||
m_pMap->m_pEditor->RenderTools()->MapScreenToWorld(
|
||||
m_pMap->m_pEditor->m_WorldOffsetX, m_pMap->m_pEditor->m_WorldOffsetY,
|
||||
m_ParallaxX, m_ParallaxY, m_OffsetX, m_OffsetY,
|
||||
m_pMap->m_pEditor->Graphics()->ScreenAspect(), m_pMap->m_pEditor->m_WorldZoom, pPoints);
|
||||
|
@ -2864,7 +2864,7 @@ void CEditor::DoMapEditor(CUIRect View)
|
|||
float aPoints[4];
|
||||
float Aspect = Start + (End - Start) * (i / (float)NumSteps);
|
||||
|
||||
RenderTools()->MapscreenToWorld(
|
||||
RenderTools()->MapScreenToWorld(
|
||||
m_WorldOffsetX, m_WorldOffsetY,
|
||||
100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
|
||||
|
||||
|
@ -2906,7 +2906,7 @@ void CEditor::DoMapEditor(CUIRect View)
|
|||
float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
|
||||
float Aspect = aAspects[i];
|
||||
|
||||
RenderTools()->MapscreenToWorld(
|
||||
RenderTools()->MapScreenToWorld(
|
||||
m_WorldOffsetX, m_WorldOffsetY,
|
||||
100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
|
||||
|
||||
|
@ -6156,7 +6156,7 @@ void CEditor::ZoomMouseTarget(float ZoomFactor)
|
|||
// zoom to the current mouse position
|
||||
// get absolute mouse position
|
||||
float aPoints[4];
|
||||
RenderTools()->MapscreenToWorld(
|
||||
RenderTools()->MapScreenToWorld(
|
||||
m_WorldOffsetX, m_WorldOffsetY,
|
||||
100.0f, 100.0f, 0.0f, 0.0f, Graphics()->ScreenAspect(), m_WorldZoom, aPoints);
|
||||
|
||||
|
|
Loading…
Reference in a new issue