diff --git a/src/kiwano/platform/Application.cpp b/src/kiwano/platform/Application.cpp index 4046f303..14a92f09 100644 --- a/src/kiwano/platform/Application.cpp +++ b/src/kiwano/platform/Application.cpp @@ -43,6 +43,31 @@ Application::~Application() { } +void Application::Run(const Settings& settings, const Function& setup) +{ + KGE_ASSERT(setup); + class CallbackRunner : public Runner + { + public: + Function setup; + + CallbackRunner(const Function& 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) { KGE_ASSERT(runner); diff --git a/src/kiwano/platform/Application.h b/src/kiwano/platform/Application.h index 85e0fc21..ae961548 100644 --- a/src/kiwano/platform/Application.h +++ b/src/kiwano/platform/Application.h @@ -52,11 +52,19 @@ public: virtual ~Application(); + /** + * \~chinese + * @brief 启动应用程序 + * @param settings 游戏设置 + * @param setup 启动函数 + * @note 该函数是阻塞的,应用程序结束时函数返回 + */ + void Run(const Settings& settings, const Function& setup); + /** * \~chinese * @brief 启动应用程序 * @param runner 程序运行器 - * @param debug 是否启用调试模式 * @note 该函数是阻塞的,应用程序结束时函数返回 */ void Run(RunnerPtr runner);