Center update info text, add -DINFORM_UPDATE flag

to be used for Steam release, since autoupdates are enforced anyway and
players don't need to be reminded to update
This commit is contained in:
def 2020-09-23 22:42:54 +02:00
parent eb725f800e
commit ebb4e3debe
2 changed files with 17 additions and 11 deletions

View file

@ -89,6 +89,7 @@ endif()
option(WEBSOCKETS "Enable websockets support" OFF) option(WEBSOCKETS "Enable websockets support" OFF)
option(MYSQL "Enable mysql support" OFF) option(MYSQL "Enable mysql support" OFF)
option(AUTOUPDATE "Enable the autoupdater" OFF) option(AUTOUPDATE "Enable the autoupdater" OFF)
option(INFORM_UPDATE "Inform about available updates" ON)
option(VIDEORECORDER "Enable video recording support via FFmpeg" OFF) option(VIDEORECORDER "Enable video recording support via FFmpeg" OFF)
option(UPNP "Enable UPnP support" OFF) option(UPNP "Enable UPnP support" OFF)
option(ANTIBOT "Enable support for a dynamic anticheat library" OFF) option(ANTIBOT "Enable support for a dynamic anticheat library" OFF)
@ -2615,6 +2616,9 @@ foreach(target ${TARGETS_OWN})
if(AUTOUPDATE) if(AUTOUPDATE)
target_compile_definitions(${target} PRIVATE CONF_AUTOUPDATE) target_compile_definitions(${target} PRIVATE CONF_AUTOUPDATE)
endif() endif()
if(INFORM_UPDATE)
target_compile_definitions(${target} PRIVATE CONF_INFORM_UPDATE)
endif()
endforeach() endforeach()
foreach(target ${TARGETS_DEP}) foreach(target ${TARGETS_DEP})

View file

@ -160,14 +160,15 @@ void CMenus::RenderStartMenu(CUIRect MainView)
} }
// render version // render version
CUIRect Version; CUIRect VersionUpdate, CurVersion;
MainView.HSplitBottom(30.0f, 0, &Version); MainView.HSplitBottom(30.0f, 0, 0);
MainView.HSplitBottom(20.0f, 0, &Version); MainView.HSplitBottom(20.0f, 0, &VersionUpdate);
Version.VSplitLeft(VMargin, 0, &Version);
Version.VSplitRight(50.0f, &Version, 0); VersionUpdate.VSplitRight(50.0f, &CurVersion, 0);
char aBuf[64]; VersionUpdate.VMargin(VMargin, &VersionUpdate);
#if defined(CONF_AUTOUPDATE) #if defined(CONF_AUTOUPDATE)
char aBuf[64];
CUIRect Part; CUIRect Part;
int State = Updater()->GetCurrentState(); int State = Updater()->GetCurrentState();
bool NeedUpdate = str_comp(Client()->LatestVersion(), "0"); bool NeedUpdate = str_comp(Client()->LatestVersion(), "0");
@ -196,10 +197,10 @@ void CMenus::RenderStartMenu(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), Localize("DDNet Client updated!")); str_format(aBuf, sizeof(aBuf), Localize("DDNet Client updated!"));
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
} }
UI()->DoLabel(&Version, aBuf, 14.0f, -1); UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, -1);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
Version.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part); VersionUpdate.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part);
if(State == IUpdater::CLEAN && NeedUpdate) if(State == IUpdater::CLEAN && NeedUpdate)
{ {
@ -233,17 +234,18 @@ void CMenus::RenderStartMenu(CUIRect MainView)
ProgressBar.w = clamp((float)Updater()->GetCurrentPercent(), 10.0f, 100.0f); ProgressBar.w = clamp((float)Updater()->GetCurrentPercent(), 10.0f, 100.0f);
RenderTools()->DrawUIRect(&ProgressBar, vec4(1.0f, 1.0f, 1.0f, 0.5f), CUI::CORNER_ALL, 5.0f); RenderTools()->DrawUIRect(&ProgressBar, vec4(1.0f, 1.0f, 1.0f, 0.5f), CUI::CORNER_ALL, 5.0f);
} }
#else #elif defined(CONF_INFORM_UPDATE)
if(str_comp(Client()->LatestVersion(), "0") != 0) if(str_comp(Client()->LatestVersion(), "0") != 0)
{ {
char aBuf[64];
str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is out!"), Client()->LatestVersion()); str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is out!"), Client()->LatestVersion());
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
UI()->DoLabel(&Version, aBuf, 14.0f, -1); UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, 0);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
} }
#endif #endif
UI()->DoLabel(&Version, GAME_RELEASE_VERSION, 14.0f, 1); UI()->DoLabel(&CurVersion, GAME_RELEASE_VERSION, 14.0f, 1);
if(NewPage != -1) if(NewPage != -1)
{ {