[deploy] support using modules with callback runner
This commit is contained in:
parent
f0ed620443
commit
0118220874
|
|
@ -43,7 +43,7 @@ Application::~Application()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::Run(const Settings& settings, const Function<void()>& setup)
|
void Application::Run(const Settings& settings, const Function<void()>& setup, std::initializer_list<Module*> modules)
|
||||||
{
|
{
|
||||||
KGE_ASSERT(setup);
|
KGE_ASSERT(setup);
|
||||||
class CallbackRunner : public Runner
|
class CallbackRunner : public Runner
|
||||||
|
|
@ -65,6 +65,11 @@ void Application::Run(const Settings& settings, const Function<void()>& setup)
|
||||||
RunnerPtr runner = new CallbackRunner(setup);
|
RunnerPtr runner = new CallbackRunner(setup);
|
||||||
runner->SetName("__KGE_CALLBACK_RUNNER__");
|
runner->SetName("__KGE_CALLBACK_RUNNER__");
|
||||||
runner->SetSettings(settings);
|
runner->SetSettings(settings);
|
||||||
|
|
||||||
|
for (auto m : modules)
|
||||||
|
{
|
||||||
|
Use(*m);
|
||||||
|
}
|
||||||
Run(runner);
|
Run(runner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,16 +161,16 @@ void Application::Destroy()
|
||||||
Renderer::GetInstance().Destroy();
|
Renderer::GetInstance().Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::Use(Module& module)
|
void Application::Use(Module& m)
|
||||||
{
|
{
|
||||||
#if defined(KGE_DEBUG)
|
#if defined(KGE_DEBUG)
|
||||||
if (std::find(modules_.begin(), modules_.end(), &module) != modules_.end())
|
if (std::find(modules_.begin(), modules_.end(), &m) != modules_.end())
|
||||||
{
|
{
|
||||||
KGE_ASSERT(false && "Module already exists!");
|
KGE_ASSERT(false && "Module already exists!");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
modules_.push_back(&module);
|
modules_.push_back(&m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::SetTimeScale(float scale_factor)
|
void Application::SetTimeScale(float scale_factor)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
* @param setup 启动函数
|
* @param setup 启动函数
|
||||||
* @note 该函数是阻塞的,应用程序结束时函数返回
|
* @note 该函数是阻塞的,应用程序结束时函数返回
|
||||||
*/
|
*/
|
||||||
void Run(const Settings& settings, const Function<void()>& setup);
|
void Run(const Settings& settings, const Function<void()>& setup, std::initializer_list<Module*> modules = {});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
|
|
@ -96,9 +96,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 添加模块
|
* @brief 添加模块
|
||||||
* @param[in] module Ä£¿é
|
* @param[in] m Ä£¿é
|
||||||
*/
|
*/
|
||||||
void Use(Module& module);
|
void Use(Module& m);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue