mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add Learn button which opens the ddnet wiki in the browser.
This commit is contained in:
parent
e36dc36b15
commit
07f0239e01
|
@ -3247,6 +3247,21 @@ void shell_execute(const char *file)
|
|||
#endif
|
||||
}
|
||||
|
||||
int open_link(const char *link)
|
||||
{
|
||||
char aBuf[512];
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
str_format(aBuf, sizeof(aBuf), "start %s", link);
|
||||
return (uintptr_t)ShellExecuteA(NULL, "open", link, NULL, NULL, SW_SHOWDEFAULT) > 32;
|
||||
#elif defined(CONF_PLATFORM_LINUX)
|
||||
str_format(aBuf, sizeof(aBuf), "xdg-open %s", link);
|
||||
return system(aBuf) == 0;
|
||||
#elif defined(CONF_FAMILY_UNIX)
|
||||
str_format(aBuf, sizeof(aBuf), "open %s", link);
|
||||
return system(aBuf) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int os_is_winxp_or_lower(void)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
|
|
|
@ -1656,6 +1656,21 @@ int net_would_block(void);
|
|||
|
||||
int net_socket_read_wait(NETSOCKET sock, int time);
|
||||
|
||||
/*
|
||||
Function: open_link
|
||||
Opens a link in the browser.
|
||||
|
||||
Parameters:
|
||||
link - The link to open in a browser.
|
||||
|
||||
Returns:
|
||||
Returns 1 on success, 0 on failure.
|
||||
|
||||
Remarks:
|
||||
This may not be called with untrusted input or it'll result in arbitrary code execution.
|
||||
*/
|
||||
int open_link(const char *link);
|
||||
|
||||
void swap_endian(void *data, unsigned elem_size, unsigned num);
|
||||
|
||||
|
||||
|
|
|
@ -676,11 +676,22 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
// offline menus
|
||||
Box.VSplitLeft(90.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_TL))
|
||||
{
|
||||
NewPage = PAGE_NEWS;
|
||||
m_DoubleClickIndex = -1;
|
||||
}
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
static int s_LearnButton=0;
|
||||
if(DoButton_MenuTab(&s_LearnButton, Localize("Learn"), false, &Button, CUI::CORNER_TR))
|
||||
{
|
||||
if(!open_link("https://wiki.ddnet.tw/"))
|
||||
{
|
||||
dbg_msg("menus", "couldn't open link");
|
||||
}
|
||||
m_DoubleClickIndex = -1;
|
||||
}
|
||||
|
||||
Box.VSplitLeft(10.0f, 0, &Box);
|
||||
|
||||
Box.VSplitLeft(100.0f, &Button, &Box);
|
||||
|
|
Loading…
Reference in a new issue