Improve autoupdater a bit

- Only ask for restart when we're ingame or unsaved changes in editor
- Otherwise restart directly
This commit is contained in:
def 2015-03-14 16:10:46 +01:00
parent b4336e4638
commit 8ae27f81b6
4 changed files with 6 additions and 5 deletions

View file

@ -178,6 +178,7 @@ public:
virtual void DemoSlice(const char *pDstPath) = 0; virtual void DemoSlice(const char *pDstPath) = 0;
virtual void RequestDDNetSrvList() = 0; virtual void RequestDDNetSrvList() = 0;
virtual bool EditorHasUnsavedData() = 0;
}; };
class IGameClient : public IInterface class IGameClient : public IInterface

View file

@ -52,7 +52,10 @@ void CAutoUpdate::CompletionCallback(CFetchTask *pTask, void *pUser)
pUpdate->ReplaceClient(); pUpdate->ReplaceClient();
if(pUpdate->m_ServerUpdate) if(pUpdate->m_ServerUpdate)
pUpdate->ReplaceServer(); pUpdate->ReplaceServer();
if(pUpdate->m_pClient->State() == IClient::STATE_ONLINE || pUpdate->m_pClient->EditorHasUnsavedData())
pUpdate->m_State = NEED_RESTART; pUpdate->m_State = NEED_RESTART;
else
pUpdate->m_pClient->Restart();
} }
else if(pTask->State() == CFetchTask::STATE_ERROR) else if(pTask->State() == CFetchTask::STATE_ERROR)
pUpdate->m_State = FAIL; pUpdate->m_State = FAIL;

View file

@ -362,5 +362,6 @@ public:
virtual void DemoSlice(const char *pDstPath); virtual void DemoSlice(const char *pDstPath);
void RequestDDNetSrvList(); void RequestDDNetSrvList();
bool EditorHasUnsavedData() { return m_pEditor->HasUnsavedData(); }
}; };
#endif #endif

View file

@ -1302,10 +1302,6 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "DDNet Client updated!"); str_format(aBuf, sizeof(aBuf), "DDNet Client updated!");
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
} }
//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); UI()->DoLabelScaled(&Button, aBuf, 14.0f, -1);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);