Load entity templates for the AI via the progressive loader.

Display message while loading the map list for the setup screen.

This was SVN commit r9019.
This commit is contained in:
Ykkrosh
2011-03-05 01:56:59 +00:00
parent 19c8ca3ef4
commit e608d9269a
9 changed files with 181 additions and 16 deletions
+36 -1
View File
@@ -27,8 +27,9 @@
#include "simulation2/components/ICmpCommandQueue.h"
#include "simulation2/components/ICmpTemplateManager.h"
#include "lib/file/file_system_util.h"
#include "lib/timer.h"
#include "lib/utf8.h"
#include "lib/file/file_system_util.h"
#include "maths/MathUtil.h"
#include "ps/CLogger.h"
#include "ps/Filesystem.h"
@@ -118,6 +119,7 @@ public:
return static_cast<CSimulation2Impl*>(param)->ReloadChangedFile(path);
}
int ProgressiveLoad();
bool Update(int turnLength, const std::vector<SimulationCommand>& commands);
void Interpolate(float frameLength, float frameOffset);
@@ -177,6 +179,34 @@ LibError CSimulation2Impl::ReloadChangedFile(const VfsPath& path)
return INFO::OK;
}
int CSimulation2Impl::ProgressiveLoad()
{
// yield after this time is reached. balances increased progress bar
// smoothness vs. slowing down loading.
const double end_time = timer_Time() + 200e-3;
int ret;
do
{
bool progressed = false;
int total = 0;
int progress = 0;
CMessageProgressiveLoad msg(&progressed, &total, &progress);
m_ComponentManager.BroadcastMessage(msg);
if (!progressed || total == 0)
return 0; // we have nothing left to load
ret = Clamp(100*progress / total, 1, 100);
}
while (timer_Time() < end_time);
return ret;
}
bool CSimulation2Impl::Update(int turnLength, const std::vector<SimulationCommand>& commands)
{
fixed turnLengthFixed = fixed::FromInt(turnLength) / 1000;
@@ -448,6 +478,11 @@ void CSimulation2::LoadMapSettings()
GetScriptInterface().LoadScript(L"map startup script", m->m_StartupScript);
}
int CSimulation2::ProgressiveLoad()
{
return m->ProgressiveLoad();
}
LibError CSimulation2::ReloadChangedFile(const VfsPath& path)
{
return m->ReloadChangedFile(path);