Move News/Website/Wiki/Discord to bottom left

This commit is contained in:
def 2020-09-07 12:05:34 +02:00
parent 83d297a370
commit 0aef743d7a
3 changed files with 50 additions and 48 deletions

View file

@ -213,7 +213,6 @@ void CBinds::SetDefaults()
UnbindAll();
Bind(KEY_F1, "toggle_local_console");
Bind(KEY_F2, "toggle_remote_console");
Bind(KEY_F7, "toggle_server_console");
Bind(KEY_TAB, "+scoreboard");
Bind(KEY_EQUALS, "+statboard");
Bind(KEY_F10, "screenshot");
@ -447,9 +446,7 @@ void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData)
void CBinds::SetDDRaceBinds(bool FreeOnly)
{
if(g_Config.m_ClDDRaceBindsSet < 2)
{
Bind(KEY_F7, "toggle_server_console", FreeOnly);
}
Bind(KEY_F7, "toggle_econ_console", FreeOnly);
if(g_Config.m_ClDDRaceBindsSet < 1)
{

View file

@ -2071,27 +2071,6 @@ extern "C" void font_debug_render();
void CMenus::OnRender()
{
if(m_ServerProcess.Process != 0)
{
// TODO: Maybe call this less often, or probably even cleaner, use econ
if(!m_ServerProcess.Initialized)
{
char aBuf[MAX_PATH_LENGTH];
IOHANDLE File = Storage()->OpenFile(Storage()->GetBinaryPath("autoexec_server.log", aBuf, sizeof(aBuf)), IOFLAG_READ, IStorage::TYPE_ALL);
if(File)
{
m_ServerProcess.LineReader.Init(File);
m_ServerProcess.Initialized = true;
}
}
if(m_ServerProcess.Initialized)
{
const char *pLine = m_ServerProcess.LineReader.Get();
if(pLine)
GameClient()->m_pGameConsole->PrintLine(CGameConsole::CONSOLETYPE_ECON, pLine);
}
}
if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)
SetActive(true);

View file

@ -28,19 +28,64 @@ void CMenus::RenderStartMenu(CUIRect MainView)
const float Rounding = 10.0f;
const float VMargin = MainView.w/2-190.0f;
CUIRect Button;
int NewPage = -1;
CUIRect ExtMenu;
MainView.VSplitLeft(30.0f, 0, &ExtMenu);
ExtMenu.VSplitLeft(100.0f, &ExtMenu, 0);
ExtMenu.HSplitBottom(30.0f, &ExtMenu, &Button);
static int s_DiscordButton;
if(DoButton_Menu(&s_DiscordButton, "Discord", 0, &Button, 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)))
{
if(!open_link("https://ddnet.tw/discord"))
{
dbg_msg("menus", "couldn't open link");
}
m_DoubleClickIndex = -1;
}
ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space
ExtMenu.HSplitBottom(30.0f, &ExtMenu, &Button);
static int s_LearnButton;
if(DoButton_Menu(&s_LearnButton, Localize("Learn"), 0, &Button, 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)))
{
if(!open_link(Localize("https://wiki.ddnet.tw/")))
{
dbg_msg("menus", "couldn't open link");
}
m_DoubleClickIndex = -1;
}
ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space
ExtMenu.HSplitBottom(30.0f, &ExtMenu, &Button);
static int s_WebsiteButton;
if(DoButton_Menu(&s_WebsiteButton, Localize("Website"), 0, &Button, 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)))
{
if(!open_link("https://ddnet.tw/"))
{
dbg_msg("menus", "couldn't open link");
}
m_DoubleClickIndex = -1;
}
ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space
ExtMenu.HSplitBottom(30.0f, &ExtMenu, &Button);
static int s_NewsButton;
if(DoButton_Menu(&s_NewsButton, Localize("News"), 0, &Button, 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), g_Config.m_UiUnreadNews ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_N))
NewPage = PAGE_NEWS;
CUIRect Menu;
MainView.VMargin(VMargin, &Menu);
Menu.HSplitBottom(20.0f, &Menu, 0);
CUIRect Button;
int NewPage = -1;
Menu.HSplitBottom(40.0f, &Menu, &Button);
static int s_QuitButton;
if(DoButton_Menu(&s_QuitButton, Localize("Quit"), 0, &Button, 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || m_EscapePressed || CheckHotKey(KEY_Q))
m_Popup = POPUP_QUIT;
Menu.HSplitBottom(40.0f, &Menu, 0);
Menu.HSplitBottom(100.0f, &Menu, 0);
Menu.HSplitBottom(40.0f, &Menu, &Button);
static int s_SettingsButton;
if(DoButton_Menu(&s_SettingsButton, Localize("Settings"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "settings" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_S))
@ -58,30 +103,11 @@ void CMenus::RenderStartMenu(CUIRect MainView)
}
else
{
Storage()->RemoveBinaryFile("autoexec_server.log");
char aBuf[MAX_PATH_LENGTH];
m_ServerProcess.Process = shell_execute(Storage()->GetBinaryPath(PLAT_SERVER_EXEC, aBuf, sizeof(aBuf)));
}
}
Menu.HSplitBottom(5.0f, &Menu, 0); // little space
Menu.HSplitBottom(40.0f, &Menu, &Button);
static int s_LearnButton;
if(DoButton_Menu(&s_LearnButton, Localize("Learn"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "learn" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_L))
{
if(!open_link(Localize("https://wiki.ddnet.tw/")))
{
dbg_msg("menus", "couldn't open link");
}
m_DoubleClickIndex = -1;
}
Menu.HSplitBottom(5.0f, &Menu, 0); // little space
Menu.HSplitBottom(40.0f, &Menu, &Button);
static int s_NewsButton;
if(DoButton_Menu(&s_NewsButton, Localize("News"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "news" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), g_Config.m_UiUnreadNews ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_N))
NewPage = PAGE_NEWS;
static bool EditorHotkeyWasPressed = true;
static float EditorHotKeyChecktime = 0;
Menu.HSplitBottom(5.0f, &Menu, 0); // little space