2019-04-11 14:40:54 +08:00
|
|
|
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
2019-03-31 01:37:06 +08:00
|
|
|
|
//
|
|
|
|
|
|
// 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
|
2019-08-13 21:16:38 +08:00
|
|
|
|
#include "../core/core.h"
|
2019-03-31 01:37:06 +08:00
|
|
|
|
#include "../base/time.h"
|
|
|
|
|
|
#include "../base/Component.h"
|
2019-08-03 23:28:45 +08:00
|
|
|
|
#include "../base/Event.hpp"
|
2019-08-23 13:00:43 +08:00
|
|
|
|
#include "../base/Window.h"
|
|
|
|
|
|
#include "../renderer/Renderer.h"
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-04-11 14:40:54 +08:00
|
|
|
|
namespace kiwano
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
2019-08-23 13:00:43 +08:00
|
|
|
|
struct Config
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
2019-08-23 13:00:43 +08:00
|
|
|
|
WindowConfig window; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
RenderConfig render; // <20><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
|
|
|
|
|
|
bool debug; // <20><><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
|
|
|
|
|
|
Config(
|
2019-08-19 09:28:59 +08:00
|
|
|
|
String const& title = L"Kiwano Game",
|
2019-08-23 13:00:43 +08:00
|
|
|
|
UInt32 width = 640,
|
|
|
|
|
|
UInt32 height = 480,
|
|
|
|
|
|
UInt32 icon = 0
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
Config(
|
|
|
|
|
|
WindowConfig const& wnd_config,
|
|
|
|
|
|
RenderConfig const& render_config = RenderConfig()
|
2019-08-12 14:51:54 +08:00
|
|
|
|
);
|
2019-03-31 01:37:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-12 14:51:54 +08:00
|
|
|
|
// Ӧ<><D3A6>
|
2019-04-11 14:40:54 +08:00
|
|
|
|
class KGE_API Application
|
2019-08-13 21:16:38 +08:00
|
|
|
|
: protected noncopyable
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
Application();
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~Application();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
void Init(
|
2019-08-23 13:00:43 +08:00
|
|
|
|
Config const& config = Config()
|
2019-03-31 01:37:06 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-08-12 14:51:54 +08:00
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>ʱ
|
|
|
|
|
|
virtual void OnReady() {}
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-08-12 14:51:54 +08:00
|
|
|
|
// <20><><EFBFBD>ڹر<DAB9>ʱ
|
2019-03-31 01:37:06 +08:00
|
|
|
|
virtual bool OnClosing() { return true; }
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ʱ
|
|
|
|
|
|
virtual void OnDestroy() {}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
void Quit();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void Use(
|
2019-09-10 13:17:47 +08:00
|
|
|
|
ComponentBase* component
|
2019-03-31 01:37:06 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void SetTimeScale(
|
2019-08-18 22:49:44 +08:00
|
|
|
|
Float32 scale_factor
|
2019-03-31 01:37:06 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-08-03 23:28:45 +08:00
|
|
|
|
// <20>ַ<EFBFBD><D6B7>¼<EFBFBD>
|
2019-08-12 14:51:54 +08:00
|
|
|
|
void DispatchEvent(Event& evt);
|
2019-08-03 23:28:45 +08:00
|
|
|
|
|
2019-04-11 14:40:54 +08:00
|
|
|
|
// <20><> Kiwano <20><><EFBFBD>߳<EFBFBD><DFB3><EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD>
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳<DFB3><CCB5><EFBFBD> Kiwano <20><><EFBFBD><EFBFBD>ʱʹ<CAB1><CAB9>
|
2019-04-24 13:33:19 +08:00
|
|
|
|
static void PreformInMainThread(
|
2019-08-13 21:16:38 +08:00
|
|
|
|
Function<void()> Function
|
2019-03-31 01:37:06 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
void Render();
|
|
|
|
|
|
|
|
|
|
|
|
void Update();
|
|
|
|
|
|
|
2019-08-18 22:49:44 +08:00
|
|
|
|
static LRESULT CALLBACK WndProc(HWND, UInt32, WPARAM, LPARAM);
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
|
|
|
|
|
protected:
|
2019-08-12 14:51:54 +08:00
|
|
|
|
bool end_;
|
|
|
|
|
|
bool inited_;
|
2019-08-18 22:49:44 +08:00
|
|
|
|
Float32 time_scale_;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-09-10 13:17:47 +08:00
|
|
|
|
Vector<ComponentBase*> comps_;
|
|
|
|
|
|
Vector<RenderComponent*> render_comps_;
|
|
|
|
|
|
Vector<UpdateComponent*> update_comps_;
|
|
|
|
|
|
Vector<EventComponent*> event_comps_;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|