mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
improved the add/remove friend and ignore/notice chat buttons
This commit is contained in:
parent
0307138950
commit
9712e4004c
|
@ -38,7 +38,7 @@ class CMenus : public CComponent
|
|||
|
||||
|
||||
int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect);
|
||||
int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners);
|
||||
int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners);
|
||||
int DoButton_PageMenu(const void *pID, const char *pText, int Checked, bool Active, const CUIRect *pRect, int Corners);
|
||||
|
|
|
@ -26,11 +26,13 @@ int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked,
|
|||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
||||
int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect)
|
||||
int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners)
|
||||
{
|
||||
RenderTools()->DrawUIRect(pRect, vec4(1,1,1, Checked ? 0.10f : 0.5f)*ButtonColorMul(pID), CUI::CORNER_ALL, 5.0f);
|
||||
RenderTools()->DrawUIRect(pRect, Checked ? vec4(1.0f, 1.0f, 1.0f, 0.10f) : vec4(1.0f, 1.0f, 1.0f, 0.5f)*ButtonColorMul(pID), Corners, 5.0f);
|
||||
Graphics()->TextureSet(g_pData->m_aImages[ImageID].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
if(!Checked)
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
RenderTools()->SelectSprite(SpriteID);
|
||||
IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
|
@ -147,12 +149,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
static int s_PlayPauseButton = 0;
|
||||
if(!pInfo->m_Paused)
|
||||
{
|
||||
if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_PAUSE, pInfo->m_Paused, &Button))
|
||||
if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_PAUSE, false, &Button, CUI::CORNER_ALL))
|
||||
DemoPlayer()->Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_PLAY, !pInfo->m_Paused, &Button))
|
||||
if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_PLAY, false, &Button, CUI::CORNER_ALL))
|
||||
DemoPlayer()->Unpause();
|
||||
}
|
||||
|
||||
|
@ -161,7 +163,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
ButtonBar.VSplitLeft(Margins, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
|
||||
static int s_ResetButton = 0;
|
||||
if(DoButton_Sprite(&s_ResetButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_STOP, false, &Button))
|
||||
if(DoButton_Sprite(&s_ResetButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_STOP, false, &Button, CUI::CORNER_ALL))
|
||||
{
|
||||
m_pClient->OnReset();
|
||||
DemoPlayer()->Pause();
|
||||
|
@ -172,14 +174,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
ButtonBar.VSplitLeft(Margins, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
|
||||
static int s_SlowDownButton = 0;
|
||||
if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button) || Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
|
||||
if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL) || Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
|
||||
DecreaseDemoSpeed = true;
|
||||
|
||||
// fastforward
|
||||
ButtonBar.VSplitLeft(Margins, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
|
||||
static int s_FastForwardButton = 0;
|
||||
if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button))
|
||||
if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button, CUI::CORNER_ALL))
|
||||
IncreaseDemoSpeed = true;
|
||||
|
||||
// speed meter
|
||||
|
|
|
@ -115,14 +115,14 @@ void CMenus::RenderGame(CUIRect MainView)
|
|||
UI()->DoLabelScaled(&Button, Localize("Player options"), 34.0f, -1);
|
||||
|
||||
CUIRect Player;
|
||||
static int s_aPlayerIDs[MAX_CLIENTS][2] = {{0}};
|
||||
static int s_aPlayerIDs[MAX_CLIENTS][4] = {{0}};
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(!m_pClient->m_Snap.m_paPlayerInfos[i] || i == m_pClient->m_Snap.m_LocalClientID)
|
||||
continue;
|
||||
|
||||
Options.HSplitTop(28.0f, &ButtonBar, &Options);
|
||||
ButtonBar.VSplitRight(200.0f, &Player, &ButtonBar);
|
||||
ButtonBar.VSplitRight(220.0f, &Player, &ButtonBar);
|
||||
|
||||
// player info
|
||||
Player.VSplitLeft(28.0f, &Button, &Player);
|
||||
|
@ -142,32 +142,22 @@ void CMenus::RenderGame(CUIRect MainView)
|
|||
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[i].m_aClan, -1);
|
||||
|
||||
// ignore button
|
||||
ButtonBar.VSplitLeft(10.0f, 0, &ButtonBar);
|
||||
ButtonBar.HMargin(1.0f, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(ButtonBar.h*2.0f, &Button, &ButtonBar);
|
||||
if(m_pClient->m_aClients[i].m_ChatIgnore)
|
||||
{
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][0], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_CHATON, m_pClient->m_aClients[i].m_ChatIgnore, &Button))
|
||||
m_pClient->m_aClients[i].m_ChatIgnore = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][0], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_CHATOFF, !m_pClient->m_aClients[i].m_ChatIgnore, &Button))
|
||||
m_pClient->m_aClients[i].m_ChatIgnore = 1;
|
||||
}
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][0], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_CHATON, !m_pClient->m_aClients[i].m_ChatIgnore, &Button, CUI::CORNER_L))
|
||||
m_pClient->m_aClients[i].m_ChatIgnore = 0;
|
||||
ButtonBar.VSplitLeft(ButtonBar.h*2.0f, &Button, &ButtonBar);
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][1], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_CHATOFF, m_pClient->m_aClients[i].m_ChatIgnore, &Button, CUI::CORNER_R))
|
||||
m_pClient->m_aClients[i].m_ChatIgnore = 1;
|
||||
|
||||
// friend button
|
||||
ButtonBar.VSplitLeft(10.0f, 0, &ButtonBar);
|
||||
ButtonBar.VSplitLeft(ButtonBar.h*2.0f, &Button, &ButtonBar);
|
||||
if(m_pClient->m_aClients[i].m_Friend)
|
||||
{
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][1], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_FRIENDREM, m_pClient->m_aClients[i].m_Friend, &Button))
|
||||
m_pClient->Friends()->RemoveFriend(m_pClient->m_aClients[i].m_aName, m_pClient->m_aClients[i].m_aClan);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][1], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_FRIENDADD, !m_pClient->m_aClients[i].m_Friend, &Button))
|
||||
m_pClient->Friends()->AddFriend(m_pClient->m_aClients[i].m_aName, m_pClient->m_aClients[i].m_aClan);
|
||||
}
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][2], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_FRIENDREM, !m_pClient->m_aClients[i].m_Friend, &Button, CUI::CORNER_L))
|
||||
m_pClient->Friends()->RemoveFriend(m_pClient->m_aClients[i].m_aName, m_pClient->m_aClients[i].m_aClan);
|
||||
ButtonBar.VSplitLeft(ButtonBar.h*2.0f, &Button, &ButtonBar);
|
||||
if(DoButton_Sprite(&s_aPlayerIDs[i][3], IMAGE_GUIBUTTONS, SPRITE_GUIBUTTON_FRIENDADD, m_pClient->m_aClients[i].m_Friend, &Button, CUI::CORNER_R))
|
||||
m_pClient->Friends()->AddFriend(m_pClient->m_aClients[i].m_aName, m_pClient->m_aClients[i].m_aClan);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue