Rename AutoUpdater to Updater because you have to press a button now

This commit is contained in:
def 2015-04-18 21:17:27 +02:00
parent 4625a4de58
commit 710a786f88
10 changed files with 65 additions and 65 deletions

View file

@ -59,7 +59,7 @@
#include "friends.h"
#include "serverbrowser.h"
#include "fetcher.h"
#include "autoupdate.h"
#include "updater.h"
#include "client.h"
#include <zlib.h>
@ -2489,7 +2489,7 @@ void CClient::RegisterInterfaces()
Kernel()->RegisterInterface(static_cast<IServerBrowser*>(&m_ServerBrowser));
Kernel()->RegisterInterface(static_cast<IFetcher*>(&m_Fetcher));
#if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__)
Kernel()->RegisterInterface(static_cast<IAutoUpdate*>(&m_AutoUpdate));
Kernel()->RegisterInterface(static_cast<IUpdater*>(&m_Updater));
#endif
Kernel()->RegisterInterface(static_cast<IFriends*>(&m_Friends));
}
@ -2507,7 +2507,7 @@ void CClient::InitInterfaces()
m_pMasterServer = Kernel()->RequestInterface<IEngineMasterServer>();
m_pFetcher = Kernel()->RequestInterface<IFetcher>();
#if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__)
m_pAutoUpdate = Kernel()->RequestInterface<IAutoUpdate>();
m_pUpdater = Kernel()->RequestInterface<IUpdater>();
#endif
m_pStorage = Kernel()->RequestInterface<IStorage>();
@ -2518,7 +2518,7 @@ void CClient::InitInterfaces()
m_Fetcher.Init();
#if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__)
m_AutoUpdate.Init();
m_Updater.Init();
#endif
m_Friends.Init();
@ -2656,7 +2656,7 @@ void CClient::Run()
if(Input()->Update())
break; // SDL_QUIT
#if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__)
AutoUpdate()->Update();
Updater()->Update();
#endif
// update sound

View file

@ -64,7 +64,7 @@ class CClient : public IClient, public CDemoPlayer::IListner
IConsole *m_pConsole;
IStorage *m_pStorage;
IFetcher *m_pFetcher;
IAutoUpdate *m_pAutoUpdate;
IUpdater *m_pUpdater;
IEngineMasterServer *m_pMasterServer;
enum
@ -79,7 +79,7 @@ class CClient : public IClient, public CDemoPlayer::IListner
class CDemoEditor m_DemoEditor;
class CServerBrowser m_ServerBrowser;
class CFetcher m_Fetcher;
class CAutoUpdate m_AutoUpdate;
class CUpdater m_Updater;
class CFriends m_Friends;
class CMapChecker m_MapChecker;
@ -204,7 +204,7 @@ public:
IEngineMasterServer *MasterServer() { return m_pMasterServer; }
IStorage *Storage() { return m_pStorage; }
IFetcher *Fetcher() { return m_pFetcher; }
IAutoUpdate *AutoUpdate() { return m_pAutoUpdate; }
IUpdater *Updater() { return m_pUpdater; }
CClient();

View file

