Merge pull request #8192 from dobrykafe/pr-conchain-bg-entities

Add console chain for `ClBackgroundEntities`
This commit is contained in:
Dennis Felsing 2024-04-08 12:39:00 +00:00 committed by GitHub
commit 8f58cbaea3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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_music", ConchainUpdateMusicState, this);
Console()->Chain("cl_background_entities", ConchainBackgroundEntities, this);
Console()->Chain("cl_assets_entities", ConchainAssetsEntities, 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");
}
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)
{
pfnCallback(pResult, pCallbackUserData);

View file

@ -427,6 +427,8 @@ protected:
#endif
void RenderMenubar(CUIRect Box, IClient::EClientState ClientState);
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);
void UpdateMusicState();

View file

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