Add DDNet settings button to unregister protocol and file extensions

Add a button to the Miscellaneous DDNet settings to manually unregister the protocol and file extension handlers.
This commit is contained in:
Robert Müller 2022-12-29 17:16:51 +01:00
parent db3d1f19a9
commit a61eec8f1e
4 changed files with 26 additions and 0 deletions

View file

@ -283,6 +283,7 @@ public:
#if defined(CONF_FAMILY_WINDOWS) #if defined(CONF_FAMILY_WINDOWS)
virtual void ShellRegister() = 0; virtual void ShellRegister() = 0;
virtual void ShellUnregister() = 0;
#endif #endif
}; };

View file

@ -4928,4 +4928,17 @@ void CClient::ShellRegister()
if(Updated) if(Updated)
shell_update(); shell_update();
} }
void CClient::ShellUnregister()
{
bool Updated = false;
if(!shell_unregister("ddnet", &Updated))
dbg_msg("client", "Failed to unregister ddnet protocol");
if(!shell_unregister(GAME_NAME ".map", &Updated))
dbg_msg("client", "Failed to unregister .map file extension");
if(!shell_unregister(GAME_NAME ".demo", &Updated))
dbg_msg("client", "Failed to unregister .demo file extension");
if(Updated)
shell_update();
}
#endif #endif

View file

@ -549,6 +549,7 @@ public:
#if defined(CONF_FAMILY_WINDOWS) #if defined(CONF_FAMILY_WINDOWS)
void ShellRegister() override; void ShellRegister() override;
void ShellUnregister() override;
#endif #endif
}; };

View file

@ -3433,6 +3433,17 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
SUIExEditBoxProperties EditProps; SUIExEditBoxProperties EditProps;
EditProps.m_pEmptyText = Localize("Chat command (e.g. showall 1)"); EditProps.m_pEmptyText = Localize("Chat command (e.g. showall 1)");
UI()->DoEditBox(g_Config.m_ClRunOnJoin, &Button, g_Config.m_ClRunOnJoin, sizeof(g_Config.m_ClRunOnJoin), 14.0f, &s_RunOnJoin, false, IGraphics::CORNER_ALL, EditProps); UI()->DoEditBox(g_Config.m_ClRunOnJoin, &Button, g_Config.m_ClRunOnJoin, sizeof(g_Config.m_ClRunOnJoin), 14.0f, &s_RunOnJoin, false, IGraphics::CORNER_ALL, EditProps);
#if defined(CONF_FAMILY_WINDOWS)
static CButtonContainer s_ButtonUnregisterShell;
Right.HSplitTop(10.0f, nullptr, &Right);
Right.HSplitTop(20.0f, &Button, &Right);
if(DoButton_Menu(&s_ButtonUnregisterShell, Localize("Unregister protocol and file extensions"), 0, &Button))
{
Client()->ShellUnregister();
}
#endif
// Updater // Updater
#if defined(CONF_AUTOUPDATE) #if defined(CONF_AUTOUPDATE)
{ {