@ -1,4 +1,4 @@
#include "autoupdate.h"
#include "updater.h"
#include <base/system.h>
#include <engine/fetcher.h>
#include <engine/storage.h>
@ -11,7 +11,7 @@
using std::string;
using std::vector;
CAutoUpdate::CAutoUpdate()
CUpdater::CUpdater()
{
m_pClient = NULL;
m_pStorage = NULL;
@ -20,7 +20,7 @@ CAutoUpdate::CAutoUpdate()
m_Percent = 0;
}
void CAutoUpdate::Init()
void CUpdater::Init()
{
m_pClient = Kernel()->RequestInterface<IClient>();
m_pStorage = Kernel()->RequestInterface<IStorage>();
@ -28,16 +28,16 @@ void CAutoUpdate::Init()
m_IsWinXP = os_compare_version(5, 1) <= 0;
}
void CAutoUpdate::ProgressCallback(CFetchTask *pTask, void *pUser)
void CUpdater::ProgressCallback(CFetchTask *pTask, void *pUser)
{
CAutoUpdate *pUpdate = (CAutoUpdate *)pUser;
CUpdater *pUpdate = (CUpdater *)pUser;
str_copy(pUpdate->m_Status, pTask->Dest(), sizeof(pUpdate->m_Status));
pUpdate->m_Percent = pTask->Progress();
}
void CAutoUpdate::CompletionCallback(CFetchTask *pTask, void *pUser)
void CUpdater::CompletionCallback(CFetchTask *pTask, void *pUser)
{
CAutoUpdate *pUpdate = (CAutoUpdate *)pUser;
CUpdater *pUpdate = (CUpdater *)pUser;
if(!str_comp(pTask->Dest(), "update.json"))
{
if(pTask->State() == CFetchTask::STATE_DONE)
@ -68,17 +68,17 @@ void CAutoUpdate::CompletionCallback(CFetchTask *pTask, void *pUser)
delete pTask;
}
void CAutoUpdate::FetchFile(const char *pFile, const char *pDestPath)
void CUpdater::FetchFile(const char *pFile, const char *pDestPath)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "https://%s/%s", g_Config.m_ClDDNetUpdateServer, pFile);
if(!pDestPath)
pDestPath = pFile;
CFetchTask *Task = new CFetchTask;
m_pFetcher->QueueAdd(Task, aBuf, pDestPath, -2, this, &CAutoUpdate::CompletionCallback, &CAutoUpdate::ProgressCallback);
m_pFetcher->QueueAdd(Task, aBuf, pDestPath, -2, this, &CUpdater::CompletionCallback, &CUpdater::ProgressCallback);
}
void CAutoUpdate::Update()
void CUpdater::Update()
{
switch(m_State)
{
@ -89,7 +89,7 @@ void CAutoUpdate::Update()
}
}
void CAutoUpdate::AddNewFile(const char *pFile)
void CUpdater::AddNewFile(const char *pFile)
{
//Check if already on the download list
for(vector<string>::iterator it = m_AddedFiles.begin(); it < m_AddedFiles.end(); ++it)
@ -100,7 +100,7 @@ void CAutoUpdate::AddNewFile(const char *pFile)
m_AddedFiles.push_back(string(pFile));
}
void CAutoUpdate::AddRemovedFile(const char *pFile)
void CUpdater::AddRemovedFile(const char *pFile)
{
//First remove from to be downloaded list
for(vector<string>::iterator it = m_AddedFiles.begin(); it < m_AddedFiles.end(); ++it)
@ -113,9 +113,9 @@ void CAutoUpdate::AddRemovedFile(const char *pFile)
m_RemovedFiles.push_back(string(pFile));
}
void CAutoUpdate::ReplaceClient()
void CUpdater::ReplaceClient()
{
dbg_msg("autoupdate", "Replacing " PLAT_CLIENT_EXEC);
dbg_msg("updater", "Replacing " PLAT_CLIENT_EXEC);
//Replace running executable by renaming twice...
if(m_IsWinXP)
@ -130,13 +130,13 @@ void CAutoUpdate::ReplaceClient()
char aBuf[512];
str_format(aBuf, sizeof aBuf, "chmod +x %s", aPath);
if (system(aBuf))
dbg_msg("autoupdate", "Error setting client executable bit");
dbg_msg("updater", "Error setting client executable bit");
#endif
}
void CAutoUpdate::ReplaceServer()
void CUpdater::ReplaceServer()
{
dbg_msg("autoupdate", "Replacing " PLAT_SERVER_EXEC);
dbg_msg("updater", "Replacing " PLAT_SERVER_EXEC);
//Replace running executable by renaming twice...
m_pStorage->RemoveBinaryFile("DDNet-Server.old");
@ -148,11 +148,11 @@ void CAutoUpdate::ReplaceServer()
char aBuf[512];
str_format(aBuf, sizeof aBuf, "chmod +x %s", aPath);
if (system(aBuf))
dbg_msg("autoupdate", "Error setting server executable bit");
dbg_msg("updater", "Error setting server executable bit");
#endif
}
void CAutoUpdate::ParseUpdate()
void CUpdater::ParseUpdate()
{
char aPath[512];
IOHANDLE File = m_pStorage->OpenFile(m_pStorage->GetBinaryPath("update.json", aPath, sizeof aPath), IOFLAG_READ, IStorage::TYPE_ALL);
@ -195,16 +195,16 @@ void CAutoUpdate::ParseUpdate()
}
}
void CAutoUpdate::InitiateUpdate()
void CUpdater::InitiateUpdate()
{
m_State = GETTING_MANIFEST;
FetchFile("update.json");
}
void CAutoUpdate::PerformUpdate()
void CUpdater::PerformUpdate()
{
m_State = PARSING_UPDATE;
dbg_msg("autoupdate", "Parsing update.json");
dbg_msg("updater", "Parsing update.json");
ParseUpdate();
m_State = DOWNLOADING;
@ -234,7 +234,7 @@ void CAutoUpdate::PerformUpdate()
FetchFile(PLAT_CLIENT_DOWN, "DDNet.tmp");
}
void CAutoUpdate::WinXpRestart()
void CUpdater::WinXpRestart()
{
char aBuf[512];
IOHANDLE bhFile = io_open(m_pStorage->GetBinaryPath("du.bat", aBuf, sizeof aBuf), IOFLAG_WRITE);

View file

@ -1,7 +1,7 @@
#ifndef ENGINE_CLIENT_AUTOUPDATE_H
#define ENGINE_CLIENT_AUTOUPDATE_H
#ifndef ENGINE_CLIENT_UPDATER_H
#define ENGINE_CLIENT_UPDATER_H
#include <engine/autoupdate.h>
#include <engine/updater.h>
#include <engine/fetcher.h>
#include <vector>
#include <string>
@ -32,7 +32,7 @@
#define PLAT_CLIENT_EXEC CLIENT_EXEC PLAT_EXT
#define PLAT_SERVER_EXEC SERVER_EXEC PLAT_EXT
class CAutoUpdate : public IAutoUpdate
class CUpdater : public IUpdater
{
class IClient *m_pClient;
class IStorage *m_pStorage;
@ -62,7 +62,7 @@ class CAutoUpdate : public IAutoUpdate
void ReplaceServer();
public:
CAutoUpdate();
CUpdater();
static void ProgressCallback(CFetchTask *pTask, void *pUser);
static void CompletionCallback(CFetchTask *pTask, void *pUser);

View file

@ -1,11 +1,11 @@
#ifndef ENGINE_AUTOUPDATE_H
#define ENGINE_AUTOUPDATE_H
#ifndef ENGINE_UPDATER_H
#define ENGINE_UPDATER_H
#include "kernel.h"
class IAutoUpdate : public IInterface
class IUpdater : public IInterface
{
MACRO_INTERFACE("autoupdate", 0)
MACRO_INTERFACE("updater", 0)
public:
enum
{

View file

@ -28,7 +28,7 @@ protected:
class IServerBrowser *ServerBrowser() const { return m_pClient->ServerBrowser(); }
class CLayers *Layers() const { return m_pClient->Layers(); }
class CCollision *Collision() const { return m_pClient->Collision(); }
class IAutoUpdate *AutoUpdate() const { return m_pClient->AutoUpdate(); }
class IUpdater *Updater() const { return m_pClient->Updater(); }
public:
virtual ~CComponent() {}
class CGameClient *GameClient() const { return m_pClient; }

View file

@ -6,7 +6,7 @@
#include <engine/keys.h>
#include <engine/serverbrowser.h>
#include <engine/textrender.h>
#include <engine/autoupdate.h>
#include <engine/updater.h>
#include <engine/shared/config.h>
#include <game/generated/client_data.h>
@ -1281,23 +1281,23 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
#if defined(CONF_FAMILY_WINDOWS) || (defined(CONF_PLATFORM_LINUX) && !defined(__ANDROID__))
StatusBox.HSplitBottom(15.0f, &StatusBox, &Button);
char aBuf[64];
int State = AutoUpdate()->GetCurrentState();
int State = Updater()->GetCurrentState();
bool NeedUpdate = str_comp(Client()->LatestVersion(), "0");
if(State == IAutoUpdate::CLEAN && NeedUpdate)
if(State == IUpdater::CLEAN && NeedUpdate)
{
str_format(aBuf, sizeof(aBuf), "DDNet %s is out!", Client()->LatestVersion());
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
}
else if(State == IAutoUpdate::CLEAN)
else if(State == IUpdater::CLEAN)
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::FAIL)
else if(State >= IUpdater::GETTING_MANIFEST && State < IUpdater::NEED_RESTART)
str_format(aBuf, sizeof(aBuf), "Downloading %s:", Updater()->GetCurrentFile());
else if(State == IUpdater::FAIL)
{
str_format(aBuf, sizeof(aBuf), "Failed to download a file! Restart client to retry...");
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
}
else if(State == IAutoUpdate::NEED_RESTART)
else if(State == IUpdater::NEED_RESTART)
{
str_format(aBuf, sizeof(aBuf), "DDNet Client updated!");
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
@ -1307,7 +1307,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
Button.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1) + 10.0f, &Button, &Part);
if(State == IAutoUpdate::CLEAN && NeedUpdate)
if(State == IUpdater::CLEAN && NeedUpdate)
{
CUIRect Update;
Part.VSplitLeft(100.0f, &Update, NULL);
@ -1315,10 +1315,10 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
static int s_ButtonUpdate = 0;
if(DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Update))
{
AutoUpdate()->InitiateUpdate();
Updater()->InitiateUpdate();
}
}
else if(State == IAutoUpdate::NEED_RESTART)
else if(State == IUpdater::NEED_RESTART)
{
CUIRect Restart;
Part.VSplitLeft(50.0f, &Restart, &Part);
@ -1329,14 +1329,14 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
Client()->Restart();
}
}
else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART)
else if(State >= IUpdater::GETTING_MANIFEST && State < IUpdater::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 = clamp((float)AutoUpdate()->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);
}
#else

