Remove CRenderTools' pointers to CUI and CGameClient

This commit is contained in:
Robert Müller 2022-05-14 13:31:07 +02:00
parent e9b59e72ff
commit 3708abe8e0
7 changed files with 30 additions and 37 deletions

View file

@ -751,7 +751,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s", s->m_aName);
SLabelProperties Props;
Props.m_MaxWidth = Item.m_Rect.w;
RenderTools()->UI()->DoLabelScaled(&Item.m_Rect, aBuf, 12.0f, TEXTALIGN_LEFT, Props);
UI()->DoLabelScaled(&Item.m_Rect, aBuf, 12.0f, TEXTALIGN_LEFT, Props);
if(g_Config.m_Debug)
{
ColorRGBA BloodColor = *UseCustomColor ? color_cast<ColorRGBA>(ColorHSLA(*ColorBody)) : s->m_BloodColor;

View file

@ -222,8 +222,7 @@ void CGameClient::OnInit()
// propagate pointers
m_UI.Init(Graphics(), TextRender());
m_RenderTools.Init(Graphics(), UI(), this);
m_RenderTools.Init(Graphics(), TextRender());
int64_t Start = time_get();

View file

@ -19,11 +19,10 @@
static float gs_SpriteWScale;
static float gs_SpriteHScale;
void CRenderTools::Init(IGraphics *pGraphics, CUI *pUI, CGameClient *pGameClient)
void CRenderTools::Init(IGraphics *pGraphics, ITextRender *pTextRender)
{
m_pGraphics = pGraphics;
m_pUI = pUI;
m_pGameClient = (CGameClient *)pGameClient;
m_pTextRender = pTextRender;
m_TeeQuadContainerIndex = Graphics()->CreateQuadContainer(false);
Graphics()->SetColor(1.f, 1.f, 1.f, 1.f);
@ -483,7 +482,7 @@ void CRenderTools::DrawUIRect(const CUIRect *pRect, ColorRGBA Color, int Corners
// TODO: FIX US
Graphics()->QuadsBegin();
Graphics()->SetColor(Color);
DrawRoundRectExt(pRect->x, pRect->y, pRect->w, pRect->h, Rounding * UI()->Scale(), Corners);
DrawRoundRectExt(pRect->x, pRect->y, pRect->w, pRect->h, Rounding * pRect->Scale(), Corners);
Graphics()->QuadsEnd();
}

View file

@ -53,6 +53,9 @@ typedef void (*ENVELOPE_EVAL)(int TimeOffsetMillis, int Env, float *pChannels, v
class CRenderTools
{
class IGraphics *m_pGraphics;
class ITextRender *m_pTextRender;
int m_TeeQuadContainerIndex;
void GetRenderTeeAnimScaleAndBaseSize(class CAnimState *pAnim, CTeeRenderInfo *pInfo, float &AnimScale, float &BaseSize);
@ -60,17 +63,10 @@ class CRenderTools
void GetRenderTeeFeetScale(float BaseSize, float &FeetScaleWidth, float &FeetScaleHeight);
public:
class IGraphics *m_pGraphics;
class CUI *m_pUI;
class CGameClient *m_pGameClient;
class IGraphics *Graphics() const { return m_pGraphics; }
class CUI *UI() const { return m_pUI; }
class CGameClient *GameClient() const { return m_pGameClient; }
class ITextRender *TextRender() const { return m_pTextRender; }
void Init(class IGraphics *pGraphics, class CUI *pUI, class CGameClient *pGameClient);
//typedef struct SPRITE;
void Init(class IGraphics *pGraphics, class ITextRender *pTextRender);
void SelectSprite(struct CDataSprite *pSprite, int Flags = 0, int sx = 0, int sy = 0);
void SelectSprite(int id, int Flags = 0, int sx = 0, int sy = 0);

View file

@ -472,9 +472,9 @@ void CRenderTools::RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale
{
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Index);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx * Scale - 3.f, (my + ToCenterOffset) * Scale, Size * Scale, aBuf, -1.0f);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale - 3.f, (my + ToCenterOffset) * Scale, Size * Scale, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
@ -534,15 +534,15 @@ void CRenderTools::RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, fl
// draw force
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Force);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
if(MaxSpeed)
{
str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
}
@ -591,9 +591,9 @@ void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float
{
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Index);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
unsigned char Delay = pSwitch[c].m_Delay;
@ -601,9 +601,9 @@ void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float
{
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Delay);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
@ -650,9 +650,9 @@ void CRenderTools::RenderTuneOverlay(CTuneTile *pTune, int w, int h, float Scale
{
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Index);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx * Scale + 11.f, my * Scale + 6.f, Size * Scale / 1.5f - 5.f, aBuf, -1.0f); // numbers shouldn't be too big and in the center of the tile
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale + 11.f, my * Scale + 6.f, Size * Scale / 1.5f - 5.f, aBuf, -1.0f); // numbers shouldn't be too big and in the center of the tile
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}

View file

@ -10,10 +10,10 @@
class CUIRect
{
public:
// TODO: Refactor: Redo UI scaling
float Scale() const;
public:
float x, y, w, h;
/**

View file

@ -6342,9 +6342,8 @@ void CEditor::Init()
m_pTextRender = Kernel()->RequestInterface<ITextRender>();
m_pStorage = Kernel()->RequestInterface<IStorage>();
m_pSound = Kernel()->RequestInterface<ISound>();
CGameClient *pGameClient = (CGameClient *)Kernel()->RequestInterface<IGameClient>();
m_UI.Init(m_pGraphics, m_pTextRender);
m_RenderTools.Init(m_pGraphics, &m_UI, pGameClient);
m_RenderTools.Init(m_pGraphics, m_pTextRender);
m_Map.m_pEditor = this;
UIEx()->Init(UI(), Kernel(), RenderTools(), Input()->GetEventsRaw(), Input()->GetEventCountRaw());