From e40539c9fd87a4da06442353db299b7ff90ef934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 26 Oct 2020 04:10:55 +0300 Subject: [PATCH 01/12] Settings Tabs Animations --- src/game/client/components/menus.cpp | 56 +++++++++++++++---- src/game/client/components/menus.h | 6 +- src/game/client/components/menus_browser.cpp | 6 +- src/game/client/components/menus_settings.cpp | 2 +- .../components/menus_settings_assets.cpp | 8 +-- src/game/client/ui.h | 7 +++ 6 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 52380d56c..4fe738ee4 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -196,14 +196,41 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0); } -int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) +int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) { + int Time = 0; + bool MouseInside = UI()->MouseInside(pRect); + CUIRect Rect = *pRect; + + if(pAnimator != NULL) + { + Time = time(); + + if(pAnimator->m_Time + 1000000.f < Time) + { + pAnimator->m_Value = pAnimator->m_Active ? 1 : 0; + pAnimator->m_Time = Time; + } + + pAnimator->m_Active = Checked || MouseInside; + + if(pAnimator->m_Active) + pAnimator->m_Value = clamp(pAnimator->m_Value + (Time - pAnimator->m_Time) / 1000000.f, 0, 1); + else + pAnimator->m_Value = clamp(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; + } + if(Checked) { ColorRGBA ColorMenuTab = ms_ColorTabbarActive; if(pActiveColor) ColorMenuTab = *pActiveColor; - RenderTools()->DrawUIRect(pRect, ColorMenuTab, Corners, EdgeRounding); + + RenderTools()->DrawUIRect(&Rect, ColorMenuTab, Corners, EdgeRounding); } else { @@ -212,18 +239,25 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co ColorRGBA HoverColorMenuTab = ms_ColorTabbarHover; if(pHoverColor) HoverColorMenuTab = *pHoverColor; - RenderTools()->DrawUIRect(pRect, HoverColorMenuTab, Corners, EdgeRounding); + + + RenderTools()->DrawUIRect(&Rect, HoverColorMenuTab, Corners, EdgeRounding); } else { ColorRGBA ColorMenuTab = ms_ColorTabbarInactive; if(pDefaultColor) ColorMenuTab = *pDefaultColor; - RenderTools()->DrawUIRect(pRect, ColorMenuTab, Corners, EdgeRounding); + + RenderTools()->DrawUIRect(&Rect, ColorMenuTab, Corners, EdgeRounding); } } + + if(pAnimator != NULL) + pAnimator->m_Time = Time; + CUIRect Temp; - pRect->HMargin(2.0f, &Temp); + Rect.HMargin(2.0f, &Temp); UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically); return UI()->DoButtonLogic(pID, pText, Checked, pRect); @@ -818,7 +852,7 @@ int CMenus::RenderMenubar(CUIRect r) pHomeButtonColorHover = &HomeButtonColorAlertHover; } - if(DoButton_MenuTab(&s_StartButton, pHomeScreenButtonLabel, false, &Button, CUI::CORNER_T, pHomeButtonColor, pHomeButtonColor, pHomeButtonColorHover, 10.0f, 0)) + if(DoButton_MenuTab(&s_StartButton, pHomeScreenButtonLabel, false, &Button, CUI::CORNER_T, NULL, pHomeButtonColor, pHomeButtonColor, pHomeButtonColorHover, 10.0f, 0)) { m_ShowStart = true; m_DoubleClickIndex = -1; @@ -956,7 +990,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, &QuitColor, 10.0f, 0)) + if(DoButton_MenuTab(&s_QuitButton, "\xEE\x97\x8D", 0, &Button, CUI::CORNER_T, NULL, NULL, NULL, &QuitColor, 10.0f, 0)) { if(m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0)) { @@ -972,13 +1006,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, 10.0f, 0)) + if(DoButton_MenuTab(&s_SettingsButton, "\xEE\xA2\xB8", m_ActivePage == PAGE_SETTINGS, &Button, CUI::CORNER_T, NULL, 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, 10.0f, 0)) + if(DoButton_MenuTab(&s_EditorButton, "\xEE\x8F\x89", 0, &Button, CUI::CORNER_T, NULL, NULL, NULL, NULL, 10.0f, 0)) { g_Config.m_ClEditor = 1; } @@ -989,14 +1023,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, 10.0f, 0)) + if(DoButton_MenuTab(&s_DemoButton, "\xEE\x80\xAC", m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, NULL, 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, 10.0f, 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)) NewPage = g_Config.m_UiPage; } diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 79df6207b..ef12e1660 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -54,7 +54,7 @@ class CMenus : public CComponent int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = 0, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1); - int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, const ColorRGBA *pDefaultColor = NULL, const ColorRGBA *pActiveColor = NULL, const ColorRGBA *pHoverColor = NULL, float EdgeRounding = 10, int AlignVertically = 1); + int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = NULL, const ColorRGBA *pDefaultColor = NULL, const ColorRGBA *pActiveColor = NULL, const ColorRGBA *pHoverColor = NULL, float EdgeRounding = 10, int AlignVertically = 1); int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); @@ -186,6 +186,8 @@ protected: char m_aMessageBody[512]; char m_aMessageButton[512]; + SUIAnimator m_aUIAnimators[10]; + void PopupMessage(const char *pTopic, const char *pBody, const char *pButton); // TODO: this is a bit ugly but.. well.. yeah @@ -449,7 +451,7 @@ public: SETTINGS_GRAPHICS, SETTINGS_SOUND, SETTINGS_DDNET, - SETTINGS_ASSETS, + SETTINGS_ASSETS }; // DDRace diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index d7ebf876a..be0c7bd1a 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -1392,15 +1392,15 @@ void CMenus::RenderServerbrowser(CUIRect MainView) ms_ColorTabbarInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f); static int s_FiltersTab = 0; - if(DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage == 0, &TabButton0, CUI::CORNER_BL, NULL, NULL, NULL, 4.0f)) + if(DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage == 0, &TabButton0, CUI::CORNER_BL, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 0; static int s_InfoTab = 0; - if(DoButton_MenuTab(&s_InfoTab, Localize("Info"), ToolboxPage == 1, &TabButton1, 0, NULL, NULL, NULL, 4.0f)) + if(DoButton_MenuTab(&s_InfoTab, Localize("Info"), ToolboxPage == 1, &TabButton1, 0, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 1; static int s_FriendsTab = 0; - if(DoButton_MenuTab(&s_FriendsTab, Localize("Friends"), ToolboxPage == 2, &TabButton2, CUI::CORNER_BR, NULL, NULL, NULL, 4.0f)) + if(DoButton_MenuTab(&s_FriendsTab, Localize("Friends"), ToolboxPage == 2, &TabButton2, CUI::CORNER_BR, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 2; ms_ColorTabbarActive = Active; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 1abeea02e..2cc8ef72f 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -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)) + if(DoButton_MenuTab(aTabs[i], aTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aUIAnimators[i])) g_Config.m_UiSettingsPage = i; } diff --git a/src/game/client/components/menus_settings_assets.cpp b/src/game/client/components/menus_settings_assets.cpp index 539480243..25799ce4b 100644 --- a/src/game/client/components/menus_settings_assets.cpp +++ b/src/game/client/components/menus_settings_assets.cpp @@ -310,13 +310,13 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) Page2Tab.VSplitLeft(TabsW / 4, &Page2Tab, &Page3Tab); Page3Tab.VSplitLeft(TabsW / 4, &Page3Tab, &Page4Tab); - if(DoButton_MenuTab((void *)&Page1Tab, Localize("Entities"), s_CurCustomTab == 0, &Page1Tab, 5, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((void *)&Page1Tab, Localize("Entities"), s_CurCustomTab == 0, &Page1Tab, 5, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = 0; - if(DoButton_MenuTab((void *)&Page2Tab, Localize("Game"), s_CurCustomTab == 1, &Page2Tab, 0, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((void *)&Page2Tab, Localize("Game"), s_CurCustomTab == 1, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = 1; - if(DoButton_MenuTab((void *)&Page3Tab, Localize("Emoticons"), s_CurCustomTab == 2, &Page3Tab, 0, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((void *)&Page3Tab, Localize("Emoticons"), s_CurCustomTab == 2, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = 2; - if(DoButton_MenuTab((void *)&Page4Tab, Localize("Particles"), s_CurCustomTab == 3, &Page4Tab, 10, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((void *)&Page4Tab, Localize("Particles"), s_CurCustomTab == 3, &Page4Tab, 10, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = 3; if(s_CurCustomTab == 0) diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 22afe4480..f1b0c94f9 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -97,6 +97,13 @@ public: void HMargin(float Cut, CUIRect *pOtherRect) const; }; +struct SUIAnimator +{ + float m_Time; + float m_Value; + bool m_Active; +}; + class CUI { const void *m_pHotItem; From c02086a6891c10571a6ff5a11ba72ec9bbf2210c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 26 Oct 2020 04:43:34 +0300 Subject: [PATCH 02/12] Fixes --- src/game/client/components/menus.cpp | 8 +++----- src/game/client/components/menus.h | 5 +++-- src/game/client/components/menus_settings.cpp | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 4fe738ee4..3dee8e59a 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -204,7 +204,7 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co if(pAnimator != NULL) { - Time = time(); + Time = time(); if(pAnimator->m_Time + 1000000.f < Time) { @@ -222,6 +222,8 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co Rect.w += pAnimator->m_Value * 5; Rect.y -= pAnimator->m_Value * 2.5f; Rect.h += pAnimator->m_Value * 5; + + pAnimator->m_Time = Time; } if(Checked) @@ -240,7 +242,6 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co if(pHoverColor) HoverColorMenuTab = *pHoverColor; - RenderTools()->DrawUIRect(&Rect, HoverColorMenuTab, Corners, EdgeRounding); } else @@ -253,9 +254,6 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co } } - if(pAnimator != NULL) - pAnimator->m_Time = Time; - CUIRect Temp; Rect.HMargin(2.0f, &Temp); UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically); diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index ef12e1660..be874fbfe 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -186,7 +186,7 @@ protected: char m_aMessageBody[512]; char m_aMessageButton[512]; - SUIAnimator m_aUIAnimators[10]; + SUIAnimator m_aSettingsTabAnimators[10]; void PopupMessage(const char *pTopic, const char *pBody, const char *pButton); @@ -451,7 +451,8 @@ public: SETTINGS_GRAPHICS, SETTINGS_SOUND, SETTINGS_DDNET, - SETTINGS_ASSETS + SETTINGS_ASSETS, + SETTINGS_LENGTH }; // DDRace diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 2cc8ef72f..6eddc4e27 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -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_aUIAnimators[i])) + if(DoButton_MenuTab(aTabs[i], aTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aSettingsTabAnimators[i])) g_Config.m_UiSettingsPage = i; } From 9b3d9965fb701ed38f8104ec450588d1a81da7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 26 Oct 2020 05:48:05 +0300 Subject: [PATCH 03/12] More UI Animation settings, more tabs animated --- src/game/client/components/menus.cpp | 68 ++++++++++++++----- src/game/client/components/menus.h | 30 +++++++- src/game/client/components/menus_settings.cpp | 2 +- src/game/client/ui.h | 10 ++- 4 files changed, 88 insertions(+), 22 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 3dee8e59a..4f28369b8 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -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(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; } diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index be874fbfe..33e697b98 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -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 m_lDemos; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 6eddc4e27..a86c23a94 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -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; } diff --git a/src/game/client/ui.h b/src/game/client/ui.h index f1b0c94f9..ee97f96cd 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -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 From b6d94a85f3acfa7bc43af8993ac81d2458b44cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 26 Oct 2020 06:10:58 +0300 Subject: [PATCH 04/12] Visual Improvements, Fixed check-style --- src/game/client/components/menus.cpp | 8 +++++++- src/game/client/ui.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 4f28369b8..7b87b576c 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -100,7 +100,7 @@ CMenus::CMenus() animator.m_YOffset = -2.5f; animator.m_HOffset = 5.0f; animator.m_WOffset = 5.0f; - animator.m_ScaleLabel = true; + animator.m_RepositionLabel = true; } for(SUIAnimator &animator : m_aAnimatorsBigPage) @@ -279,6 +279,12 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co if(pAnimator != NULL) { + if(pAnimator->m_RepositionLabel) + { + Rect.x += Rect.w - pRect->w + Rect.x - pRect->x; + Rect.y += Rect.h - pRect->h + Rect.y - pRect->y; + } + if(!pAnimator->m_ScaleLabel) { Rect.w = pRect->w; diff --git a/src/game/client/ui.h b/src/game/client/ui.h index ee97f96cd..6dc159b26 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -101,6 +101,7 @@ struct SUIAnimator { bool m_Active; bool m_ScaleLabel; + bool m_RepositionLabel; float m_Time; float m_Value; @@ -109,7 +110,6 @@ struct SUIAnimator float m_YOffset; float m_WOffset; float m_HOffset; - }; class CUI From b18d72db1fc59a8ad733b134bf2ee6c9c92bc7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 26 Oct 2020 17:47:26 +0300 Subject: [PATCH 05/12] using time_get_mircoseconds and storing it as int64 val --- src/game/client/components/menus.cpp | 16 ++++++---------- src/game/client/ui.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 7b87b576c..3c21bc2d6 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -218,15 +218,14 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) { - int Time = 0; bool MouseInside = UI()->MouseInside(pRect); CUIRect Rect = *pRect; if(pAnimator != NULL) { - Time = time(); + int64 Time = time_get_microseconds(); - if(pAnimator->m_Time + 1000000.f < Time) + if(pAnimator->m_Time + 100000 < Time) { pAnimator->m_Value = pAnimator->m_Active ? 1 : 0; pAnimator->m_Time = Time; @@ -235,9 +234,9 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co pAnimator->m_Active = Checked || MouseInside; if(pAnimator->m_Active) - pAnimator->m_Value = clamp(pAnimator->m_Value + (Time - pAnimator->m_Time) / 1000000.f, 0, 1); + pAnimator->m_Value = clamp(pAnimator->m_Value + (Time - pAnimator->m_Time) / 100000.f, 0, 1); else - pAnimator->m_Value = clamp(pAnimator->m_Value - (Time - pAnimator->m_Time) / 1000000.f, 0, 1); + pAnimator->m_Value = clamp(pAnimator->m_Value - (Time - pAnimator->m_Time) / 100000.f, 0, 1); Rect.w += pAnimator->m_Value * pAnimator->m_WOffset; Rect.h += pAnimator->m_Value * pAnimator->m_HOffset; @@ -290,12 +289,9 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co Rect.w = pRect->w; Rect.h = pRect->h; } - - Rect.HMargin(2.0f, &Temp); } - else - pRect->HMargin(2.0f, &Temp); - + + Rect.HMargin(2.0f, &Temp); UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically); return UI()->DoButtonLogic(pID, pText, Checked, pRect); diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 6dc159b26..7b8887272 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -103,7 +103,7 @@ struct SUIAnimator bool m_ScaleLabel; bool m_RepositionLabel; - float m_Time; + long long m_Time; float m_Value; float m_XOffset; From 7e180f93cb06b3d4e160afd206799aa039dea05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Sat, 31 Oct 2020 01:45:46 +0300 Subject: [PATCH 06/12] Fix rarest bug and typedef in UI animations --- src/game/client/components/menus.cpp | 2 +- src/game/client/ui.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 3c21bc2d6..746eea096 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -225,7 +225,7 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co { int64 Time = time_get_microseconds(); - if(pAnimator->m_Time + 100000 < Time) + if(pAnimator->m_Time + (int64)100000 < Time) { pAnimator->m_Value = pAnimator->m_Active ? 1 : 0; pAnimator->m_Time = Time; diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 7b8887272..ccba1acdd 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -3,6 +3,8 @@ #ifndef GAME_CLIENT_UI_H #define GAME_CLIENT_UI_H +#include "base/system.h" + class CUIRect { // TODO: Refactor: Redo UI scaling @@ -103,7 +105,7 @@ struct SUIAnimator bool m_ScaleLabel; bool m_RepositionLabel; - long long m_Time; + int64 m_Time; float m_Value; float m_XOffset; From cd00c4c04b846a822b3ea229f1d126d963b5e785 Mon Sep 17 00:00:00 2001 From: def Date: Sat, 12 Dec 2020 12:37:43 +0100 Subject: [PATCH 07/12] Move PNG loading in SkinDL to fetch thread (fixes #3398) Sorry for the trouble, seems to work. --- src/engine/client/http.cpp | 4 +-- src/engine/client/http.h | 5 ++-- src/game/client/components/skins.cpp | 44 +++++++++++++++++++++++++--- src/game/client/components/skins.h | 16 +++++++++- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/src/engine/client/http.cpp b/src/engine/client/http.cpp index 9333636d2..388a9430c 100644 --- a/src/engine/client/http.cpp +++ b/src/engine/client/http.cpp @@ -250,8 +250,8 @@ size_t CGet::OnData(char *pData, size_t DataSize) CGetFile::CGetFile(IStorage *pStorage, const char *pUrl, const char *pDest, int StorageType, CTimeout Timeout, bool LogProgress) : CRequest(pUrl, Timeout, LogProgress), m_pStorage(pStorage), - m_StorageType(StorageType), - m_File(0) + m_File(0), + m_StorageType(StorageType) { str_copy(m_aDest, pDest, sizeof(m_aDest)); diff --git a/src/engine/client/http.h b/src/engine/client/http.h index 79ab1f7bb..a29514499 100644 --- a/src/engine/client/http.h +++ b/src/engine/client/http.h @@ -101,12 +101,13 @@ class CGetFile : public CRequest IStorage *m_pStorage; - char m_aDest[MAX_PATH_LENGTH]; char m_aDestFull[MAX_PATH_LENGTH]; - int m_StorageType; IOHANDLE m_File; protected: + char m_aDest[MAX_PATH_LENGTH]; + int m_StorageType; + virtual int OnCompletion(int State); public: diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index 15bc9e07d..d5272adc2 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -30,6 +30,22 @@ static bool IsVanillaSkin(const char *pName) return false; } +int CSkins::CGetPngFile::OnCompletion(int State) +{ + State = CGetFile::OnCompletion(State); + + if(State != HTTP_ERROR && State != HTTP_ABORTED && !m_pSkins->LoadSkinPNG(m_Info, m_aDest, m_aDest, m_StorageType)) + { + State = HTTP_ERROR; + } + return State; +} + +CSkins::CGetPngFile::CGetPngFile(CSkins *pSkins, IStorage *pStorage, const char *pUrl, const char *pDest, int StorageType, CTimeout Timeout, bool LogProgress) : + CGetFile(pStorage, pUrl, pDest, StorageType, Timeout, LogProgress), m_pSkins(pSkins) +{ +} + int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) { CSkins *pSelf = (CSkins *)pUser; @@ -92,12 +108,32 @@ static void CheckMetrics(CSkin::SSkinMetricVariable &Metrics, uint8_t *pImg, int int CSkins::LoadSkin(const char *pName, const char *pPath, int DirType) { - char aBuf[512]; CImageInfo Info; - if(!Graphics()->LoadPNG(&Info, pPath, DirType) || !Graphics()->CheckImageDivisibility(pPath, Info, g_pData->m_aSprites[SPRITE_TEE_BODY].m_pSet->m_Gridx, g_pData->m_aSprites[SPRITE_TEE_BODY].m_pSet->m_Gridy, true)) + if(!LoadSkinPNG(Info, pName, pPath, DirType)) + return 0; + return LoadSkin(pName, Info); +} + +bool CSkins::LoadSkinPNG(CImageInfo &Info, const char *pName, const char *pPath, int DirType) +{ + char aBuf[512]; + if(!Graphics()->LoadPNG(&Info, pPath, DirType)) { str_format(aBuf, sizeof(aBuf), "failed to load skin from %s", pName); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); + return false; + } + return true; +} + +int CSkins::LoadSkin(const char *pName, CImageInfo &Info) +{ + char aBuf[512]; + + if(!Graphics()->CheckImageDivisibility(pName, Info, g_pData->m_aSprites[SPRITE_TEE_BODY].m_pSet->m_Gridx, g_pData->m_aSprites[SPRITE_TEE_BODY].m_pSet->m_Gridy, true)) + { + str_format(aBuf, sizeof(aBuf), "skin failed image divisibility: %s", pName); + Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); return 0; } @@ -366,7 +402,7 @@ int CSkins::FindImpl(const char *pName) char aPath[MAX_PATH_LENGTH]; str_format(aPath, sizeof(aPath), "downloadedskins/%s.png", d.front().m_aName); Storage()->RenameFile(d.front().m_aPath, aPath, IStorage::TYPE_SAVE); - LoadSkin(d.front().m_aName, aPath, IStorage::TYPE_SAVE); + LoadSkin(d.front().m_aName, d.front().m_pTask->m_Info); d.front().m_pTask = nullptr; } if(d.front().m_pTask && (d.front().m_pTask->State() == HTTP_ERROR || d.front().m_pTask->State() == HTTP_ABORTED)) @@ -382,7 +418,7 @@ int CSkins::FindImpl(const char *pName) char aUrl[256]; str_format(aUrl, sizeof(aUrl), "%s%s.png", g_Config.m_ClSkinDownloadUrl, pName); str_format(Skin.m_aPath, sizeof(Skin.m_aPath), "downloadedskins/%s.%d.tmp", pName, pid()); - Skin.m_pTask = std::make_shared(Storage(), aUrl, Skin.m_aPath, IStorage::TYPE_SAVE, CTimeout{0, 0, 0}, false); + Skin.m_pTask = std::make_shared(this, Storage(), aUrl, Skin.m_aPath, IStorage::TYPE_SAVE, CTimeout{0, 0, 0}, false); m_pClient->Engine()->AddJob(Skin.m_pTask); m_aDownloadSkins.add(Skin); return -1; diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index 4b6c35aff..8ec94f750 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -12,9 +12,21 @@ class CSkins : public CComponent { public: + class CGetPngFile : public CGetFile + { + CSkins *m_pSkins; + + protected: + virtual int OnCompletion(int State); + + public: + CGetPngFile(CSkins *pSkins, IStorage *pStorage, const char *pUrl, const char *pDest, int StorageType = -2, CTimeout Timeout = CTimeout{4000, 500, 5}, bool LogProgress = true); + CImageInfo m_Info; + }; + struct CDownloadSkin { - std::shared_ptr m_pTask; + std::shared_ptr m_pTask; char m_aPath[MAX_PATH_LENGTH]; char m_aName[24]; @@ -35,7 +47,9 @@ private: sorted_array m_aDownloadSkins; char m_EventSkinPrefix[24]; + bool LoadSkinPNG(CImageInfo &Info, const char *pName, const char *pPath, int DirType); int LoadSkin(const char *pName, const char *pPath, int DirType); + int LoadSkin(const char *pName, CImageInfo &Info); int FindImpl(const char *pName); static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser); }; From 3c9d1ab804a1bd28ffd95a286abacb166def5e27 Mon Sep 17 00:00:00 2001 From: def Date: Sat, 12 Dec 2020 17:51:09 +0100 Subject: [PATCH 08/12] No need to call png_init every time --- src/engine/client/graphics_threaded.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 0bd802f29..591f825dc 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -154,6 +154,8 @@ CGraphics_Threaded::CGraphics_Threaded() m_RenderEnable = true; m_DoScreenshot = false; + + png_init(0, 0); // ignore_convention } void CGraphics_Threaded::ClipEnable(int x, int y, int w, int h) @@ -521,8 +523,6 @@ int CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int Sto png_t Png; // ignore_convention // open file for reading - png_init(0, 0); // ignore_convention - IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType, aCompleteFilename, sizeof(aCompleteFilename)); if(File) io_close(File); From 82faad33e901a628a939df8eadd6bdc99ff69fad Mon Sep 17 00:00:00 2001 From: def Date: Sun, 13 Dec 2020 19:31:37 +0100 Subject: [PATCH 09/12] Fix clang-format --- src/game/client/components/menus.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 8da97f652..72e576093 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -285,14 +285,14 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co Rect.x += Rect.w - pRect->w + Rect.x - pRect->x; Rect.y += Rect.h - pRect->h + Rect.y - pRect->y; } - + if(!pAnimator->m_ScaleLabel) { Rect.w = pRect->w; Rect.h = pRect->h; } } - + Rect.HMargin(2.0f, &Temp); UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically); From bd1c8473006729e31d6a60e1701a10607be71c67 Mon Sep 17 00:00:00 2001 From: Learath2 Date: Mon, 14 Dec 2020 12:06:11 +0100 Subject: [PATCH 10/12] Allow reordering in the settings editor --- src/game/editor/editor.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 68b5f8bcc..9eb8ab49a 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -5524,6 +5524,24 @@ void CEditor::RenderServerSettingsEditor(CUIRect View, bool ShowServerSettingsEd str_copy(m_aSettingsCommand, m_Map.m_lSettings[s_CommandSelectedIndex].m_aCommand, sizeof(m_aSettingsCommand)); UI()->SetActiveItem(&m_CommandBox); } + + ToolBar.VSplitRight(25.0f, &ToolBar, &Button); + Button.VSplitRight(5.0f, &Button, 0); + static int s_DownButton = 0; + if(s_CommandSelectedIndex < m_Map.m_lSettings.size() - 1 && DoButton_Editor(&s_DownButton, "▼", 0, &Button, 0, "Move command down")) + { + std::swap(m_Map.m_lSettings[s_CommandSelectedIndex], m_Map.m_lSettings[s_CommandSelectedIndex + 1]); + s_CommandSelectedIndex++; + } + + ToolBar.VSplitRight(25.0f, &ToolBar, &Button); + Button.VSplitRight(5.0f, &Button, 0); + static int s_UpButton = 0; + if(s_CommandSelectedIndex > 0 && DoButton_Editor(&s_UpButton, "▲", 0, &Button, 0, "Move command up")) + { + std::swap(m_Map.m_lSettings[s_CommandSelectedIndex], m_Map.m_lSettings[s_CommandSelectedIndex - 1]); + s_CommandSelectedIndex--; + } } } From da6930fba51270c490f51e0ed881dc523fb591d3 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 15 Dec 2020 16:22:25 +0100 Subject: [PATCH 11/12] Version 15.2.4 --- src/game/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/version.h b/src/game/version.h index d29b55d7f..ffb1997af 100644 --- a/src/game/version.h +++ b/src/game/version.h @@ -3,11 +3,11 @@ #ifndef GAME_VERSION_H #define GAME_VERSION_H #ifndef GAME_RELEASE_VERSION -#define GAME_RELEASE_VERSION "15.2.3" +#define GAME_RELEASE_VERSION "15.2.4" #endif #define GAME_VERSION "0.6.4, " GAME_RELEASE_VERSION #define GAME_NETVERSION "0.6 626fce9a778df4d4" #define GAME_NAME "DDNet" -#define CLIENT_VERSIONNR 15023 +#define CLIENT_VERSIONNR 15024 extern const char *GIT_SHORTREV_HASH; #endif From b05674c48dc8555010176dd3282a43b3b1baa9ee Mon Sep 17 00:00:00 2001 From: def Date: Wed, 16 Dec 2020 13:24:41 +0100 Subject: [PATCH 12/12] Update ddnet.appdata.xml --- other/ddnet.appdata.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/other/ddnet.appdata.xml b/other/ddnet.appdata.xml index 7c465abeb..36c0b5a70 100644 --- a/other/ddnet.appdata.xml +++ b/other/ddnet.appdata.xml @@ -37,6 +37,7 @@ intense +