View file

@ -9,7 +9,7 @@
#include <engine/graphics.h>
#include <engine/storage.h>
#include <engine/textrender.h>
#include <engine/autoupdate.h>
#include <engine/updater.h>
#include <engine/shared/config.h>
#include <engine/shared/linereader.h>
@ -1798,27 +1798,27 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
g_Config.m_ClHttpMapDownload ^= 1;
}
//AutoUpdate
//Updater
#if defined(CONF_FAMILY_WINDOWS) || (defined(CONF_PLATFORM_LINUX) && !defined(__ANDROID__))
{
Left.HSplitTop(20.0f, &Label, &Left);
bool NeedUpdate = str_comp(Client()->LatestVersion(), "0");
char aBuf[256];
int State = AutoUpdate()->GetCurrentState();
int State = Updater()->GetCurrentState();
//Update Button
if(NeedUpdate && State <= IAutoUpdate::CLEAN)
if(NeedUpdate && State <= IUpdater::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);
Button.VSplitLeft(100.0f, &Button, 0);
static int s_ButtonUpdate = 0;
if(DoButton_Menu(&s_ButtonUpdate, "Update now", 0, &Button))
AutoUpdate()->InitiateUpdate();
Updater()->InitiateUpdate();
}
else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART)
else if(State >= IUpdater::GETTING_MANIFEST && State < IUpdater::NEED_RESTART)
str_format(aBuf, sizeof(aBuf), "Updating...");
else if(State == IAutoUpdate::NEED_RESTART){
else if(State == IUpdater::NEED_RESTART){
str_format(aBuf, sizeof(aBuf), "DDNet Client updated!");
m_NeedRestartUpdate = true;
}

View file

@ -10,7 +10,7 @@
#include <engine/storage.h>
#include <engine/sound.h>
#include <engine/serverbrowser.h>
#include <engine/autoupdate.h>
#include <engine/updater.h>
#include <engine/shared/demo.h>
#include <engine/shared/config.h>
@ -125,7 +125,7 @@ void CGameClient::OnConsoleInit()
m_pEditor = Kernel()->RequestInterface<IEditor>();
m_pFriends = Kernel()->RequestInterface<IFriends>();
#if defined(CONF_FAMILY_WINDOWS) || (defined(CONF_PLATFORM_LINUX) && !defined(__ANDROID__))
m_pAutoUpdate = Kernel()->RequestInterface<IAutoUpdate>();
m_pUpdater = Kernel()->RequestInterface<IUpdater>();
#endif
// setup pointers

View file

@ -95,7 +95,7 @@ class CGameClient : public IGameClient
class IServerBrowser *m_pServerBrowser;
class IEditor *m_pEditor;
class IFriends *m_pFriends;
class IAutoUpdate *m_pAutoUpdate;
class IUpdater *m_pUpdater;
CLayers m_Layers;
class CCollision m_Collision;
@ -136,7 +136,7 @@ public:
class CCollision *Collision() { return &m_Collision; };
class IEditor *Editor() { return m_pEditor; }
class IFriends *Friends() { return m_pFriends; }
class IAutoUpdate *AutoUpdate() { return m_pAutoUpdate; }
class IUpdater *Updater() { return m_pUpdater; }
int NetobjNumCorrections() { return m_NetObjHandler.NumObjCorrections(); }
const char *NetobjCorrectedOn() { return m_NetObjHandler.CorrectedObjOn(); }