Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
- --- a/src/game/client/components/menus.cpp 2010-11-19 16:24:16.441000000 +0500
- +++ b/src/game/client/components/menus.cpp 2010-11-19 23:34:43.919000000 +0500
- @@ -24,6 +24,8 @@
- #include <game/localization.h>
- #include <mastersrv/mastersrv.h>
- +#include <time.h>
- +
- vec4 CMenus::ms_GuiColor;
- vec4 CMenus::ms_ColorTabbarInactiveOutgame;
- vec4 CMenus::ms_ColorTabbarActiveOutgame;
- @@ -101,6 +103,8 @@
- str_copy(m_aCurrentDemoFolder, "demos", sizeof(m_aCurrentDemoFolder));
- m_aCallvoteReason[0] = 0;
- +
- + m_DownloadLastCheckSize = 0;
- }
- vec4 CMenus::ButtonColorMul(const void *pID)
- @@ -838,6 +842,8 @@
- const char *pExtraText = "";
- const char *pButtonText = "";
- int ExtraAlign = 0;
- + bool bProgressBar = false;
- + float fProgress = 0.0f;
- if(m_Popup == POPUP_MESSAGE)
- {
- @@ -852,9 +858,69 @@
- pButtonText = Localize("Abort");
- if(Client()->MapDownloadTotalsize() > 0)
- {
- + int currTime = (int)time(0);
- +
- + if (!m_DownloadLastCheckSize || m_DownloadLastCheckSize > (unsigned long)Client()->MapDownloadAmount())
- + {
- + m_DownloadSpeed = 0;
- + m_DownloadLastCheckSize = 1; // we'll think that we've got 1 byte
- + m_DownloadLastCheckTime = currTime;
- + } else {
- + int diffTime = currTime - m_DownloadLastCheckTime;
- + int diffSize = Client()->MapDownloadAmount() - m_DownloadLastCheckSize;
- + float currSpeed = diffTime ? diffSize / diffTime : 0;
- +
- + if (diffTime >= 1.0f && diffSize > 0)
- + {
- + if (m_DownloadSpeed == 0)
- + m_DownloadSpeed = currSpeed;
- + else
- + m_DownloadSpeed = (m_DownloadSpeed + currSpeed) * 0.5f;
- +
- + m_DownloadLastCheckSize = Client()->MapDownloadAmount();
- + m_DownloadLastCheckTime = currTime;
- + }
- + }
- +
- pTitle = Localize("Downloading map");
- - str_format(aBuf, sizeof(aBuf), "%d/%d KiB", Client()->MapDownloadAmount()/1024, Client()->MapDownloadTotalsize()/1024);
- + if (m_DownloadSpeed == 0)
- + {
- + str_format(aBuf, sizeof(aBuf), Localize("%d/%d KiB"), Client()->MapDownloadAmount()/1024, Client()->MapDownloadTotalsize()/1024);
- + } else {
- + char aBuf2[256];
- +
- + double remaining = abs( (Client()->MapDownloadTotalsize() - Client()->MapDownloadAmount()) / m_DownloadSpeed );
- + str_format(aBuf, sizeof(aBuf), Localize("%d/%d KiB (%.1f KiB/sec)"), Client()->MapDownloadAmount() / 1024, Client()->MapDownloadTotalsize() / 1024, m_DownloadSpeed / 1024.0f);
- +
- + char * aBufEnd = aBuf + str_length(aBuf);
- + char * aBufMax = aBuf + sizeof(aBuf);
- +
- + str_format(aBufEnd, aBufMax - aBufEnd, "\n\n%s ", Localize("Please wait"));
- + while (aBufEnd[0]) aBufEnd++;
- +
- + if (remaining > 60.0)
- + {
- + int minutes = (int)(remaining / 60.0);
- + int seconds = (int)remaining % 60;
- +
- + str_format(aBuf2, sizeof(aBuf2), Localize("%d minute(s)"), minutes);
- + str_format(aBufEnd, aBufMax - aBufEnd, "%s ", Localize(aBuf2)); // localize number texts
- + while (aBufEnd[0]) aBufEnd++;
- +
- + if (seconds)
- + {
- + str_format(aBuf2, sizeof(aBuf2), Localize("%d second(s)"), seconds);
- + str_format(aBufEnd, aBufMax - aBufEnd, "%s", Localize(aBuf2)); // localize number texts
- + }
- + } else {
- + str_format(aBuf2, sizeof(aBuf2), Localize("%d second(s)"), (int)remaining);
- + str_format(aBufEnd, aBufMax - aBufEnd, "%s", Localize(aBuf2)); // localize number texts
- + }
- + }
- pExtraText = aBuf;
- +
- + bProgressBar = true;
- + fProgress = clamp((float)Client()->MapDownloadAmount() / (float)Client()->MapDownloadTotalsize(), 0.0f, 1.0f);
- }
- }
- else if(m_Popup == POPUP_DISCONNECTED)
- @@ -916,6 +982,19 @@
- else
- UI()->DoLabel(&Part, pExtraText, 20.f, 0, -1);
- + if(bProgressBar)
- + {
- + CUIRect Rect;
- + Rect.x = Screen.x + 175.0f;
- + Rect.y = Screen.h - 225.0f;
- + Rect.w = Screen.w - 350.0f;
- + Rect.h = 25.0f;
- + RenderTools()->DrawUIRect(&Rect, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
- +
- + Rect.w *= fProgress;
- + RenderTools()->DrawUIRect(&Rect, vec4(1.0f, 1.0f, 1.0f, 0.5f), CUI::CORNER_ALL, 5.0f);
- + }
- +
- if(m_Popup == POPUP_QUIT)
- {
- CUIRect Yes, No;
- diff -Naur a/src/game/client/components/menus.h b/src/game/client/components/menus.h
- --- a/src/game/client/components/menus.h 2010-11-19 16:25:07.572000000 +0500
- +++ b/src/game/client/components/menus.h 2010-11-19 16:11:19.481000000 +0500
- @@ -174,6 +174,11 @@
- int m_DemolistSelectedIndex;
- bool m_DemolistSelectedIsDir;
- int m_DemolistStorageType;
- +
- + // for download bar
- + int m_DownloadLastCheckTime;
- + unsigned long m_DownloadLastCheckSize;
- + float m_DownloadSpeed;
- void DemolistOnUpdate(bool Reset);
- void DemolistPopulate();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement