mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
More UI Animation settings, more tabs animated
This commit is contained in:
parent
c02086a689
commit
9b3d9965fb
|
@ -94,6 +94,26 @@ CMenus::CMenus()
|
|||
|
||||
m_ServerProcess.Process = 0;
|
||||
m_ServerProcess.Initialized = false;
|
||||
|
||||
for(SUIAnimator &animator : m_aAnimatorsSettingsTab)
|
||||
{
|
||||
animator.m_YOffset = -2.5f;
|
||||
animator.m_HOffset = 5.0f;
|
||||
animator.m_WOffset = 5.0f;
|
||||
animator.m_ScaleLabel = true;
|
||||
}
|
||||
|
||||
for(SUIAnimator &animator : m_aAnimatorsBigPage)
|
||||
{
|
||||
animator.m_YOffset = -5.0f;
|
||||
animator.m_HOffset = 5.0f;
|
||||
}
|
||||
|
||||
for(SUIAnimator &animator : m_aAnimatorsSmallPage)
|
||||
{
|
||||
animator.m_YOffset = -2.5f;
|
||||
animator.m_HOffset = 2.5f;
|
||||
}
|
||||
}
|
||||
|
||||
float CMenus::ButtonColorMul(const void *pID)
|
||||
|
@ -219,9 +239,10 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co
|
|||
else
|
||||
pAnimator->m_Value = clamp<float>(pAnimator->m_Value - (Time - pAnimator->m_Time) / 1000000.f, 0, 1);
|
||||
|
||||
Rect.w += pAnimator->m_Value * 5;
|
||||
Rect.y -= pAnimator->m_Value * 2.5f;
|
||||
Rect.h += pAnimator->m_Value * 5;
|
||||
Rect.w += pAnimator->m_Value * pAnimator->m_WOffset;
|
||||
Rect.h += pAnimator->m_Value * pAnimator->m_HOffset;
|
||||
Rect.x += pAnimator->m_Value * pAnimator->m_XOffset;
|
||||
Rect.y += pAnimator->m_Value * pAnimator->m_YOffset;
|
||||
|
||||
pAnimator->m_Time = Time;
|
||||
}
|
||||
|
@ -255,7 +276,20 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co
|
|||
}
|
||||
|
||||
CUIRect Temp;
|
||||
Rect.HMargin(2.0f, &Temp);
|
||||
|
||||
if(pAnimator != NULL)
|
||||
{
|
||||
if(!pAnimator->m_ScaleLabel)
|
||||
{
|
||||
Rect.w = pRect->w;
|
||||
Rect.h = pRect->h;
|
||||
}
|
||||
|
||||
Rect.HMargin(2.0f, &Temp);
|
||||
}
|
||||
else
|
||||
pRect->HMargin(2.0f, &Temp);
|
||||
|
||||
UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically);
|
||||
|
||||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
|
@ -850,7 +884,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
pHomeButtonColorHover = &HomeButtonColorAlertHover;
|
||||
}
|
||||
|
||||
if(DoButton_MenuTab(&s_StartButton, pHomeScreenButtonLabel, false, &Button, CUI::CORNER_T, NULL, pHomeButtonColor, pHomeButtonColor, pHomeButtonColorHover, 10.0f, 0))
|
||||
if(DoButton_MenuTab(&s_StartButton, pHomeScreenButtonLabel, false, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_HOME], pHomeButtonColor, pHomeButtonColor, pHomeButtonColorHover, 10.0f, 0))
|
||||
{
|
||||
m_ShowStart = true;
|
||||
m_DoubleClickIndex = -1;
|
||||
|
@ -866,7 +900,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
{
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_NewsButton = 0;
|
||||
if(DoButton_MenuTab(&s_NewsButton, Localize("News"), m_ActivePage == PAGE_NEWS, &Button, CUI::CORNER_T))
|
||||
if(DoButton_MenuTab(&s_NewsButton, Localize("News"), m_ActivePage == PAGE_NEWS, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_NEWS]))
|
||||
{
|
||||
NewPage = PAGE_NEWS;
|
||||
m_DoubleClickIndex = -1;
|
||||
|
@ -876,7 +910,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
{
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_DemosButton = 0;
|
||||
if(DoButton_MenuTab(&s_DemosButton, Localize("Demos"), m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T))
|
||||
if(DoButton_MenuTab(&s_DemosButton, Localize("Demos"), m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_DEMOS]))
|
||||
{
|
||||
DemolistPopulate();
|
||||
NewPage = PAGE_DEMOS;
|
||||
|
@ -887,7 +921,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
{
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_InternetButton = 0;
|
||||
if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), m_ActivePage == PAGE_INTERNET, &Button, CUI::CORNER_TL))
|
||||
if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), m_ActivePage == PAGE_INTERNET, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_INTERNET]))
|
||||
{
|
||||
if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_INTERNET)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
||||
|
@ -897,7 +931,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_LanButton = 0;
|
||||
if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), m_ActivePage == PAGE_LAN, &Button, 0))
|
||||
if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), m_ActivePage == PAGE_LAN, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_LAN]))
|
||||
{
|
||||
if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_LAN)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
|
||||
|
@ -907,7 +941,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_FavoritesButton = 0;
|
||||
if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), m_ActivePage == PAGE_FAVORITES, &Button, 0))
|
||||
if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), m_ActivePage == PAGE_FAVORITES, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_FAVORITES]))
|
||||
{
|
||||
if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_FAVORITES)
|
||||
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
||||
|
@ -917,7 +951,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
|
||||
Box.VSplitLeft(90.0f, &Button, &Box);
|
||||
static int s_DDNetButton = 0;
|
||||
if(DoButton_MenuTab(&s_DDNetButton, "DDNet", m_ActivePage == PAGE_DDNET, &Button, 0))
|
||||
if(DoButton_MenuTab(&s_DDNetButton, "DDNet", m_ActivePage == PAGE_DDNET, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_DDNET]))
|
||||
{
|
||||
if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_DDNET)
|
||||
{
|
||||
|
@ -930,7 +964,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
|
||||
Box.VSplitLeft(90.0f, &Button, &Box);
|
||||
static int s_KoGButton = 0;
|
||||
if(DoButton_MenuTab(&s_KoGButton, "KoG", m_ActivePage == PAGE_KOG, &Button, CUI::CORNER_TR))
|
||||
if(DoButton_MenuTab(&s_KoGButton, "KoG", m_ActivePage == PAGE_KOG, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_KOG]))
|
||||
{
|
||||
if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_KOG)
|
||||
{
|
||||
|
@ -988,7 +1022,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
Box.VSplitRight(33.0f, &Box, &Button);
|
||||
static int s_QuitButton = 0;
|
||||
ColorRGBA QuitColor(1, 0, 0, 0.5f);
|
||||
if(DoButton_MenuTab(&s_QuitButton, "\xEE\x97\x8D", 0, &Button, CUI::CORNER_T, NULL, NULL, NULL, &QuitColor, 10.0f, 0))
|
||||
if(DoButton_MenuTab(&s_QuitButton, "\xEE\x97\x8D", 0, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_QUIT], NULL, NULL, &QuitColor, 10.0f, 0))
|
||||
{
|
||||
if(m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0))
|
||||
{
|
||||
|
@ -1004,13 +1038,13 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
Box.VSplitRight(33.0f, &Box, &Button);
|
||||
static int s_SettingsButton = 0;
|
||||
|
||||
if(DoButton_MenuTab(&s_SettingsButton, "\xEE\xA2\xB8", m_ActivePage == PAGE_SETTINGS, &Button, CUI::CORNER_T, NULL, NULL, NULL, NULL, 10.0f, 0))
|
||||
if(DoButton_MenuTab(&s_SettingsButton, "\xEE\xA2\xB8", m_ActivePage == PAGE_SETTINGS, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SETTINGS], NULL, NULL, NULL, 10.0f, 0))
|
||||
NewPage = PAGE_SETTINGS;
|
||||
|
||||
Box.VSplitRight(10.0f, &Box, &Button);
|
||||
Box.VSplitRight(33.0f, &Box, &Button);
|
||||
static int s_EditorButton = 0;
|
||||
if(DoButton_MenuTab(&s_EditorButton, "\xEE\x8F\x89", 0, &Button, CUI::CORNER_T, NULL, NULL, NULL, NULL, 10.0f, 0))
|
||||
if(DoButton_MenuTab(&s_EditorButton, "\xEE\x8F\x89", 0, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_EDITOR], NULL, NULL, NULL, 10.0f, 0))
|
||||
{
|
||||
g_Config.m_ClEditor = 1;
|
||||
}
|
||||
|
@ -1021,14 +1055,14 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
Box.VSplitRight(33.0f, &Box, &Button);
|
||||
static int s_DemoButton = 0;
|
||||
|
||||
if(DoButton_MenuTab(&s_DemoButton, "\xEE\x80\xAC", m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, NULL, NULL, NULL, NULL, 10.0f, 0))
|
||||
if(DoButton_MenuTab(&s_DemoButton, "\xEE\x80\xAC", m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_DEMOBUTTON], NULL, NULL, NULL, 10.0f, 0))
|
||||
NewPage = PAGE_DEMOS;
|
||||
|
||||
Box.VSplitRight(10.0f, &Box, &Button);
|
||||
Box.VSplitRight(33.0f, &Box, &Button);
|
||||
static int s_ServerButton = 0;
|
||||
|
||||
if(DoButton_MenuTab(&s_ServerButton, "\xEE\xA0\x8B", m_ActivePage == g_Config.m_UiPage, &Button, CUI::CORNER_T, NULL, NULL, NULL, NULL, 10.0f, 0))
|
||||
if(DoButton_MenuTab(&s_ServerButton, "\xEE\xA0\x8B", m_ActivePage == g_Config.m_UiPage, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SERVER], NULL, NULL, NULL, 10.0f, 0))
|
||||
NewPage = g_Config.m_UiPage;
|
||||
}
|
||||
|
||||
|
|
|
@ -186,8 +186,6 @@ protected:
|
|||
char m_aMessageBody[512];
|
||||
char m_aMessageButton[512];
|
||||
|
||||
SUIAnimator m_aSettingsTabAnimators[10];
|
||||
|
||||
void PopupMessage(const char *pTopic, const char *pBody, const char *pButton);
|
||||
|
||||
// TODO: this is a bit ugly but.. well.. yeah
|
||||
|
@ -442,6 +440,8 @@ public:
|
|||
PAGE_NETWORK,
|
||||
PAGE_GHOST,
|
||||
|
||||
PAGE_LENGTH,
|
||||
|
||||
SETTINGS_LANGUAGE = 0,
|
||||
SETTINGS_GENERAL,
|
||||
SETTINGS_PLAYER,
|
||||
|
@ -452,9 +452,33 @@ public:
|
|||
SETTINGS_SOUND,
|
||||
SETTINGS_DDNET,
|
||||
SETTINGS_ASSETS,
|
||||
SETTINGS_LENGTH
|
||||
|
||||
SETTINGS_LENGTH,
|
||||
|
||||
BIG_TAB_NEWS = 0,
|
||||
BIG_TAB_INTERNET,
|
||||
BIG_TAB_LAN,
|
||||
BIG_TAB_FAVORITES,
|
||||
BIG_TAB_DDNET,
|
||||
BIG_TAB_KOG,
|
||||
BIG_TAB_DEMOS,
|
||||
|
||||
BIG_TAB_LENGTH,
|
||||
|
||||
SMALL_TAB_HOME = 0,
|
||||
SMALL_TAB_QUIT,
|
||||
SMALL_TAB_SETTINGS,
|
||||
SMALL_TAB_EDITOR,
|
||||
SMALL_TAB_DEMOBUTTON,
|
||||
SMALL_TAB_SERVER,
|
||||
|
||||
SMALL_TAB_LENGTH,
|
||||
};
|
||||
|
||||
SUIAnimator m_aAnimatorsBigPage[BIG_TAB_LENGTH];
|
||||
SUIAnimator m_aAnimatorsSmallPage[SMALL_TAB_LENGTH];
|
||||
SUIAnimator m_aAnimatorsSettingsTab[SETTINGS_LENGTH];
|
||||
|
||||
// DDRace
|
||||
int DoButton_CheckBox_DontCare(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
sorted_array<CDemoItem> m_lDemos;
|
||||
|
|
|
@ -1496,7 +1496,7 @@ void CMenus::RenderSettings(CUIRect MainView)
|
|||
{
|
||||
TabBar.HSplitTop(10, &Button, &TabBar);
|
||||
TabBar.HSplitTop(26, &Button, &TabBar);
|
||||
if(DoButton_MenuTab(aTabs[i], aTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aSettingsTabAnimators[i]))
|
||||
if(DoButton_MenuTab(aTabs[i], aTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aAnimatorsSettingsTab[i]))
|
||||
g_Config.m_UiSettingsPage = i;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,9 +99,17 @@ public:
|
|||
|
||||
struct SUIAnimator
|
||||
{
|
||||
bool m_Active;
|
||||
bool m_ScaleLabel;
|
||||
|
||||
float m_Time;
|
||||
float m_Value;
|
||||
bool m_Active;
|
||||
|
||||
float m_XOffset;
|
||||
float m_YOffset;
|
||||
float m_WOffset;
|
||||
float m_HOffset;
|
||||
|
||||
};
|
||||
|
||||
class CUI
|
||||
|
|
Loading…
Reference in a new issue