Merge branch 'pr_color_picker' of https://github.com/Banana090/ddnet into pr_color_picker

This commit is contained in:
Дядя Женя 2020-12-18 23:29:52 +03:00
commit 2c3d24d5b3
14 changed files with 225 additions and 46 deletions

View file

@ -37,6 +37,7 @@
<content_attribute id="social-chat">intense</content_attribute> <content_attribute id="social-chat">intense</content_attribute>
</content_rating> </content_rating>
<releases> <releases>
<release date="2020-12-16" version="15.2.4"/>
<release date="2020-11-19" version="15.2.3"/> <release date="2020-11-19" version="15.2.3"/>
<release date="2020-11-17" version="15.2.2"/> <release date="2020-11-17" version="15.2.2"/>
<release date="2020-11-17" version="15.2.1"/> <release date="2020-11-17" version="15.2.1"/>

View file

@ -154,6 +154,8 @@ CGraphics_Threaded::CGraphics_Threaded()
m_RenderEnable = true; m_RenderEnable = true;
m_DoScreenshot = false; m_DoScreenshot = false;
png_init(0, 0); // ignore_convention
} }
void CGraphics_Threaded::ClipEnable(int x, int y, int w, int h) 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 png_t Png; // ignore_convention
// open file for reading // open file for reading
png_init(0, 0); // ignore_convention
IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType, aCompleteFilename, sizeof(aCompleteFilename)); IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType, aCompleteFilename, sizeof(aCompleteFilename));
if(File) if(File)
io_close(File); io_close(File);

View file

@ -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) : CGetFile::CGetFile(IStorage *pStorage, const char *pUrl, const char *pDest, int StorageType, CTimeout Timeout, bool LogProgress) :
CRequest(pUrl, Timeout, LogProgress), CRequest(pUrl, Timeout, LogProgress),
m_pStorage(pStorage), m_pStorage(pStorage),
m_StorageType(StorageType), m_File(0),
m_File(0) m_StorageType(StorageType)
{ {
str_copy(m_aDest, pDest, sizeof(m_aDest)); str_copy(m_aDest, pDest, sizeof(m_aDest));

View file

@ -101,12 +101,13 @@ class CGetFile : public CRequest
IStorage *m_pStorage; IStorage *m_pStorage;
char m_aDest[MAX_PATH_LENGTH];
char m_aDestFull[MAX_PATH_LENGTH]; char m_aDestFull[MAX_PATH_LENGTH];
int m_StorageType;
IOHANDLE m_File; IOHANDLE m_File;
protected: protected:
char m_aDest[MAX_PATH_LENGTH];
int m_StorageType;
virtual int OnCompletion(int State); virtual int OnCompletion(int State);
public: public:

View file

@ -99,6 +99,26 @@ CMenus::CMenus()
m_ServerProcess.Process = 0; m_ServerProcess.Process = 0;
m_ServerProcess.Initialized = false; 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_RepositionLabel = 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) float CMenus::ButtonColorMul(const void *pID)
@ -222,14 +242,43 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked,
UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0); 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)
{ {
bool MouseInside = UI()->MouseInside(pRect);
CUIRect Rect = *pRect;
if(pAnimator != NULL)
{
int64 Time = time_get_microseconds();
if(pAnimator->m_Time + (int64)100000 < 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<float>(pAnimator->m_Value + (Time - pAnimator->m_Time) / 100000.f, 0, 1);
else
pAnimator->m_Value = clamp<float>(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;
Rect.x += pAnimator->m_Value * pAnimator->m_XOffset;
Rect.y += pAnimator->m_Value * pAnimator->m_YOffset;
pAnimator->m_Time = Time;
}
if(Checked) if(Checked)
{ {
ColorRGBA ColorMenuTab = ms_ColorTabbarActive; ColorRGBA ColorMenuTab = ms_ColorTabbarActive;
if(pActiveColor) if(pActiveColor)
ColorMenuTab = *pActiveColor; ColorMenuTab = *pActiveColor;
RenderTools()->DrawUIRect(pRect, ColorMenuTab, Corners, EdgeRounding);
RenderTools()->DrawUIRect(&Rect, ColorMenuTab, Corners, EdgeRounding);
} }
else else
{ {
@ -238,18 +287,37 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co
ColorRGBA HoverColorMenuTab = ms_ColorTabbarHover; ColorRGBA HoverColorMenuTab = ms_ColorTabbarHover;
if(pHoverColor) if(pHoverColor)
HoverColorMenuTab = *pHoverColor; HoverColorMenuTab = *pHoverColor;
RenderTools()->DrawUIRect(pRect, HoverColorMenuTab, Corners, EdgeRounding);
RenderTools()->DrawUIRect(&Rect, HoverColorMenuTab, Corners, EdgeRounding);
} }
else else
{ {
ColorRGBA ColorMenuTab = ms_ColorTabbarInactive; ColorRGBA ColorMenuTab = ms_ColorTabbarInactive;
if(pDefaultColor) if(pDefaultColor)
ColorMenuTab = *pDefaultColor; ColorMenuTab = *pDefaultColor;
RenderTools()->DrawUIRect(pRect, ColorMenuTab, Corners, EdgeRounding);
RenderTools()->DrawUIRect(&Rect, ColorMenuTab, Corners, EdgeRounding);
} }
} }
CUIRect Temp; CUIRect Temp;
pRect->HMargin(2.0f, &Temp);
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;
Rect.h = pRect->h;
}
}
Rect.HMargin(2.0f, &Temp);
UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically); UI()->DoLabel(&Temp, pText, Temp.h * ms_FontmodHeight, 0, -1, AlignVertically);
return UI()->DoButtonLogic(pID, pText, Checked, pRect); return UI()->DoButtonLogic(pID, pText, Checked, pRect);
@ -1059,7 +1127,7 @@ int CMenus::RenderMenubar(CUIRect r)
pHomeButtonColorHover = &HomeButtonColorAlertHover; 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, &m_aAnimatorsSmallPage[SMALL_TAB_HOME], pHomeButtonColor, pHomeButtonColor, pHomeButtonColorHover, 10.0f, 0))
{ {
m_ShowStart = true; m_ShowStart = true;
m_DoubleClickIndex = -1; m_DoubleClickIndex = -1;
@ -1075,7 +1143,7 @@ int CMenus::RenderMenubar(CUIRect r)
{ {
Box.VSplitLeft(100.0f, &Button, &Box); Box.VSplitLeft(100.0f, &Button, &Box);
static int s_NewsButton = 0; 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; NewPage = PAGE_NEWS;
m_DoubleClickIndex = -1; m_DoubleClickIndex = -1;
@ -1085,7 +1153,7 @@ int CMenus::RenderMenubar(CUIRect r)
{ {
Box.VSplitLeft(100.0f, &Button, &Box); Box.VSplitLeft(100.0f, &Button, &Box);
static int s_DemosButton = 0; 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(); DemolistPopulate();
NewPage = PAGE_DEMOS; NewPage = PAGE_DEMOS;
@ -1096,7 +1164,7 @@ int CMenus::RenderMenubar(CUIRect r)
{ {
Box.VSplitLeft(100.0f, &Button, &Box); Box.VSplitLeft(100.0f, &Button, &Box);
static int s_InternetButton = 0; 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) if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_INTERNET)
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET); ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
@ -1106,7 +1174,7 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitLeft(100.0f, &Button, &Box); Box.VSplitLeft(100.0f, &Button, &Box);
static int s_LanButton = 0; 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) if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_LAN)
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN); ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
@ -1116,7 +1184,7 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitLeft(100.0f, &Button, &Box); Box.VSplitLeft(100.0f, &Button, &Box);
static int s_FavoritesButton = 0; 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) if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_FAVORITES)
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES); ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
@ -1126,7 +1194,7 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitLeft(90.0f, &Button, &Box); Box.VSplitLeft(90.0f, &Button, &Box);
static int s_DDNetButton = 0; 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) if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_DDNET)
{ {
@ -1139,7 +1207,7 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitLeft(90.0f, &Button, &Box); Box.VSplitLeft(90.0f, &Button, &Box);
static int s_KoGButton = 0; 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) if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_KOG)
{ {
@ -1197,7 +1265,7 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static int s_QuitButton = 0; static int s_QuitButton = 0;
ColorRGBA QuitColor(1, 0, 0, 0.5f); 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, &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)) if(m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0))
{ {
@ -1213,13 +1281,13 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static int s_SettingsButton = 0; 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, &m_aAnimatorsSmallPage[SMALL_TAB_SETTINGS], NULL, NULL, NULL, 10.0f, 0))
NewPage = PAGE_SETTINGS; NewPage = PAGE_SETTINGS;
Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(10.0f, &Box, &Button);
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static int s_EditorButton = 0; 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, &m_aAnimatorsSmallPage[SMALL_TAB_EDITOR], NULL, NULL, NULL, 10.0f, 0))
{ {
g_Config.m_ClEditor = 1; g_Config.m_ClEditor = 1;
} }
@ -1230,14 +1298,14 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static int s_DemoButton = 0; 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, &m_aAnimatorsSmallPage[SMALL_TAB_DEMOBUTTON], NULL, NULL, NULL, 10.0f, 0))
NewPage = PAGE_DEMOS; NewPage = PAGE_DEMOS;
Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(10.0f, &Box, &Button);
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static int s_ServerButton = 0; 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, &m_aAnimatorsSmallPage[SMALL_TAB_SERVER], NULL, NULL, NULL, 10.0f, 0))
NewPage = g_Config.m_UiPage; NewPage = g_Config.m_UiPage;
} }

View file

@ -79,7 +79,7 @@ class CMenus : public CComponent
int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); 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_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, bool CheckForActiveColorPicker = false); 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, bool CheckForActiveColorPicker = false);
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_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); int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
@ -561,6 +561,8 @@ public:
PAGE_NETWORK, PAGE_NETWORK,
PAGE_GHOST, PAGE_GHOST,
PAGE_LENGTH,
SETTINGS_LANGUAGE = 0, SETTINGS_LANGUAGE = 0,
SETTINGS_GENERAL, SETTINGS_GENERAL,
SETTINGS_PLAYER, SETTINGS_PLAYER,
@ -571,8 +573,33 @@ public:
SETTINGS_SOUND, SETTINGS_SOUND,
SETTINGS_DDNET, SETTINGS_DDNET,
SETTINGS_ASSETS, SETTINGS_ASSETS,
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 // DDRace
int DoButton_CheckBox_DontCare(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_CheckBox_DontCare(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
sorted_array<CDemoItem> m_lDemos; sorted_array<CDemoItem> m_lDemos;

View file

@ -1368,15 +1368,15 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
ms_ColorTabbarInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f); ms_ColorTabbarInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f);
static int s_FiltersTab = 0; 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; ToolboxPage = 0;
static int s_InfoTab = 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; ToolboxPage = 1;
static int s_FriendsTab = 0; 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; ToolboxPage = 2;
ms_ColorTabbarActive = Active; ms_ColorTabbarActive = Active;

View file

@ -1496,7 +1496,7 @@ void CMenus::RenderSettings(CUIRect MainView)
{ {
TabBar.HSplitTop(10, &Button, &TabBar); TabBar.HSplitTop(10, &Button, &TabBar);
TabBar.HSplitTop(26, &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_aAnimatorsSettingsTab[i]))
g_Config.m_UiSettingsPage = i; g_Config.m_UiSettingsPage = i;
} }
@ -1723,7 +1723,6 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s (echo)", Localize("Client message")); str_format(aBuf, sizeof(aBuf), "%s (echo)", Localize("Client message"));
DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, aBuf, &g_Config.m_ClMessageClientColor, ColorRGBA(0.5f, 0.78f, 1.0f)); DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, aBuf, &g_Config.m_ClMessageClientColor, ColorRGBA(0.5f, 0.78f, 1.0f));
// ***** Chat Preview ***** // // ***** Chat Preview ***** //
Chat.HSplitTop(10.0f, 0x0, &Chat); Chat.HSplitTop(10.0f, 0x0, &Chat);

View file

@ -310,13 +310,13 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
Page2Tab.VSplitLeft(TabsW / 4, &Page2Tab, &Page3Tab); Page2Tab.VSplitLeft(TabsW / 4, &Page2Tab, &Page3Tab);
Page3Tab.VSplitLeft(TabsW / 4, &Page3Tab, &Page4Tab); 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; 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; 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; 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; s_CurCustomTab = 3;
if(s_CurCustomTab == 0) if(s_CurCustomTab == 0)

View file

@ -30,6 +30,22 @@ static bool IsVanillaSkin(const char *pName)
return false; 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) int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
{ {
CSkins *pSelf = (CSkins *)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) int CSkins::LoadSkin(const char *pName, const char *pPath, int DirType)
{ {
char aBuf[512];
CImageInfo Info; 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); str_format(aBuf, sizeof(aBuf), "failed to load skin from %s", pName);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); 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; return 0;
} }
@ -366,7 +402,7 @@ int CSkins::FindImpl(const char *pName)
char aPath[MAX_PATH_LENGTH]; char aPath[MAX_PATH_LENGTH];
str_format(aPath, sizeof(aPath), "downloadedskins/%s.png", d.front().m_aName); str_format(aPath, sizeof(aPath), "downloadedskins/%s.png", d.front().m_aName);
Storage()->RenameFile(d.front().m_aPath, aPath, IStorage::TYPE_SAVE); 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; d.front().m_pTask = nullptr;
} }
if(d.front().m_pTask && (d.front().m_pTask->State() == HTTP_ERROR || d.front().m_pTask->State() == HTTP_ABORTED)) 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]; char aUrl[256];
str_format(aUrl, sizeof(aUrl), "%s%s.png", g_Config.m_ClSkinDownloadUrl, pName); 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()); str_format(Skin.m_aPath, sizeof(Skin.m_aPath), "downloadedskins/%s.%d.tmp", pName, pid());
Skin.m_pTask = std::make_shared<CGetFile>(Storage(), aUrl, Skin.m_aPath, IStorage::TYPE_SAVE, CTimeout{0, 0, 0}, false); Skin.m_pTask = std::make_shared<CGetPngFile>(this, Storage(), aUrl, Skin.m_aPath, IStorage::TYPE_SAVE, CTimeout{0, 0, 0}, false);
m_pClient->Engine()->AddJob(Skin.m_pTask); m_pClient->Engine()->AddJob(Skin.m_pTask);
m_aDownloadSkins.add(Skin); m_aDownloadSkins.add(Skin);
return -1; return -1;

View file

@ -12,9 +12,21 @@
class CSkins : public CComponent class CSkins : public CComponent
{ {
public: 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 struct CDownloadSkin
{ {
std::shared_ptr<CGetFile> m_pTask; std::shared_ptr<CSkins::CGetPngFile> m_pTask;
char m_aPath[MAX_PATH_LENGTH]; char m_aPath[MAX_PATH_LENGTH];
char m_aName[24]; char m_aName[24];
@ -35,7 +47,9 @@ private:
sorted_array<CDownloadSkin> m_aDownloadSkins; sorted_array<CDownloadSkin> m_aDownloadSkins;
char m_EventSkinPrefix[24]; 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, const char *pPath, int DirType);
int LoadSkin(const char *pName, CImageInfo &Info);
int FindImpl(const char *pName); int FindImpl(const char *pName);
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser); static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
}; };

View file

@ -102,6 +102,21 @@ public:
void HMargin(float Cut, CUIRect *pOtherRect) const; void HMargin(float Cut, CUIRect *pOtherRect) const;
}; };
struct SUIAnimator
{
bool m_Active;
bool m_ScaleLabel;
bool m_RepositionLabel;
int64 m_Time;
float m_Value;
float m_XOffset;
float m_YOffset;
float m_WOffset;
float m_HOffset;
};
class CUI; class CUI;
class CUIElement class CUIElement

View file

@ -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)); str_copy(m_aSettingsCommand, m_Map.m_lSettings[s_CommandSelectedIndex].m_aCommand, sizeof(m_aSettingsCommand));
UI()->SetActiveItem(&m_CommandBox); 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--;
}
} }
} }

View file

@ -3,11 +3,11 @@
#ifndef GAME_VERSION_H #ifndef GAME_VERSION_H
#define GAME_VERSION_H #define GAME_VERSION_H
#ifndef GAME_RELEASE_VERSION #ifndef GAME_RELEASE_VERSION
#define GAME_RELEASE_VERSION "15.2.3" #define GAME_RELEASE_VERSION "15.2.4"
#endif #endif
#define GAME_VERSION "0.6.4, " GAME_RELEASE_VERSION #define GAME_VERSION "0.6.4, " GAME_RELEASE_VERSION
#define GAME_NETVERSION "0.6 626fce9a778df4d4" #define GAME_NETVERSION "0.6 626fce9a778df4d4"
#define GAME_NAME "DDNet" #define GAME_NAME "DDNet"
#define CLIENT_VERSIONNR 15023 #define CLIENT_VERSIONNR 15024
extern const char *GIT_SHORTREV_HASH; extern const char *GIT_SHORTREV_HASH;
#endif #endif