@@ -143,6 +143,32 @@ bool CScoreboard::OnInput(const IInput::CEvent &Event)
143143
144144void CScoreboard::RenderTitle (CUIRect TitleLabel, int Team, const char *pTitle, float TitleFontSize)
145145{
146+ const bool IsMapTitle = !GameClient ()->IsTeamPlay ();
147+ if (IsMapTitle && m_MouseUnlocked && GameClient ()->m_aMapDescription [0 ] != ' \0 ' )
148+ {
149+ const int ButtonResult = Ui ()->DoButtonLogic (&m_MapTitleButtonId, 0 , &TitleLabel, BUTTONFLAG_LEFT | BUTTONFLAG_RIGHT);
150+ if (ButtonResult != 0 )
151+ {
152+ m_MapTitlePopupContext.m_pScoreboard = this ;
153+
154+ m_MapTitlePopupContext.m_FontSize = 12 .0f ;
155+ const float MaxWidth = 300 .0f ;
156+ const float Margin = 5 .0f ;
157+ const char *pDescription = GameClient ()->m_aMapDescription ;
158+ const float TextWidth = minimum (std::ceil (TextRender ()->TextWidth (m_MapTitlePopupContext.m_FontSize , pDescription) + 0 .5f ), MaxWidth);
159+ float TextHeight = 0 .0f ;
160+ STextSizeProperties TextSizeProps{};
161+ TextSizeProps.m_pHeight = &TextHeight;
162+ TextRender ()->TextWidth (m_MapTitlePopupContext.m_FontSize , pDescription, -1 , TextWidth, 0 , TextSizeProps);
163+
164+ Ui ()->DoPopupMenu (&m_MapTitlePopupContext, Ui ()->MouseX (), Ui ()->MouseY (), TextWidth + Margin * 2 , TextHeight + Margin * 2 , &m_MapTitlePopupContext, CMapTitlePopupContext::Render);
165+ }
166+ if (Ui ()->HotItem () == &m_MapTitleButtonId)
167+ {
168+ TitleLabel.Draw (ColorRGBA (0 .7f , 0 .7f , 0 .7f , 0 .3f ), IGraphics::CORNER_ALL, 5 .0f );
169+ }
170+ }
171+
146172 SLabelProperties Props;
147173 Props.m_MaxWidth = TitleLabel.w ;
148174 Props.m_EllipsisAtEnd = true ;
@@ -204,18 +230,21 @@ void CScoreboard::RenderTitleBar(CUIRect TitleBar, int Team, const char *pTitle)
204230
205231 const float TitleFontSize = 20 .0f ;
206232 const float ScoreTextWidth = TextRender ()->TextWidth (TitleFontSize, " 00:00:00" );
233+ const float TitleTextWidth = TextRender ()->TextWidth (TitleFontSize, pTitle);
207234
208235 TitleBar.VMargin (10 .0f , &TitleBar);
209236 CUIRect TitleLabel, ScoreLabel;
210237 if (Team == TEAM_RED)
211238 {
212239 TitleBar.VSplitRight (ScoreTextWidth, &TitleLabel, &ScoreLabel);
213240 TitleLabel.VSplitRight (5 .0f , &TitleLabel, nullptr );
241+ TitleLabel.VSplitLeft (minimum (TitleTextWidth + 2 .0f , TitleLabel.w ), &TitleLabel, nullptr );
214242 }
215243 else
216244 {
217245 TitleBar.VSplitLeft (ScoreTextWidth, &ScoreLabel, &TitleLabel);
218246 TitleLabel.VSplitLeft (5 .0f , nullptr , &TitleLabel);
247+ TitleLabel.VSplitRight (minimum (TitleTextWidth + 2 .0f , TitleLabel.w ), nullptr , &TitleLabel);
219248 }
220249
221250 RenderTitle (TitleLabel, Team, pTitle, TitleFontSize);
@@ -378,7 +407,7 @@ void CScoreboard::RenderSpectators(CUIRect Spectators)
378407 m_ScoreboardPopupContext.m_IsSpectating = true ;
379408
380409 Ui ()->DoPopupMenu (&m_ScoreboardPopupContext, Ui ()->MouseX (), Ui ()->MouseY (), 110 .0f ,
381- m_ScoreboardPopupContext.m_IsLocal ? 30 .0f : 60 .0f , &m_ScoreboardPopupContext, PopupScoreboard );
410+ m_ScoreboardPopupContext.m_IsLocal ? 30 .0f : 60 .0f , &m_ScoreboardPopupContext, CScoreboardPopupContext::Render );
382411 }
383412
384413 if (Ui ()->HotItem () == &m_aPlayers[pInfo->m_ClientId ].m_PlayerButtonId || Ui ()->HotItem () == &m_aPlayers[pInfo->m_ClientId ].m_SpectatorSecondLineButtonId )
@@ -630,7 +659,7 @@ void CScoreboard::RenderScoreboard(CUIRect Scoreboard, int Team, int CountStart,
630659 m_ScoreboardPopupContext.m_IsSpectating = false ;
631660
632661 Ui ()->DoPopupMenu (&m_ScoreboardPopupContext, Ui ()->MouseX (), Ui ()->MouseY (), 110 .0f ,
633- m_ScoreboardPopupContext.m_IsLocal ? 58 .5f : 87 .5f , &m_ScoreboardPopupContext, PopupScoreboard );
662+ m_ScoreboardPopupContext.m_IsLocal ? 58 .5f : 87 .5f , &m_ScoreboardPopupContext, CScoreboardPopupContext::Render );
634663 }
635664
636665 if (Ui ()->HotItem () == &m_aPlayers[pInfo->m_ClientId ].m_PlayerButtonId )
@@ -1044,7 +1073,7 @@ const char *CScoreboard::GetTeamName(int Team) const
10441073 return nullptr ;
10451074}
10461075
1047- CUi::EPopupMenuFunctionResult CScoreboard::PopupScoreboard (void *pContext, CUIRect View, bool Active)
1076+ CUi::EPopupMenuFunctionResult CScoreboard::CScoreboardPopupContext::Render (void *pContext, CUIRect View, bool Active)
10481077{
10491078 CScoreboardPopupContext *pPopupContext = static_cast <CScoreboardPopupContext *>(pContext);
10501079 CScoreboard *pScoreboard = pPopupContext->m_pScoreboard ;
@@ -1152,3 +1181,13 @@ CUi::EPopupMenuFunctionResult CScoreboard::PopupScoreboard(void *pContext, CUIRe
11521181
11531182 return CUi::POPUP_KEEP_OPEN;
11541183}
1184+
1185+ CUi::EPopupMenuFunctionResult CScoreboard::CMapTitlePopupContext::Render (void *pContext, CUIRect View, bool Active)
1186+ {
1187+ CMapTitlePopupContext *pPopupContext = static_cast <CMapTitlePopupContext *>(pContext);
1188+ CScoreboard *pScoreboard = pPopupContext->m_pScoreboard ;
1189+
1190+ pScoreboard->TextRender ()->Text (View.x , View.y , pPopupContext->m_FontSize , pScoreboard->GameClient ()->m_aMapDescription , View.w );
1191+
1192+ return CUi::POPUP_KEEP_OPEN;
1193+ }
0 commit comments