| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | // Copyright (c) 2016-2018 Kiwano - Nomango
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | // Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					
						
							|  |  |  |  | // of this software and associated documentation files (the "Software"), to deal
 | 
					
						
							|  |  |  |  | // in the Software without restriction, including without limitation the rights
 | 
					
						
							|  |  |  |  | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
					
						
							|  |  |  |  | // copies of the Software, and to permit persons to whom the Software is
 | 
					
						
							|  |  |  |  | // furnished to do so, subject to the following conditions:
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | // The above copyright notice and this permission notice shall be included in
 | 
					
						
							|  |  |  |  | // all copies or substantial portions of the Software.
 | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
					
						
							|  |  |  |  | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
					
						
							|  |  |  |  | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
					
						
							|  |  |  |  | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					
						
							|  |  |  |  | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					
						
							|  |  |  |  | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
					
						
							|  |  |  |  | // THE SOFTWARE.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #pragma once
 | 
					
						
							|  |  |  |  | #include <kiwano/core/Common.h>
 | 
					
						
							| 
									
										
										
										
											2020-05-19 21:25:00 +08:00
										 |  |  |  | #include <kiwano/core/Time.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | #include <kiwano/platform/Window.h>
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  | #include <kiwano/render/Color.h>
 | 
					
						
							|  |  |  |  | #include <kiwano/render/Texture.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace kiwano | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-19 11:50:05 +08:00
										 |  |  |  | class Application; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | KGE_DECLARE_SMART_PTR(Runner); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * \~chinese | 
					
						
							|  |  |  |  |  * @brief <EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | struct Settings | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     uint32_t width;          ///< <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>
 | 
					
						
							|  |  |  |  |     uint32_t height;         ///< <20><><EFBFBD>ڸ߶<DAB8>
 | 
					
						
							|  |  |  |  |     String   title;          ///< <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>
 | 
					
						
							|  |  |  |  |     uint32_t icon;           ///< <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
 | 
					
						
							|  |  |  |  |     bool     resizable;      ///< <20><><EFBFBD>ڴ<EFBFBD>С<EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>
 | 
					
						
							|  |  |  |  |     Color    bg_color;       ///< <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ɫ
 | 
					
						
							|  |  |  |  |     bool     vsync_enabled;  ///< <20><>ֱͬ<D6B1><CDAC>
 | 
					
						
							|  |  |  |  |     bool     debug_mode;     ///< <20><><EFBFBD><EFBFBD>ģʽ
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     Settings() | 
					
						
							|  |  |  |  |         : width(800) | 
					
						
							|  |  |  |  |         , height(600) | 
					
						
							|  |  |  |  |         , title("Kiwano") | 
					
						
							|  |  |  |  |         , icon() | 
					
						
							|  |  |  |  |         , resizable(false) | 
					
						
							|  |  |  |  |         , bg_color(Color::Black) | 
					
						
							|  |  |  |  |         , vsync_enabled(true) | 
					
						
							|  |  |  |  |         , debug_mode(false) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * \~chinese | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |  * @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2020-02-20 18:22:52 +08:00
										 |  |  |  | class KGE_API Runner : public ObjectBase | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param main_window <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  |     static RunnerPtr Create(Settings settings); | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param main_window <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param on_ready Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD>ִ<EFBFBD>еĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param on_destroy Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱִ<CAB1>еĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  |     static RunnerPtr Create(Settings settings, Function<void()> on_ready, Function<void()> on_destroy = nullptr); | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     Runner(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     virtual ~Runner(); | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |     /// @brief <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @details <20><><EFBFBD>ظú<D8B8><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA>Զ<EFBFBD>ִ<EFBFBD><D6B4>
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  |     virtual void OnReady(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |     /// @brief Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @details <20><><EFBFBD>ظú<D8B8><C3BA><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>յ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  |     virtual void OnDestroy(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |     /// @brief Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>رմ<D8B1><D5B4><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @details <20><><EFBFBD>ظú<D8B8><C3BA><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ر<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>籣<EFBFBD><E7B1A3><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݵ<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @return <20><><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>رճ<D8B1><D5B3><EFBFBD><F2A3ACB7><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  |     virtual bool OnClose(); | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |     /// @brief Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
 | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:13 +08:00
										 |  |  |  |     /// @param dt ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @details <20><><EFBFBD>ظú<D8B8><C3BA><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
 | 
					
						
							| 
									
										
										
										
											2020-03-19 14:28:50 +08:00
										 |  |  |  |     /// @return <20><><EFBFBD><EFBFBD>false<73>˳<EFBFBD><CBB3><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
 | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:13 +08:00
										 |  |  |  |     virtual bool MainLoop(Duration dt); | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  |     /// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     WindowPtr GetWindow() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>
 | 
					
						
							|  |  |  |  |     void SetWindow(WindowPtr window); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     Settings GetSettings() const; | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  |     /// \~chinese
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  |     /// @brief <20><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void SetSettings(Settings settings); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | private: | 
					
						
							|  |  |  |  |     friend class Application; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     void InitSettings(); | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | private: | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  |     Settings  settings_; | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  |     WindowPtr main_window_; | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | inline void Runner::OnReady() {} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Runner::OnDestroy() {} | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  | inline bool Runner::OnClose() | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |     return true; | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  | inline WindowPtr Runner::GetWindow() const | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  |     return main_window_; | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  | inline void Runner::SetWindow(WindowPtr window) | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-02-14 22:01:56 +08:00
										 |  |  |  |     main_window_ = window; | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 18:44:20 +08:00
										 |  |  |  | inline Settings Runner::GetSettings() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     return settings_; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Runner::SetSettings(Settings settings) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     settings_ = settings; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 17:12:13 +08:00
										 |  |  |  | }  // namespace kiwano
 |