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

Method RenderImportantAlert

src/game/client/components/important_alert.cpp:58–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void CImportantAlert::RenderImportantAlert()
59{
60 if(m_FadeOutSince >= 0.0f && Client()->GlobalTime() - m_FadeOutSince >= 1.0f)
61 {
62 OnReset();
63 return;
64 }
65
66 const float Seconds = SecondsActive();
67
68 const float Height = 300.0f;
69 const float Width = Height * Graphics()->ScreenAspect();
70 Graphics()->MapScreen(0.0f, 0.0f, Width, Height);
71
72 const float TitleFontSize = 20.0f;
73 const float MessageFontSize = 16.0f;
74 const float CloseHintFontSize = 6.0f;
75 const float Alpha = m_FadeOutSince >= 0.0f ? 1.0f - (Client()->GlobalTime() - m_FadeOutSince) : 1.0f;
76
77 if(!m_TitleTextContainerIndex.Valid())
78 {
79 CTextCursor Cursor;
80 Cursor.m_FontSize = TitleFontSize;
81 Cursor.m_LineWidth = Width;
82 TextRender()->CreateTextContainer(m_TitleTextContainerIndex, &Cursor, m_aTitleText);
83 }
84 if(m_TitleTextContainerIndex.Valid())
85 {
86 TextRender()->RenderTextContainer(m_TitleTextContainerIndex,
87 ColorRGBA(1.0f, 0.0f, 0.0f, Alpha),
88 TextRender()->DefaultTextOutlineColor().WithMultipliedAlpha(Alpha),
89 Width / 2.0f - TextRender()->GetBoundingBoxTextContainer(m_TitleTextContainerIndex).m_W / 2.0f,
90 40.0f);
91 }
92
93 if(!m_MessageTextContainerIndex.Valid())
94 {
95 CTextCursor Cursor;
96 Cursor.m_FontSize = MessageFontSize;
97 Cursor.m_LineWidth = Width;
98 TextRender()->CreateTextContainer(m_MessageTextContainerIndex, &Cursor, m_aMessageText);
99 }
100 if(m_MessageTextContainerIndex.Valid())
101 {
102 TextRender()->RenderTextContainer(m_MessageTextContainerIndex,
103 TextRender()->DefaultTextColor().WithMultipliedAlpha(Alpha),
104 TextRender()->DefaultTextOutlineColor().WithMultipliedAlpha(Alpha),
105 Width / 2.0f - TextRender()->GetBoundingBoxTextContainer(m_MessageTextContainerIndex).m_W / 2.0f, 40.0f + TitleFontSize + 10.0f);
106 }
107
108 if(Seconds > MINIMUM_ACTIVE_SECONDS)
109 {
110 if(!m_CloseHintTextContainerIndex.Valid())
111 {
112 CTextCursor Cursor;
113 Cursor.m_FontSize = CloseHintFontSize;
114 Cursor.m_LineWidth = Width;
115 TextRender()->CreateTextContainer(m_CloseHintTextContainerIndex, &Cursor, Localize("Press Esc or Tab to dismiss…", "Important alert message"));

Callers

nothing calls this directly

Calls 15

GraphicsFunction · 0.85
TextRenderFunction · 0.85
LocalizeFunction · 0.85
GlobalTimeMethod · 0.80
ScreenAspectMethod · 0.80
CreateTextContainerMethod · 0.80
RenderTextContainerMethod · 0.80
WithMultipliedAlphaMethod · 0.80
DefaultTextColorMethod · 0.80
ColorRGBAClass · 0.70

Tested by

no test coverage detected