[deploy] add callback runner
This commit is contained in:
parent
3fc100185c
commit
f0ed620443
|
|
@ -43,6 +43,31 @@ Application::~Application()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::Run(const Settings& settings, const Function<void()>& setup)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(setup);
|
||||||
|
class CallbackRunner : public Runner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Function<void()> setup;
|
||||||
|
|
||||||
|
CallbackRunner(const Function<void()>& setup)
|
||||||
|
: setup(setup)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnReady() override
|
||||||
|
{
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
RunnerPtr runner = new CallbackRunner(setup);
|
||||||
|
runner->SetName("__KGE_CALLBACK_RUNNER__");
|
||||||
|
runner->SetSettings(settings);
|
||||||
|
Run(runner);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::Run(RunnerPtr runner)
|
void Application::Run(RunnerPtr runner)
|
||||||
{
|
{
|
||||||
KGE_ASSERT(runner);
|
KGE_ASSERT(runner);
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,19 @@ public:
|
||||||
|
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \~chinese
|
||||||
|
* @brief 启动应用程序
|
||||||
|
* @param settings 游戏设置
|
||||||
|
* @param setup 启动函数
|
||||||
|
* @note 该函数是阻塞的,应用程序结束时函数返回
|
||||||
|
*/
|
||||||
|
void Run(const Settings& settings, const Function<void()>& setup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 启动应用程序
|
* @brief 启动应用程序
|
||||||
* @param runner 程序运行器
|
* @param runner 程序运行器
|
||||||
* @param debug 是否启用调试模式
|
|
||||||
* @note 该函数是阻塞的,应用程序结束时函数返回
|
* @note 该函数是阻塞的,应用程序结束时函数返回
|
||||||
*/
|
*/
|
||||||
void Run(RunnerPtr runner);
|
void Run(RunnerPtr runner);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue