add console chain for ClBackgroundEntities

This commit is contained in:
dobrykafe 2024-04-08 12:26:25 +02:00
parent e63c9481e0
commit fd5d334cd1
3 changed files with 20 additions and 2 deletions

View file

@ -903,6 +903,7 @@ void CMenus::OnInit()
Console()->Chain("snd_enable", ConchainUpdateMusicState, this); Console()->Chain("snd_enable", ConchainUpdateMusicState, this);
Console()->Chain("snd_enable_music", ConchainUpdateMusicState, this); Console()->Chain("snd_enable_music", ConchainUpdateMusicState, this);
Console()->Chain("cl_background_entities", ConchainBackgroundEntities, this);
Console()->Chain("cl_assets_entities", ConchainAssetsEntities, this); Console()->Chain("cl_assets_entities", ConchainAssetsEntities, this);
Console()->Chain("cl_asset_game", ConchainAssetGame, this); Console()->Chain("cl_asset_game", ConchainAssetGame, this);
@ -938,6 +939,22 @@ void CMenus::OnConsoleInit()
Console()->Register("remove_favorite_skin", "s[skin_name]", CFGFLAG_CLIENT, Con_RemFavoriteSkin, this, "Remove a skin from the favorites"); Console()->Register("remove_favorite_skin", "s[skin_name]", CFGFLAG_CLIENT, Con_RemFavoriteSkin, this, "Remove a skin from the favorites");
} }
void CMenus::ConchainBackgroundEntities(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
pfnCallback(pResult, pCallbackUserData);
if(pResult->NumArguments())
{
CMenus *pSelf = (CMenus *)pUserData;
pSelf->UpdateBackgroundEntities();
}
}
void CMenus::UpdateBackgroundEntities()
{
if(str_comp(g_Config.m_ClBackgroundEntities, m_pClient->m_Background.MapName()) != 0)
m_pClient->m_Background.LoadBackground();
}
void CMenus::ConchainUpdateMusicState(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) void CMenus::ConchainUpdateMusicState(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{ {
pfnCallback(pResult, pCallbackUserData); pfnCallback(pResult, pCallbackUserData);

View file

@ -427,6 +427,8 @@ protected:
#endif #endif
void RenderMenubar(CUIRect Box, IClient::EClientState ClientState); void RenderMenubar(CUIRect Box, IClient::EClientState ClientState);
void RenderNews(CUIRect MainView); void RenderNews(CUIRect MainView);
static void ConchainBackgroundEntities(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
void UpdateBackgroundEntities();
static void ConchainUpdateMusicState(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainUpdateMusicState(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
void UpdateMusicState(); void UpdateMusicState();

View file

@ -3345,8 +3345,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
static CButtonContainer s_BackgroundEntitiesReloadButton; static CButtonContainer s_BackgroundEntitiesReloadButton;
if(DoButton_Menu(&s_BackgroundEntitiesReloadButton, Localize("Reload"), 0, &Button)) if(DoButton_Menu(&s_BackgroundEntitiesReloadButton, Localize("Reload"), 0, &Button))
{ {
if(str_comp(g_Config.m_ClBackgroundEntities, m_pClient->m_Background.MapName()) != 0) UpdateBackgroundEntities();
m_pClient->m_Background.LoadBackground();
} }
Background.HSplitTop(20.0f, &Button, &Background); Background.HSplitTop(20.0f, &Button, &Background);