mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Made the user interface functional.
This commit is contained in:
parent
233ce262ac
commit
cf418160b6
|
@ -22,6 +22,9 @@ public:
|
|||
virtual void InitiateUpdate() = 0;
|
||||
virtual void IgnoreUpdate() = 0;
|
||||
|
||||
virtual int GetCurrentState() = 0;
|
||||
virtual char *GetCurrentFile() = 0;
|
||||
virtual int GetCurrentPercent() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,9 @@ public:
|
|||
static void ProgressCallback(const char *pDest, void *pUser, double DlTotal, double DlCurr, double UlTotal, double UlCurr);
|
||||
static void CompletionCallback(const char *pDest, void *pUser);
|
||||
|
||||
int GetCurrentState() { return m_State; };
|
||||
char *GetCurrentFile() { return m_Status; };
|
||||
int GetCurrentPercent() { return m_Percent; };
|
||||
|
||||
virtual void InitiateUpdate();
|
||||
void IgnoreUpdate();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <engine/keys.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/autoupdate.h>
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
#include <game/generated/client_data.h>
|
||||
|
@ -1272,47 +1273,47 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
|
|||
// version note
|
||||
StatusBox.HSplitBottom(15.0f, &StatusBox, &Button);
|
||||
char aBuf[64];
|
||||
static int s_State = 0;
|
||||
if((s_State == 0 || s_State == 1) && str_comp(Client()->LatestVersion(), "0") != 0)
|
||||
int State = AutoUpdate()->GetCurrentState();
|
||||
bool NeedUpdate = str_comp(Client()->LatestVersion(), "0");
|
||||
if(State == IAutoUpdate::CLEAN && NeedUpdate)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "DDNet %s is out! Download?", Client()->LatestVersion());
|
||||
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
|
||||
s_State = 1;
|
||||
}
|
||||
else if(s_State <= 0)
|
||||
else if(State == IAutoUpdate::CLEAN || State == IAutoUpdate::IGNORED)
|
||||
str_format(aBuf, sizeof(aBuf), Localize("Current version: %s"), GAME_VERSION);
|
||||
else if(s_State == 2)
|
||||
str_format(aBuf, sizeof(aBuf), "Downloading example.dat:");
|
||||
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){
|
||||
str_format(aBuf, sizeof(aBuf), "Restart client to finish 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(s_State == 1){
|
||||
if(State == IAutoUpdate::CLEAN && NeedUpdate){
|
||||
CUIRect Yes, No;
|
||||
Part.VSplitLeft(30.0f, &Yes, &No);
|
||||
No.VMargin(5.0f, &No);
|
||||
No.VSplitLeft(30.0f, &No, 0);
|
||||
|
||||
static int s_ButtonUpdate = 0;
|
||||
if(DoButton_Menu(&s_ButtonUpdate, Localize("Yes"), 0, &Yes)){
|
||||
dbg_msg("Test", "OHMIGODITWERKZ");
|
||||
s_State = 2;
|
||||
}
|
||||
if(DoButton_Menu(&s_ButtonUpdate, Localize("Yes"), 0, &Yes))
|
||||
AutoUpdate()->InitiateUpdate();
|
||||
|
||||
static int s_ButtonNUpdate = 0;
|
||||
if(DoButton_Menu(&s_ButtonNUpdate, Localize("No"), 0, &No)){
|
||||
dbg_msg("Test", "OHMIGODITWERKZ");
|
||||
s_State = -1;
|
||||
}
|
||||
if(DoButton_Menu(&s_ButtonNUpdate, Localize("No"), 0, &No))
|
||||
AutoUpdate()->IgnoreUpdate();
|
||||
}
|
||||
else if(s_State == 2){
|
||||
else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART){
|
||||
CUIRect ProgressBar, Percent;
|
||||
Part.VSplitLeft(100.0f, &ProgressBar, &Percent);
|
||||
ProgressBar.y += 2.0f;
|
||||
ProgressBar.HMargin(1.0f, &ProgressBar);
|
||||
RenderTools()->DrawUIRect(&ProgressBar, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
ProgressBar.w = 50.0f;
|
||||
ProgressBar.w = (float)AutoUpdate()->GetCurrentPercent();
|
||||
RenderTools()->DrawUIRect(&ProgressBar, vec4(1.0f, 1.0f, 1.0f, 0.5f), CUI::CORNER_ALL, 5.0f);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue