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

Method DoButton_FontIcon

src/game/client/ui.cpp:1153–1179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1151}
1152
1153int CUi::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const unsigned Flags, int Corners, bool Enabled, const std::optional<ColorRGBA> ButtonColor)
1154{
1155 pRect->Draw(ButtonColor.value_or(ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.1f : 0.5f) * ButtonColorMul(pButtonContainer))), Corners, 5.0f);
1156
1157 TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
1158 TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING);
1159 TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
1160 TextRender()->TextColor(TextRender()->DefaultTextColor());
1161
1162 CUIRect Label;
1163 pRect->HMargin(2.0f, &Label);
1164 DoLabel(&Label, pText, Label.h * ms_FontmodHeight, TEXTALIGN_MC);
1165
1166 if(!Enabled)
1167 {
1168 TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
1169 TextRender()->TextOutlineColor(ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f));
1170 DoLabel(&Label, FontIcon::SLASH, Label.h * ms_FontmodHeight, TEXTALIGN_MC);
1171 TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
1172 TextRender()->TextColor(TextRender()->DefaultTextColor());
1173 }
1174
1175 TextRender()->SetRenderFlags(0);
1176 TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
1177
1178 return DoButtonLogic(pButtonContainer, Checked, pRect, Flags);
1179}
1180
1181int CUi::DoButton_PopupMenu(CButtonContainer *pButtonContainer, const char *pText, const CUIRect *pRect, float Size, int Align, float Padding, bool TransparentInactive, bool Enabled, const std::optional<ColorRGBA> ButtonColor)
1182{

Callers 13

RenderPopupFullscreenMethod · 0.45
RenderSettingsDDNetMethod · 0.45
RenderSettingsBindsMethod · 0.45
RenderMethod · 0.45
RenderPreviewSettingsMethod · 0.45
DoKeyReaderMethod · 0.45
RenderDemoPlayerMethod · 0.45
RenderGameMethod · 0.45

Calls 10

TextRenderFunction · 0.85
SetRenderFlagsMethod · 0.80
TextOutlineColorMethod · 0.80
TextColorMethod · 0.80
DefaultTextColorMethod · 0.80
HMarginMethod · 0.80
ColorRGBAClass · 0.50
DrawMethod · 0.45
SetFontPresetMethod · 0.45

Tested by

no test coverage detected