* Second DDNet settings page with some settings
 * Auto reconnect feature
 * In-game commands:
  - reconnect_ban
  - reconnect_ban_timeout
  - reconnect_full
  - reconnect_full_timeout
Changed:
 * Disconnected popup
 * Name for first DDNet settings page

Signed-off-by: CookieMichal <MrCookieMichal@gmail.com>
This commit is contained in:
CookieMichal 2014-06-27 00:28:57 +02:00
parent d023db5dfd
commit b9943706b3
4 changed files with 119 additions and 4 deletions

View file

@ -216,6 +216,11 @@ MACRO_CONFIG_INT(SvAnnouncementRandom, sv_announcement_random, 1, 0, 1, CFGFLAG_
MACRO_CONFIG_INT(SvOldLaser, sv_old_laser, 0, 0, 1, CFGFLAG_SERVER, "Whether lasers can hit you if you shot them and that they pull you towards the bounce origin (0 for DDRace Beta) or lasers can't hit you if you shot them, and they pull others towards the shooter")
MACRO_CONFIG_INT(SvSlashMe, sv_slash_me, 0, 0, 1, CFGFLAG_SERVER, "Whether /me is active on the server or not")
MACRO_CONFIG_INT(ReconnectBanEnable, reconnect_ban, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Auto reconnect when banned")
MACRO_CONFIG_INT(ReconnectFullEnable, reconnect_full, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Auto reconnect when server is full")
MACRO_CONFIG_INT(ReconnectBanTimeout, reconnect_ban_timeout, 30, 5, 120, CFGFLAG_CLIENT | CFGFLAG_SAVE, "How many seconds to wait before reconnecting (when banned)")
MACRO_CONFIG_INT(ReconnectFullTimeout, reconnect_full_timeout, 5, 1, 120, CFGFLAG_CLIENT | CFGFLAG_SAVE, "How many seconds to wait before reconnecting (when server is full)")
MACRO_CONFIG_INT(ConnTimeout, conn_timeout, 100, 5, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Network timeout")
MACRO_CONFIG_INT(ClShowIDs, cl_show_ids, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Whether to show client ids in scoreboard")
MACRO_CONFIG_INT(ClAutoRaceRecord, cl_auto_race_record, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Save the best demo of each race")

View file

@ -972,12 +972,36 @@ int CMenus::Render()
pExtraText = "";
}
}
else if(m_Popup == POPUP_DISCONNECTED)
else if (m_Popup == POPUP_DISCONNECTED)
{
pTitle = Localize("Disconnected");
pExtraText = Client()->ErrorString();
pButtonText = Localize("Ok");
ExtraAlign = -1;
if ((str_find_nocase(Client()->ErrorString(), "full")) || (str_find_nocase(Client()->ErrorString(), "reserved")))
{
if (g_Config.m_ReconnectFullEnable)
{
if (_my_rtime == 0)
_my_rtime = time_get();
str_format(aBuf, sizeof(aBuf), Localize("\n\nReconnect in %d sec"), ((_my_rtime - time_get()) / time_freq() + g_Config.m_ReconnectFullTimeout));
pTitle = Client()->ErrorString();
pExtraText = aBuf;
pButtonText = Localize("Abort");
}
}
else if (str_find_nocase(Client()->ErrorString(), "ban"))
{
if (g_Config.m_ReconnectBanEnable)
{
if (_my_rtime == 0)
_my_rtime = time_get();
str_format(aBuf, sizeof(aBuf), Localize("\n\nReconnect in %d sec"), ((_my_rtime - time_get()) / time_freq() + g_Config.m_ReconnectBanTimeout));
pTitle = Client()->ErrorString();
pExtraText = aBuf;
pButtonText = Localize("Abort");
}
}
ExtraAlign = 0;
}
else if(m_Popup == POPUP_PURE)
{
@ -1508,6 +1532,22 @@ int CMenus::Render()
UI()->SetActiveItem(0);
}
if (m_Popup == POPUP_DISCONNECTED && ((g_Config.m_ReconnectFullEnable) || (g_Config.m_ReconnectBanEnable)))
{
if ((str_find_nocase(Client()->ErrorString(), "full")) || (str_find_nocase(Client()->ErrorString(), "reserved")))
{
if (time_get() > _my_rtime + time_freq() * g_Config.m_ReconnectFullTimeout)
Client()->Connect(g_Config.m_UiServerAddress);
}
else if (str_find_nocase(Client()->ErrorString(), "ban"))
{
if (time_get() > _my_rtime + time_freq() * g_Config.m_ReconnectBanTimeout)
Client()->Connect(g_Config.m_UiServerAddress);
}
}
else if (_my_rtime != 0) {
_my_rtime = 0;
}
return 0;
}

View file

@ -285,7 +285,7 @@ public:
};
// DDRace
int64 _my_rtime; // reconnect time
int DoButton_CheckBox_DontCare(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
sorted_array<CDemoItem> m_lDemos;
void DemolistPopulate();
@ -341,5 +341,6 @@ private:
// found in menus_settings.cpp
void RenderSettingsDDRace(CUIRect MainView);
void RenderSettingsDDRaceTwo(CUIRect MainView);
};
#endif

View file

@ -1100,7 +1100,8 @@ void CMenus::RenderSettings(CUIRect MainView)
Localize("Controls"),
Localize("Graphics"),
Localize("Sound"),
Localize("DDNet")
Localize("DDNet 1/2"),
Localize("DDNet 2/2")
};
int NumTabs = (int)(sizeof(aTabs)/sizeof(*aTabs));
@ -1131,6 +1132,8 @@ void CMenus::RenderSettings(CUIRect MainView)
RenderSettingsSound(MainView);
else if(s_SettingsPage == 7)
RenderSettingsDDRace(MainView);
else if (s_SettingsPage == 8)
RenderSettingsDDRaceTwo(MainView);
if(m_NeedRestartGraphics || m_NeedRestartSound)
UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 15.0f, -1);
@ -1405,3 +1408,69 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
g_Config.m_ConnTimeout = clamp(str_toint(aBuf), 5, 1000);
}
}
void CMenus::RenderSettingsDDRaceTwo(CUIRect MainView)
{
CUIRect AutoReconnect, Label, Button, Left, Right;
MainView.HSplitTop(130.0f, &AutoReconnect, &MainView);
AutoReconnect.HSplitTop(30.0f, &Label, &AutoReconnect);
UI()->DoLabelScaled(&Label, Localize("Auto reconnecting"), 20.0f, -1);
AutoReconnect.Margin(5.0f, &AutoReconnect);
AutoReconnect.VSplitMid(&Left, &Right);
Left.VSplitRight(5.0f, &Left, 0);
Right.VMargin(5.0f, &Right);
{
Right.HSplitTop(20.0f, &Button, &Right);
if (DoButton_CheckBox(&g_Config.m_ReconnectFullEnable, Localize("Reconnect when server is full"), g_Config.m_ReconnectFullEnable, &Button))
{
g_Config.m_ReconnectFullEnable ^= 1;
}
Left.HSplitTop(20.0f, &Button, &Left);
if (DoButton_CheckBox(&g_Config.m_ReconnectBanEnable, Localize("Reconnect when you are banned"), g_Config.m_ReconnectBanEnable, &Button))
{
g_Config.m_ReconnectBanEnable ^= 1;
}
Left.HSplitTop(10.0f, 0, &Left);
Left.VSplitLeft(20.0f, 0, &Left);
Left.HSplitTop(20.0f, &Label, &Left);
Button.VSplitRight(20.0f, &Button, 0);
char aBuf[64];
if (g_Config.m_ReconnectBanTimeout == 1)
{
str_format(aBuf, sizeof(aBuf), "%s: %i %s", Localize("Wait before try for"), g_Config.m_ReconnectBanTimeout, Localize("second"));
}
else
{
str_format(aBuf, sizeof(aBuf), "%s: %i %s", Localize("Wait before try for"), g_Config.m_ReconnectBanTimeout, Localize("seconds"));
}
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
Left.HSplitTop(20.0f, &Button, 0);
Button.HMargin(2.0f, &Button);
g_Config.m_ReconnectBanTimeout = static_cast<int>(DoScrollbarH(&g_Config.m_ReconnectBanTimeout, &Button, g_Config.m_ReconnectBanTimeout / 120.0f) * 120.0f);
if (g_Config.m_ReconnectBanTimeout < 5)
g_Config.m_ReconnectBanTimeout = 5;
Right.HSplitTop(10.0f, 0, &Right);
Right.VSplitLeft(20.0f, 0, &Right);
Right.HSplitTop(20.0f, &Label, &Right);
Button.VSplitRight(20.0f, &Button, 0);
if (g_Config.m_ReconnectFullTimeout == 1)
{
str_format(aBuf, sizeof(aBuf), "%s: %i %s", Localize("Wait before try for"), g_Config.m_ReconnectFullTimeout, Localize("second"));
}
else
{
str_format(aBuf, sizeof(aBuf), "%s: %i %s", Localize("Wait before try for"), g_Config.m_ReconnectFullTimeout, Localize("seconds"));
}
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
Right.HSplitTop(20.0f, &Button, 0);
Button.HMargin(2.0f, &Button);
g_Config.m_ReconnectFullTimeout = static_cast<int>(DoScrollbarH(&g_Config.m_ReconnectFullTimeout, &Button, g_Config.m_ReconnectFullTimeout / 120.0f) * 120.0f);
if (g_Config.m_ReconnectFullTimeout < 1)
g_Config.m_ReconnectFullTimeout = 1;
}
}