mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add some indication that the update is happening.
Prevent unexpected restart.
This commit is contained in:
parent
a4d16a2713
commit
1f4ddfe0ba
|
@ -127,6 +127,7 @@ class CMenus : public CComponent
|
|||
bool m_NeedRestartSkins;
|
||||
bool m_NeedRestartGraphics;
|
||||
bool m_NeedRestartSound;
|
||||
bool m_NeedRestartUpdate;
|
||||
bool m_NeedSendinfo;
|
||||
bool m_NeedSendDummyinfo;
|
||||
int m_SettingPlayerPage;
|
||||
|
|
|
@ -1276,6 +1276,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
|
|||
char aBuf[64];
|
||||
int State = AutoUpdate()->GetCurrentState();
|
||||
bool NeedUpdate = str_comp(Client()->LatestVersion(), "0");
|
||||
static bool Initiated = false;
|
||||
if(State == IAutoUpdate::CLEAN && NeedUpdate)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "DDNet %s is out! Download?", Client()->LatestVersion());
|
||||
|
@ -1285,19 +1286,25 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), Localize("Current version: %s"), GAME_VERSION);
|
||||
else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART)
|
||||
str_format(aBuf, sizeof(aBuf), "Downloading %s:", AutoUpdate()->GetCurrentFile());
|
||||
else if(State == IAutoUpdate::NEED_RESTART){
|
||||
else if(State == IAutoUpdate::NEED_RESTART && Initiated)
|
||||
{
|
||||
static float s_Counter = Client()->LocalTime() + 5.0f;
|
||||
str_format(aBuf, sizeof(aBuf), "DDNet Client will restart in %d", (int)(s_Counter - Client()->LocalTime()));
|
||||
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
|
||||
if(Client()->LocalTime() > s_Counter)
|
||||
Client()->Restart();
|
||||
}
|
||||
else if(State == IAutoUpdate::NEED_RESTART && !Initiated){
|
||||
str_format(aBuf, sizeof(aBuf), "DDNet Client needs to be restarted to complete update!");
|
||||
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
|
||||
}
|
||||
UI()->DoLabelScaled(&Button, aBuf, 14.0f, -1);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
Button.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1) + 10.0f, &Button, &Part);
|
||||
|
||||
if(State == IAutoUpdate::CLEAN && NeedUpdate){
|
||||
if(State == IAutoUpdate::CLEAN && NeedUpdate)
|
||||
{
|
||||
CUIRect Yes, No;
|
||||
Part.VSplitLeft(30.0f, &Yes, &No);
|
||||
No.VMargin(5.0f, &No);
|
||||
|
@ -1305,13 +1312,17 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
|
|||
|
||||
static int s_ButtonUpdate = 0;
|
||||
if(DoButton_Menu(&s_ButtonUpdate, Localize("Yes"), 0, &Yes))
|
||||
{
|
||||
AutoUpdate()->InitiateUpdate();
|
||||
Initiated = true;
|
||||
}
|
||||
|
||||
static int s_ButtonNUpdate = 0;
|
||||
if(DoButton_Menu(&s_ButtonNUpdate, Localize("No"), 0, &No))
|
||||
AutoUpdate()->IgnoreUpdate();
|
||||
}
|
||||
else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART){
|
||||
else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART)
|
||||
{
|
||||
CUIRect ProgressBar, Percent;
|
||||
Part.VSplitLeft(100.0f, &ProgressBar, &Percent);
|
||||
ProgressBar.y += 2.0f;
|
||||
|
|
|
@ -1110,9 +1110,10 @@ void CMenus::RenderSettings(CUIRect MainView)
|
|||
|
||||
// render background
|
||||
CUIRect Temp, TabBar, RestartWarning;
|
||||
MainView.HSplitBottom(15.0f, &MainView, &RestartWarning);
|
||||
MainView.VSplitRight(120.0f, &MainView, &TabBar);
|
||||
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_B|CUI::CORNER_TL, 10.0f);
|
||||
MainView.Margin(10.0f, &MainView);
|
||||
MainView.HSplitBottom(15.0f, &MainView, &RestartWarning);
|
||||
TabBar.HSplitTop(50.0f, &Temp, &TabBar);
|
||||
RenderTools()->DrawUIRect(&Temp, ms_ColorTabbarActive, CUI::CORNER_R, 10.0f);
|
||||
|
||||
|
@ -1163,8 +1164,14 @@ void CMenus::RenderSettings(CUIRect MainView)
|
|||
else if(s_SettingsPage == 8)
|
||||
RenderSettingsDDRace(MainView);
|
||||
|
||||
if(m_NeedRestartSkins || m_NeedRestartGraphics || m_NeedRestartSound)
|
||||
UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 15.0f, -1);
|
||||
if(m_NeedRestartUpdate)
|
||||
{
|
||||
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
|
||||
UI()->DoLabelScaled(&RestartWarning, "DDNet Client needs to be restarted to complete update!", 14.0f, -1);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
else if(m_NeedRestartSkins || m_NeedRestartGraphics || m_NeedRestartSound)
|
||||
UI()->DoLabelScaled(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 14.0f, -1);
|
||||
}
|
||||
void CMenus::RenderSettingsHUD(CUIRect MainView)
|
||||
{
|
||||
|
@ -1791,22 +1798,33 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
|
|||
g_Config.m_ClHttpMapDownload ^= 1;
|
||||
}
|
||||
|
||||
//AutoUpdate
|
||||
{
|
||||
Left.HSplitTop(20.0f, &Label, &Left);
|
||||
bool NeedUpdate = str_comp(Client()->LatestVersion(), "0");
|
||||
char aBuf[256];
|
||||
if(NeedUpdate)
|
||||
int State = AutoUpdate()->GetCurrentState();
|
||||
|
||||
//Update Button
|
||||
if(NeedUpdate && State <= IAutoUpdate::CLEAN)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "DDNet %s is available:", Client()->LatestVersion());
|
||||
Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1) + 10.0f, &Label, &Button);
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
Button.VSplitLeft(150.0f, &Button, 0);
|
||||
static int s_ButtonUpdate = 0;
|
||||
if(DoButton_Menu(&s_ButtonUpdate, "Update Now", 0, &Button))
|
||||
AutoUpdate()->InitiateUpdate();
|
||||
}
|
||||
else if(State >= IAutoUpdate::CLEAN && State < IAutoUpdate::NEED_RESTART)
|
||||
str_format(aBuf, sizeof(aBuf), "Updating...");
|
||||
else if(State == IAutoUpdate::NEED_RESTART){
|
||||
str_format(aBuf, sizeof(aBuf), "Done");
|
||||
m_NeedRestartUpdate = true;
|
||||
}
|
||||
else
|
||||
UI()->DoLabelScaled(&Label, "No updates available", 14.0f, -1);
|
||||
str_format(aBuf, sizeof(aBuf), "No updates available");
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue