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

Method RenderMousePointer

src/game/editor/editor.cpp:6728–6776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6726}
6727
6728void CEditor::RenderMousePointer()
6729{
6730 if(!m_ShowMousePointer)
6731 return;
6732
6733 constexpr float CursorSize = 16.0f;
6734
6735 // Cursor
6736 Graphics()->WrapClamp();
6737 Graphics()->TextureSet(m_aCursorTextures[m_CursorType]);
6738 Graphics()->QuadsBegin();
6739 if(m_CursorType == CURSOR_RESIZE_V)
6740 {
6741 Graphics()->QuadsSetRotation(pi / 2.0f);
6742 }
6743 if(m_pUiGotContext == Ui()->HotItem())
6744 {
6745 Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
6746 }
6747 const float CursorOffset = m_CursorType == CURSOR_RESIZE_V || m_CursorType == CURSOR_RESIZE_H ? -CursorSize / 2.0f : 0.0f;
6748 IGraphics::CQuadItem QuadItem(Ui()->MouseX() + CursorOffset, Ui()->MouseY() + CursorOffset, CursorSize, CursorSize);
6749 Graphics()->QuadsDrawTL(&QuadItem, 1);
6750 Graphics()->QuadsEnd();
6751 Graphics()->WrapNormal();
6752
6753 // Pipette color
6754 if(m_ColorPipetteActive)
6755 {
6756 CUIRect PipetteRect = {Ui()->MouseX() + CursorSize, Ui()->MouseY() + CursorSize, 80.0f, 20.0f};
6757 if(PipetteRect.x + PipetteRect.w + 2.0f > Ui()->Screen()->w)
6758 {
6759 PipetteRect.x = Ui()->MouseX() - PipetteRect.w - CursorSize / 2.0f;
6760 }
6761 if(PipetteRect.y + PipetteRect.h + 2.0f > Ui()->Screen()->h)
6762 {
6763 PipetteRect.y = Ui()->MouseY() - PipetteRect.h - CursorSize / 2.0f;
6764 }
6765 PipetteRect.Draw(ColorRGBA(0.2f, 0.2f, 0.2f, 0.7f), IGraphics::CORNER_ALL, 3.0f);
6766
6767 CUIRect Pipette, Label;
6768 PipetteRect.VSplitLeft(PipetteRect.h, &Pipette, &Label);
6769 Pipette.Margin(2.0f, &Pipette);
6770 Pipette.Draw(m_PipetteColor, IGraphics::CORNER_ALL, 3.0f);
6771
6772 char aLabel[8];
6773 str_format(aLabel, sizeof(aLabel), "#%06X", m_PipetteColor.PackAlphaLast(false));
6774 Ui()->DoLabel(&Label, aLabel, 10.0f, TEXTALIGN_MC);
6775 }
6776}
6777
6778void CEditor::RenderGameEntities(const std::shared_ptr<CLayerTiles> &pTiles)
6779{

Callers

nothing calls this directly

Calls 15

GraphicsFunction · 0.85
UiFunction · 0.85
str_formatFunction · 0.85
WrapClampMethod · 0.80
TextureSetMethod · 0.80
QuadsBeginMethod · 0.80
QuadsSetRotationMethod · 0.80
HotItemMethod · 0.80
MouseXMethod · 0.80
MouseYMethod · 0.80
QuadsDrawTLMethod · 0.80
QuadsEndMethod · 0.80

Tested by

no test coverage detected