[deploy] Change source code charset to gb2312

This commit is contained in:
Nomango 2020-03-19 14:28:50 +08:00
parent 320bd9c8dc
commit a1e7e77c96
105 changed files with 2752 additions and 2751 deletions

View File

@ -11,7 +11,7 @@ insert_final_newline = true
# Matches multiple files with brace expansion notation # Matches multiple files with brace expansion notation
# Set default charset # Set default charset
[*.{h,hpp,cpp}] [*.{h,hpp,cpp}]
charset = utf8 charset = gb2312
# 4 space indentation # 4 space indentation
indent_style = space indent_style = space

View File

@ -32,7 +32,7 @@ SHOW_NAMESPACES = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
INPUT = src/ INPUT = src/
INPUT_ENCODING = UTF-8 INPUT_ENCODING = GBK
FILE_PATTERNS = *.c \ FILE_PATTERNS = *.c \
*.cc \ *.cc \
*.cxx \ *.cxx \

View File

@ -74,7 +74,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>
@ -94,7 +93,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -73,7 +73,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>
@ -93,7 +92,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -69,7 +69,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>
@ -89,7 +88,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -80,7 +80,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>
@ -100,7 +99,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -229,7 +229,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>
@ -249,7 +248,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -32,7 +32,7 @@ namespace audio
/** /**
* \~chinese * \~chinese
* \defgroup Audio * \defgroup Audio
*/ */
/** /**
@ -42,7 +42,7 @@ namespace audio
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API AudioModule class KGE_API AudioModule
: public Singleton<AudioModule> : public Singleton<AudioModule>
@ -52,15 +52,15 @@ class KGE_API AudioModule
public: public:
/// \~chinese /// \~chinese
/// @brief 开启音频设备 /// @brief 开启音频设备
void Open(); void Open();
/// \~chinese /// \~chinese
/// @brief 关闭音频设备 /// @brief 关闭音频设备
void Close(); void Close();
/// \~chinese /// \~chinese
/// @brief 从解码器数据缓冲中创建音频对象 /// @brief 从解码器数据缓冲中创建音频对象
bool CreateSound(Sound& sound, const Transcoder::Buffer& buffer); bool CreateSound(Sound& sound, const Transcoder::Buffer& buffer);
public: public:

View File

@ -40,7 +40,7 @@ KGE_DECLARE_SMART_PTR(Sound);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Sound : public ObjectBase class KGE_API Sound : public ObjectBase
{ {
@ -48,13 +48,13 @@ class KGE_API Sound : public ObjectBase
public: public:
/// \~chinese /// \~chinese
/// @brief 创建音频对象 /// @brief 创建音频对象
/// @param res 本地音频文件路径 /// @param res 本地音频文件路径
static SoundPtr Create(const String& file_path); static SoundPtr Create(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 创建音频对象 /// @brief 创建音频对象
/// @param res 音频资源 /// @param res 音频资源
static SoundPtr Create(const Resource& res); static SoundPtr Create(const Resource& res);
Sound(); Sound();
@ -62,51 +62,51 @@ public:
virtual ~Sound(); virtual ~Sound();
/// \~chinese /// \~chinese
/// @brief 打开本地音频文件 /// @brief 打开本地音频文件
/// @param res 本地音频文件路径 /// @param res 本地音频文件路径
bool Load(const String& file_path); bool Load(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 打开音频资源 /// @brief 打开音频资源
/// @param res 音频资源 /// @param res 音频资源
bool Load(const Resource& res); bool Load(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 是否有效 /// @brief 是否有效
bool IsValid() const; bool IsValid() const;
/// \~chinese /// \~chinese
/// @brief 播放 /// @brief 播放
/// @param loop_count 播放循环次数,设置 -1 为循环播放 /// @param loop_count 播放循环次数,设置 -1 为循环播放
void Play(int loop_count = 0); void Play(int loop_count = 0);
/// \~chinese /// \~chinese
/// @brief 暂停 /// @brief 暂停
void Pause(); void Pause();
/// \~chinese /// \~chinese
/// @brief 继续 /// @brief 继续
void Resume(); void Resume();
/// \~chinese /// \~chinese
/// @brief 停止 /// @brief 停止
void Stop(); void Stop();
/// \~chinese /// \~chinese
/// @brief 关闭并销毁资源 /// @brief 关闭并销毁资源
void Close(); void Close();
/// \~chinese /// \~chinese
/// @brief 是否正在播放 /// @brief 是否正在播放
bool IsPlaying() const; bool IsPlaying() const;
/// \~chinese /// \~chinese
/// @brief 获取音量 /// @brief 获取音量
float GetVolume() const; float GetVolume() const;
/// \~chinese /// \~chinese
/// @brief 设置音量 /// @brief 设置音量
/// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量 /// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量
void SetVolume(float volume); void SetVolume(float volume);
private: private:

View File

@ -35,13 +35,13 @@ KGE_DECLARE_SMART_PTR(SoundPlayer);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API SoundPlayer : public ObjectBase class KGE_API SoundPlayer : public ObjectBase
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建音频播放器 /// @brief 创建音频播放器
static SoundPlayerPtr Create(); static SoundPlayerPtr Create();
SoundPlayer(); SoundPlayer();
@ -49,66 +49,66 @@ public:
~SoundPlayer(); ~SoundPlayer();
/// \~chinese /// \~chinese
/// @brief 加载本地音频文件 /// @brief 加载本地音频文件
/// @param file_path 本地音频文件路径 /// @param file_path 本地音频文件路径
/// @return 音频标识符 /// @return 音频标识符
size_t Load(const String& file_path); size_t Load(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 加载音频资源 /// @brief 加载音频资源
/// @param res 音频资源 /// @param res 音频资源
/// @return 音频标识符 /// @return 音频标识符
size_t Load(const Resource& res); size_t Load(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 播放音频 /// @brief 播放音频
/// @param id 音频标识符 /// @param id 音频标识符
/// @param loop_count 播放循环次数,设置 -1 为循环播放 /// @param loop_count 播放循环次数,设置 -1 为循环播放
void Play(size_t id, int loop_count = 0); void Play(size_t id, int loop_count = 0);
/// \~chinese /// \~chinese
/// @brief 暂停音频 /// @brief 暂停音频
/// @param id 音频标识符 /// @param id 音频标识符
void Pause(size_t id); void Pause(size_t id);
/// \~chinese /// \~chinese
/// @brief 继续播放音频 /// @brief 继续播放音频
/// @param id 音频标识符 /// @param id 音频标识符
void Resume(size_t id); void Resume(size_t id);
/// \~chinese /// \~chinese
/// @brief 停止音频 /// @brief 停止音频
/// @param id 音频标识符 /// @param id 音频标识符
void Stop(size_t id); void Stop(size_t id);
/// \~chinese /// \~chinese
/// @brief 获取音频播放状态 /// @brief 获取音频播放状态
/// @param id 音频标识符 /// @param id 音频标识符
bool IsPlaying(size_t id); bool IsPlaying(size_t id);
/// \~chinese /// \~chinese
/// @brief 获取音量 /// @brief 获取音量
float GetVolume() const; float GetVolume() const;
/// \~chinese /// \~chinese
/// @brief 设置音量 /// @brief 设置音量
/// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量 /// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量
void SetVolume(float volume); void SetVolume(float volume);
/// \~chinese /// \~chinese
/// @brief 暂停所有音频 /// @brief 暂停所有音频
void PauseAll(); void PauseAll();
/// \~chinese /// \~chinese
/// @brief 继续播放所有音频 /// @brief 继续播放所有音频
void ResumeAll(); void ResumeAll();
/// \~chinese /// \~chinese
/// @brief 停止所有音频 /// @brief 停止所有音频
void StopAll(); void StopAll();
/// \~chinese /// \~chinese
/// @brief 清除缓存 /// @brief 清除缓存
void ClearCache(); void ClearCache();
private: private:

View File

@ -148,25 +148,25 @@ HRESULT Transcoder::ReadSource(IMFSourceReader* reader)
hr = partial_type->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM); hr = partial_type->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM);
} }
// 设置 source reader 的媒体类型,它将使用合适的解码器去解码这个音频 // 设置 source reader 的媒体类型,它将使用合适的解码器去解码这个音频
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = reader->SetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, partial_type.Get()); hr = reader->SetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, partial_type.Get());
} }
// 从 IMFMediaType 中获取 WAVEFORMAT 结构 // 从 IMFMediaType 中获取 WAVEFORMAT 结构
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = reader->GetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, &uncompressed_type); hr = reader->GetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, &uncompressed_type);
} }
// 指定音频流 // 指定音频流
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = reader->SetStreamSelection((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, true); hr = reader->SetStreamSelection((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, true);
} }
// 获取 WAVEFORMAT 数据 // 获取 WAVEFORMAT 数据
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
uint32_t size = 0; uint32_t size = 0;
@ -174,7 +174,7 @@ HRESULT Transcoder::ReadSource(IMFSourceReader* reader)
uncompressed_type.Get(), &wave_format_, &size, (DWORD)MFWaveFormatExConvertFlag_Normal); uncompressed_type.Get(), &wave_format_, &size, (DWORD)MFWaveFormatExConvertFlag_Normal);
} }
// 估算音频流大小 // 估算音频流大小
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
PROPVARIANT prop; PROPVARIANT prop;
@ -187,7 +187,7 @@ HRESULT Transcoder::ReadSource(IMFSourceReader* reader)
PropVariantClear(&prop); PropVariantClear(&prop);
} }
// 读取音频数据 // 读取音频数据
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
DWORD flags = 0; DWORD flags = 0;

View File

@ -37,7 +37,7 @@ class Sound;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Transcoder class KGE_API Transcoder
{ {
@ -46,13 +46,13 @@ class KGE_API Transcoder
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
struct Buffer struct Buffer
{ {
BYTE* data; ///< 音频数据 BYTE* data; ///< 音频数据
uint32_t size; ///< 音频数据大小 uint32_t size; ///< 音频数据大小
const WAVEFORMATEX* format; ///< 音频数据格式 const WAVEFORMATEX* format; ///< 音频数据格式
}; };
Transcoder(); Transcoder();
@ -60,24 +60,24 @@ public:
~Transcoder(); ~Transcoder();
/// \~chinese /// \~chinese
/// @brief 获取数据缓冲 /// @brief 获取数据缓冲
Buffer GetBuffer() const; Buffer GetBuffer() const;
/// \~chinese /// \~chinese
/// @brief 清空数据缓冲 /// @brief 清空数据缓冲
void ClearBuffer(); void ClearBuffer();
private: private:
/// \~chinese /// \~chinese
/// @brief 解码本地音频文件 /// @brief 解码本地音频文件
HRESULT LoadMediaFile(const String& file_path); HRESULT LoadMediaFile(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 解码音频资源 /// @brief 解码音频资源
HRESULT LoadMediaResource(const Resource& res); HRESULT LoadMediaResource(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 读取音频源数据 /// @brief 读取音频源数据
HRESULT ReadSource(IMFSourceReader* reader); HRESULT ReadSource(IMFSourceReader* reader);
private: private:

View File

@ -28,24 +28,24 @@ namespace imgui
KGE_DECLARE_SMART_PTR(ImGuiLayer); KGE_DECLARE_SMART_PTR(ImGuiLayer);
/// \~chinese /// \~chinese
/// @brief ImGui管道 /// @brief ImGui管道
using ImGuiPipeline = Function<void()>; using ImGuiPipeline = Function<void()>;
/** /**
* \~chinese * \~chinese
* @brief ImGui图层 * @brief ImGui图层
*/ */
class ImGuiLayer : public LayerActor class ImGuiLayer : public LayerActor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建ImGui图层 /// @brief 创建ImGui图层
static ImGuiLayerPtr Create(); static ImGuiLayerPtr Create();
/// \~chinese /// \~chinese
/// @brief 创建ImGui图层 /// @brief 创建ImGui图层
/// @param name 元素名称 /// @param name 元素名称
/// @param item 管道 /// @param item 管道
static ImGuiLayerPtr Create(const String& name, const ImGuiPipeline& item); static ImGuiLayerPtr Create(const String& name, const ImGuiPipeline& item);
ImGuiLayer(); ImGuiLayer();
@ -53,19 +53,19 @@ public:
virtual ~ImGuiLayer(); virtual ~ImGuiLayer();
/// \~chinese /// \~chinese
/// @brief 添加 ImGui 元素 /// @brief 添加 ImGui 元素
/// @param name 元素名称 /// @param name 元素名称
/// @param item 管道 /// @param item 管道
void AddItem(const String& name, const ImGuiPipeline& item); void AddItem(const String& name, const ImGuiPipeline& item);
/// \~chinese /// \~chinese
/// @brief 移除 ImGui 元素 /// @brief 移除 ImGui 元素
/// @param name 元素名称 /// @param name 元素名称
void RemoveItem(const String& name); void RemoveItem(const String& name);
// 移除所有元素 // 移除所有元素
/// \~chinese /// \~chinese
/// @brief 移除所有元素 /// @brief 移除所有元素
void RemoveAllItems(); void RemoveAllItems();
public: public:

View File

@ -30,7 +30,7 @@ namespace imgui
/** /**
* \~chinese * \~chinese
* @brief ImGui模块 * @brief ImGuiдё©И
*/ */
class ImGuiModule class ImGuiModule
: public Singleton<ImGuiModule> : public Singleton<ImGuiModule>

View File

@ -31,7 +31,7 @@ namespace network
{ {
/** /**
* \~chinese * \~chinese
* \defgroup Network * \defgroup Network
*/ */
/** /**
@ -41,7 +41,7 @@ namespace network
/** /**
* \~chinese * \~chinese
* @brief HTTP模块 * @brief HTTP模块
*/ */
class KGE_API HttpModule class KGE_API HttpModule
: public Singleton<HttpModule> : public Singleton<HttpModule>
@ -51,33 +51,33 @@ class KGE_API HttpModule
public: public:
/// \~chinese /// \~chinese
/// @brief 发送HTTP请求 /// @brief 发送HTTP请求
/// @param[in] request HTTP请求 /// @param[in] request HTTP请求
/// @details 发送请求后,无论结束或失败都将调用请求的响应回调函数 /// @details 发送请求后,无论结束或失败都将调用请求的响应回调函数
void Send(HttpRequestPtr request); void Send(HttpRequestPtr request);
/// \~chinese /// \~chinese
/// @brief 设置连接超时时长 /// @brief 设置连接超时时长
void SetTimeoutForConnect(Duration timeout); void SetTimeoutForConnect(Duration timeout);
/// \~chinese /// \~chinese
/// @brief 获取连接超时时长 /// @brief 获取连接超时时长
Duration GetTimeoutForConnect() const; Duration GetTimeoutForConnect() const;
/// \~chinese /// \~chinese
/// @brief 设置读取超时时长 /// @brief 设置读取超时时长
void SetTimeoutForRead(Duration timeout); void SetTimeoutForRead(Duration timeout);
/// \~chinese /// \~chinese
/// @brief 获取读取超时时长 /// @brief 获取读取超时时长
Duration GetTimeoutForRead() const; Duration GetTimeoutForRead() const;
/// \~chinese /// \~chinese
/// @brief 设置SSL证书地址 /// @brief 设置SSL证书地址
void SetSSLVerification(const String& root_certificate_path); void SetSSLVerification(const String& root_certificate_path);
/// \~chinese /// \~chinese
/// @brief 获取SSL证书地址 /// @brief 获取SSL证书地址
const String& GetSSLVerification() const; const String& GetSSLVerification() const;
public: public:

View File

@ -37,48 +37,48 @@ KGE_DECLARE_SMART_PTR(HttpRequest);
*/ */
/// \~chinese /// \~chinese
/// @brief HTTP请求类型 /// @brief HTTP请求类型
enum class HttpType enum class HttpType
{ {
Unknown, ///< 未知 Unknown, ///< 未知
Get, ///< HTTP GET请求 Get, ///< HTTP GET请求
Post, ///< HTTP POST请求 Post, ///< HTTP POST请求
Put, ///< HTTP PUT请求 Put, ///< HTTP PUT请求
Delete ///< HTTP DELETE请求 Delete ///< HTTP DELETE请求
}; };
/** /**
* \~chinese * \~chinese
* @brief HTTP请求 * @brief HTTP请求
*/ */
class KGE_API HttpRequest : public ObjectBase class KGE_API HttpRequest : public ObjectBase
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 响应回调函数 /// @brief 响应回调函数
using ResponseCallback = Function<void(HttpRequest* /* request */, HttpResponse* /* response */)>; using ResponseCallback = Function<void(HttpRequest* /* request */, HttpResponse* /* response */)>;
/// \~chinese /// \~chinese
/// @brief 创建HTTP请求 /// @brief 创建HTTP请求
/// @param url 请求地址 /// @param url 请求地址
/// @param type 请求类型 /// @param type 请求类型
/// @param callback 响应回调函数 /// @param callback 响应回调函数
static HttpRequestPtr Create(const String& url, HttpType type, const ResponseCallback& callback); static HttpRequestPtr Create(const String& url, HttpType type, const ResponseCallback& callback);
/// \~chinese /// \~chinese
/// @brief 创建HTTP请求 /// @brief 创建HTTP请求
/// @param url 请求地址 /// @param url 请求地址
/// @param type 请求类型 /// @param type 请求类型
/// @param data 请求数据 /// @param data 请求数据
/// @param callback 响应回调函数 /// @param callback 响应回调函数
static HttpRequestPtr Create(const String& url, HttpType type, const String& data, const ResponseCallback& callback); static HttpRequestPtr Create(const String& url, HttpType type, const String& data, const ResponseCallback& callback);
/// \~chinese /// \~chinese
/// @brief 创建HTTP请求 /// @brief 创建HTTP请求
/// @param url 请求地址 /// @param url 请求地址
/// @param type 请求类型 /// @param type 请求类型
/// @param json 请求的JSON数据 /// @param json 请求的JSON数据
/// @param callback 响应回调函数 /// @param callback 响应回调函数
static HttpRequestPtr Create(const String& url, HttpType type, const Json& json, const ResponseCallback& callback); static HttpRequestPtr Create(const String& url, HttpType type, const Json& json, const ResponseCallback& callback);
HttpRequest(); HttpRequest();
@ -86,55 +86,55 @@ public:
HttpRequest(HttpType type); HttpRequest(HttpType type);
/// \~chinese /// \~chinese
/// @brief 设置请求地址 /// @brief 设置请求地址
void SetUrl(const String& url); void SetUrl(const String& url);
/// \~chinese /// \~chinese
/// @brief 设置请求类型 /// @brief 设置请求类型
void SetType(HttpType type); void SetType(HttpType type);
/// \~chinese /// \~chinese
/// @brief 设置请求数据 /// @brief 设置请求数据
void SetData(const String& data); void SetData(const String& data);
/// \~chinese /// \~chinese
/// @brief 设置请求的JSON数据 /// @brief 设置请求的JSON数据
void SetJsonData(const Json& json); void SetJsonData(const Json& json);
/// \~chinese /// \~chinese
/// @brief 设置HTTP头 /// @brief 设置HTTP头
void SetHeaders(const Map<String, String>& headers); void SetHeaders(const Map<String, String>& headers);
/// \~chinese /// \~chinese
/// @brief 设置HTTP头 /// @brief 设置HTTP头
void SetHeader(const String& field, const String& content); void SetHeader(const String& field, const String& content);
/// \~chinese /// \~chinese
/// @brief 设置响应回调函数 /// @brief 设置响应回调函数
void SetResponseCallback(const ResponseCallback& callback); void SetResponseCallback(const ResponseCallback& callback);
/// \~chinese /// \~chinese
/// @brief 获取请求地址 /// @brief 获取请求地址
const String& GetUrl() const; const String& GetUrl() const;
/// \~chinese /// \~chinese
/// @brief 获取请求类型 /// @brief 获取请求类型
HttpType GetType() const; HttpType GetType() const;
/// \~chinese /// \~chinese
/// @brief 获取请求数据 /// @brief 获取请求数据
const String& GetData() const; const String& GetData() const;
/// \~chinese /// \~chinese
/// @brief 获取HTTP头 /// @brief 获取HTTP头
Map<String, String>& GetHeaders(); Map<String, String>& GetHeaders();
/// \~chinese /// \~chinese
/// @brief 获取HTTP头 /// @brief 获取HTTP头
const String& GetHeader(const String& header) const; const String& GetHeader(const String& header) const;
/// \~chinese /// \~chinese
/// @brief 获取响应回调函数 /// @brief 获取响应回调函数
const ResponseCallback& GetResponseCallback() const; const ResponseCallback& GetResponseCallback() const;
private: private:

View File

@ -34,7 +34,7 @@ KGE_DECLARE_SMART_PTR(HttpResponse);
/** /**
* \~chinese * \~chinese
* @brief HTTP响应 * @brief HTTP响应
*/ */
class KGE_API HttpResponse : public ObjectBase class KGE_API HttpResponse : public ObjectBase
{ {
@ -42,47 +42,47 @@ public:
HttpResponse(HttpRequestPtr request); HttpResponse(HttpRequestPtr request);
/// \~chinese /// \~chinese
/// @brief 获取对应的HTTP请求 /// @brief 获取对应的HTTP请求
HttpRequestPtr GetRequest() const; HttpRequestPtr GetRequest() const;
/// \~chinese /// \~chinese
/// @brief 获取响应状态 /// @brief 获取响应状态
bool IsSucceed() const; bool IsSucceed() const;
/// \~chinese /// \~chinese
/// @brief 获取HTTP状态码 /// @brief 获取HTTP状态码
long GetResponseCode() const; long GetResponseCode() const;
/// \~chinese /// \~chinese
/// @brief 获取响应头 /// @brief 获取响应头
String GetHeader() const; String GetHeader() const;
/// \~chinese /// \~chinese
/// @brief 获取响应数据 /// @brief 获取响应数据
const String& GetData() const; const String& GetData() const;
/// \~chinese /// \~chinese
/// @brief 获取错误信息 /// @brief 获取错误信息
const String& GetError() const; const String& GetError() const;
/// \~chinese /// \~chinese
/// @brief 设置响应状态 /// @brief 设置响应状态
void SetSucceed(bool succeed); void SetSucceed(bool succeed);
/// \~chinese /// \~chinese
/// @brief 设置HTTP状态码 /// @brief 设置HTTP状态码
void SetResponseCode(long response_code); void SetResponseCode(long response_code);
/// \~chinese /// \~chinese
/// @brief 设置响应头 /// @brief 设置响应头
void SetHeader(const String& response_header); void SetHeader(const String& response_header);
/// \~chinese /// \~chinese
/// @brief 设置响应数据 /// @brief 设置响应数据
void SetData(const String& response_data); void SetData(const String& response_data);
/// \~chinese /// \~chinese
/// @brief 设置错误信息 /// @brief 设置错误信息
void SetError(const String& error_buffer); void SetError(const String& error_buffer);
private: private:

View File

@ -32,78 +32,78 @@ namespace physics
*/ */
/// \~chinese /// \~chinese
/// @brief 物理接触 /// @brief 物理接触
class KGE_API Contact class KGE_API Contact
{ {
public: public:
Contact(); Contact();
/// \~chinese /// \~chinese
/// @brief 是否是接触 /// @brief 是否是接触
bool IsTouching() const; bool IsTouching() const;
/// \~chinese /// \~chinese
/// @brief 启用或禁用 (仅作用于一个时间步) /// @brief 启用或禁用 (仅作用于一个时间步)
void SetEnabled(bool flag); void SetEnabled(bool flag);
/// \~chinese /// \~chinese
/// @brief 是否启用 /// @brief 是否启用
bool IsEnabled() const; bool IsEnabled() const;
/// \~chinese /// \~chinese
/// @brief 获取物体A的夹具 /// @brief 获取物体A的夹具
Fixture* GetFixtureA() const; Fixture* GetFixtureA() const;
/// \~chinese /// \~chinese
/// @brief 获取物体B的夹具 /// @brief 获取物体B的夹具
Fixture* GetFixtureB() const; Fixture* GetFixtureB() const;
/// \~chinese /// \~chinese
/// @brief 获取物体A /// @brief 获取物体A
PhysicBody* GetBodyA() const; PhysicBody* GetBodyA() const;
/// \~chinese /// \~chinese
/// @brief 获取物体B /// @brief 获取物体B
PhysicBody* GetBodyB() const; PhysicBody* GetBodyB() const;
/// \~chinese /// \~chinese
/// @brief 设置摩擦力 /// @brief 设置摩擦力
void SetFriction(float friction); void SetFriction(float friction);
/// \~chinese /// \~chinese
/// @brief 获取摩擦力 /// @brief 获取摩擦力
float GetFriction() const; float GetFriction() const;
/// \~chinese /// \~chinese
/// @brief 重置摩擦力 /// @brief 重置摩擦力
void ResetFriction(); void ResetFriction();
/// \~chinese /// \~chinese
/// @brief 设置弹性恢复 /// @brief 设置弹性恢复
void SetRestitution(float restitution); void SetRestitution(float restitution);
/// \~chinese /// \~chinese
/// @brief 获取弹性恢复 /// @brief 获取弹性恢复
float GetRestitution() const; float GetRestitution() const;
/// \~chinese /// \~chinese
/// @brief 重置弹性恢复 /// @brief 重置弹性恢复
void ResetRestitution(); void ResetRestitution();
/// \~chinese /// \~chinese
/// @brief 设置切线速度 /// @brief 设置切线速度
void SetTangentSpeed(float speed); void SetTangentSpeed(float speed);
/// \~chinese /// \~chinese
/// @brief 获取切线速度 /// @brief 获取切线速度
float GetTangentSpeed() const; float GetTangentSpeed() const;
/// \~chinese /// \~chinese
/// @brief 获取b2Contact /// @brief 获取b2Contact
b2Contact* GetB2Contact() const; b2Contact* GetB2Contact() const;
/// \~chinese /// \~chinese
/// @brief 设置b2Contact /// @brief 设置b2Contact
void SetB2Contact(b2Contact* contact); void SetB2Contact(b2Contact* contact);
bool operator==(const Contact& rhs) const; bool operator==(const Contact& rhs) const;
@ -114,7 +114,7 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 物理接触列表 /// @brief 物理接触列表
class ContactList class ContactList
{ {
template <typename _Ty> template <typename _Ty>

View File

@ -31,26 +31,26 @@ namespace physics
*/ */
/// \~chinese /// \~chinese
/// @brief 接触边 /// @brief 接触边
class KGE_API ContactEdge class KGE_API ContactEdge
{ {
public: public:
ContactEdge(); ContactEdge();
/// \~chinese /// \~chinese
/// @brief 获取接触物体 /// @brief 获取接触物体
PhysicBody* GetOtherBody() const; PhysicBody* GetOtherBody() const;
/// \~chinese /// \~chinese
/// @brief 获取接触 /// @brief 获取接触
Contact GetContact() const; Contact GetContact() const;
/// \~chinese /// \~chinese
/// @brief 获取b2ContactEdge /// @brief 获取b2ContactEdge
b2ContactEdge* GetB2ContactEdge() const; b2ContactEdge* GetB2ContactEdge() const;
/// \~chinese /// \~chinese
/// @brief 设置b2ContactEdge /// @brief 设置b2ContactEdge
void SetB2ContactEdge(b2ContactEdge* edge); void SetB2ContactEdge(b2ContactEdge* edge);
bool operator==(const ContactEdge& rhs) const; bool operator==(const ContactEdge& rhs) const;
@ -61,7 +61,7 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 物理接触边列表 /// @brief 物理接触边列表
class ContactEdgeList class ContactEdgeList
{ {
template <typename _Ty> template <typename _Ty>

View File

@ -35,11 +35,11 @@ KGE_DECLARE_SMART_PTR(ContactEndEvent);
*/ */
/// \~chinese /// \~chinese
/// @brief 物理接触开始事件 /// @brief 物理接触开始事件
class KGE_API ContactBeginEvent : public Event class KGE_API ContactBeginEvent : public Event
{ {
public: public:
Contact contact; ///< 产生的接触 Contact contact; ///< 产生的接触
ContactBeginEvent(); ContactBeginEvent();
@ -47,11 +47,11 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 物理接触结束事件 /// @brief 物理接触结束事件
class KGE_API ContactEndEvent : public Event class KGE_API ContactEndEvent : public Event
{ {
public: public:
Contact contact; ///< 产生的接触 Contact contact; ///< 产生的接触
ContactEndEvent(); ContactEndEvent();

View File

@ -35,18 +35,18 @@ KGE_DECLARE_SMART_PTR(Fixture);
*/ */
/// \~chinese /// \~chinese
/// @brief 物理夹具 /// @brief 物理夹具
class KGE_API Fixture : public ObjectBase class KGE_API Fixture : public ObjectBase
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 夹具参数 /// @brief 夹具参数
struct Param struct Param
{ {
float density = 0.0f; ///< 密度 float density = 0.0f; ///< 密度
float friction = 0.2f; ///< 摩擦力 float friction = 0.2f; ///< 摩擦力
float restitution = 0.0f; ///< 弹性恢复 float restitution = 0.0f; ///< 弹性恢复
bool is_sensor = false; ///< 是否是接触传感器 bool is_sensor = false; ///< 是否是接触传感器
Param() {} Param() {}
@ -60,39 +60,39 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建圆形夹具 /// @brief 创建圆形夹具
/// @param param 夹具参数 /// @param param 夹具参数
/// @param radius 圆形半径 /// @param radius 圆形半径
/// @param offset 偏移量 /// @param offset 偏移量
static FixturePtr CreateCircle(const Param& param, float radius, const Point& offset = Point()); static FixturePtr CreateCircle(const Param& param, float radius, const Point& offset = Point());
/// \~chinese /// \~chinese
/// @brief 创建矩形夹具 /// @brief 创建矩形夹具
/// @param param 夹具参数 /// @param param 夹具参数
/// @param size 矩形大小 /// @param size 矩形大小
/// @param offset 偏移量 /// @param offset 偏移量
/// @param rotation 旋转角度 /// @param rotation 旋转角度
static FixturePtr CreateRect(const Param& param, const Size& size, const Point& offset = Point(), static FixturePtr CreateRect(const Param& param, const Size& size, const Point& offset = Point(),
float rotation = 0.f); float rotation = 0.f);
/// \~chinese /// \~chinese
/// @brief 创建多边形夹具 /// @brief 创建多边形夹具
/// @param param 夹具参数 /// @param param 夹具参数
/// @param vertexs 多边形顶点 /// @param vertexs 多边形顶点
static FixturePtr CreatePolygon(const Param& param, const Vector<Point>& vertexs); static FixturePtr CreatePolygon(const Param& param, const Vector<Point>& vertexs);
/// \~chinese /// \~chinese
/// @brief 创建边夹具 /// @brief 创建边夹具
/// @param param 夹具参数 /// @param param 夹具参数
/// @param p1 边的起点 /// @param p1 边的起点
/// @param p2 边的终点 /// @param p2 边的终点
static FixturePtr CreateEdge(const Param& param, const Point& p1, const Point& p2); static FixturePtr CreateEdge(const Param& param, const Point& p1, const Point& p2);
/// \~chinese /// \~chinese
/// @brief 创建链条夹具 /// @brief 创建链条夹具
/// @param param 夹具参数 /// @param param 夹具参数
/// @param vertexs 链条顶点 /// @param vertexs 链条顶点
/// @param loop 是否连接链条的起点和终点 /// @param loop 是否连接链条的起点和终点
static FixturePtr CreateChain(const Param& param, const Vector<Point>& vertices, bool loop = false); static FixturePtr CreateChain(const Param& param, const Vector<Point>& vertices, bool loop = false);
Fixture(); Fixture();
@ -100,68 +100,68 @@ public:
virtual ~Fixture(); virtual ~Fixture();
/// \~chinese /// \~chinese
/// @brief 初始化夹具 /// @brief 初始化夹具
bool Init(PhysicBodyPtr body); bool Init(PhysicBodyPtr body);
/// \~chinese /// \~chinese
/// @brief 初始化夹具 /// @brief 初始化夹具
bool Init(PhysicBody* body); bool Init(PhysicBody* body);
/// \~chinese /// \~chinese
/// @brief 获取夹具所在的物体 /// @brief 获取夹具所在的物体
PhysicBody* GetBody() const; PhysicBody* GetBody() const;
/// \~chinese /// \~chinese
/// @brief 是否是接触传感器 /// @brief 是否是接触传感器
bool IsSensor() const; bool IsSensor() const;
/// \~chinese /// \~chinese
/// @brief 设置夹具是否是接触传感器 /// @brief 设置夹具是否是接触传感器
/// @details 接触传感器只会产生物理接触,而不会影响物体运动 /// @details 接触传感器只会产生物理接触,而不会影响物体运动
void SetSensor(bool sensor); void SetSensor(bool sensor);
/// \~chinese /// \~chinese
/// @brief 获取夹具的质量数据 /// @brief 获取夹具的质量数据
void GetMassData(float* mass, Point* center, float* inertia) const; void GetMassData(float* mass, Point* center, float* inertia) const;
/// \~chinese /// \~chinese
/// @brief 获取密度 /// @brief 获取密度
float GetDensity() const; float GetDensity() const;
/// \~chinese /// \~chinese
/// @brief 设置密度 /// @brief 设置密度
void SetDensity(float density); void SetDensity(float density);
/// \~chinese /// \~chinese
/// @brief 获取摩擦力 [N] /// @brief 获取摩擦力 [N]
float GetFriction() const; float GetFriction() const;
/// \~chinese /// \~chinese
/// @brief 设置摩擦力 [N] /// @brief 设置摩擦力 [N]
void SetFriction(float friction); void SetFriction(float friction);
/// \~chinese /// \~chinese
/// @brief 获取弹性恢复 /// @brief 获取弹性恢复
float GetRestitution() const; float GetRestitution() const;
/// \~chinese /// \~chinese
/// @brief 设置弹性恢复 /// @brief 设置弹性恢复
void SetRestitution(float restitution); void SetRestitution(float restitution);
/// \~chinese /// \~chinese
/// @brief 点测试 /// @brief 点测试
bool TestPoint(const Point& p) const; bool TestPoint(const Point& p) const;
/// \~chinese /// \~chinese
/// @brief 销毁夹具 /// @brief 销毁夹具
void Destroy(); void Destroy();
/// \~chinese /// \~chinese
/// @brief 获取b2Fixture /// @brief 获取b2Fixture
b2Fixture* GetB2Fixture() const; b2Fixture* GetB2Fixture() const;
/// \~chinese /// \~chinese
/// @brief 设置b2Fixture /// @brief 设置b2Fixture
void SetB2Fixture(b2Fixture* fixture); void SetB2Fixture(b2Fixture* fixture);
bool operator==(const Fixture& rhs) const; bool operator==(const Fixture& rhs) const;
@ -174,7 +174,7 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 物理夹具列表 /// @brief 物理夹具列表
class FixtureList class FixtureList
{ {
template <typename _Ty> template <typename _Ty>

View File

@ -36,33 +36,33 @@ namespace global
{ {
/// \~chinese /// \~chinese
/// @brief 获取全局缩放比例 /// @brief 获取全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100 /// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
float GetScale(); float GetScale();
/// \~chinese /// \~chinese
/// @brief 设置全局缩放比例 /// @brief 设置全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100 /// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
void SetScale(float scale); void SetScale(float scale);
/// \~chinese /// \~chinese
/// @brief 游戏世界单位转换为物理世界单位 /// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位 /// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
float WorldToLocal(float value); float WorldToLocal(float value);
/// \~chinese /// \~chinese
/// @brief 游戏世界单位转换为物理世界单位 /// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位 /// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
Vec2 WorldToLocal(const b2Vec2& pos); Vec2 WorldToLocal(const b2Vec2& pos);
/// \~chinese /// \~chinese
/// @brief 物理世界单位转换为游戏世界单位 /// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米 /// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
float LocalToWorld(float value); float LocalToWorld(float value);
/// \~chinese /// \~chinese
/// @brief 物理世界单位转换为游戏世界单位 /// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米 /// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
b2Vec2 LocalToWorld(const Vec2& pos); b2Vec2 LocalToWorld(const Vec2& pos);
} // namespace global } // namespace global

View File

@ -44,35 +44,35 @@ KGE_DECLARE_SMART_PTR(WheelJoint);
*/ */
/// \~chinese /// \~chinese
/// @brief 关节 /// @brief 关节
class KGE_API Joint : public ObjectBase class KGE_API Joint : public ObjectBase
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 关节类型 /// @brief 关节类型
enum class Type enum class Type
{ {
Unknown = 0, ///< 未知 Unknown = 0, ///< 未知
Revolute, ///< 旋转关节 Revolute, ///< 旋转关节
Prismatic, ///< 平移关节 Prismatic, ///< 平移关节
Distance, ///< 固定距离关节 Distance, ///< 固定距离关节
Pulley, ///< 滑轮关节 Pulley, ///< 滑轮关节
Mouse, ///< 鼠标关节 Mouse, ///< 鼠标关节
Gear, ///< 齿轮关节 Gear, ///< 齿轮关节
Wheel, ///< 轮关节 Wheel, ///< 轮关节
Weld, ///< 焊接关节 Weld, ///< 焊接关节
Friction, ///< 摩擦关节 Friction, ///< 摩擦关节
Rope, ///< 绳关节 Rope, ///< 绳关节
Motor ///< 马达关节 Motor ///< 马达关节
}; };
/// \~chinese /// \~chinese
/// @brief 关节基础参数 /// @brief 关节基础参数
struct ParamBase struct ParamBase
{ {
PhysicBody* body_a; ///< 关节连接的物体A PhysicBody* body_a; ///< 关节连接的物体A
PhysicBody* body_b; ///< 关节连接的物体B PhysicBody* body_b; ///< 关节连接的物体B
bool collide_connected; // 关节连接的物体是否允许碰撞 bool collide_connected; // 关节连接的物体是否允许碰撞
ParamBase(PhysicBody* body_a, PhysicBody* body_b) ParamBase(PhysicBody* body_a, PhysicBody* body_b)
: body_a(body_a) : body_a(body_a)
@ -92,35 +92,35 @@ public:
virtual ~Joint(); virtual ~Joint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
virtual bool Init(PhysicWorld* world); virtual bool Init(PhysicWorld* world);
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world, b2JointDef* joint_def); bool Init(PhysicWorld* world, b2JointDef* joint_def);
/// \~chinese /// \~chinese
/// @brief 获取关节连接的物体A /// @brief 获取关节连接的物体A
PhysicBodyPtr GetBodyA() const; PhysicBodyPtr GetBodyA() const;
/// \~chinese /// \~chinese
/// @brief 获取关节连接的物体B /// @brief 获取关节连接的物体B
PhysicBodyPtr GetBodyB() const; PhysicBodyPtr GetBodyB() const;
/// \~chinese /// \~chinese
/// @brief 获取物理世界 /// @brief 获取物理世界
PhysicWorld* GetWorld() const; PhysicWorld* GetWorld() const;
/// \~chinese /// \~chinese
/// @brief 销毁关节 /// @brief 销毁关节
void Destroy(); void Destroy();
/// \~chinese /// \~chinese
/// @brief 获取b2Joint /// @brief 获取b2Joint
b2Joint* GetB2Joint() const; b2Joint* GetB2Joint() const;
/// \~chinese /// \~chinese
/// @brief 设置b2Joint /// @brief 设置b2Joint
void SetB2Joint(b2Joint* joint); void SetB2Joint(b2Joint* joint);
private: private:
@ -130,18 +130,18 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 固定距离关节 /// @brief 固定距离关节
class KGE_API DistanceJoint : public Joint class KGE_API DistanceJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 固定距离关节参数 /// @brief 固定距离关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point anchor_a; ///< 关节在物体A上的连接点 Point anchor_a; ///< 关节在物体A上的连接点
Point anchor_b; ///< 关节在物体B上的连接点 Point anchor_b; ///< 关节在物体B上的连接点
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固 float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大 float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Param() Param()
: Param(nullptr, nullptr, Point(), Point()) : Param(nullptr, nullptr, Point(), Point())
@ -159,38 +159,38 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建固定距离关节 /// @brief 创建固定距离关节
/// @param param 关节参数 /// @param param 关节参数
static DistanceJointPtr Create(const Param& param); static DistanceJointPtr Create(const Param& param);
DistanceJoint(); DistanceJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 设置关节长度 /// @brief 设置关节长度
void SetLength(float length); void SetLength(float length);
/// \~chinese /// \~chinese
/// @brief 获取关节长度 /// @brief 获取关节长度
float GetLength() const; float GetLength() const;
/// \~chinese /// \~chinese
/// @brief 设置弹簧响应速度 [赫兹] /// @brief 设置弹簧响应速度 [赫兹]
void SetFrequency(float hz); void SetFrequency(float hz);
/// \~chinese /// \~chinese
/// @brief 获取弹簧响应速度 [赫兹] /// @brief 获取弹簧响应速度 [赫兹]
float GetFrequency() const; float GetFrequency() const;
/// \~chinese /// \~chinese
/// @brief 设置阻尼率 /// @brief 设置阻尼率
void SetDampingRatio(float ratio); void SetDampingRatio(float ratio);
/// \~chinese /// \~chinese
/// @brief 获取阻尼率 /// @brief 获取阻尼率
float GetDampingRatio() const; float GetDampingRatio() const;
private: private:
@ -199,15 +199,15 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 摩擦关节 /// @brief 摩擦关节
class KGE_API FrictionJoint : public Joint class KGE_API FrictionJoint : public Joint
{ {
public: public:
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point anchor; ///< 摩擦作用点 Point anchor; ///< 摩擦作用点
float max_force; ///< 最大摩擦力 float max_force; ///< 最大摩擦力
float max_torque; ///< 最大扭力 float max_torque; ///< 最大扭力
Param() Param()
: Param(nullptr, nullptr, Point()) : Param(nullptr, nullptr, Point())
@ -224,30 +224,30 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建摩擦关节 /// @brief 创建摩擦关节
/// @param param 关节参数 /// @param param 关节参数
static FrictionJointPtr Create(const Param& param); static FrictionJointPtr Create(const Param& param);
FrictionJoint(); FrictionJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 设置最大摩擦力 /// @brief 设置最大摩擦力
void SetMaxForce(float force); void SetMaxForce(float force);
/// \~chinese /// \~chinese
/// @brief 获取最大摩擦力 /// @brief 获取最大摩擦力
float GetMaxForce() const; float GetMaxForce() const;
/// \~chinese /// \~chinese
/// @brief 设置最大转矩 /// @brief 设置最大转矩
void SetMaxTorque(float torque); void SetMaxTorque(float torque);
/// \~chinese /// \~chinese
/// @brief 获取最大转矩 /// @brief 获取最大转矩
float GetMaxTorque() const; float GetMaxTorque() const;
private: private:
@ -256,17 +256,17 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 齿轮关节 /// @brief 齿轮关节
class KGE_API GearJoint : public Joint class KGE_API GearJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 齿轮关节参数 /// @brief 齿轮关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Joint* joint_a; ///< 关节A旋转关节/平移关节) Joint* joint_a; ///< 关节A旋转关节/平移关节)
Joint* joint_b; ///< 关节B旋转关节/平移关节) Joint* joint_b; ///< 关节B旋转关节/平移关节)
float ratio; ///< 齿轮传动比 float ratio; ///< 齿轮传动比
Param() Param()
: Param(nullptr, nullptr) : Param(nullptr, nullptr)
@ -283,22 +283,22 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建齿轮关节 /// @brief 创建齿轮关节
/// @param param 关节参数 /// @param param 关节参数
static GearJointPtr Create(const Param& param); static GearJointPtr Create(const Param& param);
GearJoint(); GearJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 设定齿轮传动比 /// @brief 设定齿轮传动比
void SetRatio(float ratio); void SetRatio(float ratio);
/// \~chinese /// \~chinese
/// @brief 获取齿轮传动比 /// @brief 获取齿轮传动比
float GetRatio() const; float GetRatio() const;
private: private:
@ -307,17 +307,17 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 马达关节 /// @brief 马达关节
class KGE_API MotorJoint : public Joint class KGE_API MotorJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 马达关节参数 /// @brief 马达关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
float max_force; ///< 最大摩擦力 float max_force; ///< 最大摩擦力
float max_torque; ///< 最大转矩 float max_torque; ///< 最大转矩
float correction_factor; ///< 位置矫正因子(范围 0-1 float correction_factor; ///< 位置矫正因子(范围 0-1
Param() Param()
: Param(nullptr, nullptr) : Param(nullptr, nullptr)
@ -334,30 +334,30 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建马达关节 /// @brief 创建马达关节
/// @param param 关节参数 /// @param param 关节参数
static MotorJointPtr Create(const Param& param); static MotorJointPtr Create(const Param& param);
MotorJoint(); MotorJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 设置最大摩擦力 /// @brief 设置最大摩擦力
void SetMaxForce(float force); void SetMaxForce(float force);
/// \~chinese /// \~chinese
/// @brief 获取最大摩擦力 /// @brief 获取最大摩擦力
float GetMaxForce() const; float GetMaxForce() const;
/// \~chinese /// \~chinese
/// @brief 设置最大转矩 /// @brief 设置最大转矩
void SetMaxTorque(float torque); void SetMaxTorque(float torque);
/// \~chinese /// \~chinese
/// @brief 获取最大转矩 /// @brief 获取最大转矩
float GetMaxTorque() const; float GetMaxTorque() const;
private: private:
@ -366,22 +366,22 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 平移关节 /// @brief 平移关节
class KGE_API PrismaticJoint : public Joint class KGE_API PrismaticJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 平移关节参数 /// @brief 平移关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point anchor; ///< 关节位置 Point anchor; ///< 关节位置
Vec2 axis; ///< 物体A滑动的方向 Vec2 axis; ///< 物体A滑动的方向
bool enable_limit; ///< 是否启用限制 bool enable_limit; ///< 是否启用限制
float lower_translation; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果 float lower_translation; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
float upper_translation; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果 float upper_translation; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
bool enable_motor; ///< 是否启用马达 bool enable_motor; ///< 是否启用马达
float max_motor_force; ///< 最大马达力 [N] float max_motor_force; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s] float motor_speed; ///< 马达转速 [degree/s]
Param() Param()
: Param(nullptr, nullptr, Point(), Vec2()) : Param(nullptr, nullptr, Point(), Vec2())
@ -403,70 +403,70 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建平移关节 /// @brief 创建平移关节
/// @param param 关节参数 /// @param param 关节参数
static PrismaticJointPtr Create(const Param& param); static PrismaticJointPtr Create(const Param& param);
PrismaticJoint(); PrismaticJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 获取参考角 /// @brief 获取参考角
float GetReferenceAngle() const; float GetReferenceAngle() const;
/// \~chinese /// \~chinese
/// @brief 获取关节转换 /// @brief 获取关节转换
float GetJointTranslation() const; float GetJointTranslation() const;
/// \~chinese /// \~chinese
/// @brief 获取关节速度 /// @brief 获取关节速度
float GetJointSpeed() const; float GetJointSpeed() const;
/// \~chinese /// \~chinese
/// @brief 是否启用关节限制 /// @brief 是否启用关节限制
bool IsLimitEnabled() const; bool IsLimitEnabled() const;
/// \~chinese /// \~chinese
/// @brief 设置是否启用关节限制 /// @brief 设置是否启用关节限制
void EnableLimit(bool flag); void EnableLimit(bool flag);
/// \~chinese /// \~chinese
/// @brief 获取平移最小限制 /// @brief 获取平移最小限制
float GetLowerLimit() const; float GetLowerLimit() const;
/// \~chinese /// \~chinese
/// @brief 获取平移最大限制 /// @brief 获取平移最大限制
float GetUpperLimit() const; float GetUpperLimit() const;
/// \~chinese /// \~chinese
/// @brief 设置关节限制 /// @brief 设置关节限制
void SetLimits(float lower, float upper); void SetLimits(float lower, float upper);
/// \~chinese /// \~chinese
/// @brief 是否启用马达 /// @brief 是否启用马达
bool IsMotorEnabled() const; bool IsMotorEnabled() const;
/// \~chinese /// \~chinese
/// @brief 设置是否启用马达 /// @brief 设置是否启用马达
void EnableMotor(bool flag); void EnableMotor(bool flag);
/// \~chinese /// \~chinese
/// @brief 设置马达转速 [degree/s] /// @brief 设置马达转速 [degree/s]
void SetMotorSpeed(float speed); void SetMotorSpeed(float speed);
/// \~chinese /// \~chinese
/// @brief 获取马达转速 [degree/s] /// @brief 获取马达转速 [degree/s]
float GetMotorSpeed() const; float GetMotorSpeed() const;
/// \~chinese /// \~chinese
/// @brief 设置最大马达力 [N] /// @brief 设置最大马达力 [N]
void SetMaxMotorForce(float force); void SetMaxMotorForce(float force);
/// \~chinese /// \~chinese
/// @brief 获取最大马达力 [N] /// @brief 获取最大马达力 [N]
float GetMaxMotorForce() const; float GetMaxMotorForce() const;
private: private:
@ -475,19 +475,19 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 滑轮关节 /// @brief 滑轮关节
class KGE_API PulleyJoint : public Joint class KGE_API PulleyJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 滑轮关节参数 /// @brief 滑轮关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point anchor_a; ///< 关节在物体A上的作用点 Point anchor_a; ///< 关节在物体A上的作用点
Point anchor_b; ///< 关节在物体B上的作用点 Point anchor_b; ///< 关节在物体B上的作用点
Point ground_anchor_a; ///< 物体A对应的滑轮的位置 Point ground_anchor_a; ///< 物体A对应的滑轮的位置
Point ground_anchor_b; ///< 物体B对应的滑轮的位置 Point ground_anchor_b; ///< 物体B对应的滑轮的位置
float ratio; ///< 滑轮比,关节传动时,滑轮上升和下降的两头的位移比例 float ratio; ///< 滑轮比,关节传动时,滑轮上升和下降的两头的位移比例
Param() Param()
: Param(nullptr, nullptr, Point(), Point(), Point(), Point()) : Param(nullptr, nullptr, Point(), Point(), Point(), Point())
@ -507,42 +507,42 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建滑轮关节 /// @brief 创建滑轮关节
/// @param param 关节参数 /// @param param 关节参数
static PulleyJointPtr Create(const Param& param); static PulleyJointPtr Create(const Param& param);
PulleyJoint(); PulleyJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 物体A对应的滑轮的位置 /// @brief 物体A对应的滑轮的位置
Point GetGroundAnchorA() const; Point GetGroundAnchorA() const;
/// \~chinese /// \~chinese
/// @brief 物体B对应的滑轮的位置 /// @brief 物体B对应的滑轮的位置
Point GetGroundAnchorB() const; Point GetGroundAnchorB() const;
/// \~chinese /// \~chinese
/// @brief 获取滑轮传动比 /// @brief 获取滑轮传动比
float GetRatio() const; float GetRatio() const;
/// \~chinese /// \~chinese
/// @brief 获取物体A与滑轮的距离 /// @brief 获取物体A与滑轮的距离
float GetLengthA() const; float GetLengthA() const;
/// \~chinese /// \~chinese
/// @brief 获取物体B与滑轮的距离 /// @brief 获取物体B与滑轮的距离
float GetLengthB() const; float GetLengthB() const;
/// \~chinese /// \~chinese
/// @brief 获取物体A与滑轮的当前距离 /// @brief 获取物体A与滑轮的当前距离
float GetCurrentLengthA() const; float GetCurrentLengthA() const;
/// \~chinese /// \~chinese
/// @brief 获取物体B与滑轮的当前距离 /// @brief 获取物体B与滑轮的当前距离
float GetCurrentLengthB() const; float GetCurrentLengthB() const;
private: private:
@ -551,21 +551,21 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 旋转关节 /// @brief 旋转关节
class KGE_API RevoluteJoint : public Joint class KGE_API RevoluteJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 旋转关节参数 /// @brief 旋转关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point anchor; ///< 关节位置 Point anchor; ///< 关节位置
bool enable_limit; ///< 是否启用限制 bool enable_limit; ///< 是否启用限制
float lower_angle; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果 float lower_angle; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
float upper_angle; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果 float upper_angle; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
bool enable_motor; ///< 是否启用马达 bool enable_motor; ///< 是否启用马达
float max_motor_torque; ///< 最大马达力 [N] float max_motor_torque; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s] float motor_speed; ///< 马达转速 [degree/s]
Param() Param()
: Param(nullptr, nullptr, Point()) : Param(nullptr, nullptr, Point())
@ -586,70 +586,70 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建旋转关节 /// @brief 创建旋转关节
/// @param param 关节参数 /// @param param 关节参数
static RevoluteJointPtr Create(const Param& param); static RevoluteJointPtr Create(const Param& param);
RevoluteJoint(); RevoluteJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 获取参考角 /// @brief 获取参考角
float GetReferenceAngle() const; float GetReferenceAngle() const;
/// \~chinese /// \~chinese
/// @brief 获取关节角度 /// @brief 获取关节角度
float GetJointAngle() const; float GetJointAngle() const;
/// \~chinese /// \~chinese
/// @brief 获取关节速度 /// @brief 获取关节速度
float GetJointSpeed() const; float GetJointSpeed() const;
/// \~chinese /// \~chinese
/// @brief 是否启用关节限制 /// @brief 是否启用关节限制
bool IsLimitEnabled() const; bool IsLimitEnabled() const;
/// \~chinese /// \~chinese
/// @brief 设置是否启用关节限制 /// @brief 设置是否启用关节限制
void EnableLimit(bool flag); void EnableLimit(bool flag);
/// \~chinese /// \~chinese
/// @brief 获取平移最小限制 /// @brief 获取平移最小限制
float GetLowerLimit() const; float GetLowerLimit() const;
/// \~chinese /// \~chinese
/// @brief 获取平移最大限制 /// @brief 获取平移最大限制
float GetUpperLimit() const; float GetUpperLimit() const;
/// \~chinese /// \~chinese
/// @brief 设置关节限制 /// @brief 设置关节限制
void SetLimits(float lower, float upper); void SetLimits(float lower, float upper);
/// \~chinese /// \~chinese
/// @brief 是否启用马达 /// @brief 是否启用马达
bool IsMotorEnabled() const; bool IsMotorEnabled() const;
/// \~chinese /// \~chinese
/// @brief 设置是否启用马达 /// @brief 设置是否启用马达
void EnableMotor(bool flag); void EnableMotor(bool flag);
/// \~chinese /// \~chinese
/// @brief 设置马达转速 [degree/s] /// @brief 设置马达转速 [degree/s]
void SetMotorSpeed(float speed); void SetMotorSpeed(float speed);
/// \~chinese /// \~chinese
/// @brief 获取马达转速 [degree/s] /// @brief 获取马达转速 [degree/s]
float GetMotorSpeed() const; float GetMotorSpeed() const;
/// \~chinese /// \~chinese
/// @brief 设置最大马达转矩 [N/m] /// @brief 设置最大马达转矩 [N/m]
void SetMaxMotorTorque(float torque); void SetMaxMotorTorque(float torque);
/// \~chinese /// \~chinese
/// @brief 获取最大马达转矩 [N/m] /// @brief 获取最大马达转矩 [N/m]
float GetMaxMotorTorque() const; float GetMaxMotorTorque() const;
private: private:
@ -658,17 +658,17 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 绳关节 /// @brief 绳关节
class KGE_API RopeJoint : public Joint class KGE_API RopeJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 绳关节参数 /// @brief 绳关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point local_anchor_a; ///< 关节在物体A上的连接点 Point local_anchor_a; ///< 关节在物体A上的连接点
Point local_anchor_b; ///< 关节在物体B上的连接点 Point local_anchor_b; ///< 关节在物体B上的连接点
float max_length; ///< 绳索最大长度 float max_length; ///< 绳索最大长度
Param() Param()
: Param(nullptr, nullptr, Point(), Point()) : Param(nullptr, nullptr, Point(), Point())
@ -685,22 +685,22 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建绳关节 /// @brief 创建绳关节
/// @param param 关节参数 /// @param param 关节参数
static RopeJointPtr Create(const Param& param); static RopeJointPtr Create(const Param& param);
RopeJoint(); RopeJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 设置关节最大长度 /// @brief 设置关节最大长度
void SetMaxLength(float length); void SetMaxLength(float length);
/// \~chinese /// \~chinese
/// @brief 获取关节最大长度 /// @brief 获取关节最大长度
float GetMaxLength() const; float GetMaxLength() const;
private: private:
@ -709,17 +709,17 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 焊接关节 /// @brief 焊接关节
class KGE_API WeldJoint : public Joint class KGE_API WeldJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 焊接关节参数 /// @brief 焊接关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point anchor; ///< 焊接位置 Point anchor; ///< 焊接位置
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固 float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大 float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Param() Param()
: Param(nullptr, nullptr, Point()) : Param(nullptr, nullptr, Point())
@ -736,34 +736,34 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建焊接关节 /// @brief 创建焊接关节
/// @param param 关节参数 /// @param param 关节参数
static WeldJointPtr Create(const Param& param); static WeldJointPtr Create(const Param& param);
WeldJoint(); WeldJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 获取物体B相对于物体A的角度 /// @brief 获取物体B相对于物体A的角度
float GetReferenceAngle() const; float GetReferenceAngle() const;
/// \~chinese /// \~chinese
/// @brief 设置弹簧响应速度 [赫兹] /// @brief 设置弹簧响应速度 [赫兹]
void SetFrequency(float hz); void SetFrequency(float hz);
/// \~chinese /// \~chinese
/// @brief 获取弹簧响应速度 [赫兹] /// @brief 获取弹簧响应速度 [赫兹]
float GetFrequency() const; float GetFrequency() const;
/// \~chinese /// \~chinese
/// @brief 设置阻尼率 /// @brief 设置阻尼率
void SetDampingRatio(float ratio); void SetDampingRatio(float ratio);
/// \~chinese /// \~chinese
/// @brief 获取阻尼率 /// @brief 获取阻尼率
float GetDampingRatio() const; float GetDampingRatio() const;
private: private:
@ -772,21 +772,21 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 轮关节 /// @brief 轮关节
class KGE_API WheelJoint : public Joint class KGE_API WheelJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 轮关节参数 /// @brief 轮关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point anchor; ///< 轮关节位置 Point anchor; ///< 轮关节位置
Vec2 axis; ///< 物体A滑动方向 Vec2 axis; ///< 物体A滑动方向
bool enable_motor; ///< 是否启用马达 bool enable_motor; ///< 是否启用马达
float max_motor_torque; ///< 最大马达力 [N] float max_motor_torque; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s] float motor_speed; ///< 马达转速 [degree/s]
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固 float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 弹簧阻尼率,值越大关节运动阻尼越大 float damping_ratio; ///< 弹簧阻尼率,值越大关节运动阻尼越大
Param() Param()
: Param(nullptr, nullptr, Point(), Vec2()) : Param(nullptr, nullptr, Point(), Vec2())
@ -807,70 +807,70 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建轮关节 /// @brief 创建轮关节
/// @param param 关节参数 /// @param param 关节参数
static WheelJointPtr Create(const Param& param); static WheelJointPtr Create(const Param& param);
WheelJoint(); WheelJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 获取关节当前的平移距离 /// @brief 获取关节当前的平移距离
float GetJointTranslation() const; float GetJointTranslation() const;
/// \~chinese /// \~chinese
/// @brief 获取关节当前的线性速度 /// @brief 获取关节当前的线性速度
float GetJointLinearSpeed() const; float GetJointLinearSpeed() const;
/// \~chinese /// \~chinese
/// @brief 获取关节当前的角度 /// @brief 获取关节当前的角度
float GetJointAngle() const; float GetJointAngle() const;
/// \~chinese /// \~chinese
/// @brief 获取关节当前的旋转速度 /// @brief 获取关节当前的旋转速度
float GetJointAngularSpeed() const; float GetJointAngularSpeed() const;
/// \~chinese /// \~chinese
/// @brief 是否启用马达 /// @brief 是否启用马达
bool IsMotorEnabled() const; bool IsMotorEnabled() const;
/// \~chinese /// \~chinese
/// @brief 设置是否启用马达 /// @brief 设置是否启用马达
void EnableMotor(bool flag); void EnableMotor(bool flag);
/// \~chinese /// \~chinese
/// @brief 设置马达转速 [degree/s] /// @brief 设置马达转速 [degree/s]
void SetMotorSpeed(float speed); void SetMotorSpeed(float speed);
/// \~chinese /// \~chinese
/// @brief 获取马达转速 [degree/s] /// @brief 获取马达转速 [degree/s]
float GetMotorSpeed() const; float GetMotorSpeed() const;
/// \~chinese /// \~chinese
/// @brief 设置最大马达转矩 [N/m] /// @brief 设置最大马达转矩 [N/m]
void SetMaxMotorTorque(float torque); void SetMaxMotorTorque(float torque);
/// \~chinese /// \~chinese
/// @brief 获取最大马达转矩 [N/m] /// @brief 获取最大马达转矩 [N/m]
float GetMaxMotorTorque() const; float GetMaxMotorTorque() const;
/// \~chinese /// \~chinese
/// @brief 设置弹簧响应速度 /// @brief 设置弹簧响应速度
void SetSpringFrequencyHz(float hz); void SetSpringFrequencyHz(float hz);
/// \~chinese /// \~chinese
/// @brief 获取弹簧响应速度 /// @brief 获取弹簧响应速度
float GetSpringFrequencyHz() const; float GetSpringFrequencyHz() const;
/// \~chinese /// \~chinese
/// @brief 设置弹簧阻尼率 /// @brief 设置弹簧阻尼率
void SetSpringDampingRatio(float ratio); void SetSpringDampingRatio(float ratio);
/// \~chinese /// \~chinese
/// @brief 获取弹簧阻尼率 /// @brief 获取弹簧阻尼率
float GetSpringDampingRatio() const; float GetSpringDampingRatio() const;
private: private:
@ -879,19 +879,19 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标关节 /// @brief 鼠标关节
/// @details 用于使身体的某个点追踪世界上的指定点,例如让物体追踪鼠标位置 /// @details 用于使身体的某个点追踪世界上的指定点,例如让物体追踪鼠标位置
class KGE_API MouseJoint : public Joint class KGE_API MouseJoint : public Joint
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 鼠标关节参数 /// @brief 鼠标关节参数
struct Param : public Joint::ParamBase struct Param : public Joint::ParamBase
{ {
Point target; ///< 关节作用目标位置 Point target; ///< 关节作用目标位置
float max_force; ///< 作用在物体A上的最大力 float max_force; ///< 作用在物体A上的最大力
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固 float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大 float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Param() Param()
: Param(nullptr, nullptr, Point()) : Param(nullptr, nullptr, Point())
@ -909,38 +909,38 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 创建鼠标关节 /// @brief 创建鼠标关节
/// @param param 关节参数 /// @param param 关节参数
static MouseJointPtr Create(const Param& param); static MouseJointPtr Create(const Param& param);
MouseJoint(); MouseJoint();
/// \~chinese /// \~chinese
/// @brief 初始化关节 /// @brief 初始化关节
bool Init(PhysicWorld* world) override; bool Init(PhysicWorld* world) override;
/// \~chinese /// \~chinese
/// @brief 设定最大摩擦力 [N] /// @brief 设定最大摩擦力 [N]
void SetMaxForce(float force); void SetMaxForce(float force);
/// \~chinese /// \~chinese
/// @brief 获取最大摩擦力 [N] /// @brief 获取最大摩擦力 [N]
float GetMaxForce() const; float GetMaxForce() const;
/// \~chinese /// \~chinese
/// @brief 设置响应速度 [hz] /// @brief 设置响应速度 [hz]
void SetFrequency(float hz); void SetFrequency(float hz);
/// \~chinese /// \~chinese
/// @brief 获取响应速度 [hz] /// @brief 获取响应速度 [hz]
float GetFrequency() const; float GetFrequency() const;
/// \~chinese /// \~chinese
/// @brief 设置阻尼率 /// @brief 设置阻尼率
void SetDampingRatio(float ratio); void SetDampingRatio(float ratio);
/// \~chinese /// \~chinese
/// @brief 获取阻尼率 /// @brief 获取阻尼率
float GetDampingRatio() const; float GetDampingRatio() const;
private: private:

View File

@ -35,31 +35,31 @@ class PhysicWorld;
*/ */
/// \~chinese /// \~chinese
/// @brief 物体 /// @brief 物体
class KGE_API PhysicBody : public Component class KGE_API PhysicBody : public Component
{ {
friend class PhysicWorld; friend class PhysicWorld;
public: public:
/// \~chinese /// \~chinese
/// @brief 物体类型 /// @brief 物体类型
enum class Type enum class Type
{ {
Static = 0, ///< 静态物体 Static = 0, ///< 静态物体
Kinematic, ///< 动力学物体 Kinematic, ///< 动力学物体
Dynamic, ///< 动态物体 Dynamic, ///< 动态物体
}; };
/// \~chinese /// \~chinese
/// @brief 初始化物体 /// @brief 初始化物体
/// @param world 物理世界 /// @param world 物理世界
/// @param type 物体类型 /// @param type 物体类型
static PhysicBodyPtr Create(PhysicWorldPtr world, Type type); static PhysicBodyPtr Create(PhysicWorldPtr world, Type type);
/// \~chinese /// \~chinese
/// @brief 初始化物体 /// @brief 初始化物体
/// @param world 物理世界 /// @param world 物理世界
/// @param type 物体类型 /// @param type 物体类型
static PhysicBodyPtr Create(PhysicWorld* world, Type type); static PhysicBodyPtr Create(PhysicWorld* world, Type type);
PhysicBody(); PhysicBody();
@ -67,297 +67,297 @@ public:
virtual ~PhysicBody(); virtual ~PhysicBody();
/// \~chinese /// \~chinese
/// @brief 初始化物体 /// @brief 初始化物体
/// @param[in] world 物理世界 /// @param[in] world 物理世界
bool Init(PhysicWorldPtr world); bool Init(PhysicWorldPtr world);
/// \~chinese /// \~chinese
/// @brief 初始化物体 /// @brief 初始化物体
/// @param[in] world 物理世界 /// @param[in] world 物理世界
bool Init(PhysicWorld* world); bool Init(PhysicWorld* world);
/// \~chinese /// \~chinese
/// @brief 添加夹具 /// @brief 添加夹具
void AddFixture(FixturePtr fixture); void AddFixture(FixturePtr fixture);
/// \~chinese /// \~chinese
/// @brief 添加圆形夹具 /// @brief 添加圆形夹具
/// @param radius 圆形半径 /// @param radius 圆形半径
/// @param density 物体密度 /// @param density 物体密度
/// @param /// @param
Fixture* AddCircleShape(float radius, float density, float friction = 0.2f); Fixture* AddCircleShape(float radius, float density, float friction = 0.2f);
/// \~chinese /// \~chinese
/// @brief 添加矩形夹具 /// @brief 添加矩形夹具
/// @param size 矩形大小 /// @param size 矩形大小
/// @param density 物体密度 /// @param density 物体密度
Fixture* AddRectShape(const Vec2& size, float density, float friction = 0.2f); Fixture* AddRectShape(const Vec2& size, float density, float friction = 0.2f);
/// \~chinese /// \~chinese
/// @brief 添加多边形夹具 /// @brief 添加多边形夹具
/// @param vertexs 多边形端点 /// @param vertexs 多边形端点
/// @param density 物体密度 /// @param density 物体密度
Fixture* AddPolygonShape(const Vector<Point>& vertexs, float density, float friction = 0.2f); Fixture* AddPolygonShape(const Vector<Point>& vertexs, float density, float friction = 0.2f);
/// \~chinese /// \~chinese
/// @brief 添加线段形夹具 /// @brief 添加线段形夹具
/// @param p1 线段起点 /// @param p1 线段起点
/// @param p2 线段终点 /// @param p2 线段终点
/// @param density 物体密度 /// @param density 物体密度
Fixture* AddEdgeShape(const Point& p1, const Point& p2, float density, float friction = 0.2f); Fixture* AddEdgeShape(const Point& p1, const Point& p2, float density, float friction = 0.2f);
/// \~chinese /// \~chinese
/// @brief 添加链条形夹具 /// @brief 添加链条形夹具
/// @param vertexs 链条端点 /// @param vertexs 链条端点
/// @param loop 是否闭合 /// @param loop 是否闭合
/// @param density 物体密度 /// @param density 物体密度
Fixture* AddChainShape(const Vector<Point>& vertices, bool loop, float density, float friction = 0.2f); Fixture* AddChainShape(const Vector<Point>& vertices, bool loop, float density, float friction = 0.2f);
/// \~chinese /// \~chinese
/// @brief 移除夹具 /// @brief 移除夹具
void RemoveFixture(FixturePtr fixture); void RemoveFixture(FixturePtr fixture);
/// \~chinese /// \~chinese
/// @brief 移除所有夹具 /// @brief 移除所有夹具
void RemoveAllFixtures(); void RemoveAllFixtures();
/// \~chinese /// \~chinese
/// @brief 获取夹具列表 /// @brief 获取夹具列表
FixtureList GetFixtureList() const; FixtureList GetFixtureList() const;
/// \~chinese /// \~chinese
/// @brief 获取接触边列表 /// @brief 获取接触边列表
ContactEdgeList GetContactList() const; ContactEdgeList GetContactList() const;
/// \~chinese /// \~chinese
/// @brief 获取类别码 /// @brief 获取类别码
uint16_t GetCategoryBits() const; uint16_t GetCategoryBits() const;
/// \~chinese /// \~chinese
/// @brief 设置类别码 /// @brief 设置类别码
void SetCategoryBits(uint16_t category_bits); void SetCategoryBits(uint16_t category_bits);
/// \~chinese /// \~chinese
/// @brief 获取碰撞掩码 /// @brief 获取碰撞掩码
uint16_t GetMaskBits() const; uint16_t GetMaskBits() const;
/// \~chinese /// \~chinese
/// @brief 设置碰撞掩码 /// @brief 设置碰撞掩码
void SetMaskBits(uint16_t mask_bits); void SetMaskBits(uint16_t mask_bits);
/// \~chinese /// \~chinese
/// @brief 获取组索引 /// @brief 获取组索引
int16_t GetGroupIndex() const; int16_t GetGroupIndex() const;
/// \~chinese /// \~chinese
/// @brief 设置组索引 /// @brief 设置组索引
void SetGroupIndex(int16_t index); void SetGroupIndex(int16_t index);
/// \~chinese /// \~chinese
/// @brief 获取旋转角度 /// @brief 获取旋转角度
float GetRotation() const; float GetRotation() const;
/// \~chinese /// \~chinese
/// @brief 设置旋转角度 /// @brief 设置旋转角度
void SetRotation(float angle); void SetRotation(float angle);
/// \~chinese /// \~chinese
/// @brief 获取物体位置 /// @brief 获取物体位置
Point GetPosition() const; Point GetPosition() const;
/// \~chinese /// \~chinese
/// @brief 设置物体位置 /// @brief 设置物体位置
void SetPosition(const Point& pos); void SetPosition(const Point& pos);
/// \~chinese /// \~chinese
/// @brief 位置和旋转变换 /// @brief 位置和旋转变换
void SetTransform(const Point& pos, float angle); void SetTransform(const Point& pos, float angle);
/// \~chinese /// \~chinese
/// @brief 获取质量 [kg] /// @brief 获取质量 [kg]
float GetMass() const; float GetMass() const;
/// \~chinese /// \~chinese
/// @brief 获取惯性 /// @brief 获取惯性
float GetInertia() const; float GetInertia() const;
/// \~chinese /// \~chinese
/// @brief 获取质量数据 /// @brief 获取质量数据
/// @param[out] mass 物体质量 [kg] /// @param[out] mass 物体质量 [kg]
/// @param[out] center 质心位置 /// @param[out] center 质心位置
/// @param[out] inertia 惯性 /// @param[out] inertia 惯性
void GetMassData(float* mass, Point* center, float* inertia) const; void GetMassData(float* mass, Point* center, float* inertia) const;
/// \~chinese /// \~chinese
/// @brief 设置质量数据 /// @brief 设置质量数据
/// @param mass 物体质量 [kg] /// @param mass 物体质量 [kg]
/// @param center 质心位置 /// @param center 质心位置
/// @param inertia 惯性 /// @param inertia 惯性
void SetMassData(float mass, const Point& center, float inertia); void SetMassData(float mass, const Point& center, float inertia);
/// \~chinese /// \~chinese
/// @brief 重置质量数据 /// @brief 重置质量数据
void ResetMassData(); void ResetMassData();
/// \~chinese /// \~chinese
/// @brief 获取世界坐标系上的点在物体上的位置 /// @brief 获取世界坐标系上的点在物体上的位置
Point GetLocalPoint(const Point& world) const; Point GetLocalPoint(const Point& world) const;
/// \~chinese /// \~chinese
/// @brief 将世界坐标系中的向量转换到物体坐标系下 /// @brief 将世界坐标系中的向量转换到物体坐标系下
Vec2 GetLocalVector(const Vec2& world) const; Vec2 GetLocalVector(const Vec2& world) const;
/// \~chinese /// \~chinese
/// @brief 获取物体上的点在世界坐标系的位置 /// @brief 获取物体上的点在世界坐标系的位置
Point GetWorldPoint(const Point& local) const; Point GetWorldPoint(const Point& local) const;
/// \~chinese /// \~chinese
/// @brief 将物体坐标系中的向量转换到世界坐标系下 /// @brief 将物体坐标系中的向量转换到世界坐标系下
Vec2 GetWorldVector(const Vec2& local) const; Vec2 GetWorldVector(const Vec2& local) const;
/// \~chinese /// \~chinese
/// @brief 获取物体质心相对于物体的位置 /// @brief 获取物体质心相对于物体的位置
Point GetLocalCenter() const; Point GetLocalCenter() const;
/// \~chinese /// \~chinese
/// @brief 获取物体质心位置 /// @brief 获取物体质心位置
Point GetWorldCenter() const; Point GetWorldCenter() const;
/// \~chinese /// \~chinese
/// @brief 获取物体类型 /// @brief 获取物体类型
Type GetType() const; Type GetType() const;
/// \~chinese /// \~chinese
/// @brief 设置物体类型 /// @brief 设置物体类型
void SetType(Type type); void SetType(Type type);
/// \~chinese /// \~chinese
/// @brief 获取物体受重力的比例 /// @brief 获取物体受重力的比例
float GetGravityScale() const; float GetGravityScale() const;
/// \~chinese /// \~chinese
/// @brief 设置物体受重力的比例 /// @brief 设置物体受重力的比例
void SetGravityScale(float scale); void SetGravityScale(float scale);
/// \~chinese /// \~chinese
/// @brief 获取线性阻尼 /// @brief 获取线性阻尼
float GetLinearDamping() const; float GetLinearDamping() const;
/// \~chinese /// \~chinese
/// @brief 设置线性阻尼 /// @brief 设置线性阻尼
void SetLinearDamping(float damping); void SetLinearDamping(float damping);
/// \~chinese /// \~chinese
/// @brief 获取旋转阻尼 /// @brief 获取旋转阻尼
float GetAngularDamping() const; float GetAngularDamping() const;
/// \~chinese /// \~chinese
/// @brief 设置旋转阻尼 /// @brief 设置旋转阻尼
void SetAngularDamping(float damping); void SetAngularDamping(float damping);
/// \~chinese /// \~chinese
/// @brief 施力 /// @brief 施力
/// @param force 力的大小和方向 /// @param force 力的大小和方向
/// @param point 施力点 /// @param point 施力点
/// @param wake 是否唤醒物体 /// @param wake 是否唤醒物体
void ApplyForce(const Vec2& force, const Point& point, bool wake = true); void ApplyForce(const Vec2& force, const Point& point, bool wake = true);
/// \~chinese /// \~chinese
/// @brief 给物体中心施力 /// @brief 给物体中心施力
/// @param force 力的大小和方向 /// @param force 力的大小和方向
/// @param wake 是否唤醒物体 /// @param wake 是否唤醒物体
void ApplyForceToCenter(const Vec2& force, bool wake = true); void ApplyForceToCenter(const Vec2& force, bool wake = true);
/// \~chinese /// \~chinese
/// @brief 施加扭矩 /// @brief 施加扭矩
/// @param torque 扭矩 /// @param torque 扭矩
/// @param wake 是否唤醒物体 /// @param wake 是否唤醒物体
void ApplyTorque(float torque, bool wake = false); void ApplyTorque(float torque, bool wake = false);
/// \~chinese /// \~chinese
/// @brief 旋转角度是否固定 /// @brief 旋转角度是否固定
bool IsIgnoreRotation() const; bool IsIgnoreRotation() const;
/// \~chinese /// \~chinese
/// @brief 设置是否固定旋转角度 /// @brief 设置是否固定旋转角度
void SetIgnoreRotation(bool flag); void SetIgnoreRotation(bool flag);
/// \~chinese /// \~chinese
/// @brief 是否是子弹物体 /// @brief 是否是子弹物体
bool IsBullet() const; bool IsBullet() const;
/// \~chinese /// \~chinese
/// @brief 设置物体是否是子弹物体 /// @brief 设置物体是否是子弹物体
void SetBullet(bool flag); void SetBullet(bool flag);
/// \~chinese /// \~chinese
/// @brief 是否处于唤醒状态 /// @brief 是否处于唤醒状态
bool IsAwake() const; bool IsAwake() const;
/// \~chinese /// \~chinese
/// @brief 设置唤醒状态 /// @brief 设置唤醒状态
void SetAwake(bool flag); void SetAwake(bool flag);
/// \~chinese /// \~chinese
/// @brief 是否启用休眠 /// @brief 是否启用休眠
bool IsSleepingAllowed() const; bool IsSleepingAllowed() const;
/// \~chinese /// \~chinese
/// @brief 设置是否允许休眠 /// @brief 设置是否允许休眠
void SetSleepingAllowed(bool flag); void SetSleepingAllowed(bool flag);
/// \~chinese /// \~chinese
/// @brief 是否启用 /// @brief 是否启用
bool IsActive() const; bool IsActive() const;
/// \~chinese /// \~chinese
/// @brief 设置启用状态 /// @brief 设置启用状态
void SetActive(bool flag); void SetActive(bool flag);
/// \~chinese /// \~chinese
/// @brief 获取物体所在物理世界 /// @brief 获取物体所在物理世界
PhysicWorld* GetWorld() const; PhysicWorld* GetWorld() const;
/// \~chinese /// \~chinese
/// @brief 销毁物体 /// @brief 销毁物体
void Destroy(); void Destroy();
/// \~chinese /// \~chinese
/// @brief 获取b2Body /// @brief 获取b2Body
b2Body* GetB2Body() const; b2Body* GetB2Body() const;
/// \~chinese /// \~chinese
/// @brief 设置b2Body /// @brief 设置b2Body
void SetB2Body(b2Body* body); void SetB2Body(b2Body* body);
protected: protected:
/// \~chinese /// \~chinese
/// @brief 初始化组件 /// @brief 初始化组件
void InitComponent(Actor* actor) override; void InitComponent(Actor* actor) override;
/// \~chinese /// \~chinese
/// @brief 销毁组件 /// @brief 销毁组件
void DestroyComponent() override; void DestroyComponent() override;
/// \~chinese /// \~chinese
/// @brief 更新物体状态 /// @brief 更新物体状态
void UpdateFromActor(Actor* actor); void UpdateFromActor(Actor* actor);
/// \~chinese /// \~chinese
/// @brief 更新物体状态 /// @brief 更新物体状态
void UpdateFromActor(Actor* actor, const Matrix3x2& actor_to_world, float parent_rotation); void UpdateFromActor(Actor* actor, const Matrix3x2& actor_to_world, float parent_rotation);
/// \~chinese /// \~chinese
/// @brief 更新夹具过滤器 /// @brief 更新夹具过滤器
void UpdateFixtureFilter(b2Fixture* fixture); void UpdateFixtureFilter(b2Fixture* fixture);
/// \~chinese /// \~chinese
/// @brief 更新物理身体前 /// @brief 更新物理身体前
void BeforeSimulation(Actor* actor, const Matrix3x2& parent_to_world, const Matrix3x2& actor_to_world, void BeforeSimulation(Actor* actor, const Matrix3x2& parent_to_world, const Matrix3x2& actor_to_world,
float parent_rotation); float parent_rotation);
/// \~chinese /// \~chinese
/// @brief 更新物理身体后 /// @brief 更新物理身体后
void AfterSimulation(Actor* actorconst, const Matrix3x2& parent_to_world, float parent_rotation); void AfterSimulation(Actor* actorconst, const Matrix3x2& parent_to_world, float parent_rotation);
private: private:

View File

@ -29,7 +29,7 @@ namespace physics
/** /**
* \~chinese * \~chinese
* \defgroup Physics * \defgroup Physics
*/ */
/** /**
@ -39,7 +39,7 @@ namespace physics
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API PhysicWorld : public Component class KGE_API PhysicWorld : public Component
{ {
@ -48,12 +48,12 @@ class KGE_API PhysicWorld : public Component
public: public:
/// \~chinese /// \~chinese
/// @brief 创建物理世界 /// @brief 创建物理世界
static PhysicWorldPtr Create(); static PhysicWorldPtr Create();
/// \~chinese /// \~chinese
/// @brief 创建物理世界 /// @brief 创建物理世界
/// @param gravity 重力 /// @param gravity 重力
static PhysicWorldPtr Create(const Vec2& gravity); static PhysicWorldPtr Create(const Vec2& gravity);
PhysicWorld(); PhysicWorld();
@ -61,96 +61,96 @@ public:
virtual ~PhysicWorld(); virtual ~PhysicWorld();
/// \~chinese /// \~chinese
/// @brief 添加物体 /// @brief 添加物体
void AddBody(PhysicBodyPtr body); void AddBody(PhysicBodyPtr body);
/// \~chinese /// \~chinese
/// @brief 移除物体 /// @brief 移除物体
void RemoveBody(PhysicBodyPtr body); void RemoveBody(PhysicBodyPtr body);
/// \~chinese /// \~chinese
/// @brief 移除所有物体 /// @brief 移除所有物体
void RemoveAllBodies(); void RemoveAllBodies();
/// \~chinese /// \~chinese
/// @brief 获取所有物体 /// @brief 获取所有物体
const List<PhysicBodyPtr>& GetAllBodies() const; const List<PhysicBodyPtr>& GetAllBodies() const;
/// \~chinese /// \~chinese
/// @brief 添加关节 /// @brief 添加关节
void AddJoint(JointPtr joint); void AddJoint(JointPtr joint);
/// \~chinese /// \~chinese
/// @brief 移除关节 /// @brief 移除关节
void RemoveJoint(JointPtr joint); void RemoveJoint(JointPtr joint);
/// \~chinese /// \~chinese
/// @brief 移除所有关节 /// @brief 移除所有关节
void RemoveAllJoints(); void RemoveAllJoints();
/// \~chinese /// \~chinese
/// @brief 获取所有关节 /// @brief 获取所有关节
const List<JointPtr>& GetAllJoints() const; const List<JointPtr>& GetAllJoints() const;
/// \~chinese /// \~chinese
/// @brief 获取重力 [N] /// @brief 获取重力 [N]
Vec2 GetGravity() const; Vec2 GetGravity() const;
/// \~chinese /// \~chinese
/// @brief 设置重力 [N] /// @brief 设置重力 [N]
void SetGravity(Vec2 gravity); void SetGravity(Vec2 gravity);
/// \~chinese /// \~chinese
/// @brief 获取物理接触列表 /// @brief 获取物理接触列表
ContactList GetContactList(); ContactList GetContactList();
/// \~chinese /// \~chinese
/// @brief 设置速度迭代次数, 默认为 6 /// @brief 设置速度迭代次数, 默认为 6
void SetVelocityIterations(int vel_iter); void SetVelocityIterations(int vel_iter);
/// \~chinese /// \~chinese
/// @brief 设置位置迭代次数, 默认为 2 /// @brief 设置位置迭代次数, 默认为 2
void SetPositionIterations(int pos_iter); void SetPositionIterations(int pos_iter);
/// \~chinese /// \~chinese
/// @brief 设置是否绘制调试信息 /// @brief 设置是否绘制调试信息
void ShowDebugInfo(bool show); void ShowDebugInfo(bool show);
/// \~chinese /// \~chinese
/// @brief 获取b2World /// @brief 获取b2World
b2World* GetB2World(); b2World* GetB2World();
/// \~chinese /// \~chinese
/// @brief 获取b2World /// @brief 获取b2World
const b2World* GetB2World() const; const b2World* GetB2World() const;
protected: protected:
/// \~chinese /// \~chinese
/// @brief 初始化组件 /// @brief 初始化组件
void InitComponent(Actor* actor) override; void InitComponent(Actor* actor) override;
/// \~chinese /// \~chinese
/// @brief 更新组件 /// @brief 更新组件
void OnUpdate(Duration dt) override; void OnUpdate(Duration dt) override;
/// \~chinese /// \~chinese
/// @brief 渲染组件 /// @brief 渲染组件
void OnRender(RenderContext& ctx) override; void OnRender(RenderContext& ctx) override;
/// \~chinese /// \~chinese
/// @brief 分发物理世界事件 /// @brief 分发物理世界事件
void DispatchEvent(Event* evt); void DispatchEvent(Event* evt);
/// \~chinese /// \~chinese
/// @brief 关节移除时的回调函数 /// @brief 关节移除时的回调函数
void JointRemoved(b2Joint* b2joint); void JointRemoved(b2Joint* b2joint);
/// \~chinese /// \~chinese
/// @brief 更新物理世界前 /// @brief 更新物理世界前
void BeforeSimulation(Actor* parent, const Matrix3x2& parent_to_world, float parent_rotation); void BeforeSimulation(Actor* parent, const Matrix3x2& parent_to_world, float parent_rotation);
/// \~chinese /// \~chinese
/// @brief 更新物理世界后 /// @brief 更新物理世界后
void AfterSimulation(Actor* parent, const Matrix3x2& parent_to_world, float parent_rotation); void AfterSimulation(Actor* parent, const Matrix3x2& parent_to_world, float parent_rotation);
private: private:

View File

@ -41,12 +41,12 @@ class PhysicBody;
KGE_DECLARE_SMART_PTR(Actor); KGE_DECLARE_SMART_PTR(Actor);
/// \~chinese /// \~chinese
/// @brief 角色列表 /// @brief 角色列表
typedef IntrusiveList<ActorPtr> ActorList; typedef IntrusiveList<ActorPtr> ActorList;
/** /**
* \~chinese * \~chinese
* \defgroup Actors * \defgroup Actors
*/ */
/** /**
@ -56,9 +56,9 @@ typedef IntrusiveList<ActorPtr> ActorList;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
* *
*/ */
class KGE_API Actor class KGE_API Actor
: public ObjectBase : public ObjectBase
@ -73,11 +73,11 @@ class KGE_API Actor
public: public:
/// \~chinese /// \~chinese
/// @brief 角色更新回调函数 /// @brief 角色更新回调函数
typedef Function<void(Duration)> UpdateCallback; typedef Function<void(Duration)> UpdateCallback;
/// \~chinese /// \~chinese
/// @brief 创建角色 /// @brief 创建角色
static ActorPtr Create(); static ActorPtr Create();
Actor(); Actor();
@ -85,418 +85,418 @@ public:
virtual ~Actor(); virtual ~Actor();
/// \~chinese /// \~chinese
/// @brief 更新角色 /// @brief 更新角色
/// @details 每帧画面刷新前调用该函数,重载该函数以实现角色的更新处理 /// @details 每帧画面刷新前调用该函数,重载该函数以实现角色的更新处理
/// @param dt 距上一次更新的时间间隔 /// @param dt 距上一次更新的时间间隔
virtual void OnUpdate(Duration dt); virtual void OnUpdate(Duration dt);
/// \~chinese /// \~chinese
/// @brief 渲染角色 /// @brief 渲染角色
/// @details /// @details
/// 每帧画面刷新时调用该函数,默认不进行渲染,重载该函数以实现具体渲染过程 /// 每帧画面刷新时调用该函数,默认不进行渲染,重载该函数以实现具体渲染过程
/// @param ctx 渲染上下文 /// @param ctx 渲染上下文
virtual void OnRender(RenderContext& ctx); virtual void OnRender(RenderContext& ctx);
/// \~chinese /// \~chinese
/// @brief 获取显示状态 /// @brief 获取显示状态
bool IsVisible() const; bool IsVisible() const;
/// \~chinese /// \~chinese
/// @brief 获取响应状态 /// @brief 获取响应状态
bool IsResponsible() const; bool IsResponsible() const;
/// \~chinese /// \~chinese
/// @brief 是否启用级联透明度 /// @brief 是否启用级联透明度
bool IsCascadeOpacityEnabled() const; bool IsCascadeOpacityEnabled() const;
/// \~chinese /// \~chinese
/// @brief 获取名称的 Hash 值 /// @brief 获取名称的 Hash 值
size_t GetHashName() const; size_t GetHashName() const;
/// \~chinese /// \~chinese
/// @brief 获取 Z 轴顺序 /// @brief 获取 Z 轴顺序
int GetZOrder() const; int GetZOrder() const;
/// \~chinese /// \~chinese
/// @brief 获取坐标 /// @brief 获取坐标
virtual Point GetPosition() const; virtual Point GetPosition() const;
/// \~chinese /// \~chinese
/// @brief 获取 x 坐标 /// @brief 获取 x 坐标
float GetPositionX() const; float GetPositionX() const;
/// \~chinese /// \~chinese
/// @brief 获取 y 坐标 /// @brief 获取 y 坐标
float GetPositionY() const; float GetPositionY() const;
/// \~chinese /// \~chinese
/// @brief 获取大小 /// @brief 获取大小
virtual Size GetSize() const; virtual Size GetSize() const;
/// \~chinese /// \~chinese
/// @brief 获取宽度 /// @brief 获取宽度
float GetWidth() const; float GetWidth() const;
/// \~chinese /// \~chinese
/// @brief 获取高度 /// @brief 获取高度
float GetHeight() const; float GetHeight() const;
/// \~chinese /// \~chinese
/// @brief 获取缩放后的宽度 /// @brief 获取缩放后的宽度
float GetScaledWidth() const; float GetScaledWidth() const;
/// \~chinese /// \~chinese
/// @brief 获取缩放后的高度 /// @brief 获取缩放后的高度
float GetScaledHeight() const; float GetScaledHeight() const;
/// \~chinese /// \~chinese
/// @brief 获取缩放后的大小 /// @brief 获取缩放后的大小
Size GetScaledSize() const; Size GetScaledSize() const;
/// \~chinese /// \~chinese
/// @brief 获取锚点 /// @brief 获取锚点
virtual Point GetAnchor() const; virtual Point GetAnchor() const;
/// \~chinese /// \~chinese
/// @brief 获取 x 方向锚点 /// @brief 获取 x 方向锚点
float GetAnchorX() const; float GetAnchorX() const;
/// \~chinese /// \~chinese
/// @brief 获取 y 方向锚点 /// @brief 获取 y 方向锚点
float GetAnchorY() const; float GetAnchorY() const;
/// \~chinese /// \~chinese
/// @brief 获取透明度 /// @brief 获取透明度
virtual float GetOpacity() const; virtual float GetOpacity() const;
/// \~chinese /// \~chinese
/// @brief 获取显示透明度 /// @brief 获取显示透明度
float GetDisplayedOpacity() const; float GetDisplayedOpacity() const;
/// \~chinese /// \~chinese
/// @brief 获取旋转角度 /// @brief 获取旋转角度
virtual float GetRotation() const; virtual float GetRotation() const;
/// \~chinese /// \~chinese
/// @brief 获取缩放比例 /// @brief 获取缩放比例
virtual Point GetScale() const; virtual Point GetScale() const;
/// \~chinese /// \~chinese
/// @brief 获取横向缩放比例 /// @brief 获取横向缩放比例
float GetScaleX() const; float GetScaleX() const;
/// \~chinese /// \~chinese
/// @brief 获取纵向缩放比例 /// @brief 获取纵向缩放比例
float GetScaleY() const; float GetScaleY() const;
/// \~chinese /// \~chinese
/// @brief 获取错切角度 /// @brief 获取错切角度
virtual Point GetSkew() const; virtual Point GetSkew() const;
/// \~chinese /// \~chinese
/// @brief 获取横向错切角度 /// @brief 获取横向错切角度
float GetSkewX() const; float GetSkewX() const;
/// \~chinese /// \~chinese
/// @brief 获取纵向错切角度 /// @brief 获取纵向错切角度
float GetSkewY() const; float GetSkewY() const;
/// \~chinese /// \~chinese
/// @brief 获取变换 /// @brief 获取变换
Transform GetTransform() const; Transform GetTransform() const;
/// \~chinese /// \~chinese
/// @brief 获取父角色 /// @brief 获取父角色
Actor* GetParent() const; Actor* GetParent() const;
/// \~chinese /// \~chinese
/// @brief 获取所在舞台 /// @brief 获取所在舞台
Stage* GetStage() const; Stage* GetStage() const;
/// \~chinese /// \~chinese
/// @brief 获取边框 /// @brief 获取边框
virtual Rect GetBounds() const; virtual Rect GetBounds() const;
/// \~chinese /// \~chinese
/// @brief 获取外切包围盒 /// @brief 获取外切包围盒
virtual Rect GetBoundingBox() const; virtual Rect GetBoundingBox() const;
/// \~chinese /// \~chinese
/// @brief 获取二维变换矩阵 /// @brief 获取二维变换矩阵
const Matrix3x2& GetTransformMatrix() const; const Matrix3x2& GetTransformMatrix() const;
/// \~chinese /// \~chinese
/// @brief 获取二维变换的逆矩阵 /// @brief 获取二维变换的逆矩阵
const Matrix3x2& GetTransformInverseMatrix() const; const Matrix3x2& GetTransformInverseMatrix() const;
/// \~chinese /// \~chinese
/// @brief 获取变换到父角色的二维变换矩阵 /// @brief 获取变换到父角色的二维变换矩阵
const Matrix3x2& GetTransformMatrixToParent() const; const Matrix3x2& GetTransformMatrixToParent() const;
/// \~chinese /// \~chinese
/// @brief 设置角色是否可见 /// @brief 设置角色是否可见
void SetVisible(bool val); void SetVisible(bool val);
/// \~chinese /// \~chinese
/// @brief 设置名称 /// @brief 设置名称
void SetName(const String& name); void SetName(const String& name);
/// \~chinese /// \~chinese
/// @brief 设置坐标 /// @brief 设置坐标
virtual void SetPosition(const Point& point); virtual void SetPosition(const Point& point);
/// \~chinese /// \~chinese
/// @brief 设置坐标 /// @brief 设置坐标
void SetPosition(float x, float y); void SetPosition(float x, float y);
/// \~chinese /// \~chinese
/// @brief 设置横坐标 /// @brief 设置横坐标
void SetPositionX(float x); void SetPositionX(float x);
/// \~chinese /// \~chinese
/// @brief 设置纵坐标 /// @brief 设置纵坐标
void SetPositionY(float y); void SetPositionY(float y);
/// \~chinese /// \~chinese
/// @brief 移动坐标 /// @brief 移动坐标
void Move(const Vec2& v); void Move(const Vec2& v);
/// \~chinese /// \~chinese
/// @brief 移动坐标 /// @brief 移动坐标
void Move(float vx, float vy); void Move(float vx, float vy);
/// \~chinese /// \~chinese
/// @brief 设置缩放比例,默认为 (1.0, 1.0) /// @brief 设置缩放比例,默认为 (1.0, 1.0)
virtual void SetScale(const Vec2& scale); virtual void SetScale(const Vec2& scale);
/// \~chinese /// \~chinese
/// @brief 设置缩放比例,默认为 (1.0, 1.0) /// @brief 设置缩放比例,默认为 (1.0, 1.0)
void SetScale(float scalex, float scaley); void SetScale(float scalex, float scaley);
/// \~chinese /// \~chinese
/// @brief 设置错切角度,默认为 (0, 0) /// @brief 设置错切角度,默认为 (0, 0)
virtual void SetSkew(const Vec2& skew); virtual void SetSkew(const Vec2& skew);
/// \~chinese /// \~chinese
/// @brief 设置错切角度,默认为 (0, 0) /// @brief 设置错切角度,默认为 (0, 0)
void SetSkew(float skewx, float skewy); void SetSkew(float skewx, float skewy);
/// \~chinese /// \~chinese
/// @brief 设置旋转角度,默认为 0 /// @brief 设置旋转角度,默认为 0
virtual void SetRotation(float rotation); virtual void SetRotation(float rotation);
/// \~chinese /// \~chinese
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1] /// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
virtual void SetAnchor(const Vec2& anchor); virtual void SetAnchor(const Vec2& anchor);
/// \~chinese /// \~chinese
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1] /// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
void SetAnchor(float anchorx, float anchory); void SetAnchor(float anchorx, float anchory);
/// \~chinese /// \~chinese
/// @brief 修改大小 /// @brief 修改大小
virtual void SetSize(const Size& size); virtual void SetSize(const Size& size);
/// \~chinese /// \~chinese
/// @brief 修改大小 /// @brief 修改大小
void SetSize(float width, float height); void SetSize(float width, float height);
/// \~chinese /// \~chinese
/// @brief 修改宽度 /// @brief 修改宽度
void SetWidth(float width); void SetWidth(float width);
/// \~chinese /// \~chinese
/// @brief 修改高度 /// @brief 修改高度
void SetHeight(float height); void SetHeight(float height);
/// \~chinese /// \~chinese
/// @brief 设置透明度,默认为 1.0, 范围 [0, 1] /// @brief 设置透明度,默认为 1.0, 范围 [0, 1]
virtual void SetOpacity(float opacity); virtual void SetOpacity(float opacity);
/// \~chinese /// \~chinese
/// @brief 启用或禁用级联透明度 /// @brief 启用或禁用级联透明度
void SetCascadeOpacityEnabled(bool enabled); void SetCascadeOpacityEnabled(bool enabled);
/// \~chinese /// \~chinese
/// @brief 设置二维仿射变换 /// @brief 设置二维仿射变换
void SetTransform(const Transform& transform); void SetTransform(const Transform& transform);
/// \~chinese /// \~chinese
/// @brief 设置 Z 轴顺序,默认为 0 /// @brief 设置 Z 轴顺序,默认为 0
void SetZOrder(int zorder); void SetZOrder(int zorder);
/// \~chinese /// \~chinese
/// @brief 设置角色是否可响应,默认为 false /// @brief 设置角色是否可响应,默认为 false
/// @details 可响应的角色会收到鼠标的 Hover | Out | Click 消息 /// @details 可响应的角色会收到鼠标的 Hover | Out | Click 消息
void SetResponsible(bool enable); void SetResponsible(bool enable);
/// \~chinese /// \~chinese
/// @brief 添加子角色 /// @brief 添加子角色
void AddChild(ActorPtr child, int zorder = 0); void AddChild(ActorPtr child, int zorder = 0);
/// \~chinese /// \~chinese
/// @brief 添加多个子角色 /// @brief 添加多个子角色
void AddChildren(const Vector<ActorPtr>& children); void AddChildren(const Vector<ActorPtr>& children);
/// \~chinese /// \~chinese
/// @brief 获取名称相同的子角色 /// @brief 获取名称相同的子角色
ActorPtr GetChild(const String& name) const; ActorPtr GetChild(const String& name) const;
/// \~chinese /// \~chinese
/// @brief 获取所有名称相同的子角色 /// @brief 获取所有名称相同的子角色
Vector<ActorPtr> GetChildren(const String& name) const; Vector<ActorPtr> GetChildren(const String& name) const;
/// \~chinese /// \~chinese
/// @brief 获取全部子角色 /// @brief 获取全部子角色
ActorList& GetAllChildren(); ActorList& GetAllChildren();
/// \~chinese /// \~chinese
/// @brief 获取全部子角色 /// @brief 获取全部子角色
const ActorList& GetAllChildren() const; const ActorList& GetAllChildren() const;
/// \~chinese /// \~chinese
/// @brief 移除子角色 /// @brief 移除子角色
void RemoveChild(ActorPtr child); void RemoveChild(ActorPtr child);
/// \~chinese /// \~chinese
/// @brief 移除所有名称相同的子角色 /// @brief 移除所有名称相同的子角色
void RemoveChildren(const String& child_name); void RemoveChildren(const String& child_name);
/// \~chinese /// \~chinese
/// @brief 移除所有角色 /// @brief 移除所有角色
void RemoveAllChildren(); void RemoveAllChildren();
/// \~chinese /// \~chinese
/// @brief 从父角色移除 /// @brief 从父角色移除
void RemoveFromParent(); void RemoveFromParent();
/// \~chinese /// \~chinese
/// @brief 添加组件 /// @brief 添加组件
/// @param component 组件 /// @param component 组件
Component* AddComponent(ComponentPtr component); Component* AddComponent(ComponentPtr component);
/// \~chinese /// \~chinese
/// @brief 获取所有组件 /// @brief 获取所有组件
ComponentList& GetAllComponents(); ComponentList& GetAllComponents();
/// \~chinese /// \~chinese
/// @brief 获取所有组件 /// @brief 获取所有组件
const ComponentList& GetAllComponents() const; const ComponentList& GetAllComponents() const;
/// \~chinese /// \~chinese
/// @brief 移除组件 /// @brief 移除组件
void RemoveComponent(ComponentPtr component); void RemoveComponent(ComponentPtr component);
/// \~chinese /// \~chinese
/// @brief 移除组件 /// @brief 移除组件
/// @param name 组件名称 /// @param name 组件名称
void RemoveComponents(const String& name); void RemoveComponents(const String& name);
/// \~chinese /// \~chinese
/// @brief 移除所有组件 /// @brief 移除所有组件
void RemoveAllComponents(); void RemoveAllComponents();
/// \~chinese /// \~chinese
/// @brief 暂停角色更新 /// @brief 暂停角色更新
void PauseUpdating(); void PauseUpdating();
/// \~chinese /// \~chinese
/// @brief 继续角色更新 /// @brief 继续角色更新
void ResumeUpdating(); void ResumeUpdating();
/// \~chinese /// \~chinese
/// @brief 角色更新是否暂停 /// @brief 角色更新是否暂停
bool IsUpdatePausing() const; bool IsUpdatePausing() const;
/// \~chinese /// \~chinese
/// @brief 设置更新时的回调函数 /// @brief 设置更新时的回调函数
void SetCallbackOnUpdate(const UpdateCallback& cb); void SetCallbackOnUpdate(const UpdateCallback& cb);
/// \~chinese /// \~chinese
/// @brief 获取更新时的回调函数 /// @brief 获取更新时的回调函数
UpdateCallback GetCallbackOnUpdate() const; UpdateCallback GetCallbackOnUpdate() const;
/// \~chinese /// \~chinese
/// @brief 获取物理身体仅当kiwano-physics包启用时生效 /// @brief 获取物理身体仅当kiwano-physics包启用时生效
physics::PhysicBody* GetPhysicBody() const; physics::PhysicBody* GetPhysicBody() const;
/// \~chinese /// \~chinese
/// @brief 设置物理身体仅当kiwano-physics包启用时生效 /// @brief 设置物理身体仅当kiwano-physics包启用时生效
void SetPhysicBody(physics::PhysicBody* body); void SetPhysicBody(physics::PhysicBody* body);
/// \~chinese /// \~chinese
/// @brief 判断点是否在角色内 /// @brief 判断点是否在角色内
virtual bool ContainsPoint(const Point& point) const; virtual bool ContainsPoint(const Point& point) const;
/// \~chinese /// \~chinese
/// @brief 将世界坐标系点转换为局部坐标系点 /// @brief 将世界坐标系点转换为局部坐标系点
Point ConvertToLocal(const Point& point) const; Point ConvertToLocal(const Point& point) const;
/// \~chinese /// \~chinese
/// @brief 将局部坐标系点转换为世界坐标系点 /// @brief 将局部坐标系点转换为世界坐标系点
Point ConvertToWorld(const Point& point) const; Point ConvertToWorld(const Point& point) const;
/// \~chinese /// \~chinese
/// @brief 渲染角色边界 /// @brief 渲染角色边界
void ShowBorder(bool show); void ShowBorder(bool show);
/// \~chinese /// \~chinese
/// @brief 分发事件 /// @brief 分发事件
/// @param evt 事件 /// @param evt 事件
/// @return 是否继续分发该事件 /// @return 是否继续分发该事件
virtual bool DispatchEvent(Event* evt); virtual bool DispatchEvent(Event* evt);
/// \~chinese /// \~chinese
/// @brief 设置默认锚点 /// @brief 设置默认锚点
static void SetDefaultAnchor(float anchor_x, float anchor_y); static void SetDefaultAnchor(float anchor_x, float anchor_y);
protected: protected:
/// \~chinese /// \~chinese
/// @brief 更新自身和所有子角色 /// @brief 更新自身和所有子角色
virtual void Update(Duration dt); virtual void Update(Duration dt);
/// \~chinese /// \~chinese
/// @brief 渲染自身和所有子角色 /// @brief 渲染自身和所有子角色
virtual void Render(RenderContext& ctx); virtual void Render(RenderContext& ctx);
/// \~chinese /// \~chinese
/// @brief 绘制自身和所有子角色的边界 /// @brief 绘制自身和所有子角色的边界
virtual void RenderBorder(RenderContext& ctx); virtual void RenderBorder(RenderContext& ctx);
/// \~chinese /// \~chinese
/// @brief 检查是否在渲染上下文的视区内 /// @brief 检查是否在渲染上下文的视区内
virtual bool CheckVisibility(RenderContext& ctx) const; virtual bool CheckVisibility(RenderContext& ctx) const;
/// \~chinese /// \~chinese
/// @brief 渲染前初始化渲染上下文状态,仅当 CheckVisibility 返回真时调用该函数 /// @brief 渲染前初始化渲染上下文状态,仅当 CheckVisibility 返回真时调用该函数
virtual void PrepareToRender(RenderContext& ctx); virtual void PrepareToRender(RenderContext& ctx);
/// \~chinese /// \~chinese
/// @brief 更新自己的二维变换,并通知所有子角色 /// @brief 更新自己的二维变换,并通知所有子角色
void UpdateTransform() const; void UpdateTransform() const;
/// \~chinese /// \~chinese
/// @brief 更新自己和所有子角色的透明度 /// @brief 更新自己和所有子角色的透明度
void UpdateOpacity(); void UpdateOpacity();
/// \~chinese /// \~chinese
/// @brief 将所有子角色按Z轴顺序排序 /// @brief 将所有子角色按Z轴顺序排序
void Reorder(); void Reorder();
/// \~chinese /// \~chinese
/// @brief 设置节点所在舞台 /// @brief 设置节点所在舞台
void SetStage(Stage* stage); void SetStage(Stage* stage);
/// \~chinese /// \~chinese
/// @brief 处理事件 /// @brief 处理事件
bool HandleEvent(Event* evt); bool HandleEvent(Event* evt);
/// \~chinese /// \~chinese
/// @brief 更新组件 /// @brief 更新组件
void UpdateComponents(Duration dt); void UpdateComponents(Duration dt);
/// \~chinese /// \~chinese
/// @brief 渲染组件 /// @brief 渲染组件
void RenderComponents(RenderContext& ctx); void RenderComponents(RenderContext& ctx);
private: private:

View File

@ -28,26 +28,26 @@ KGE_DECLARE_SMART_PTR(Button);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Button : public Component class KGE_API Button : public Component
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 按钮回调函数 /// @brief 按钮回调函数
using Callback = Function<void(Button* /* self */, Actor* /* target */)>; using Callback = Function<void(Button* /* self */, Actor* /* target */)>;
/// \~chinese /// \~chinese
/// @brief 创建按钮 /// @brief 创建按钮
/// @param click 按钮点击回调函数 /// @param click 按钮点击回调函数
static ButtonPtr Create(const Callback& click); static ButtonPtr Create(const Callback& click);
/// \~chinese /// \~chinese
/// @brief 创建按钮 /// @brief 创建按钮
/// @param click 按钮点击回调函数 /// @param click 按钮点击回调函数
/// @param pressed 按钮按下回调函数 /// @param pressed 按钮按下回调函数
/// @param mouse_over 按钮移入回调函数 /// @param mouse_over 按钮移入回调函数
/// @param mouse_out 按钮移出回调函数 /// @param mouse_out 按钮移出回调函数
static ButtonPtr Create(const Callback& click, const Callback& pressed, const Callback& mouse_over, static ButtonPtr Create(const Callback& click, const Callback& pressed, const Callback& mouse_over,
const Callback& mouse_out); const Callback& mouse_out);
@ -56,49 +56,49 @@ public:
virtual ~Button(); virtual ~Button();
/// \~chinese /// \~chinese
/// @brief 设置按钮点击后的回调函数 /// @brief 设置按钮点击后的回调函数
void SetClickCallback(const Callback& func); void SetClickCallback(const Callback& func);
/// \~chinese /// \~chinese
/// @brief 设置按钮被按下时的回调函数 /// @brief 设置按钮被按下时的回调函数
void SetPressedCallback(const Callback& func); void SetPressedCallback(const Callback& func);
/// \~chinese /// \~chinese
/// @brief 设置鼠标移入按钮时的回调函数 /// @brief 设置鼠标移入按钮时的回调函数
void SetMouseOverCallback(const Callback& func); void SetMouseOverCallback(const Callback& func);
/// \~chinese /// \~chinese
/// @brief 设置鼠标移出按钮时的回调函数 /// @brief 设置鼠标移出按钮时的回调函数
void SetMouseOutCallback(const Callback& func); void SetMouseOutCallback(const Callback& func);
protected: protected:
/// \~chinese /// \~chinese
/// @brief 按钮状态 /// @brief 按钮状态
enum class Status enum class Status
{ {
Normal, ///< 普通 Normal, ///< 普通
Hover, ///< 鼠标在按钮内 Hover, ///< 鼠标在按钮内
Pressed ///< 被按下 Pressed ///< 被按下
}; };
/// \~chinese /// \~chinese
/// @brief 获取按钮状态 /// @brief 获取按钮状态
Status GetStatus() const; Status GetStatus() const;
/// \~chinese /// \~chinese
/// @brief 设置按钮状态 /// @brief 设置按钮状态
void SetStatus(Status status); void SetStatus(Status status);
/// \~chinese /// \~chinese
/// @brief 初始化组件 /// @brief 初始化组件
void InitComponent(Actor* actor) override; void InitComponent(Actor* actor) override;
/// \~chinese /// \~chinese
/// @brief 销毁组件 /// @brief 销毁组件
void DestroyComponent() override; void DestroyComponent() override;
/// \~chinese /// \~chinese
/// @brief 处理角色事件 /// @brief 处理角色事件
void HandleEvent(Event* evt) override; void HandleEvent(Event* evt) override;
private: private:

View File

@ -36,238 +36,238 @@ KGE_DECLARE_SMART_PTR(Canvas);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
*/ */
class KGE_API Canvas : public Actor class KGE_API Canvas : public Actor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建画布 /// @brief 创建画布
/// @param size 画布大小 /// @param size 画布大小
static CanvasPtr Create(const Size& size); static CanvasPtr Create(const Size& size);
/// \~chinese /// \~chinese
/// @brief 开始绘图 /// @brief 开始绘图
void BeginDraw(); void BeginDraw();
/// \~chinese /// \~chinese
/// @brief 结束绘图 /// @brief 结束绘图
void EndDraw(); void EndDraw();
/// \~chinese /// \~chinese
/// @brief 画形状轮廓 /// @brief 画形状轮廓
/// @param shape 形状 /// @param shape 形状
void DrawShape(ShapePtr shape); void DrawShape(ShapePtr shape);
/// \~chinese /// \~chinese
/// @brief 画线段 /// @brief 画线段
/// @param begin 线段起点 /// @param begin 线段起点
/// @param end 线段终点 /// @param end 线段终点
void DrawLine(const Point& begin, const Point& end); void DrawLine(const Point& begin, const Point& end);
/// \~chinese /// \~chinese
/// @brief 画圆形边框 /// @brief 画圆形边框
/// @param center 圆形原点 /// @param center 圆形原点
/// @param radius 圆形半径 /// @param radius 圆形半径
void DrawCircle(const Point& center, float radius); void DrawCircle(const Point& center, float radius);
/// \~chinese /// \~chinese
/// @brief 画椭圆形边框 /// @brief 画椭圆形边框
/// @param center 椭圆原点 /// @param center 椭圆原点
/// @param radius 椭圆半径 /// @param radius 椭圆半径
void DrawEllipse(const Point& center, const Vec2& radius); void DrawEllipse(const Point& center, const Vec2& radius);
/// \~chinese /// \~chinese
/// @brief 画矩形边框 /// @brief 画矩形边框
/// @param rect 矩形 /// @param rect 矩形
void DrawRect(const Rect& rect); void DrawRect(const Rect& rect);
/// \~chinese /// \~chinese
/// @brief 画圆角矩形边框 /// @brief 画圆角矩形边框
/// @param rect 矩形 /// @param rect 矩形
/// @param radius 矩形圆角半径 /// @param radius 矩形圆角半径
void DrawRoundedRect(const Rect& rect, const Vec2& radius); void DrawRoundedRect(const Rect& rect, const Vec2& radius);
/// \~chinese /// \~chinese
/// @brief 填充形状 /// @brief 填充形状
/// @param shape 形状 /// @param shape 形状
void FillShape(ShapePtr shape); void FillShape(ShapePtr shape);
/// \~chinese /// \~chinese
/// @brief 填充圆形 /// @brief 填充圆形
/// @param center 圆形原点 /// @param center 圆形原点
/// @param radius 圆形半径 /// @param radius 圆形半径
void FillCircle(const Point& center, float radius); void FillCircle(const Point& center, float radius);
/// \~chinese /// \~chinese
/// @brief 填充椭圆形 /// @brief 填充椭圆形
/// @param center 椭圆原点 /// @param center 椭圆原点
/// @param radius 椭圆半径 /// @param radius 椭圆半径
void FillEllipse(const Point& center, const Vec2& radius); void FillEllipse(const Point& center, const Vec2& radius);
/// \~chinese /// \~chinese
/// @brief 填充矩形 /// @brief 填充矩形
/// @param rect 矩形 /// @param rect 矩形
void FillRect(const Rect& rect); void FillRect(const Rect& rect);
/// \~chinese /// \~chinese
/// @brief 填充圆角矩形 /// @brief 填充圆角矩形
/// @param rect 矩形 /// @param rect 矩形
/// @param radius 矩形圆角半径 /// @param radius 矩形圆角半径
void FillRoundedRect(const Rect& rect, const Vec2& radius); void FillRoundedRect(const Rect& rect, const Vec2& radius);
/// \~chinese /// \~chinese
/// @brief 绘制图像帧 /// @brief 绘制图像帧
/// @param frame 图像帧 /// @param frame 图像帧
/// @param pos 绘制图像的位置 /// @param pos 绘制图像的位置
void DrawFrame(FramePtr frame, const Point& pos); void DrawFrame(FramePtr frame, const Point& pos);
/// \~chinese /// \~chinese
/// @brief 绘制图像帧 /// @brief 绘制图像帧
/// @param frame 图像帧 /// @param frame 图像帧
/// @param pos 绘制图像的位置 /// @param pos 绘制图像的位置
/// @param size 渲染的图像大小 /// @param size 渲染的图像大小
void DrawFrame(FramePtr frame, const Point& pos, const Size& size); void DrawFrame(FramePtr frame, const Point& pos, const Size& size);
/// \~chinese /// \~chinese
/// @brief 绘制文字布局 /// @brief 绘制文字布局
/// @param text 文字 /// @param text 文字
/// @param style 文字样式 /// @param style 文字样式
/// @param point 绘制文字的位置 /// @param point 绘制文字的位置
void DrawTextLayout(const String& text, const TextStyle& style, const Point& point); void DrawTextLayout(const String& text, const TextStyle& style, const Point& point);
/// \~chinese /// \~chinese
/// @brief 绘制文字布局 /// @brief 绘制文字布局
/// @param layout 文字布局 /// @param layout 文字布局
/// @param point 绘制布局的位置 /// @param point 绘制布局的位置
void DrawTextLayout(TextLayoutPtr layout, const Point& point); void DrawTextLayout(TextLayoutPtr layout, const Point& point);
/// \~chinese /// \~chinese
/// @brief 开始绘制路径 /// @brief 开始绘制路径
/// @param begin_pos 路径起始点 /// @param begin_pos 路径起始点
void BeginPath(const Point& begin_pos); void BeginPath(const Point& begin_pos);
/// \~chinese /// \~chinese
/// @brief 结束路径 /// @brief 结束路径
/// @param closed 路径是否闭合 /// @param closed 路径是否闭合
void EndPath(bool closed = false); void EndPath(bool closed = false);
/// \~chinese /// \~chinese
/// @brief 添加一条线段 /// @brief 添加一条线段
/// @param point 端点 /// @param point 端点
void AddLine(const Point& point); void AddLine(const Point& point);
/// \~chinese /// \~chinese
/// @brief 添加多条线段 /// @brief 添加多条线段
/// @param points 端点集合 /// @param points 端点集合
void AddLines(const Vector<Point>& points); void AddLines(const Vector<Point>& points);
/// \~chinese /// \~chinese
/// @brief 添加一条三次方贝塞尔曲线 /// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点 /// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点 /// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点 /// @param point3 贝塞尔曲线的终点
void AddBezier(const Point& point1, const Point& point2, const Point& point3); void AddBezier(const Point& point1, const Point& point2, const Point& point3);
/// \~chinese /// \~chinese
/// @brief 添加弧线 /// @brief 添加弧线
/// @param point 终点 /// @param point 终点
/// @param radius 椭圆半径 /// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度 /// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针 /// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧 /// @param is_small 是否取小于 180° 的弧
void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true); void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true);
/// \~chinese /// \~chinese
/// @brief 以描边的方式绘制路径 /// @brief 以描边的方式绘制路径
void StrokePath(); void StrokePath();
/// \~chinese /// \~chinese
/// @brief 以填充的方式绘制路径 /// @brief 以填充的方式绘制路径
void FillPath(); void FillPath();
/// \~chinese /// \~chinese
/// @brief 清空画布 /// @brief 清空画布
void Clear(); void Clear();
/// \~chinese /// \~chinese
/// @brief 清空画布 /// @brief 清空画布
/// @param clear_color 清空颜色 /// @param clear_color 清空颜色
void Clear(const Color& clear_color); void Clear(const Color& clear_color);
/// \~chinese /// \~chinese
/// @brief 设置填充颜色 /// @brief 设置填充颜色
/// @param color 填充颜色 /// @param color 填充颜色
void SetFillColor(const Color& color); void SetFillColor(const Color& color);
/// \~chinese /// \~chinese
/// @brief 设置填充画刷 /// @brief 设置填充画刷
/// @param[in] brush 填充画刷 /// @param[in] brush 填充画刷
void SetFillBrush(BrushPtr brush); void SetFillBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置轮廓颜色 /// @brief 设置轮廓颜色
/// @param color 轮廓颜色 /// @param color 轮廓颜色
void SetStrokeColor(const Color& color); void SetStrokeColor(const Color& color);
/// \~chinese /// \~chinese
/// @brief 设置轮廓画刷 /// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷 /// @param[in] brush 轮廓画刷
void SetStrokeBrush(BrushPtr brush); void SetStrokeBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置轮廓样式 /// @brief 设置轮廓样式
/// @param stroke_style 轮廓样式 /// @param stroke_style 轮廓样式
void SetStrokeStyle(StrokeStylePtr stroke_style); void SetStrokeStyle(StrokeStylePtr stroke_style);
/// \~chinese /// \~chinese
/// @brief 设置画刷 /// @brief 设置画刷
/// @param[in] brush 画刷 /// @param[in] brush 画刷
void SetBrush(BrushPtr brush); void SetBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置画刷二维变换 /// @brief 设置画刷二维变换
/// @param transform 二维变换 /// @param transform 二维变换
void SetBrushTransform(const Transform& transform); void SetBrushTransform(const Transform& transform);
/// \~chinese /// \~chinese
/// @brief 设置画刷二维变换矩阵 /// @brief 设置画刷二维变换矩阵
/// @param transform 二维变换矩阵 /// @param transform 二维变换矩阵
void SetBrushTransform(const Matrix3x2& transform); void SetBrushTransform(const Matrix3x2& transform);
/// \~chinese /// \~chinese
/// @brief 添加一个图层 /// @brief 添加一个图层
/// @param layer 图层 /// @param layer 图层
void PushLayer(LayerPtr layer); void PushLayer(LayerPtr layer);
/// \~chinese /// \~chinese
/// @brief 删除最近添加的图层 /// @brief 删除最近添加的图层
void PopLayer(); void PopLayer();
/// \~chinese /// \~chinese
/// @brief 添加一个裁剪区域 /// @brief 添加一个裁剪区域
/// @param clip_rect 裁剪矩形 /// @param clip_rect 裁剪矩形
void PushClipRect(const Rect& clip_rect); void PushClipRect(const Rect& clip_rect);
/// \~chinese /// \~chinese
/// @brief 删除最近添加的裁剪区域 /// @brief 删除最近添加的裁剪区域
void PopClipRect(); void PopClipRect();
/// \~chinese /// \~chinese
/// @brief 获取填充画刷 /// @brief 获取填充画刷
BrushPtr GetFillBrush() const; BrushPtr GetFillBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取轮廓画刷 /// @brief 获取轮廓画刷
BrushPtr GetStrokeBrush() const; BrushPtr GetStrokeBrush() const;
/// \~chinese /// \~chinese
/// @brief 清空画布大小并重设画布大小 /// @brief 清空画布大小并重设画布大小
void ResizeAndClear(Size size); void ResizeAndClear(Size size);
/// \~chinese /// \~chinese
/// @brief 导出纹理 /// @brief 导出纹理
TexturePtr ExportToTexture() const; TexturePtr ExportToTexture() const;
void OnRender(RenderContext& ctx) override; void OnRender(RenderContext& ctx) override;

View File

@ -33,12 +33,12 @@ class Event;
KGE_DECLARE_SMART_PTR(Component); KGE_DECLARE_SMART_PTR(Component);
/// \~chinese /// \~chinese
/// @brief 组件列表 /// @brief 组件列表
typedef IntrusiveList<ComponentPtr> ComponentList; typedef IntrusiveList<ComponentPtr> ComponentList;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Component class KGE_API Component
: public ObjectBase : public ObjectBase
@ -49,19 +49,19 @@ class KGE_API Component
public: public:
/// \~chinese /// \~chinese
/// @brief 是否启用组件 /// @brief 是否启用组件
bool IsEnable() const; bool IsEnable() const;
/// \~chinese /// \~chinese
/// @brief 设置组件启用或禁用 /// @brief 设置组件启用或禁用
void SetEnabled(bool enabled); void SetEnabled(bool enabled);
/// \~chinese /// \~chinese
/// @brief 获取绑定的角色 /// @brief 获取绑定的角色
Actor* GetBoundActor() const; Actor* GetBoundActor() const;
/// \~chinese /// \~chinese
/// @brief 从角色中移除 /// @brief 从角色中移除
void RemoveFromActor(); void RemoveFromActor();
protected: protected:
@ -70,23 +70,23 @@ protected:
virtual ~Component(); virtual ~Component();
/// \~chinese /// \~chinese
/// @brief 初始化组件 /// @brief 初始化组件
virtual void InitComponent(Actor* actor); virtual void InitComponent(Actor* actor);
/// \~chinese /// \~chinese
/// @brief 销毁组件 /// @brief 销毁组件
virtual void DestroyComponent(); virtual void DestroyComponent();
/// \~chinese /// \~chinese
/// @brief 更新组件 /// @brief 更新组件
virtual void OnUpdate(Duration dt); virtual void OnUpdate(Duration dt);
/// \~chinese /// \~chinese
/// @brief 渲染组件 /// @brief 渲染组件
virtual void OnRender(RenderContext& ctx); virtual void OnRender(RenderContext& ctx);
/// \~chinese /// \~chinese
/// @brief 处理角色事件 /// @brief 处理角色事件
virtual void HandleEvent(Event* evt); virtual void HandleEvent(Event* evt);
private: private:

View File

@ -31,7 +31,7 @@ namespace kiwano
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API DebugActor : public Actor class KGE_API DebugActor : public Actor
{ {

View File

@ -28,88 +28,88 @@ KGE_DECLARE_SMART_PTR(Frame);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Frame : public ObjectBase class KGE_API Frame : public ObjectBase
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建图像帧 /// @brief 创建图像帧
/// @param file_path 图像路径 /// @param file_path 图像路径
static FramePtr Create(const String& file_path); static FramePtr Create(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 创建图像帧 /// @brief 创建图像帧
/// @param res 图像资源 /// @param res 图像资源
static FramePtr Create(const Resource& res); static FramePtr Create(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 创建图像帧 /// @brief 创建图像帧
/// @param texture 纹理 /// @param texture 纹理
static FramePtr Create(TexturePtr texture); static FramePtr Create(TexturePtr texture);
/// \~chinese /// \~chinese
/// @brief 构建空图像帧 /// @brief 构建空图像帧
Frame(); Frame();
/// \~chinese /// \~chinese
/// @brief 加载图像 /// @brief 加载图像
/// @param file_path 图像路径 /// @param file_path 图像路径
bool Load(const String& file_path); bool Load(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 加载图像 /// @brief 加载图像
/// @param res 图像资源 /// @param res 图像资源
bool Load(const Resource& res); bool Load(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 裁剪图像帧为矩形 /// @brief 裁剪图像帧为矩形
/// @param crop_rect 裁剪矩形定义 /// @param crop_rect 裁剪矩形定义
void SetCropRect(const Rect& crop_rect); void SetCropRect(const Rect& crop_rect);
/// \~chinese /// \~chinese
/// @brief 设置纹理 /// @brief 设置纹理
/// @param texture 纹理 /// @param texture 纹理
void SetTexture(TexturePtr texture); void SetTexture(TexturePtr texture);
/// \~chinese /// \~chinese
/// @brief 是否有效 /// @brief 是否有效
bool IsValid() const; bool IsValid() const;
/// \~chinese /// \~chinese
/// @brief 获取宽度 /// @brief 获取宽度
float GetWidth() const; float GetWidth() const;
/// \~chinese /// \~chinese
/// @brief 获取高度 /// @brief 获取高度
float GetHeight() const; float GetHeight() const;
/// \~chinese /// \~chinese
/// @brief 获取大小 /// @brief 获取大小
Size GetSize() const; Size GetSize() const;
/// \~chinese /// \~chinese
/// @brief 获取裁剪位置 /// @brief 获取裁剪位置
Point GetCropPoint() const; Point GetCropPoint() const;
/// \~chinese /// \~chinese
/// @brief 获取裁剪矩形 /// @brief 获取裁剪矩形
const Rect& GetCropRect() const; const Rect& GetCropRect() const;
/// \~chinese /// \~chinese
/// @brief 获取图像原宽度 /// @brief 获取图像原宽度
float GetSourceWidth() const; float GetSourceWidth() const;
/// \~chinese /// \~chinese
/// @brief 获取图像原高度 /// @brief 获取图像原高度
float GetSourceHeight() const; float GetSourceHeight() const;
/// \~chinese /// \~chinese
/// @brief 获取图像原大小 /// @brief 获取图像原大小
Size GetSourceSize() const; Size GetSourceSize() const;
/// \~chinese /// \~chinese
/// @brief 获取纹理 /// @brief 获取纹理
TexturePtr GetTexture() const; TexturePtr GetTexture() const;
private: private:

View File

@ -29,76 +29,76 @@ KGE_DECLARE_SMART_PTR(FrameSequence);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API FrameSequence : public ObjectBase class KGE_API FrameSequence : public ObjectBase
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建序列帧 /// @brief 创建序列帧
static FrameSequencePtr Create(); static FrameSequencePtr Create();
/// \~chinese /// \~chinese
/// @brief 创建序列帧 /// @brief 创建序列帧
/// @param frames 图像帧集合 /// @param frames 图像帧集合
static FrameSequencePtr Create(const Vector<FramePtr>& frames); static FrameSequencePtr Create(const Vector<FramePtr>& frames);
/// \~chinese /// \~chinese
/// @brief 按行列分割图像并创建序列帧 /// @brief 按行列分割图像并创建序列帧
/// @param frame 图像帧 /// @param frame 图像帧
/// @param cols 列数 /// @param cols 列数
/// @param rows 行数 /// @param rows 行数
/// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧 /// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧
/// @param padding_x X方向间隔 /// @param padding_x X方向间隔
/// @param padding_y Y方向间隔 /// @param padding_y Y方向间隔
static FrameSequencePtr Create(FramePtr frame, int cols, int rows = 1, int max_num = -1, float padding_x = 0, static FrameSequencePtr Create(FramePtr frame, int cols, int rows = 1, int max_num = -1, float padding_x = 0,
float padding_y = 0); float padding_y = 0);
/// \~chinese /// \~chinese
/// @brief 构建空序列帧 /// @brief 构建空序列帧
FrameSequence(); FrameSequence();
virtual ~FrameSequence(); virtual ~FrameSequence();
/// \~chinese /// \~chinese
/// @brief 添加关键帧 /// @brief 添加关键帧
/// @param frame 图像帧 /// @param frame 图像帧
void AddFrame(FramePtr frame); void AddFrame(FramePtr frame);
/// \~chinese /// \~chinese
/// @brief 添加多个关键帧 /// @brief 添加多个关键帧
/// @param frames 图像帧集合 /// @param frames 图像帧集合
void AddFrames(const Vector<FramePtr>& frames); void AddFrames(const Vector<FramePtr>& frames);
/// \~chinese /// \~chinese
/// @brief 按行列分割图像并添加序列帧 /// @brief 按行列分割图像并添加序列帧
/// @param frame 图像帧 /// @param frame 图像帧
/// @param cols 列数 /// @param cols 列数
/// @param rows 行数 /// @param rows 行数
/// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧 /// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧
/// @param padding_x X方向间隔 /// @param padding_x X方向间隔
/// @param padding_y Y方向间隔 /// @param padding_y Y方向间隔
void AddFrames(FramePtr frame, int cols, int rows = 1, int max_num = -1, float padding_x = 0, float padding_y = 0); void AddFrames(FramePtr frame, int cols, int rows = 1, int max_num = -1, float padding_x = 0, float padding_y = 0);
/// \~chinese /// \~chinese
/// @brief 获取关键帧 /// @brief 获取关键帧
/// @param index 图像帧下标 /// @param index 图像帧下标
FramePtr GetFrame(size_t index) const; FramePtr GetFrame(size_t index) const;
/// \~chinese /// \~chinese
/// @brief 获取所有关键帧 /// @brief 获取所有关键帧
const Vector<FramePtr>& GetFrames() const; const Vector<FramePtr>& GetFrames() const;
/// \~chinese /// \~chinese
/// @brief 获取关键帧数量 /// @brief 获取关键帧数量
size_t GetFramesCount() const; size_t GetFramesCount() const;
/// \~chinese /// \~chinese
/// @brief 获取序列帧的拷贝对象 /// @brief 获取序列帧的拷贝对象
FrameSequencePtr Clone() const; FrameSequencePtr Clone() const;
/// \~chinese /// \~chinese
/// @brief 获取序列帧的倒转 /// @brief 获取序列帧的倒转
FrameSequencePtr Reverse() const; FrameSequencePtr Reverse() const;
private: private:

View File

@ -35,81 +35,81 @@ KGE_DECLARE_SMART_PTR(GifSprite);
/** /**
* \~chinese * \~chinese
* @brief GIF * @brief GIF
*/ */
class KGE_API GifSprite : public Actor class KGE_API GifSprite : public Actor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief GIF播放循环结束回调 /// @brief GIF播放循环结束回调
using LoopDoneCallback = Function<void(int /* times */)>; using LoopDoneCallback = Function<void(int /* times */)>;
/// \~chinese /// \~chinese
/// @brief GIF播放结束回调 /// @brief GIF播放结束回调
using DoneCallback = Function<void()>; using DoneCallback = Function<void()>;
/// \~chinese /// \~chinese
/// @brief 创建GIF精灵 /// @brief 创建GIF精灵
/// @param file_path GIF图片路径 /// @param file_path GIF图片路径
static GifSpritePtr Create(const String& file_path); static GifSpritePtr Create(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 创建GIF精灵 /// @brief 创建GIF精灵
/// @param res GIF图片资源 /// @param res GIF图片资源
static GifSpritePtr Create(const Resource& res); static GifSpritePtr Create(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 创建GIF精灵 /// @brief 创建GIF精灵
/// @param gif GIF图片 /// @param gif GIF图片
static GifSpritePtr Create(GifImagePtr gif); static GifSpritePtr Create(GifImagePtr gif);
GifSprite(); GifSprite();
/// \~chinese /// \~chinese
/// @brief 加载GIF图片 /// @brief 加载GIF图片
/// @param file_path GIF图片路径 /// @param file_path GIF图片路径
bool Load(const String& file_path); bool Load(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 加载GIF图片 /// @brief 加载GIF图片
/// @param res GIF图片资源 /// @param res GIF图片资源
bool Load(const Resource& res); bool Load(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 加载GIF图片 /// @brief 加载GIF图片
/// @param gif GIF图片 /// @param gif GIF图片
bool Load(GifImagePtr gif); bool Load(GifImagePtr gif);
/// \~chinese /// \~chinese
/// @brief 设置 GIF 动画循环次数 /// @brief 设置 GIF 动画循环次数
void SetLoopCount(int loops); void SetLoopCount(int loops);
/// \~chinese /// \~chinese
/// @brief 设置 GIF 动画每次循环结束回调函数 /// @brief 设置 GIF 动画每次循环结束回调函数
void SetLoopDoneCallback(const LoopDoneCallback& cb); void SetLoopDoneCallback(const LoopDoneCallback& cb);
/// \~chinese /// \~chinese
/// @brief 设置 GIF 动画结束回调函数 /// @brief 设置 GIF 动画结束回调函数
void SetDoneCallback(const DoneCallback& cb); void SetDoneCallback(const DoneCallback& cb);
/// \~chinese /// \~chinese
/// @brief 设置 GIF 图像 /// @brief 设置 GIF 图像
void SetGifImage(GifImagePtr gif); void SetGifImage(GifImagePtr gif);
/// \~chinese /// \~chinese
/// @brief 重新播放 GIF 动画 /// @brief 重新播放 GIF 动画
void RestartAnimation(); void RestartAnimation();
/// \~chinese /// \~chinese
/// @brief 获取 GIF 动画循环结束回调 /// @brief 获取 GIF 动画循环结束回调
LoopDoneCallback GetLoopDoneCallback() const; LoopDoneCallback GetLoopDoneCallback() const;
/// \~chinese /// \~chinese
/// @brief 获取 GIF 动画播放结束回调 /// @brief 获取 GIF 动画播放结束回调
DoneCallback GetDoneCallback() const; DoneCallback GetDoneCallback() const;
/// \~chinese /// \~chinese
/// @brief 获取 GIF 图片 /// @brief 获取 GIF 图片
GifImagePtr GetGifImage() const; GifImagePtr GetGifImage() const;
void OnRender(RenderContext& ctx) override; void OnRender(RenderContext& ctx) override;
@ -118,35 +118,35 @@ private:
void Update(Duration dt) override; void Update(Duration dt) override;
/// \~chinese /// \~chinese
/// @brief 是否是最后一帧 /// @brief 是否是最后一帧
bool IsLastFrame() const; bool IsLastFrame() const;
/// \~chinese /// \~chinese
/// @brief 动画是否已结束 /// @brief 动画是否已结束
bool EndOfAnimation() const; bool EndOfAnimation() const;
/// \~chinese /// \~chinese
/// @brief 合成下一帧 /// @brief 合成下一帧
void ComposeNextFrame(); void ComposeNextFrame();
/// \~chinese /// \~chinese
/// @brief 解析当前图像帧 /// @brief 解析当前图像帧
void DisposeCurrentFrame(); void DisposeCurrentFrame();
/// \~chinese /// \~chinese
/// @brief 覆盖下一帧 /// @brief 覆盖下一帧
void OverlayNextFrame(); void OverlayNextFrame();
/// \~chinese /// \~chinese
/// @brief 保存合成后的图像帧 /// @brief 保存合成后的图像帧
void SaveComposedFrame(); void SaveComposedFrame();
/// \~chinese /// \~chinese
/// @brief 恢复已保存的图像帧 /// @brief 恢复已保存的图像帧
void RestoreSavedFrame(); void RestoreSavedFrame();
/// \~chinese /// \~chinese
/// @brief 清空当前图像区域 /// @brief 清空当前图像区域
void ClearCurrentFrameArea(); void ClearCurrentFrameArea();
private: private:

View File

@ -34,13 +34,13 @@ KGE_DECLARE_SMART_PTR(LayerActor);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API LayerActor : public Actor class KGE_API LayerActor : public Actor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建图层 /// @brief 创建图层
static LayerActorPtr Create(); static LayerActorPtr Create();
LayerActor(); LayerActor();
@ -48,26 +48,26 @@ public:
virtual ~LayerActor(); virtual ~LayerActor();
/// \~chinese /// \~chinese
/// @brief 是否开启消息吞没 /// @brief 是否开启消息吞没
bool IsSwallowEventsEnabled() const; bool IsSwallowEventsEnabled() const;
/// \~chinese /// \~chinese
/// @brief 获取图层 /// @brief 获取图层
LayerPtr GetLayer() const; LayerPtr GetLayer() const;
/// \~chinese /// \~chinese
/// @brief 设置图层 /// @brief 设置图层
/// @param layer 图层 /// @param layer 图层
void SetLayer(LayerPtr layer); void SetLayer(LayerPtr layer);
/// \~chinese /// \~chinese
/// @brief 设置消息吞没功能 /// @brief 设置消息吞没功能
/// @param enabled 是否启用 /// @param enabled 是否启用
void SetSwallowEvents(bool enabled); void SetSwallowEvents(bool enabled);
/// \~chinese /// \~chinese
/// @brief 设置图层透明度 /// @brief 设置图层透明度
/// @param opacity 透明度 /// @param opacity 透明度
void SetOpacity(float opacity) override; void SetOpacity(float opacity) override;
bool DispatchEvent(Event* evt) override; bool DispatchEvent(Event* evt) override;

View File

@ -43,90 +43,90 @@ KGE_DECLARE_SMART_PTR(PolygonActor);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API ShapeActor : public Actor class KGE_API ShapeActor : public Actor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建形状角色 /// @brief 创建形状角色
/// @param shape 形状 /// @param shape 形状
static ShapeActorPtr Create(ShapePtr shape); static ShapeActorPtr Create(ShapePtr shape);
/// \~chinese /// \~chinese
/// @brief 创建形状角色 /// @brief 创建形状角色
/// @param shape 形状 /// @param shape 形状
/// @param fill_color 填充颜色 /// @param fill_color 填充颜色
/// @param stroke_color 轮廓颜色 /// @param stroke_color 轮廓颜色
static ShapeActorPtr Create(ShapePtr shape, const Color& fill_color, const Color& stroke_color); static ShapeActorPtr Create(ShapePtr shape, const Color& fill_color, const Color& stroke_color);
/// \~chinese /// \~chinese
/// @brief 创建形状角色 /// @brief 创建形状角色
/// @param shape 形状 /// @param shape 形状
/// @param fill_brush 填充画刷 /// @param fill_brush 填充画刷
/// @param stroke_brush 轮廓画刷 /// @param stroke_brush 轮廓画刷
static ShapeActorPtr Create(ShapePtr shape, BrushPtr fill_brush, BrushPtr stroke_brush); static ShapeActorPtr Create(ShapePtr shape, BrushPtr fill_brush, BrushPtr stroke_brush);
/// \~chinese /// \~chinese
/// @brief 构造形状角色 /// @brief 构造形状角色
ShapeActor(); ShapeActor();
virtual ~ShapeActor(); virtual ~ShapeActor();
/// \~chinese /// \~chinese
/// @brief 获取填充画刷 /// @brief 获取填充画刷
BrushPtr GetFillBrush() const; BrushPtr GetFillBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取轮廓画刷 /// @brief 获取轮廓画刷
BrushPtr GetStrokeBrush() const; BrushPtr GetStrokeBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取线条样式 /// @brief 获取线条样式
StrokeStylePtr GetStrokeStyle() const; StrokeStylePtr GetStrokeStyle() const;
/// \~chinese /// \~chinese
/// @brief 获取形状 /// @brief 获取形状
ShapePtr GetShape() const; ShapePtr GetShape() const;
/// \~chinese /// \~chinese
/// @brief 获取边界 /// @brief 获取边界
Rect GetBounds() const override; Rect GetBounds() const override;
/// \~chinese /// \~chinese
/// @brief 获取外切包围盒 /// @brief 获取外切包围盒
Rect GetBoundingBox() const override; Rect GetBoundingBox() const override;
/// \~chinese /// \~chinese
/// @brief 判断点是否在形状内 /// @brief 判断点是否在形状内
bool ContainsPoint(const Point& point) const override; bool ContainsPoint(const Point& point) const override;
/// \~chinese /// \~chinese
/// @brief 设置填充颜色 /// @brief 设置填充颜色
/// @param color 填充颜色 /// @param color 填充颜色
void SetFillColor(const Color& color); void SetFillColor(const Color& color);
/// \~chinese /// \~chinese
/// @brief 设置填充画刷 /// @brief 设置填充画刷
/// @param[in] brush 填充画刷 /// @param[in] brush 填充画刷
void SetFillBrush(BrushPtr brush); void SetFillBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置轮廓颜色 /// @brief 设置轮廓颜色
/// @param color 轮廓颜色 /// @param color 轮廓颜色
void SetStrokeColor(const Color& color); void SetStrokeColor(const Color& color);
/// \~chinese /// \~chinese
/// @brief 设置轮廓画刷 /// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷 /// @param[in] brush 轮廓画刷
void SetStrokeBrush(BrushPtr brush); void SetStrokeBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置线条样式 /// @brief 设置线条样式
void SetStrokeStyle(StrokeStylePtr stroke_style); void SetStrokeStyle(StrokeStylePtr stroke_style);
/// \~chinese /// \~chinese
/// @brief 设置形状 /// @brief 设置形状
void SetShape(ShapePtr shape); void SetShape(ShapePtr shape);
void OnRender(RenderContext& ctx) override; void OnRender(RenderContext& ctx) override;
@ -143,14 +143,14 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 线段角色 /// @brief 线段角色
class KGE_API LineActor : public ShapeActor class KGE_API LineActor : public ShapeActor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建线段角色 /// @brief 创建线段角色
/// @param begin 线段起点 /// @param begin 线段起点
/// @param end 线段终点 /// @param end 线段终点
static LineActorPtr Create(const Point& begin, const Point& end); static LineActorPtr Create(const Point& begin, const Point& end);
LineActor(); LineActor();
@ -158,27 +158,27 @@ public:
virtual ~LineActor(); virtual ~LineActor();
/// \~chinese /// \~chinese
/// @brief 获取线段起点 /// @brief 获取线段起点
const Point& GetBeginPoint() const; const Point& GetBeginPoint() const;
/// \~chinese /// \~chinese
/// @brief 获取线段终点 /// @brief 获取线段终点
const Point& GetEndPoint() const; const Point& GetEndPoint() const;
/// \~chinese /// \~chinese
/// @brief 设置线段起点 /// @brief 设置线段起点
/// @param begin 线段起点 /// @param begin 线段起点
void SetBeginPoint(const Point& begin); void SetBeginPoint(const Point& begin);
/// \~chinese /// \~chinese
/// @brief 设置线段终点 /// @brief 设置线段终点
/// @param end 线段终点 /// @param end 线段终点
void SetEndPoint(const Point& end); void SetEndPoint(const Point& end);
/// \~chinese /// \~chinese
/// @brief 设置线段起点和终点 /// @brief 设置线段起点和终点
/// @param begin 线段起点 /// @param begin 线段起点
/// @param end 线段终点 /// @param end 线段终点
void SetLine(const Point& begin, const Point& end); void SetLine(const Point& begin, const Point& end);
private: private:
@ -187,13 +187,13 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 矩形角色 /// @brief 矩形角色
class KGE_API RectActor : public ShapeActor class KGE_API RectActor : public ShapeActor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建矩形角色 /// @brief 创建矩形角色
/// @param size 矩形大小 /// @param size 矩形大小
static RectActorPtr Create(const Size& size); static RectActorPtr Create(const Size& size);
RectActor(); RectActor();
@ -201,12 +201,12 @@ public:
virtual ~RectActor(); virtual ~RectActor();
/// \~chinese /// \~chinese
/// @brief 获取矩形大小 /// @brief 获取矩形大小
const Size& GetRectSize() const; const Size& GetRectSize() const;
/// \~chinese /// \~chinese
/// @brief 设置矩形大小 /// @brief 设置矩形大小
/// @param size 矩形大小 /// @param size 矩形大小
void SetRectSize(const Size& size); void SetRectSize(const Size& size);
private: private:
@ -214,14 +214,14 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 圆角矩形角色 /// @brief 圆角矩形角色
class KGE_API RoundedRectActor : public ShapeActor class KGE_API RoundedRectActor : public ShapeActor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建圆角矩形角色 /// @brief 创建圆角矩形角色
/// @param size 圆角矩形大小 /// @param size 圆角矩形大小
/// @param radius 圆角半径 /// @param radius 圆角半径
static RoundedRectActorPtr Create(const Size& size, const Vec2& radius); static RoundedRectActorPtr Create(const Size& size, const Vec2& radius);
RoundedRectActor(); RoundedRectActor();
@ -229,27 +229,27 @@ public:
virtual ~RoundedRectActor(); virtual ~RoundedRectActor();
/// \~chinese /// \~chinese
/// @brief 获取圆角半径 /// @brief 获取圆角半径
Vec2 GetRadius() const; Vec2 GetRadius() const;
/// \~chinese /// \~chinese
/// @brief 获取圆角矩形大小 /// @brief 获取圆角矩形大小
Size GetRectSize() const; Size GetRectSize() const;
/// \~chinese /// \~chinese
/// @brief 设置圆角半径 /// @brief 设置圆角半径
/// @param radius 圆角半径 /// @param radius 圆角半径
void SetRadius(const Vec2& radius); void SetRadius(const Vec2& radius);
/// \~chinese /// \~chinese
/// @brief 设置圆角矩形大小 /// @brief 设置圆角矩形大小
/// @param size 圆角矩形大小 /// @param size 圆角矩形大小
void SetRectSize(const Size& size); void SetRectSize(const Size& size);
/// \~chinese /// \~chinese
/// @brief 设置圆角矩形 /// @brief 设置圆角矩形
/// @param size 圆角矩形大小 /// @param size 圆角矩形大小
/// @param radius 圆角半径 /// @param radius 圆角半径
void SetRoundedRect(const Size& size, const Vec2& radius); void SetRoundedRect(const Size& size, const Vec2& radius);
private: private:
@ -258,13 +258,13 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 圆形角色 /// @brief 圆形角色
class KGE_API CircleActor : public ShapeActor class KGE_API CircleActor : public ShapeActor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建圆形角色 /// @brief 创建圆形角色
/// @param radius 圆形半径 /// @param radius 圆形半径
static CircleActorPtr Create(float radius); static CircleActorPtr Create(float radius);
CircleActor(); CircleActor();
@ -272,12 +272,12 @@ public:
virtual ~CircleActor(); virtual ~CircleActor();
/// \~chinese /// \~chinese
/// @brief 获取圆形半径 /// @brief 获取圆形半径
float GetRadius() const; float GetRadius() const;
/// \~chinese /// \~chinese
/// @brief 设置圆形半径 /// @brief 设置圆形半径
/// @param radius 圆形半径 /// @param radius 圆形半径
void SetRadius(float radius); void SetRadius(float radius);
private: private:
@ -285,13 +285,13 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 椭圆角色 /// @brief 椭圆角色
class KGE_API EllipseActor : public ShapeActor class KGE_API EllipseActor : public ShapeActor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建椭圆角色 /// @brief 创建椭圆角色
/// @param radius 椭圆半径 /// @param radius 椭圆半径
static EllipseActorPtr Create(const Vec2& radius); static EllipseActorPtr Create(const Vec2& radius);
EllipseActor(); EllipseActor();
@ -299,12 +299,12 @@ public:
virtual ~EllipseActor(); virtual ~EllipseActor();
/// \~chinese /// \~chinese
/// @brief 获取椭圆半径 /// @brief 获取椭圆半径
Vec2 GetRadius() const; Vec2 GetRadius() const;
/// \~chinese /// \~chinese
/// @brief 设置椭圆半径 /// @brief 设置椭圆半径
/// @param radius 椭圆半径 /// @param radius 椭圆半径
void SetRadius(const Vec2& radius); void SetRadius(const Vec2& radius);
private: private:
@ -312,13 +312,13 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 多边形角色 /// @brief 多边形角色
class KGE_API PolygonActor : public ShapeActor class KGE_API PolygonActor : public ShapeActor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建多边形角色 /// @brief 创建多边形角色
/// @param points 多边形端点集合 /// @param points 多边形端点集合
static PolygonActorPtr Create(const Vector<Point>& points); static PolygonActorPtr Create(const Vector<Point>& points);
PolygonActor(); PolygonActor();
@ -326,8 +326,8 @@ public:
virtual ~PolygonActor(); virtual ~PolygonActor();
/// \~chinese /// \~chinese
/// @brief 设置多边形端点 /// @brief 设置多边形端点
/// @param points 多边形端点集合 /// @param points 多边形端点集合
void SetVertices(const Vector<Point>& points); void SetVertices(const Vector<Point>& points);
}; };

View File

@ -33,36 +33,36 @@ KGE_DECLARE_SMART_PTR(Sprite);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Sprite : public Actor class KGE_API Sprite : public Actor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建精灵 /// @brief 创建精灵
/// @param file_path 本地图片路径 /// @param file_path 本地图片路径
static SpritePtr Create(const String& file_path); static SpritePtr Create(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 创建精灵 /// @brief 创建精灵
/// @param res 图片资源 /// @param res 图片资源
static SpritePtr Create(const Resource& res); static SpritePtr Create(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 创建精灵 /// @brief 创建精灵
/// @param frame 图像帧 /// @param frame 图像帧
static SpritePtr Create(FramePtr frame); static SpritePtr Create(FramePtr frame);
/// \~chinese /// \~chinese
/// @brief 创建精灵 /// @brief 创建精灵
/// @param file_path 本地图片路径 /// @param file_path 本地图片路径
/// @param crop_rect 裁剪矩形 /// @param crop_rect 裁剪矩形
static SpritePtr Create(const String& file_path, const Rect& crop_rect); static SpritePtr Create(const String& file_path, const Rect& crop_rect);
/// \~chinese /// \~chinese
/// @brief 创建精灵 /// @brief 创建精灵
/// @param res 图片资源 /// @param res 图片资源
/// @param crop_rect 裁剪矩形 /// @param crop_rect 裁剪矩形
static SpritePtr Create(const Resource& res, const Rect& crop_rect); static SpritePtr Create(const Resource& res, const Rect& crop_rect);
Sprite(); Sprite();
@ -70,46 +70,46 @@ public:
virtual ~Sprite(); virtual ~Sprite();
/// \~chinese /// \~chinese
/// @brief 加载本地图片 /// @brief 加载本地图片
/// @param file_path 本地图片路径 /// @param file_path 本地图片路径
/// @param autoresize 是否自动调整自身大小为图像大小 /// @param autoresize 是否自动调整自身大小为图像大小
bool Load(const String& file_path, bool autoresize = true); bool Load(const String& file_path, bool autoresize = true);
/// \~chinese /// \~chinese
/// @brief 加载图像资源 /// @brief 加载图像资源
/// @param res 图片资源 /// @param res 图片资源
/// @param autoresize 是否自动调整自身大小为图像大小 /// @param autoresize 是否自动调整自身大小为图像大小
bool Load(const Resource& res, bool autoresize = true); bool Load(const Resource& res, bool autoresize = true);
/// \~chinese /// \~chinese
/// @brief 获取图像原宽度 /// @brief 获取图像原宽度
float GetSourceWidth() const; float GetSourceWidth() const;
/// \~chinese /// \~chinese
/// @brief 获取图像原高度 /// @brief 获取图像原高度
float GetSourceHeight() const; float GetSourceHeight() const;
/// \~chinese /// \~chinese
/// @brief 获取图像原大小 /// @brief 获取图像原大小
Size GetSourceSize() const; Size GetSourceSize() const;
/// \~chinese /// \~chinese
/// @brief 获取裁剪矩形 /// @brief 获取裁剪矩形
Rect GetCropRect() const; Rect GetCropRect() const;
/// \~chinese /// \~chinese
/// @brief 使用矩形区域裁剪精灵 /// @brief 使用矩形区域裁剪精灵
/// @param crop_rect 裁剪矩形 /// @param crop_rect 裁剪矩形
void SetCropRect(const Rect& crop_rect); void SetCropRect(const Rect& crop_rect);
/// \~chinese /// \~chinese
/// @brief 获取帧图像 /// @brief 获取帧图像
FramePtr GetFrame() const; FramePtr GetFrame() const;
/// \~chinese /// \~chinese
/// @brief 设置图像帧 /// @brief 设置图像帧
/// @param[in] frame 图像帧 /// @param[in] frame 图像帧
/// @param autoresize 是否自动调整自身大小为图像大小 /// @param autoresize 是否自动调整自身大小为图像大小
void SetFrame(FramePtr frame, bool autoresize = true); void SetFrame(FramePtr frame, bool autoresize = true);
void OnRender(RenderContext& ctx) override; void OnRender(RenderContext& ctx) override;

View File

@ -33,8 +33,8 @@ KGE_DECLARE_SMART_PTR(Stage);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
* @see kiwano::Actor kiwano::Director * @see kiwano::Actor kiwano::Director
*/ */
class KGE_API Stage : public Actor class KGE_API Stage : public Actor
@ -44,7 +44,7 @@ class KGE_API Stage : public Actor
public: public:
/// \~chinese /// \~chinese
/// @brief 进入舞台时 /// @brief 进入舞台时
static StagePtr Create(); static StagePtr Create();
Stage(); Stage();
@ -52,34 +52,34 @@ public:
virtual ~Stage(); virtual ~Stage();
/// \~chinese /// \~chinese
/// @brief 进入舞台时 /// @brief 进入舞台时
/// @details 重载该函数以处理进入舞台前的行为 /// @details 重载该函数以处理进入舞台前的行为
virtual void OnEnter(); virtual void OnEnter();
/// \~chinese /// \~chinese
/// @brief 退出舞台时 /// @brief 退出舞台时
/// @details 重载该函数以处理退出舞台前的行为 /// @details 重载该函数以处理退出舞台前的行为
virtual void OnExit(); virtual void OnExit();
/// \~chinese /// \~chinese
/// @brief 获取角色边界填充画刷 /// @brief 获取角色边界填充画刷
BrushPtr GetBorderFillBrush() const; BrushPtr GetBorderFillBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取角色边界轮廓画刷 /// @brief 获取角色边界轮廓画刷
BrushPtr GetBorderStrokeBrush() const; BrushPtr GetBorderStrokeBrush() const;
/// \~chinese /// \~chinese
/// @brief 设置角色边界填充画刷 /// @brief 设置角色边界填充画刷
void SetBorderFillBrush(BrushPtr brush); void SetBorderFillBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置角色边界轮廓画刷 /// @brief 设置角色边界轮廓画刷
void SetBorderStrokeBrush(BrushPtr brush); void SetBorderStrokeBrush(BrushPtr brush);
protected: protected:
/// \~chinese /// \~chinese
/// @brief 绘制所有子角色的边界 /// @brief 绘制所有子角色的边界
void RenderBorder(RenderContext& ctx) override; void RenderBorder(RenderContext& ctx) override;
private: private:

View File

@ -34,20 +34,20 @@ KGE_DECLARE_SMART_PTR(TextActor);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API TextActor : public Actor class KGE_API TextActor : public Actor
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建文本角色 /// @brief 创建文本角色
/// @param text 文字内容 /// @param text 文字内容
static TextActorPtr Create(const String& text); static TextActorPtr Create(const String& text);
/// \~chinese /// \~chinese
/// @brief 创建文本角色 /// @brief 创建文本角色
/// @param text 文字内容 /// @param text 文字内容
/// @param style 文本样式 /// @param style 文本样式
static TextActorPtr Create(const String& text, const TextStyle& style); static TextActorPtr Create(const String& text, const TextStyle& style);
TextActor(); TextActor();
@ -55,117 +55,117 @@ public:
virtual ~TextActor(); virtual ~TextActor();
/// \~chinese /// \~chinese
/// @brief 获取文本 /// @brief 获取文本
String GetText() const; String GetText() const;
/// \~chinese /// \~chinese
/// @brief 获取文本样式 /// @brief 获取文本样式
TextStyle GetStyle() const; TextStyle GetStyle() const;
/// \~chinese /// \~chinese
/// @brief 获取文本布局 /// @brief 获取文本布局
TextLayoutPtr GetLayout() const; TextLayoutPtr GetLayout() const;
/// \~chinese /// \~chinese
/// @brief 获取大小 /// @brief 获取大小
Size GetSize() const override; Size GetSize() const override;
/// \~chinese /// \~chinese
/// @brief 获取填充画刷 /// @brief 获取填充画刷
BrushPtr GetFillBrush() const; BrushPtr GetFillBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取描边画刷 /// @brief 获取描边画刷
BrushPtr GetOutlineBrush() const; BrushPtr GetOutlineBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取描边线条样式 /// @brief 获取描边线条样式
StrokeStylePtr GetOutlineStrokeStyle() const; StrokeStylePtr GetOutlineStrokeStyle() const;
/// \~chinese /// \~chinese
/// @brief 获取字体 /// @brief 获取字体
FontPtr GetFont() const; FontPtr GetFont() const;
/// \~chinese /// \~chinese
/// @brief 设置文本 /// @brief 设置文本
void SetText(const String& text); void SetText(const String& text);
/// \~chinese /// \~chinese
/// @brief 设置文本样式 /// @brief 设置文本样式
void SetStyle(const TextStyle& style); void SetStyle(const TextStyle& style);
/// \~chinese /// \~chinese
/// @brief 设置字体 /// @brief 设置字体
void SetFont(FontPtr font); void SetFont(FontPtr font);
/// \~chinese /// \~chinese
/// @brief 设置字体族 /// @brief 设置字体族
void SetFontFamily(const String& family); void SetFontFamily(const String& family);
/// \~chinese /// \~chinese
/// @brief 设置字号(默认值为 18 /// @brief 设置字号(默认值为 18
void SetFontSize(float size); void SetFontSize(float size);
/// \~chinese /// \~chinese
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal /// @brief 设置字体粗细值(默认值为 FontWeight::Normal
void SetFontWeight(uint32_t weight); void SetFontWeight(uint32_t weight);
/// \~chinese /// \~chinese
/// @brief 设置文字填充画刷 /// @brief 设置文字填充画刷
void SetFillBrush(BrushPtr brush); void SetFillBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置文字填充颜色(默认值为 Color::White /// @brief 设置文字填充颜色(默认值为 Color::White
void SetFillColor(const Color& color); void SetFillColor(const Color& color);
/// \~chinese /// \~chinese
/// @brief 设置文字斜体(默认值为 false /// @brief 设置文字斜体(默认值为 false
void SetItalic(bool italic); void SetItalic(bool italic);
/// \~chinese /// \~chinese
/// @brief 设置文本自动换行的宽度(默认为 0 /// @brief 设置文本自动换行的宽度(默认为 0
void SetWrapWidth(float wrap_width); void SetWrapWidth(float wrap_width);
/// \~chinese /// \~chinese
/// @brief 设置行间距(默认为 0 /// @brief 设置行间距(默认为 0
void SetLineSpacing(float line_spacing); void SetLineSpacing(float line_spacing);
/// \~chinese /// \~chinese
/// @brief 设置对齐方式(默认为 TextAlign::Left /// @brief 设置对齐方式(默认为 TextAlign::Left
void SetAlignment(TextAlign align); void SetAlignment(TextAlign align);
/// \~chinese /// \~chinese
/// @brief 设置文字描边画刷 /// @brief 设置文字描边画刷
void SetOutlineBrush(BrushPtr brush); void SetOutlineBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置文字描边颜色 /// @brief 设置文字描边颜色
void SetOutlineColor(const Color& outline_color); void SetOutlineColor(const Color& outline_color);
/// \~chinese /// \~chinese
/// @brief 设置描边线条样式 /// @brief 设置描边线条样式
void SetOutlineStrokeStyle(StrokeStylePtr stroke); void SetOutlineStrokeStyle(StrokeStylePtr stroke);
/// \~chinese /// \~chinese
/// @brief 设置是否显示下划线(默认值为 false /// @brief 设置是否显示下划线(默认值为 false
void SetUnderline(bool enable); void SetUnderline(bool enable);
/// \~chinese /// \~chinese
/// @brief 设置是否显示删除线(默认值为 false /// @brief 设置是否显示删除线(默认值为 false
void SetStrikethrough(bool enable); void SetStrikethrough(bool enable);
/// \~chinese /// \~chinese
/// @brief 设置文本布局 /// @brief 设置文本布局
void SetTextLayout(TextLayoutPtr layout); void SetTextLayout(TextLayoutPtr layout);
/// \~chinese /// \~chinese
/// @brief 更新脏文字布局 /// @brief 更新脏文字布局
/// @details 仅当文字布局脏时更新 /// @details 仅当文字布局脏时更新
void UpdateDirtyLayout(); void UpdateDirtyLayout();
/// \~chinese /// \~chinese
/// @brief 强制更新文字布局 /// @brief 强制更新文字布局
/// @details 文字布局是懒更新的,手动更新文字布局以更新节点状态 /// @details 文字布局是懒更新的,手动更新文字布局以更新节点状态
void ForceUpdateLayout(); void ForceUpdateLayout();
void OnRender(RenderContext& ctx) override; void OnRender(RenderContext& ctx) override;

View File

@ -36,7 +36,7 @@ KGE_DECLARE_SMART_PTR(RotationTransition);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Transition : public ObjectBase class KGE_API Transition : public ObjectBase
{ {
@ -49,48 +49,48 @@ public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
void SetDuration(Duration dt); void SetDuration(Duration dt);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
bool IsDone(); bool IsDone();
protected: protected:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param[in] prev * @param[in] prev
* @param[in] next * @param[in] next
*/ */
virtual void Init(StagePtr prev, StagePtr next); virtual void Init(StagePtr prev, StagePtr next);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param dt * @param dt
*/ */
virtual void Update(Duration dt); virtual void Update(Duration dt);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param[in] ctx * @param[in] ctx
*/ */
virtual void Render(RenderContext& ctx); virtual void Render(RenderContext& ctx);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
virtual void Stop(); virtual void Stop();
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
virtual void Reset() {} virtual void Reset() {}
@ -108,16 +108,16 @@ protected:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
*/ */
class FadeTransition : public Transition class FadeTransition : public Transition
{ {
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param duration * @param duration
*/ */
static FadeTransitionPtr Create(Duration duration); static FadeTransitionPtr Create(Duration duration);
@ -131,16 +131,16 @@ protected:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
*/ */
class EmergeTransition : public Transition class EmergeTransition : public Transition
{ {
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param duration * @param duration
*/ */
static EmergeTransitionPtr Create(Duration duration); static EmergeTransitionPtr Create(Duration duration);
@ -154,16 +154,16 @@ protected:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
*/ */
class BoxTransition : public Transition class BoxTransition : public Transition
{ {
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param duration * @param duration
*/ */
static BoxTransitionPtr Create(Duration duration); static BoxTransitionPtr Create(Duration duration);
@ -177,29 +177,29 @@ protected:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
*/ */
class MoveTransition : public Transition class MoveTransition : public Transition
{ {
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
enum class Type : int enum class Type : int
{ {
Up, ///< 上移 Up, ///< 上移
Down, ///< 下移 Down, ///< 下移
Left, ///< 左移 Left, ///< 左移
Right ///< 右移 Right ///< 右移
}; };
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param duration * @param duration
* @param type * @param type
*/ */
static MoveTransitionPtr Create(Duration duration, Type type); static MoveTransitionPtr Create(Duration duration, Type type);
@ -220,17 +220,17 @@ private:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
*/ */
class RotationTransition : public Transition class RotationTransition : public Transition
{ {
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param duration * @param duration
* @param rotation * @param rotation
*/ */
static RotationTransitionPtr Create(Duration duration, float rotation = 360.0f); static RotationTransitionPtr Create(Duration duration, float rotation = 360.0f);

View File

@ -34,12 +34,12 @@ class ActionManager;
KGE_DECLARE_SMART_PTR(Action); KGE_DECLARE_SMART_PTR(Action);
/// \~chinese /// \~chinese
/// @brief 动画列表 /// @brief 动画列表
typedef IntrusiveList<ActionPtr> ActionList; typedef IntrusiveList<ActionPtr> ActionList;
/** /**
* \~chinese * \~chinese
* \defgroup Actions * \defgroup Actions
*/ */
/** /**
@ -48,7 +48,7 @@ typedef IntrusiveList<ActionPtr> ActionList;
*/ */
/// \~chinese /// \~chinese
/// @brief 动画 /// @brief 动画
class KGE_API Action class KGE_API Action
: public ObjectBase : public ObjectBase
, protected IntrusiveListValue<ActionPtr> , protected IntrusiveListValue<ActionPtr>
@ -59,7 +59,7 @@ class KGE_API Action
public: public:
/// \~chinese /// \~chinese
/// @brief 动画结束时的回调函数 /// @brief 动画结束时的回调函数
using DoneCallback = Function<void(Actor* /* target */)>; using DoneCallback = Function<void(Actor* /* target */)>;
Action(); Action();
@ -67,120 +67,120 @@ public:
virtual ~Action(); virtual ~Action();
/// \~chinese /// \~chinese
/// @brief 继续动画 /// @brief 继续动画
void Resume(); void Resume();
/// \~chinese /// \~chinese
/// @brief 暂停动画 /// @brief 暂停动画
void Pause(); void Pause();
/// \~chinese /// \~chinese
/// @brief 停止动画 /// @brief 停止动画
void Stop(); void Stop();
/// \~chinese /// \~chinese
/// @brief 设置动画延时 /// @brief 设置动画延时
void SetDelay(Duration delay); void SetDelay(Duration delay);
/// \~chinese /// \~chinese
/// @brief 设置循环次数 /// @brief 设置循环次数
/// @param loops 循环次数,-1 为永久循环 /// @param loops 循环次数,-1 为永久循环
void SetLoops(int loops); void SetLoops(int loops);
/// \~chinese /// \~chinese
/// @brief 动画结束时移除目标角色 /// @brief 动画结束时移除目标角色
void RemoveTargetWhenDone(); void RemoveTargetWhenDone();
/// \~chinese /// \~chinese
/// @brief 设置动画结束时的回调函数 /// @brief 设置动画结束时的回调函数
void SetDoneCallback(const DoneCallback& cb); void SetDoneCallback(const DoneCallback& cb);
/// \~chinese /// \~chinese
/// @brief 设置动画循环结束时的回调函数 /// @brief 设置动画循环结束时的回调函数
void SetLoopDoneCallback(const DoneCallback& cb); void SetLoopDoneCallback(const DoneCallback& cb);
/// \~chinese /// \~chinese
/// @brief 获取动画的拷贝 /// @brief 获取动画的拷贝
virtual ActionPtr Clone() const = 0; virtual ActionPtr Clone() const = 0;
/// \~chinese /// \~chinese
/// @brief 获取动画的倒转 /// @brief 获取动画的倒转
virtual ActionPtr Reverse() const = 0; virtual ActionPtr Reverse() const = 0;
/// \~chinese /// \~chinese
/// @brief 获取动画的运行状态 /// @brief 获取动画的运行状态
bool IsRunning() const; bool IsRunning() const;
/// \~chinese /// \~chinese
/// @brief 获取动画的循环次数 /// @brief 获取动画的循环次数
int GetLoops() const; int GetLoops() const;
/// \~chinese /// \~chinese
/// @brief 获取动画的延时 /// @brief 获取动画的延时
Duration GetDelay() const; Duration GetDelay() const;
/// \~chinese /// \~chinese
/// @brief 获取动画结束时的回调函数 /// @brief 获取动画结束时的回调函数
DoneCallback GetDoneCallback() const; DoneCallback GetDoneCallback() const;
/// \~chinese /// \~chinese
/// @brief 获取动画循环结束时的回调函数 /// @brief 获取动画循环结束时的回调函数
DoneCallback GetLoopDoneCallback() const; DoneCallback GetLoopDoneCallback() const;
protected: protected:
/// \~chinese /// \~chinese
/// @brief 初始化动画 /// @brief 初始化动画
virtual void Init(Actor* target); virtual void Init(Actor* target);
/// \~chinese /// \~chinese
/// @brief 更新动画 /// @brief 更新动画
virtual void Update(Actor* target, Duration dt); virtual void Update(Actor* target, Duration dt);
/// \~chinese /// \~chinese
/// @brief 更新一个时间步 /// @brief 更新一个时间步
void UpdateStep(Actor* target, Duration dt); void UpdateStep(Actor* target, Duration dt);
/// \~chinese /// \~chinese
/// @brief 完成动画 /// @brief 完成动画
void Complete(Actor* target); void Complete(Actor* target);
/// \~chinese /// \~chinese
/// @brief 重新开始动画 /// @brief 重新开始动画
void Restart(Actor* target); void Restart(Actor* target);
/// \~chinese /// \~chinese
/// @brief 动画状态 /// @brief 动画状态
enum class Status enum class Status
{ {
NotStarted, ///< 未开始 NotStarted, ///< 未开始
Delayed, ///< 等待延时 Delayed, ///< 等待延时
Started, ///< 已开始 Started, ///< 已开始
Done, ///< 已结束 Done, ///< 已结束
Removeable ///< 可移除 Removeable ///< 可移除
}; };
/// \~chinese /// \~chinese
/// @brief 获取动画状态 /// @brief 获取动画状态
Status GetStatus() const; Status GetStatus() const;
/// \~chinese /// \~chinese
/// @brief 获取消逝时间 /// @brief 获取消逝时间
Duration GetElapsed() const; Duration GetElapsed() const;
/// \~chinese /// \~chinese
/// @brief 获取完成的循环次数 /// @brief 获取完成的循环次数
int GetLoopsDone() const; int GetLoopsDone() const;
/// \~chinese /// \~chinese
/// @brief 结束动画 /// @brief 结束动画
void Done(); void Done();
/// \~chinese /// \~chinese
/// @brief 是否已结束 /// @brief 是否已结束
bool IsDone() const; bool IsDone() const;
/// \~chinese /// \~chinese
/// @brief 是否可移除 /// @brief 是否可移除
bool IsRemoveable() const; bool IsRemoveable() const;
protected: protected:

View File

@ -32,21 +32,21 @@ KGE_DECLARE_SMART_PTR(ActionDelay);
*/ */
/// \~chinese /// \~chinese
/// @brief 延时动画 /// @brief 延时动画
class KGE_API ActionDelay : public Action class KGE_API ActionDelay : public Action
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建延时动画 /// @brief 创建延时动画
/// @param delay 延时时长 /// @param delay 延时时长
static ActionDelayPtr Create(Duration delay); static ActionDelayPtr Create(Duration delay);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
}; };

View File

@ -31,16 +31,16 @@ KGE_DECLARE_SMART_PTR(ActionGroup);
*/ */
/// \~chinese /// \~chinese
/// @brief 动画组合 /// @brief 动画组合
class KGE_API ActionGroup : public Action class KGE_API ActionGroup : public Action
{ {
public: public:
using ActionList = IntrusiveList<ActionPtr>; using ActionList = IntrusiveList<ActionPtr>;
/// \~chinese /// \~chinese
/// @brief 创建动画组合 /// @brief 创建动画组合
/// @param actions 动画集合 /// @param actions 动画集合
/// @param sync 同步执行 /// @param sync 同步执行
static ActionGroupPtr Create(const Vector<ActionPtr>& actions, bool sync = false); static ActionGroupPtr Create(const Vector<ActionPtr>& actions, bool sync = false);
ActionGroup(); ActionGroup();
@ -50,25 +50,25 @@ public:
virtual ~ActionGroup(); virtual ~ActionGroup();
/// \~chinese /// \~chinese
/// @brief 添加动画 /// @brief 添加动画
/// @param action 动画 /// @param action 动画
void AddAction(ActionPtr action); void AddAction(ActionPtr action);
/// \~chinese /// \~chinese
/// @brief 添加多个动画 /// @brief 添加多个动画
/// @param actions 动画集合 /// @param actions 动画集合
void AddActions(const Vector<ActionPtr>& actions); void AddActions(const Vector<ActionPtr>& actions);
/// \~chinese /// \~chinese
/// @brief 获取所有动画 /// @brief 获取所有动画
const ActionList& GetActions() const; const ActionList& GetActions() const;
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:

View File

@ -33,13 +33,13 @@ namespace kiwano
*/ */
/// \~chinese /// \~chinese
/// @brief 动画辅助类 /// @brief 动画辅助类
struct ActionHelper struct ActionHelper
{ {
using DoneCallback = Action::DoneCallback; using DoneCallback = Action::DoneCallback;
/// \~chinese /// \~chinese
/// @brief 设置循环次数 /// @brief 设置循环次数
inline ActionHelper& SetLoops(int loops) inline ActionHelper& SetLoops(int loops)
{ {
ptr->SetLoops(loops); ptr->SetLoops(loops);
@ -47,7 +47,7 @@ struct ActionHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置动画延迟 /// @brief 设置动画延迟
inline ActionHelper& SetDelay(Duration delay) inline ActionHelper& SetDelay(Duration delay)
{ {
ptr->SetDelay(delay); ptr->SetDelay(delay);
@ -55,7 +55,7 @@ struct ActionHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置动画结束回调函数 /// @brief 设置动画结束回调函数
inline ActionHelper& SetDoneCallback(const DoneCallback& cb) inline ActionHelper& SetDoneCallback(const DoneCallback& cb)
{ {
ptr->SetDoneCallback(cb); ptr->SetDoneCallback(cb);
@ -63,7 +63,7 @@ struct ActionHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置动画循环结束时的回调函数 /// @brief 设置动画循环结束时的回调函数
inline ActionHelper& SetLoopDoneCallback(const DoneCallback& cb) inline ActionHelper& SetLoopDoneCallback(const DoneCallback& cb)
{ {
ptr->SetLoopDoneCallback(cb); ptr->SetLoopDoneCallback(cb);
@ -71,7 +71,7 @@ struct ActionHelper
} }
/// \~chinese /// \~chinese
/// @brief 动画结束时移除目标角色 /// @brief 动画结束时移除目标角色
inline ActionHelper& RemoveTargetWhenDone() inline ActionHelper& RemoveTargetWhenDone()
{ {
ptr->RemoveTargetWhenDone(); ptr->RemoveTargetWhenDone();
@ -79,7 +79,7 @@ struct ActionHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置名称 /// @brief 设置名称
inline ActionHelper& SetName(const String& name) inline ActionHelper& SetName(const String& name)
{ {
ptr->SetName(name); ptr->SetName(name);
@ -87,7 +87,7 @@ struct ActionHelper
} }
/// \~chinese /// \~chinese
/// @brief 获取指针 /// @brief 获取指针
inline ActionPtr Get() const inline ActionPtr Get() const
{ {
return ptr; return ptr;
@ -113,13 +113,13 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 补间动画辅助类 /// @brief 补间动画辅助类
struct TweenHelper struct TweenHelper
{ {
using DoneCallback = Action::DoneCallback; using DoneCallback = Action::DoneCallback;
/// \~chinese /// \~chinese
/// @brief 设置动画持续时长 /// @brief 设置动画持续时长
inline TweenHelper& SetDuration(Duration dur) inline TweenHelper& SetDuration(Duration dur)
{ {
ptr->SetDuration(dur); ptr->SetDuration(dur);
@ -127,7 +127,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置循环次数 /// @brief 设置循环次数
inline TweenHelper& SetLoops(int loops) inline TweenHelper& SetLoops(int loops)
{ {
ptr->SetLoops(loops); ptr->SetLoops(loops);
@ -135,7 +135,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置缓动函数 /// @brief 设置缓动函数
inline TweenHelper& SetEaseFunc(EaseFunc ease) inline TweenHelper& SetEaseFunc(EaseFunc ease)
{ {
ptr->SetEaseFunc(ease); ptr->SetEaseFunc(ease);
@ -143,7 +143,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置动画延迟 /// @brief 设置动画延迟
inline TweenHelper& SetDelay(Duration delay) inline TweenHelper& SetDelay(Duration delay)
{ {
ptr->SetDelay(delay); ptr->SetDelay(delay);
@ -151,7 +151,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置动画结束回调函数 /// @brief 设置动画结束回调函数
inline TweenHelper& SetDoneCallback(const DoneCallback& cb) inline TweenHelper& SetDoneCallback(const DoneCallback& cb)
{ {
ptr->SetDoneCallback(cb); ptr->SetDoneCallback(cb);
@ -159,7 +159,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置动画循环结束时的回调函数 /// @brief 设置动画循环结束时的回调函数
inline TweenHelper& SetLoopDoneCallback(const DoneCallback& cb) inline TweenHelper& SetLoopDoneCallback(const DoneCallback& cb)
{ {
ptr->SetLoopDoneCallback(cb); ptr->SetLoopDoneCallback(cb);
@ -167,7 +167,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 动画结束时移除目标角色 /// @brief 动画结束时移除目标角色
inline TweenHelper& RemoveTargetWhenDone() inline TweenHelper& RemoveTargetWhenDone()
{ {
ptr->RemoveTargetWhenDone(); ptr->RemoveTargetWhenDone();
@ -175,7 +175,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 设置名称 /// @brief 设置名称
inline TweenHelper& SetName(const String& name) inline TweenHelper& SetName(const String& name)
{ {
ptr->SetName(name); ptr->SetName(name);
@ -183,7 +183,7 @@ struct TweenHelper
} }
/// \~chinese /// \~chinese
/// @brief 获取指针 /// @brief 获取指针
inline ActionTweenPtr Get() const inline ActionTweenPtr Get() const
{ {
return ptr; return ptr;
@ -214,120 +214,120 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 动画构造器 /// @brief 动画构造器
struct Tween struct Tween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 构造相对位移动画 /// @brief 构造相对位移动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param vector 移动向量 /// @param vector 移动向量
static inline TweenHelper MoveBy(Duration dur, const Point& vector) static inline TweenHelper MoveBy(Duration dur, const Point& vector)
{ {
return TweenHelper(ActionMoveBy::Create(dur, vector)); return TweenHelper(ActionMoveBy::Create(dur, vector));
} }
/// \~chinese /// \~chinese
/// @brief 构造位移动画 /// @brief 构造位移动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param pos 目的坐标 /// @param pos 目的坐标
static inline TweenHelper MoveTo(Duration dur, const Point& pos) static inline TweenHelper MoveTo(Duration dur, const Point& pos)
{ {
return TweenHelper(ActionMoveTo::Create(dur, pos)); return TweenHelper(ActionMoveTo::Create(dur, pos));
} }
/// \~chinese /// \~chinese
/// @brief 构造相对跳跃动画 /// @brief 构造相对跳跃动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param vec 跳跃位移向量 /// @param vec 跳跃位移向量
/// @param height 跳跃高度 /// @param height 跳跃高度
/// @param jumps 跳跃次数 /// @param jumps 跳跃次数
static inline TweenHelper JumpBy(Duration duration, const Vec2& vec, float height, int jumps = 1) static inline TweenHelper JumpBy(Duration duration, const Vec2& vec, float height, int jumps = 1)
{ {
return TweenHelper(ActionJumpBy::Create(duration, vec, height, jumps)); return TweenHelper(ActionJumpBy::Create(duration, vec, height, jumps));
} }
/// \~chinese /// \~chinese
/// @brief 构造跳跃动画 /// @brief 构造跳跃动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param pos 目的坐标 /// @param pos 目的坐标
/// @param height 跳跃高度 /// @param height 跳跃高度
/// @param jumps 跳跃次数 /// @param jumps 跳跃次数
static inline TweenHelper JumpTo(Duration duration, const Point& pos, float height, int jumps = 1) static inline TweenHelper JumpTo(Duration duration, const Point& pos, float height, int jumps = 1)
{ {
return TweenHelper(ActionJumpTo::Create(duration, pos, height, jumps)); return TweenHelper(ActionJumpTo::Create(duration, pos, height, jumps));
} }
/// \~chinese /// \~chinese
/// @brief 构造相对缩放动画 /// @brief 构造相对缩放动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值 /// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值 /// @param scale_y 纵向缩放相对变化值
static inline TweenHelper ScaleBy(Duration dur, float scale_x, float scale_y) static inline TweenHelper ScaleBy(Duration dur, float scale_x, float scale_y)
{ {
return TweenHelper(ActionScaleBy::Create(dur, scale_x, scale_y)); return TweenHelper(ActionScaleBy::Create(dur, scale_x, scale_y));
} }
/// \~chinese /// \~chinese
/// @brief 构造缩放动画 /// @brief 构造缩放动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param scale_x 横向缩放目标值 /// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值 /// @param scale_y 纵向缩放目标值
static inline TweenHelper ScaleTo(Duration dur, float scale_x, float scale_y) static inline TweenHelper ScaleTo(Duration dur, float scale_x, float scale_y)
{ {
return TweenHelper(ActionScaleTo::Create(dur, scale_x, scale_y)); return TweenHelper(ActionScaleTo::Create(dur, scale_x, scale_y));
} }
/// \~chinese /// \~chinese
/// @brief 构造透明度渐变动画 /// @brief 构造透明度渐变动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param opacity 目标透明度 /// @param opacity 目标透明度
static inline TweenHelper FadeTo(Duration dur, float opacity) static inline TweenHelper FadeTo(Duration dur, float opacity)
{ {
return TweenHelper(ActionFadeTo::Create(dur, opacity)); return TweenHelper(ActionFadeTo::Create(dur, opacity));
} }
/// \~chinese /// \~chinese
/// @brief 构造淡入动画 /// @brief 构造淡入动画
/// @param duration 动画时长 /// @param duration 动画时长
static inline TweenHelper FadeIn(Duration dur) static inline TweenHelper FadeIn(Duration dur)
{ {
return TweenHelper(ActionFadeIn::Create(dur)); return TweenHelper(ActionFadeIn::Create(dur));
} }
/// \~chinese /// \~chinese
/// @brief 构造淡出动画 /// @brief 构造淡出动画
/// @param duration 动画时长 /// @param duration 动画时长
static inline TweenHelper FadeOut(Duration dur) static inline TweenHelper FadeOut(Duration dur)
{ {
return TweenHelper(ActionFadeOut::Create(dur)); return TweenHelper(ActionFadeOut::Create(dur));
} }
/// \~chinese /// \~chinese
/// @brief 构造相对旋转动画 /// @brief 构造相对旋转动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param rotation 角度相对变化值 /// @param rotation 角度相对变化值
static inline TweenHelper RotateBy(Duration dur, float rotation) static inline TweenHelper RotateBy(Duration dur, float rotation)
{ {
return TweenHelper(ActionRotateBy::Create(dur, rotation)); return TweenHelper(ActionRotateBy::Create(dur, rotation));
} }
/// \~chinese /// \~chinese
/// @brief 构造旋转动画 /// @brief 构造旋转动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param rotation 目标角度 /// @param rotation 目标角度
static inline TweenHelper RotateTo(Duration dur, float rotation) static inline TweenHelper RotateTo(Duration dur, float rotation)
{ {
return TweenHelper(ActionRotateTo::Create(dur, rotation)); return TweenHelper(ActionRotateTo::Create(dur, rotation));
} }
/// \~chinese /// \~chinese
/// @brief 构造路径行走动画 /// @brief 构造路径行走动画
/// @param duration 持续时长 /// @param duration 持续时长
/// @param path 路径形状 /// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转 /// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比) /// @param start 路径起点(百分比)
/// @param end 路径终点(百分比) /// @param end 路径终点(百分比)
static inline TweenHelper Walk(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f, static inline TweenHelper Walk(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f,
float end = 1.f) float end = 1.f)
{ {
@ -335,35 +335,35 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 构建帧动画 /// @brief 构建帧动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param[in] frame_seq 序列帧 /// @param[in] frame_seq 序列帧
static inline TweenHelper Animation(Duration dur, FrameSequencePtr frames) static inline TweenHelper Animation(Duration dur, FrameSequencePtr frames)
{ {
return TweenHelper(Animation::Create(dur, frames)); return TweenHelper(Animation::Create(dur, frames));
} }
/// \~chinese /// \~chinese
/// @brief 构造自定义动画 /// @brief 构造自定义动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param tween_func 动画回调函数 /// @param tween_func 动画回调函数
static inline TweenHelper Custom(Duration dur, ActionCustom::TweenFunc tween_func) static inline TweenHelper Custom(Duration dur, ActionCustom::TweenFunc tween_func)
{ {
return TweenHelper(ActionCustom::Create(dur, tween_func)); return TweenHelper(ActionCustom::Create(dur, tween_func));
} }
/// \~chinese /// \~chinese
/// @brief 构建延时动画 /// @brief 构建延时动画
/// @param delay 延时时长 /// @param delay 延时时长
static inline ActionHelper Delay(Duration delay) static inline ActionHelper Delay(Duration delay)
{ {
return ActionHelper(ActionDelay::Create(delay)); return ActionHelper(ActionDelay::Create(delay));
} }
/// \~chinese /// \~chinese
/// @brief 动画组合 /// @brief 动画组合
/// @param actions 动画集合 /// @param actions 动画集合
/// @param sync 同步执行 /// @param sync 同步执行
static inline ActionHelper Group(const Vector<ActionPtr>& actions, bool sync = false) static inline ActionHelper Group(const Vector<ActionPtr>& actions, bool sync = false)
{ {
return ActionHelper(ActionGroup::Create(actions, sync)); return ActionHelper(ActionGroup::Create(actions, sync));

View File

@ -30,39 +30,39 @@ namespace kiwano
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API ActionManager class KGE_API ActionManager
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 添加动画 /// @brief 添加动画
Action* AddAction(ActionPtr action); Action* AddAction(ActionPtr action);
/// \~chinese /// \~chinese
/// @brief 继续所有暂停动画 /// @brief 继续所有暂停动画
void ResumeAllActions(); void ResumeAllActions();
/// \~chinese /// \~chinese
/// @brief 暂停所有动画 /// @brief 暂停所有动画
void PauseAllActions(); void PauseAllActions();
/// \~chinese /// \~chinese
/// @brief 停止所有动画 /// @brief 停止所有动画
void StopAllActions(); void StopAllActions();
/// \~chinese /// \~chinese
/// @brief 获取指定名称的动画 /// @brief 获取指定名称的动画
/// @param name 动画名称 /// @param name 动画名称
ActionPtr GetAction(const String& name); ActionPtr GetAction(const String& name);
/// \~chinese /// \~chinese
/// @brief 获取所有动画 /// @brief 获取所有动画
const ActionList& GetAllActions() const; const ActionList& GetAllActions() const;
protected: protected:
/// \~chinese /// \~chinese
/// @brief 更新动画 /// @brief 更新动画
void UpdateActions(Actor* target, Duration dt); void UpdateActions(Actor* target, Duration dt);
private: private:

View File

@ -25,27 +25,27 @@
namespace kiwano namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief 缓动函数 /// @brief 缓动函数
using EaseFunc = Function<float(float)>; using EaseFunc = Function<float(float)>;
/// \~chinese /// \~chinese
/// @brief 缓动函数枚举 /// @brief 缓动函数枚举
/// @details 查看 https://easings.net 获取更多信息 /// @details 查看 https://easings.net 获取更多信息
struct Ease struct Ease
{ {
static KGE_API EaseFunc Linear; ///< 线性 static KGE_API EaseFunc Linear; ///< 线性
static KGE_API EaseFunc EaseIn; ///< 由慢变快 static KGE_API EaseFunc EaseIn; ///< 由慢变快
static KGE_API EaseFunc EaseOut; ///< 由快变慢 static KGE_API EaseFunc EaseOut; ///< 由快变慢
static KGE_API EaseFunc EaseInOut; ///< 由慢变快, 再由快变慢 static KGE_API EaseFunc EaseInOut; ///< 由慢变快, 再由快变慢
static KGE_API EaseFunc ExpoIn; ///< 由慢变极快 static KGE_API EaseFunc ExpoIn; ///< 由慢变极快
static KGE_API EaseFunc ExpoOut; ///< 由极快变慢 static KGE_API EaseFunc ExpoOut; ///< 由极快变慢
static KGE_API EaseFunc ExpoInOut; ///< 由慢至极快, 再由极快边慢 static KGE_API EaseFunc ExpoInOut; ///< 由慢至极快, 再由极快边慢
static KGE_API EaseFunc ElasticIn; ///< 自起点赋予弹性 static KGE_API EaseFunc ElasticIn; ///< 自起点赋予弹性
static KGE_API EaseFunc ElasticOut; ///< 自终点赋予弹性 static KGE_API EaseFunc ElasticOut; ///< 自终点赋予弹性
static KGE_API EaseFunc ElasticInOut; ///< 再起点和终点赋予弹性 static KGE_API EaseFunc ElasticInOut; ///< 再起点和终点赋予弹性
static KGE_API EaseFunc BounceIn; ///< 自起点赋予反弹力 static KGE_API EaseFunc BounceIn; ///< 自起点赋予反弹力
static KGE_API EaseFunc BounceOut; ///< 自终点赋予反弹力 static KGE_API EaseFunc BounceOut; ///< 自终点赋予反弹力
static KGE_API EaseFunc BounceInOut; ///< 在起点和终点赋予反弹力 static KGE_API EaseFunc BounceInOut; ///< 在起点和终点赋予反弹力
static KGE_API EaseFunc BackIn; static KGE_API EaseFunc BackIn;
static KGE_API EaseFunc BackOut; static KGE_API EaseFunc BackOut;
static KGE_API EaseFunc BackInOut; static KGE_API EaseFunc BackInOut;
@ -86,32 +86,32 @@ KGE_DECLARE_SMART_PTR(ActionCustom);
*/ */
/// \~chinese /// \~chinese
/// @brief 补间动画 /// @brief 补间动画
class KGE_API ActionTween : public Action class KGE_API ActionTween : public Action
{ {
public: public:
ActionTween(); ActionTween();
/// \~chinese /// \~chinese
/// @brief 补间动画 /// @brief 补间动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param func 动画速度缓动函数 /// @param func 动画速度缓动函数
ActionTween(Duration duration, EaseFunc ease); ActionTween(Duration duration, EaseFunc ease);
/// \~chinese /// \~chinese
/// @brief 获取动画时长 /// @brief 获取动画时长
Duration GetDuration() const; Duration GetDuration() const;
/// \~chinese /// \~chinese
/// @brief 设置动画时长 /// @brief 设置动画时长
void SetDuration(Duration duration); void SetDuration(Duration duration);
/// \~chinese /// \~chinese
/// @brief 获取动画速度缓动函数 /// @brief 获取动画速度缓动函数
const EaseFunc& GetEaseFunc() const; const EaseFunc& GetEaseFunc() const;
/// \~chinese /// \~chinese
/// @brief 设置动画速度缓动函数 /// @brief 设置动画速度缓动函数
void SetEaseFunc(const EaseFunc& func); void SetEaseFunc(const EaseFunc& func);
protected: protected:
@ -127,32 +127,32 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 相对位移动画 /// @brief 相对位移动画
class KGE_API ActionMoveBy : public ActionTween class KGE_API ActionMoveBy : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建相对位移动画 /// @brief 创建相对位移动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param displacement 位移向量 /// @param displacement 位移向量
static ActionMoveByPtr Create(Duration duration, const Vec2& displacement); static ActionMoveByPtr Create(Duration duration, const Vec2& displacement);
ActionMoveBy(); ActionMoveBy();
/// \~chinese /// \~chinese
/// @brief 获取位移向量 /// @brief 获取位移向量
Vec2 GetDisplacement() const; Vec2 GetDisplacement() const;
/// \~chinese /// \~chinese
/// @brief 设置位移向量 /// @brief 设置位移向量
void SetDisplacement(const Vec2& displacement); void SetDisplacement(const Vec2& displacement);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
@ -167,32 +167,32 @@ protected:
}; };
/// \~chinese /// \~chinese
/// @brief 位移动画 /// @brief 位移动画
class KGE_API ActionMoveTo : public ActionMoveBy class KGE_API ActionMoveTo : public ActionMoveBy
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建位移动画 /// @brief 创建位移动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param distination 目的坐标 /// @param distination 目的坐标
static ActionMoveToPtr Create(Duration duration, const Point& distination); static ActionMoveToPtr Create(Duration duration, const Point& distination);
ActionMoveTo(); ActionMoveTo();
/// \~chinese /// \~chinese
/// @brief 获取目的坐标 /// @brief 获取目的坐标
Point GetDistination() const; Point GetDistination() const;
/// \~chinese /// \~chinese
/// @brief 设置目的坐标 /// @brief 设置目的坐标
void SetDistination(const Point& distination); void SetDistination(const Point& distination);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override virtual ActionPtr Reverse() const override
{ {
KGE_ERROR("Reverse() not supported in ActionMoveTo"); KGE_ERROR("Reverse() not supported in ActionMoveTo");
@ -207,51 +207,51 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 相对跳跃动画 /// @brief 相对跳跃动画
class KGE_API ActionJumpBy : public ActionTween class KGE_API ActionJumpBy : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建相对跳跃动画 /// @brief 创建相对跳跃动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param displacement 跳跃位移向量 /// @param displacement 跳跃位移向量
/// @param height 跳跃高度 /// @param height 跳跃高度
/// @param count 跳跃次数 /// @param count 跳跃次数
static ActionJumpByPtr Create(Duration duration, const Vec2& displacement, float height, int count = 1, static ActionJumpByPtr Create(Duration duration, const Vec2& displacement, float height, int count = 1,
EaseFunc ease = nullptr); EaseFunc ease = nullptr);
ActionJumpBy(); ActionJumpBy();
/// \~chinese /// \~chinese
/// @brief 获取跳跃位移 /// @brief 获取跳跃位移
Vec2 GetDisplacement() const; Vec2 GetDisplacement() const;
/// \~chinese /// \~chinese
/// @brief 获取跳跃高度 /// @brief 获取跳跃高度
float GetJumpHeight() const; float GetJumpHeight() const;
/// \~chinese /// \~chinese
/// @brief 获取跳跃次数 /// @brief 获取跳跃次数
int GetJumpCount() const; int GetJumpCount() const;
/// \~chinese /// \~chinese
/// @brief 设置跳跃位移 /// @brief 设置跳跃位移
void SetDisplacement(const Vec2& displacement); void SetDisplacement(const Vec2& displacement);
/// \~chinese /// \~chinese
/// @brief 设置跳跃高度 /// @brief 设置跳跃高度
void SetJumpHeight(float height); void SetJumpHeight(float height);
/// \~chinese /// \~chinese
/// @brief 设置跳跃次数 /// @brief 设置跳跃次数
void SetJumpCount(int count); void SetJumpCount(int count);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
@ -268,35 +268,35 @@ protected:
}; };
/// \~chinese /// \~chinese
/// @brief 跳跃动画 /// @brief 跳跃动画
class KGE_API ActionJumpTo : public ActionJumpBy class KGE_API ActionJumpTo : public ActionJumpBy
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建跳跃动画 /// @brief 创建跳跃动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param distination 目的坐标 /// @param distination 目的坐标
/// @param height 跳跃高度 /// @param height 跳跃高度
/// @param count 跳跃次数 /// @param count 跳跃次数
static ActionJumpToPtr Create(Duration duration, const Point& distination, float height, int count = 1, static ActionJumpToPtr Create(Duration duration, const Point& distination, float height, int count = 1,
EaseFunc ease = nullptr); EaseFunc ease = nullptr);
ActionJumpTo(); ActionJumpTo();
/// \~chinese /// \~chinese
/// @brief 获取目的坐标 /// @brief 获取目的坐标
Point GetDistination() const; Point GetDistination() const;
/// \~chinese /// \~chinese
/// @brief 设置目的坐标 /// @brief 设置目的坐标
void SetDistination(const Point& distination); void SetDistination(const Point& distination);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override virtual ActionPtr Reverse() const override
{ {
KGE_ERROR("Reverse() not supported in ActionJumpTo"); KGE_ERROR("Reverse() not supported in ActionJumpTo");
@ -311,41 +311,41 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 相对缩放动画 /// @brief 相对缩放动画
class KGE_API ActionScaleBy : public ActionTween class KGE_API ActionScaleBy : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建相对缩放动画 /// @brief 创建相对缩放动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值 /// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值 /// @param scale_y 纵向缩放相对变化值
static ActionScaleByPtr Create(Duration duration, float scale_x, float scale_y); static ActionScaleByPtr Create(Duration duration, float scale_x, float scale_y);
ActionScaleBy(); ActionScaleBy();
/// \~chinese /// \~chinese
/// @brief 获取横向缩放相对变化值 /// @brief 获取横向缩放相对变化值
float GetScaleX() const; float GetScaleX() const;
/// \~chinese /// \~chinese
/// @brief 获取横向缩放相对变化值 /// @brief 获取横向缩放相对变化值
float GetScaleY() const; float GetScaleY() const;
/// \~chinese /// \~chinese
/// @brief 设置纵向缩放相对变化值 /// @brief 设置纵向缩放相对变化值
void SetScaleX(float scale_x); void SetScaleX(float scale_x);
/// \~chinese /// \~chinese
/// @brief 设置纵向缩放相对变化值 /// @brief 设置纵向缩放相对变化值
void SetScaleY(float scale_y); void SetScaleY(float scale_y);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
@ -361,41 +361,41 @@ protected:
}; };
/// \~chinese /// \~chinese
/// @brief 缩放动画 /// @brief 缩放动画
class KGE_API ActionScaleTo : public ActionScaleBy class KGE_API ActionScaleTo : public ActionScaleBy
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建缩放动画 /// @brief 创建缩放动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param scale_x 横向缩放目标值 /// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值 /// @param scale_y 纵向缩放目标值
static ActionScaleToPtr Create(Duration duration, float scale_x, float scale_y); static ActionScaleToPtr Create(Duration duration, float scale_x, float scale_y);
ActionScaleTo(); ActionScaleTo();
/// \~chinese /// \~chinese
/// @brief 获取横向缩放目标值 /// @brief 获取横向缩放目标值
float GetTargetScaleX() const; float GetTargetScaleX() const;
/// \~chinese /// \~chinese
/// @brief 获取横向缩放目标值 /// @brief 获取横向缩放目标值
float GetTargetScaleY() const; float GetTargetScaleY() const;
/// \~chinese /// \~chinese
/// @brief 设置纵向缩放目标值 /// @brief 设置纵向缩放目标值
void SetTargetScaleX(float scale_x); void SetTargetScaleX(float scale_x);
/// \~chinese /// \~chinese
/// @brief 设置纵向缩放目标值 /// @brief 设置纵向缩放目标值
void SetTargetScaleY(float scale_y); void SetTargetScaleY(float scale_y);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override virtual ActionPtr Reverse() const override
{ {
KGE_ERROR("Reverse() not supported in ActionScaleTo"); KGE_ERROR("Reverse() not supported in ActionScaleTo");
@ -411,32 +411,32 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 透明度渐变动画 /// @brief 透明度渐变动画
class KGE_API ActionFadeTo : public ActionTween class KGE_API ActionFadeTo : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建透明度渐变动画 /// @brief 创建透明度渐变动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param opacity 目标透明度 /// @param opacity 目标透明度
static ActionFadeToPtr Create(Duration duration, float opacity); static ActionFadeToPtr Create(Duration duration, float opacity);
ActionFadeTo(); ActionFadeTo();
/// \~chinese /// \~chinese
/// @brief 获取目标透明度 /// @brief 获取目标透明度
float GetTargetOpacity() const; float GetTargetOpacity() const;
/// \~chinese /// \~chinese
/// @brief 设置目标透明度 /// @brief 设置目标透明度
void SetTargetOpacity(float opacity); void SetTargetOpacity(float opacity);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override virtual ActionPtr Reverse() const override
{ {
KGE_ERROR("Reverse() not supported in ActionFadeTo"); KGE_ERROR("Reverse() not supported in ActionFadeTo");
@ -455,54 +455,54 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 淡入动画 /// @brief 淡入动画
class KGE_API ActionFadeIn : public ActionFadeTo class KGE_API ActionFadeIn : public ActionFadeTo
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建淡入动画 /// @brief 创建淡入动画
/// @param duration 动画时长 /// @param duration 动画时长
static ActionFadeInPtr Create(Duration duration); static ActionFadeInPtr Create(Duration duration);
}; };
/// \~chinese /// \~chinese
/// @brief 淡出动画 /// @brief 淡出动画
class KGE_API ActionFadeOut : public ActionFadeTo class KGE_API ActionFadeOut : public ActionFadeTo
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建淡出动画 /// @brief 创建淡出动画
/// @param duration 动画时长 /// @param duration 动画时长
static ActionFadeOutPtr Create(Duration duration); static ActionFadeOutPtr Create(Duration duration);
}; };
/// \~chinese /// \~chinese
/// @brief 相对旋转动画 /// @brief 相对旋转动画
class KGE_API ActionRotateBy : public ActionTween class KGE_API ActionRotateBy : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建相对旋转动画 /// @brief 创建相对旋转动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param rotation 角度相对变化值 /// @param rotation 角度相对变化值
static ActionRotateByPtr Create(Duration duration, float rotation); static ActionRotateByPtr Create(Duration duration, float rotation);
ActionRotateBy(); ActionRotateBy();
/// \~chinese /// \~chinese
/// @brief 获取角度相对变化值 /// @brief 获取角度相对变化值
float GetRotation() const; float GetRotation() const;
/// \~chinese /// \~chinese
/// @brief 设置角度相对变化值 /// @brief 设置角度相对变化值
void SetRotation(float rotation); void SetRotation(float rotation);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
@ -516,32 +516,32 @@ protected:
}; };
/// \~chinese /// \~chinese
/// @brief 旋转动画 /// @brief 旋转动画
class KGE_API ActionRotateTo : public ActionRotateBy class KGE_API ActionRotateTo : public ActionRotateBy
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建旋转动画 /// @brief 创建旋转动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param rotation 目标角度 /// @param rotation 目标角度
static ActionRotateToPtr Create(Duration duration, float rotation); static ActionRotateToPtr Create(Duration duration, float rotation);
ActionRotateTo(); ActionRotateTo();
/// \~chinese /// \~chinese
/// @brief 获取目标角度 /// @brief 获取目标角度
float GetTargetRotation() const; float GetTargetRotation() const;
/// \~chinese /// \~chinese
/// @brief 设置目标角度 /// @brief 设置目标角度
void SetTargetRotation(float rotation); void SetTargetRotation(float rotation);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override virtual ActionPtr Reverse() const override
{ {
KGE_ERROR("Reverse() not supported in ActionRotateTo"); KGE_ERROR("Reverse() not supported in ActionRotateTo");
@ -556,37 +556,37 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 自定义动画 /// @brief 自定义动画
class KGE_API ActionCustom : public ActionTween class KGE_API ActionCustom : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 动画回调函数 /// @brief 动画回调函数
/// @details 在动画更新时回调该函数第一个参数是执行动画的目标第二个参数是动画进度0.0 - 1.0 /// @details 在动画更新时回调该函数第一个参数是执行动画的目标第二个参数是动画进度0.0 - 1.0
using TweenFunc = Function<void(Actor* /* target */, float /* percent */)>; using TweenFunc = Function<void(Actor* /* target */, float /* percent */)>;
/// \~chinese /// \~chinese
/// @brief 创建自定义动画 /// @brief 创建自定义动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param tween_func 动画回调函数 /// @param tween_func 动画回调函数
static ActionCustomPtr Create(Duration duration, TweenFunc tween_func); static ActionCustomPtr Create(Duration duration, TweenFunc tween_func);
ActionCustom(); ActionCustom();
/// \~chinese /// \~chinese
/// @brief 获取动画回调函数 /// @brief 获取动画回调函数
TweenFunc GetTweenFunc() const; TweenFunc GetTweenFunc() const;
/// \~chinese /// \~chinese
/// @brief 设置动画回调函数 /// @brief 设置动画回调函数
void SetTweenFunc(const TweenFunc& tween_func); void SetTweenFunc(const TweenFunc& tween_func);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override ActionPtr Reverse() const override
{ {
KGE_ERROR("Reverse() not supported in ActionCustom"); KGE_ERROR("Reverse() not supported in ActionCustom");

View File

@ -33,60 +33,60 @@ KGE_DECLARE_SMART_PTR(ActionWalk);
*/ */
/// \~chinese /// \~chinese
/// @brief 路径行走动画 /// @brief 路径行走动画
class KGE_API ActionWalk : public ActionTween class KGE_API ActionWalk : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建路径行走动画 /// @brief 创建路径行走动画
/// @param duration 持续时长 /// @param duration 持续时长
/// @param path 路径形状 /// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转 /// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比) /// @param start 路径起点(百分比)
/// @param end 路径终点(百分比) /// @param end 路径终点(百分比)
static ActionWalkPtr Create(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f, static ActionWalkPtr Create(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f,
float end = 1.f); float end = 1.f);
ActionWalk(); ActionWalk();
/// \~chinese /// \~chinese
/// @brief 获取路线 /// @brief 获取路线
ShapePtr GetPath() const; ShapePtr GetPath() const;
/// \~chinese /// \~chinese
/// @brief 是否沿路径切线方向旋转 /// @brief 是否沿路径切线方向旋转
bool IsRotating() const; bool IsRotating() const;
/// \~chinese /// \~chinese
/// @brief 获取路径起点(百分比) /// @brief 获取路径起点(百分比)
float GetStartValue() const; float GetStartValue() const;
/// \~chinese /// \~chinese
/// @brief 获取路径终点(百分比) /// @brief 获取路径终点(百分比)
float GetEndValue() const; float GetEndValue() const;
/// \~chinese /// \~chinese
/// @brief 设置路径形状 /// @brief 设置路径形状
void SetPath(ShapePtr path); void SetPath(ShapePtr path);
/// \~chinese /// \~chinese
/// @brief 设置沿路径切线方向旋转 /// @brief 设置沿路径切线方向旋转
void SetRotating(bool rotating); void SetRotating(bool rotating);
/// \~chinese /// \~chinese
/// @brief 设置路径起点(百分比) /// @brief 设置路径起点(百分比)
void SetStartValue(float start); void SetStartValue(float start);
/// \~chinese /// \~chinese
/// @brief 设置路径终点(百分比) /// @brief 设置路径终点(百分比)
void SetEndValue(float end); void SetEndValue(float end);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:

View File

@ -32,14 +32,14 @@ KGE_DECLARE_SMART_PTR(Animation);
*/ */
/// \~chinese /// \~chinese
/// @brief 帧动画 /// @brief 帧动画
class KGE_API Animation : public ActionTween class KGE_API Animation : public ActionTween
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建帧动画 /// @brief 创建帧动画
/// @param duration 动画时长 /// @param duration 动画时长
/// @param[in] frame_seq 序列帧 /// @param[in] frame_seq 序列帧
static AnimationPtr Create(Duration duration, FrameSequencePtr frame_seq); static AnimationPtr Create(Duration duration, FrameSequencePtr frame_seq);
Animation(); Animation();
@ -47,20 +47,20 @@ public:
virtual ~Animation(); virtual ~Animation();
/// \~chinese /// \~chinese
/// @brief 获取序列帧 /// @brief 获取序列帧
FrameSequencePtr GetFrameSequence() const; FrameSequencePtr GetFrameSequence() const;
/// \~chinese /// \~chinese
/// @brief 设置序列帧 /// @brief 设置序列帧
/// @param[in] frame_seq 序列帧 /// @param[in] frame_seq 序列帧
void SetFrameSequence(FrameSequencePtr frame_seq); void SetFrameSequence(FrameSequencePtr frame_seq);
/// \~chinese /// \~chinese
/// @brief 获取该动画的拷贝对象 /// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override; ActionPtr Clone() const override;
/// \~chinese /// \~chinese
/// @brief 获取该动画的倒转 /// @brief 获取该动画的倒转
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:

View File

@ -29,29 +29,29 @@ namespace memory
{ {
/// \~chinese /// \~chinese
/// @brief 内存分配器 /// @brief 内存分配器
class KGE_API MemoryAllocator class KGE_API MemoryAllocator
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 申请内存 /// @brief 申请内存
virtual void* Alloc(size_t size) = 0; virtual void* Alloc(size_t size) = 0;
/// \~chinese /// \~chinese
/// @brief 释放内存 /// @brief 释放内存
virtual void Free(void* ptr) = 0; virtual void Free(void* ptr) = 0;
}; };
/// \~chinese /// \~chinese
/// @brief 获取当前内存分配器 /// @brief 获取当前内存分配器
MemoryAllocator* GetAllocator(); MemoryAllocator* GetAllocator();
/// \~chinese /// \~chinese
/// @brief 设置当前内存分配器 /// @brief 设置当前内存分配器
void SetAllocator(MemoryAllocator* allocator); void SetAllocator(MemoryAllocator* allocator);
/// \~chinese /// \~chinese
/// @brief 使用当前内存分配器分配内存 /// @brief 使用当前内存分配器分配内存
template <typename _Ty> template <typename _Ty>
inline void* Alloc() inline void* Alloc()
{ {
@ -59,14 +59,14 @@ inline void* Alloc()
} }
/// \~chinese /// \~chinese
/// @brief 使用当前内存分配器释放内存 /// @brief 使用当前内存分配器释放内存
inline void Free(void* ptr) inline void Free(void* ptr)
{ {
return memory::GetAllocator()->Free(ptr); return memory::GetAllocator()->Free(ptr);
} }
/// \~chinese /// \~chinese
/// @brief 使用当前内存分配器创建对象 /// @brief 使用当前内存分配器创建对象
template <typename _Ty> template <typename _Ty>
inline _Ty* New() inline _Ty* New()
{ {
@ -79,7 +79,7 @@ inline _Ty* New()
} }
/// \~chinese /// \~chinese
/// @brief 使用当前内存分配器创建对象 /// @brief 使用当前内存分配器创建对象
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
inline _Ty* New(_Args&&... args) inline _Ty* New(_Args&&... args)
{ {
@ -92,7 +92,7 @@ inline _Ty* New(_Args&&... args)
} }
/// \~chinese /// \~chinese
/// @brief 使用当前内存分配器销毁对象 /// @brief 使用当前内存分配器销毁对象
template <typename _Ty> template <typename _Ty>
inline void Delete(_Ty* ptr) inline void Delete(_Ty* ptr)
{ {
@ -104,21 +104,21 @@ inline void Delete(_Ty* ptr)
} }
/// \~chinese /// \~chinese
/// @brief 全局内存分配器使用malloc和free分配内存 /// @brief 全局内存分配器使用malloc和free分配内存
class KGE_API GlobalAllocator : public MemoryAllocator class KGE_API GlobalAllocator : public MemoryAllocator
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 申请内存 /// @brief 申请内存
virtual void* Alloc(size_t size) override; virtual void* Alloc(size_t size) override;
/// \~chinese /// \~chinese
/// @brief 释放内存 /// @brief 释放内存
virtual void Free(void* ptr) override; virtual void Free(void* ptr) override;
}; };
/// \~chinese /// \~chinese
/// @brief 获取全局内存分配器 /// @brief 获取全局内存分配器
GlobalAllocator* GetGlobalAllocator(); GlobalAllocator* GetGlobalAllocator();
} // namespace memory } // namespace memory

View File

@ -27,7 +27,7 @@ namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief 可储存单个任意对象的容器 /// @brief 可储存单个任意对象的容器
class Any class Any
{ {
public: public:
@ -72,7 +72,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 获取含有对象类型 /// @brief 获取含有对象类型
inline const type_info& GetType() const noexcept inline const type_info& GetType() const noexcept
{ {
const type_info* const info = GetTypeinfo(); const type_info* const info = GetTypeinfo();
@ -84,14 +84,14 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 是否含有对象 /// @brief 是否含有对象
inline bool HasValue() const noexcept inline bool HasValue() const noexcept
{ {
return GetTypeinfo() != nullptr; return GetTypeinfo() != nullptr;
} }
/// \~chinese /// \~chinese
/// @brief 从参数构造对象 /// @brief 从参数构造对象
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
void Emplace(_Args&&... args) void Emplace(_Args&&... args)
{ {
@ -102,7 +102,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 交换容器 /// @brief 交换容器
void Swap(Any& rhs) noexcept void Swap(Any& rhs) noexcept
{ {
Any old = std::move(rhs); Any old = std::move(rhs);
@ -111,14 +111,14 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 销毁所含对象 /// @brief 销毁所含对象
inline void Clear() noexcept inline void Clear() noexcept
{ {
Tidy(); Tidy();
} }
/// \~chinese /// \~chinese
/// @brief 转换为指定类型的指针 /// @brief 转换为指定类型的指针
template <typename _Ty> template <typename _Ty>
_Ty* CastPtr() noexcept _Ty* CastPtr() noexcept
{ {
@ -126,7 +126,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 转换为指定类型的指针 /// @brief 转换为指定类型的指针
template <typename _Ty> template <typename _Ty>
const _Ty* CastPtr() const noexcept const _Ty* CastPtr() const noexcept
{ {
@ -148,8 +148,8 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 转换为指定类型 /// @brief 转换为指定类型
/// @throw std::bad_cast 转换失败时抛出 /// @throw std::bad_cast 转换失败时抛出
template <typename _Ty> template <typename _Ty>
_Ty Cast() _Ty Cast()
{ {
@ -164,8 +164,8 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 转换为指定类型 /// @brief 转换为指定类型
/// @throw std::bad_cast 转换失败时抛出 /// @throw std::bad_cast 转换失败时抛出
template <typename _Ty> template <typename _Ty>
_Ty Cast() const _Ty Cast() const
{ {

View File

@ -39,68 +39,68 @@ namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief 输入流 /// @brief 输入流
using InputStream = std::istream; using InputStream = std::istream;
/// \~chinese /// \~chinese
/// @brief 输出流 /// @brief 输出流
using OutputStream = std::ostream; using OutputStream = std::ostream;
/// \~chinese /// \~chinese
/// @brief 字符串流 /// @brief 字符串流
using StringStream = std::stringstream; using StringStream = std::stringstream;
/// \~chinese /// \~chinese
/// @brief 宽字符串流 /// @brief 宽字符串流
using WideStringStream = std::wstringstream; using WideStringStream = std::wstringstream;
/// \~chinese /// \~chinese
/// @brief 线性数组容器 /// @brief 线性数组容器
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
using Vector = std::vector<_Ty, _Args...>; using Vector = std::vector<_Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 链表容器 /// @brief 链表容器
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
using List = std::list<_Ty, _Args...>; using List = std::list<_Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 队列容器 /// @brief 队列容器
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
using Queue = std::queue<_Ty, _Args...>; using Queue = std::queue<_Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 集合容器 /// @brief 集合容器
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
using Set = std::set<_Ty, _Args...>; using Set = std::set<_Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 对容器 /// @brief 对容器
template <typename _Ty1, typename _Ty2> template <typename _Ty1, typename _Ty2>
using Pair = std::pair<_Ty1, _Ty2>; using Pair = std::pair<_Ty1, _Ty2>;
/// \~chinese /// \~chinese
/// @brief 无序集合容器 /// @brief 无序集合容器
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
using UnorderedSet = std::unordered_set<_Ty, _Args...>; using UnorderedSet = std::unordered_set<_Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 栈容器 /// @brief 栈容器
template <typename _Ty, typename... _Args> template <typename _Ty, typename... _Args>
using Stack = std::stack<_Ty, _Args...>; using Stack = std::stack<_Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 字符串容器 /// @brief 字符串容器
template <typename _Kty, typename _Ty, typename... _Args> template <typename _Kty, typename _Ty, typename... _Args>
using Map = std::map<_Kty, _Ty, _Args...>; using Map = std::map<_Kty, _Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 字符串容器 /// @brief 字符串容器
template <typename _Kty, typename _Ty, typename... _Args> template <typename _Kty, typename _Ty, typename... _Args>
using UnorderedMap = std::unordered_map<_Kty, _Ty, _Args...>; using UnorderedMap = std::unordered_map<_Kty, _Ty, _Args...>;
/// \~chinese /// \~chinese
/// @brief 不可拷贝对象 /// @brief 不可拷贝对象
class Noncopyable class Noncopyable
{ {
protected: protected:

View File

@ -28,8 +28,8 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
* @see kiwano::Stage * @see kiwano::Stage
*/ */
class KGE_API Director class KGE_API Director
@ -43,51 +43,51 @@ class KGE_API Director
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param[in] stage * @param[in] stage
* @param[in] transition * @param[in] transition
*/ */
void EnterStage(StagePtr stage, TransitionPtr transition = nullptr); void EnterStage(StagePtr stage, TransitionPtr transition = nullptr);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param[in] stage * @param[in] stage
* @param[in] transition * @param[in] transition
*/ */
void PushStage(StagePtr stage, TransitionPtr transition = nullptr); void PushStage(StagePtr stage, TransitionPtr transition = nullptr);
/** /**
* \~chinese * \~chinese
* @brief 退 * @brief 退
* @param[in] transition * @param[in] transition
*/ */
void PopStage(TransitionPtr transition = nullptr); void PopStage(TransitionPtr transition = nullptr);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @return * @return
*/ */
StagePtr GetCurrentStage(); StagePtr GetCurrentStage();
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param enabled * @param enabled
*/ */
void SetRenderBorderEnabled(bool enabled); void SetRenderBorderEnabled(bool enabled);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param show * @param show
*/ */
void ShowDebugInfo(bool show = true); void ShowDebugInfo(bool show = true);
/** /**
* \~chinese * \~chinese
* @brief 退 * @brief 退
*/ */
void ClearStages(); void ClearStages();

View File

@ -25,32 +25,32 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API EventDispatcher class KGE_API EventDispatcher
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 添加监听器 /// @brief 添加监听器
EventListener* AddListener(EventListenerPtr listener); EventListener* AddListener(EventListenerPtr listener);
/// \~chinese /// \~chinese
/// @brief 添加监听器 /// @brief 添加监听器
/// @param type 监听的事件类型 /// @param type 监听的事件类型
/// @param callback 回调函数 /// @param callback 回调函数
EventListener* AddListener(EventType type, EventListener::Callback callback); EventListener* AddListener(EventType type, EventListener::Callback callback);
/// \~chinese /// \~chinese
/// @brief 添加监听器 /// @brief 添加监听器
/// @param name 监听器名称 /// @param name 监听器名称
/// @param type 监听的事件类型 /// @param type 监听的事件类型
/// @param callback 回调函数 /// @param callback 回调函数
EventListener* AddListener(const String& name, EventType type, EventListener::Callback callback); EventListener* AddListener(const String& name, EventType type, EventListener::Callback callback);
/// \~chinese /// \~chinese
/// @brief 添加监听器 /// @brief 添加监听器
/// @tparam _EventTy 事件类型 /// @tparam _EventTy 事件类型
/// @param callback 回调函数 /// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type> template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
EventListener* AddListener(EventListener::Callback callback) EventListener* AddListener(EventListener::Callback callback)
{ {
@ -58,10 +58,10 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 添加监听器 /// @brief 添加监听器
/// @tparam _EventTy 事件类型 /// @tparam _EventTy 事件类型
/// @param name 监听器名称 /// @param name 监听器名称
/// @param callback 回调函数 /// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>> template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>>
EventListener* AddListener(const String& name, EventListener::Callback callback) EventListener* AddListener(const String& name, EventListener::Callback callback)
{ {
@ -69,55 +69,55 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 启动监听器 /// @brief 启动监听器
/// @param name 监听器名称 /// @param name 监听器名称
void StartListeners(const String& name); void StartListeners(const String& name);
/// \~chinese /// \~chinese
/// @brief 停止监听器 /// @brief 停止监听器
/// @param name 监听器名称 /// @param name 监听器名称
void StopListeners(const String& name); void StopListeners(const String& name);
/// \~chinese /// \~chinese
/// @brief 移除监听器 /// @brief 移除监听器
/// @param name 监听器名称 /// @param name 监听器名称
void RemoveListeners(const String& name); void RemoveListeners(const String& name);
/// \~chinese /// \~chinese
/// @brief 启动监听器 /// @brief 启动监听器
/// @param type 监听的事件类型 /// @param type 监听的事件类型
void StartListeners(const EventType& type); void StartListeners(const EventType& type);
/// \~chinese /// \~chinese
/// @brief 停止监听器 /// @brief 停止监听器
/// @param type 监听的事件类型 /// @param type 监听的事件类型
void StopListeners(const EventType& type); void StopListeners(const EventType& type);
/// \~chinese /// \~chinese
/// @brief 移除监听器 /// @brief 移除监听器
/// @param type 监听的事件类型 /// @param type 监听的事件类型
void RemoveListeners(const EventType& type); void RemoveListeners(const EventType& type);
/// \~chinese /// \~chinese
/// @brief 启动所有监听器 /// @brief 启动所有监听器
void StartAllListeners(); void StartAllListeners();
/// \~chinese /// \~chinese
/// @brief 停止所有监听器 /// @brief 停止所有监听器
void StopAllListeners(); void StopAllListeners();
/// \~chinese /// \~chinese
/// @brief 移除所有监听器 /// @brief 移除所有监听器
void RemoveAllListeners(); void RemoveAllListeners();
/// \~chinese /// \~chinese
/// @brief 获取所有监听器 /// @brief 获取所有监听器
const ListenerList& GetAllListeners() const; const ListenerList& GetAllListeners() const;
/// \~chinese /// \~chinese
/// @brief 分发事件 /// @brief 分发事件
/// @param evt 事件 /// @param evt 事件
/// @return 是否继续分发该事件 /// @return 是否继续分发该事件
bool DispatchEvent(Event* evt); bool DispatchEvent(Event* evt);
private: private:

View File

@ -35,12 +35,12 @@ class EventDispatcher;
KGE_DECLARE_SMART_PTR(EventListener); KGE_DECLARE_SMART_PTR(EventListener);
/// \~chinese /// \~chinese
/// @brief 监听器列表 /// @brief 监听器列表
typedef IntrusiveList<EventListenerPtr> ListenerList; typedef IntrusiveList<EventListenerPtr> ListenerList;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API EventListener class KGE_API EventListener
: public ObjectBase : public ObjectBase
@ -51,26 +51,26 @@ class KGE_API EventListener
public: public:
/// \~chinese /// \~chinese
/// @brief 监听器回调函数 /// @brief 监听器回调函数
using Callback = Function<void(Event*)>; using Callback = Function<void(Event*)>;
/// \~chinese /// \~chinese
/// @brief 创建监听器 /// @brief 创建监听器
/// @param type 监听的事件类型 /// @param type 监听的事件类型
/// @param callback 回调函数 /// @param callback 回调函数
static EventListenerPtr Create(EventType type, const Callback& callback); static EventListenerPtr Create(EventType type, const Callback& callback);
/// \~chinese /// \~chinese
/// @brief 创建监听器 /// @brief 创建监听器
/// @param name 监听器名称 /// @param name 监听器名称
/// @param type 监听的事件类型 /// @param type 监听的事件类型
/// @param callback 回调函数 /// @param callback 回调函数
static EventListenerPtr Create(const String& name, EventType type, const Callback& callback); static EventListenerPtr Create(const String& name, EventType type, const Callback& callback);
/// \~chinese /// \~chinese
/// @brief 创建监听器 /// @brief 创建监听器
/// @tparam _EventTy 事件类型 /// @tparam _EventTy 事件类型
/// @param callback 回调函数 /// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type> template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
static inline EventListenerPtr Create(const Callback& callback) static inline EventListenerPtr Create(const Callback& callback)
{ {
@ -78,10 +78,10 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 创建监听器 /// @brief 创建监听器
/// @tparam _EventTy 事件类型 /// @tparam _EventTy 事件类型
/// @param name 监听器名称 /// @param name 监听器名称
/// @param callback 回调函数 /// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type> template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
static inline EventListenerPtr Create(const String& name, const Callback& callback) static inline EventListenerPtr Create(const String& name, const Callback& callback)
{ {
@ -93,53 +93,53 @@ public:
virtual ~EventListener(); virtual ~EventListener();
/// \~chinese /// \~chinese
/// @brief 启动监听器 /// @brief 启动监听器
void Start(); void Start();
/// \~chinese /// \~chinese
/// @brief 停止监听器 /// @brief 停止监听器
void Stop(); void Stop();
/// \~chinese /// \~chinese
/// @brief 移除监听器 /// @brief 移除监听器
void Remove(); void Remove();
/// \~chinese /// \~chinese
/// @brief 是否正在运行 /// @brief 是否正在运行
bool IsRunning() const; bool IsRunning() const;
/// \~chinese /// \~chinese
/// @brief 是否可移除 /// @brief 是否可移除
bool IsRemoveable() const; bool IsRemoveable() const;
/// \~chinese /// \~chinese
/// @brief 是否开启消息吞没 /// @brief 是否开启消息吞没
bool IsSwallowEnabled() const; bool IsSwallowEnabled() const;
/// \~chinese /// \~chinese
/// @brief 设置消息吞没功能 /// @brief 设置消息吞没功能
/// @param enabled 是否启用 /// @param enabled 是否启用
void SetSwallowEnabled(bool enabled); void SetSwallowEnabled(bool enabled);
/// \~chinese /// \~chinese
/// @brief 获取回调函数 /// @brief 获取回调函数
const Callback& GetCallback() const; const Callback& GetCallback() const;
/// \~chinese /// \~chinese
/// @brief 设置回调函数 /// @brief 设置回调函数
void SetCallback(const Callback& cb); void SetCallback(const Callback& cb);
/// \~chinese /// \~chinese
/// @brief 获取监听的事件类型 /// @brief 获取监听的事件类型
EventType GetEventType() const; EventType GetEventType() const;
/// \~chinese /// \~chinese
/// @brief 设置监听的事件类型 /// @brief 设置监听的事件类型
void SetEventType(const EventType& type); void SetEventType(const EventType& type);
/// \~chinese /// \~chinese
/// @brief 设置监听的事件类型 /// @brief 设置监听的事件类型
/// @tparam _EventTy 事件类型 /// @tparam _EventTy 事件类型
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type> template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
inline void SetEventType() inline void SetEventType()
{ {
@ -147,7 +147,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 接收消息 /// @brief 接收消息
void Receive(Event* evt); void Receive(Event* evt);
private: private:

View File

@ -41,15 +41,15 @@ namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief 异常 /// @brief 异常
typedef std::exception Exception; typedef std::exception Exception;
/// \~chinese /// \~chinese
/// @brief 运行时异常 /// @brief 运行时异常
typedef std::runtime_error RuntimeError; typedef std::runtime_error RuntimeError;
/// \~chinese /// \~chinese
/// @brief 系统异常 /// @brief 系统异常
typedef std::system_error SystemError; typedef std::system_error SystemError;
class StackTracer class StackTracer

View File

@ -28,7 +28,7 @@ namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief 侵入式链表 /// @brief 侵入式链表
template <typename _PtrTy> template <typename _PtrTy>
class IntrusiveList class IntrusiveList
{ {
@ -49,42 +49,42 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 获取首元素 /// @brief 获取首元素
const value_type& GetFirst() const const value_type& GetFirst() const
{ {
return first_; return first_;
} }
/// \~chinese /// \~chinese
/// @brief 获取首元素 /// @brief 获取首元素
value_type& GetFirst() value_type& GetFirst()
{ {
return first_; return first_;
} }
/// \~chinese /// \~chinese
/// @brief 获取尾元素 /// @brief 获取尾元素
const value_type& GetLast() const const value_type& GetLast() const
{ {
return last_; return last_;
} }
/// \~chinese /// \~chinese
/// @brief 获取尾元素 /// @brief 获取尾元素
value_type& GetLast() value_type& GetLast()
{ {
return last_; return last_;
} }
/// \~chinese /// \~chinese
/// @brief 链表是否为空 /// @brief 链表是否为空
inline bool IsEmpty() const inline bool IsEmpty() const
{ {
return first_ == nullptr; return first_ == nullptr;
} }
/// \~chinese /// \~chinese
/// @brief 在链表尾部添加对象 /// @brief 在链表尾部添加对象
void PushBack(reference child) void PushBack(reference child)
{ {
if (child->prev_) if (child->prev_)
@ -108,7 +108,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 在链表头部添加对象 /// @brief 在链表头部添加对象
void PushFront(reference child) void PushFront(reference child)
{ {
if (child->prev_) if (child->prev_)
@ -132,7 +132,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 在链表的对象前插入新对象 /// @brief 在链表的对象前插入新对象
void InsertBefore(reference child, reference before) void InsertBefore(reference child, reference before)
{ {
if (child->prev_) if (child->prev_)
@ -151,7 +151,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 在链表的对象后插入新对象 /// @brief 在链表的对象后插入新对象
void InsertAfter(reference child, reference after) void InsertAfter(reference child, reference after)
{ {
if (child->prev_) if (child->prev_)
@ -170,7 +170,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 移除对象 /// @brief 移除对象
void Remove(reference child) void Remove(reference child)
{ {
if (child->next_) if (child->next_)
@ -196,7 +196,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 清空所有对象 /// @brief 清空所有对象
void Clear() void Clear()
{ {
value_type p = first_; value_type p = first_;
@ -215,7 +215,7 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 检查链表是否有效 /// @brief 检查链表是否有效
bool CheckValid() bool CheckValid()
{ {
if (!first_) if (!first_)
@ -429,7 +429,7 @@ private:
/// \~chinese /// \~chinese
/// @brief 侵入式链表元素 /// @brief 侵入式链表元素
template <typename _PtrTy> template <typename _PtrTy>
class IntrusiveListValue class IntrusiveListValue
{ {
@ -456,28 +456,28 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 获取前一元素 /// @brief 获取前一元素
const value_type& GetPrev() const const value_type& GetPrev() const
{ {
return prev_; return prev_;
} }
/// \~chinese /// \~chinese
/// @brief 获取前一元素 /// @brief 获取前一元素
value_type& GetPrev() value_type& GetPrev()
{ {
return prev_; return prev_;
} }
/// \~chinese /// \~chinese
/// @brief 获取下一元素 /// @brief 获取下一元素
const value_type& GetNext() const const value_type& GetNext() const
{ {
return next_; return next_;
} }
/// \~chinese /// \~chinese
/// @brief 获取下一元素 /// @brief 获取下一元素
value_type& GetNext() value_type& GetNext()
{ {
return next_; return next_;

View File

@ -26,7 +26,7 @@ namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief JSON对象容器 /// @brief JSON对象容器
using Json = nlohmann::basic_json<Map, Vector, String>; using Json = nlohmann::basic_json<Map, Vector, String>;
} // namespace kiwano } // namespace kiwano

View File

@ -24,97 +24,97 @@
namespace kiwano namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief 鼠标按键 /// @brief 鼠标按键
enum class MouseButton enum class MouseButton
{ {
Left, ///< 鼠标左键 Left, ///< 鼠标左键
Right, ///< 鼠标右键 Right, ///< 鼠标右键
Middle, ///< 鼠标中键 Middle, ///< 鼠标中键
Last Last
}; };
/// \~chinese /// \~chinese
/// @brief 按键键值 /// @brief 按键键值
enum class KeyCode enum class KeyCode
{ {
Unknown, ///< 未知 Unknown, ///< 未知
Up, ///< 上键 Up, ///< 上键
Left, ///< 左键 Left, ///< 左键
Right, ///< 右键 Right, ///< 右键
Down, ///< 下键 Down, ///< 下键
Enter, ///< 回车键 Enter, ///< 回车键
Space, ///< 空格键 Space, ///< 空格键
Esc, ///< 退出键 Esc, ///< 退出键
Ctrl, ///< CTRL键 Ctrl, ///< CTRL键
Shift, ///< SHIFT键 Shift, ///< SHIFT键
Alt, ///< ALT键 Alt, ///< ALT键
Tab, ///< TAB键 Tab, ///< TAB键
Delete, ///< 删除键 Delete, ///< 删除键
Back, ///< 退格键 Back, ///< 退格键
Super, ///< Cmd|Super|Windows键 Super, ///< Cmd|Super|Windows键
A, ///< A键 A, ///< A键
B, ///< B键 B, ///< B键
C, ///< C键 C, ///< C键
D, ///< D键 D, ///< D键
E, ///< E键 E, ///< E键
F, ///< F键 F, ///< F键
G, ///< G键 G, ///< G键
H, ///< H键 H, ///< H键
I, ///< I键 I, ///< I键
J, ///< J键 J, ///< J键
K, ///< K键 K, ///< K键
L, ///< L键 L, ///< L键
M, ///< M键 M, ///< M键
N, ///< N键 N, ///< N键
O, ///< O键 O, ///< O键
P, ///< P键 P, ///< P键
Q, ///< Q键 Q, ///< Q键
R, ///< R键 R, ///< R键
S, ///< S键 S, ///< S键
T, ///< T键 T, ///< T键
U, ///< U键 U, ///< U键
V, ///< V键 V, ///< V键
W, ///< W键 W, ///< W键
X, ///< X键 X, ///< X键
Y, ///< Y键 Y, ///< Y键
Z, ///< Z键 Z, ///< Z键
Num0, ///< 数字0键 Num0, ///< 数字0键
Num1, ///< 数字1键 Num1, ///< 数字1键
Num2, ///< 数字2键 Num2, ///< 数字2键
Num3, ///< 数字3键 Num3, ///< 数字3键
Num4, ///< 数字4键 Num4, ///< 数字4键
Num5, ///< 数字5键 Num5, ///< 数字5键
Num6, ///< 数字6键 Num6, ///< 数字6键
Num7, ///< 数字7键 Num7, ///< 数字7键
Num8, ///< 数字8键 Num8, ///< 数字8键
Num9, ///< 数字9键 Num9, ///< 数字9键
Numpad0, ///< 数字小键盘0键 Numpad0, ///< 数字小键盘0键
Numpad1, ///< 数字小键盘1键 Numpad1, ///< 数字小键盘1键
Numpad2, ///< 数字小键盘2键 Numpad2, ///< 数字小键盘2键
Numpad3, ///< 数字小键盘3键 Numpad3, ///< 数字小键盘3键
Numpad4, ///< 数字小键盘4键 Numpad4, ///< 数字小键盘4键
Numpad5, ///< 数字小键盘5键 Numpad5, ///< 数字小键盘5键
Numpad6, ///< 数字小键盘6键 Numpad6, ///< 数字小键盘6键
Numpad7, ///< 数字小键盘7键 Numpad7, ///< 数字小键盘7键
Numpad8, ///< 数字小键盘8键 Numpad8, ///< 数字小键盘8键
Numpad9, ///< 数字小键盘9键 Numpad9, ///< 数字小键盘9键
F1, ///< F1键 F1, ///< F1键
F2, ///< F2键 F2, ///< F2键
F3, ///< F3键 F3, ///< F3键
F4, ///< F4键 F4, ///< F4键
F5, ///< F5键 F5, ///< F5键
F6, ///< F6键 F6, ///< F6键
F7, ///< F7键 F7, ///< F7键
F8, ///< F8键 F8, ///< F8键
F9, ///< F9键 F9, ///< F9键
F10, ///< F10键 F10, ///< F10键
F11, ///< F11键 F11, ///< F11键
F12, ///< F12键 F12, ///< F12键
Last Last
}; };

View File

@ -25,43 +25,43 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief DLL库 * @brief DLL库
*/ */
class KGE_API Library class KGE_API Library
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 构造DLL库 /// @brief 构造DLL库
Library(); Library();
/// \~chinese /// \~chinese
/// @brief 构造DLL库 /// @brief 构造DLL库
/// @param lib DLL文件路径 /// @param lib DLL文件路径
Library(const String& lib); Library(const String& lib);
virtual ~Library(); virtual ~Library();
/// \~chinese /// \~chinese
/// @brief 加载DLL /// @brief 加载DLL
/// @param lib DLL文件路径 /// @param lib DLL文件路径
bool Load(const String& lib); bool Load(const String& lib);
/// \~chinese /// \~chinese
/// @brief 是否有效 /// @brief 是否有效
bool IsValid() const; bool IsValid() const;
/// \~chinese /// \~chinese
/// @brief 释放DLL /// @brief 释放DLL
void Free(); void Free();
/// \~chinese /// \~chinese
/// @brief 检索指定的DLL中的输出库函数地址 /// @brief 检索指定的DLL中的输出库函数地址
/// @param proc_name 函数名 /// @param proc_name 函数名
FARPROC GetProcess(const String& proc_name); FARPROC GetProcess(const String& proc_name);
/// \~chinese /// \~chinese
/// @brief 检索指定的DLL中的输出库函数地址 /// @brief 检索指定的DLL中的输出库函数地址
/// @param proc_name 函数名 /// @param proc_name 函数名
template <typename _Proc> template <typename _Proc>
inline _Proc GetProcess(const String& proc_name) inline _Proc GetProcess(const String& proc_name)
{ {

View File

@ -53,7 +53,7 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Logger : public Singleton<Logger> class KGE_API Logger : public Singleton<Logger>
{ {
@ -61,66 +61,66 @@ class KGE_API Logger : public Singleton<Logger>
public: public:
/// \~chinese /// \~chinese
/// @brief 日志级别 /// @brief 日志级别
enum class Level enum class Level
{ {
Info, ///< 信息 Info, ///< 信息
System, ///< 系统 System, ///< 系统
Warning, ///< 警告 Warning, ///< 警告
Error ///< 错误 Error ///< 错误
}; };
/// \~chinese /// \~chinese
/// @brief 打印日志 /// @brief 打印日志
/// @param level 日志级别 /// @param level 日志级别
/// @param format 格式字符串 /// @param format 格式字符串
void Printf(Level level, const char* format, ...); void Printf(Level level, const char* format, ...);
/// \~chinese /// \~chinese
/// @brief 打印日志 /// @brief 打印日志
/// @param level 日志级别 /// @param level 日志级别
/// @param args 参数 /// @param args 参数
template <typename... _Args> template <typename... _Args>
void Print(Level level, _Args&&... args); void Print(Level level, _Args&&... args);
/// \~chinese /// \~chinese
/// @brief 打印一行日志 /// @brief 打印一行日志
/// @param level 日志级别 /// @param level 日志级别
/// @param args 参数 /// @param args 参数
template <typename... _Args> template <typename... _Args>
void Println(Level level, _Args&&... args); void Println(Level level, _Args&&... args);
/// \~chinese /// \~chinese
/// @brief 显示或关闭控制台 /// @brief 显示或关闭控制台
/// @note 此操作会重置输出流 /// @note 此操作会重置输出流
void ShowConsole(bool show); void ShowConsole(bool show);
/// \~chinese /// \~chinese
/// @brief 启用日志 /// @brief 启用日志
void Enable(); void Enable();
/// \~chinese /// \~chinese
/// @brief 禁用日志 /// @brief 禁用日志
void Disable(); void Disable();
/// \~chinese /// \~chinese
/// @brief 获取输出流 /// @brief 获取输出流
OutputStream& GetOutputStream(); OutputStream& GetOutputStream();
/// \~chinese /// \~chinese
/// @brief 获取错误流 /// @brief 获取错误流
OutputStream& GetErrorStream(); OutputStream& GetErrorStream();
/// \~chinese /// \~chinese
/// @brief 重定向输出流 /// @brief 重定向输出流
std::streambuf* RedirectOutputStreamBuffer(std::streambuf* buf); std::streambuf* RedirectOutputStreamBuffer(std::streambuf* buf);
/// \~chinese /// \~chinese
/// @brief 重定向错误流 /// @brief 重定向错误流
std::streambuf* RedirectErrorStreamBuffer(std::streambuf* buf); std::streambuf* RedirectErrorStreamBuffer(std::streambuf* buf);
/// \~chinese /// \~chinese
/// @brief 重置输出流 /// @brief 重置输出流
void ResetOutputStream(); void ResetOutputStream();
private: private:

View File

@ -31,17 +31,17 @@ struct ModuleFlag;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Module class KGE_API Module
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 启动模块 /// @brief 启动模块
virtual void SetupModule() {} virtual void SetupModule() {}
/// \~chinese /// \~chinese
/// @brief 销毁模块 /// @brief 销毁模块
virtual void DestroyModule() {} virtual void DestroyModule() {}
template <typename _CompTy> template <typename _CompTy>
@ -61,22 +61,22 @@ protected:
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API RenderModule : public virtual Module class KGE_API RenderModule : public virtual Module
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 渲染前 /// @brief 渲染前
virtual void BeforeRender() {} virtual void BeforeRender() {}
/// \~chinese /// \~chinese
/// @brief 渲染时 /// @brief 渲染时
/// @param ctx 渲染上下文 /// @param ctx 渲染上下文
virtual void OnRender(RenderContext& ctx) {} virtual void OnRender(RenderContext& ctx) {}
/// \~chinese /// \~chinese
/// @brief 渲染后 /// @brief 渲染后
virtual void AfterRender() {} virtual void AfterRender() {}
public: public:
@ -85,22 +85,22 @@ public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API UpdateModule : public virtual Module class KGE_API UpdateModule : public virtual Module
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 更新前 /// @brief 更新前
virtual void BeforeUpdate() {} virtual void BeforeUpdate() {}
/// \~chinese /// \~chinese
/// @brief 更新时 /// @brief 更新时
/// @param dt 间隔时间 /// @param dt 间隔时间
virtual void OnUpdate(Duration dt) {} virtual void OnUpdate(Duration dt) {}
/// \~chinese /// \~chinese
/// @brief 更新后 /// @brief 更新后
virtual void AfterUpdate() {} virtual void AfterUpdate() {}
public: public:
@ -109,14 +109,14 @@ public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API EventModule : public virtual Module class KGE_API EventModule : public virtual Module
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 事件处理 /// @brief 事件处理
/// @param evt 事件 /// @param evt 事件
virtual void HandleEvent(Event* evt) {} virtual void HandleEvent(Event* evt) {}
public: public:

View File

@ -30,65 +30,65 @@ KGE_DECLARE_SMART_PTR(ObjectBase);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API ObjectBase : public RefCounter class KGE_API ObjectBase : public RefCounter
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 构造基础对象 /// @brief 构造基础对象
ObjectBase(); ObjectBase();
virtual ~ObjectBase(); virtual ~ObjectBase();
/// \~chinese /// \~chinese
/// @brief 设置对象名 /// @brief 设置对象名
void SetName(const String& name); void SetName(const String& name);
/// \~chinese /// \~chinese
/// @brief 获取对象名 /// @brief 获取对象名
String GetName() const; String GetName() const;
/// \~chinese /// \~chinese
/// @brief 判断对象的名称是否相同 /// @brief 判断对象的名称是否相同
/// @param name 需要判断的名称 /// @param name 需要判断的名称
bool IsName(const String& name) const; bool IsName(const String& name) const;
/// \~chinese /// \~chinese
/// @brief 获取用户数据 /// @brief 获取用户数据
const Any& GetUserData() const; const Any& GetUserData() const;
/// \~chinese /// \~chinese
/// @brief 设置用户数据 /// @brief 设置用户数据
void SetUserData(const Any& data); void SetUserData(const Any& data);
/// \~chinese /// \~chinese
/// @brief 获取对象ID /// @brief 获取对象ID
uint32_t GetObjectID() const; uint32_t GetObjectID() const;
/// \~chinese /// \~chinese
/// @brief 序列化对象 /// @brief 序列化对象
String DumpObject(); String DumpObject();
public: public:
/// \~chinese /// \~chinese
/// @brief 是否启用了内存泄漏追踪 /// @brief 是否启用了内存泄漏追踪
static bool IsTracingLeaks(); static bool IsTracingLeaks();
/// \~chinese /// \~chinese
/// @brief 开始追踪内存泄漏 /// @brief 开始追踪内存泄漏
static void StartTracingLeaks(); static void StartTracingLeaks();
/// \~chinese /// \~chinese
/// @brief 停止追踪内存泄漏 /// @brief 停止追踪内存泄漏
static void StopTracingLeaks(); static void StopTracingLeaks();
/// \~chinese /// \~chinese
/// @brief 打印所有追踪中的对象信息 /// @brief 打印所有追踪中的对象信息
static void DumpTracingObjects(); static void DumpTracingObjects();
/// \~chinese /// \~chinese
/// @brief 获取所有追踪中的对象 /// @brief 获取所有追踪中的对象
static Vector<ObjectBase*>& GetTracingObjects(); static Vector<ObjectBase*>& GetTracingObjects();
private: private:

View File

@ -26,7 +26,7 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API RefCounter : protected Noncopyable class KGE_API RefCounter : protected Noncopyable
{ {
@ -36,15 +36,15 @@ public:
virtual ~RefCounter(); virtual ~RefCounter();
/// \~chinese /// \~chinese
/// @brief 增加引用计数 /// @brief 增加引用计数
void Retain(); void Retain();
/// \~chinese /// \~chinese
/// @brief 减少引用计数 /// @brief 减少引用计数
void Release(); void Release();
/// \~chinese /// \~chinese
/// @brief 获取引用计数 /// @brief 获取引用计数
uint32_t GetRefCount() const; uint32_t GetRefCount() const;
private: private:

View File

@ -26,26 +26,26 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
* exe * exe
* "WAVE" * "WAVE"
* IDR_WAVE_1: * IDR_WAVE_1:
* @code * @code
* Resource(IDR_WAVE_1, "WAVE"); * Resource(IDR_WAVE_1, "WAVE");
* @endcode * @endcode
* : * :
* https://docs.microsoft.com/en-us/windows/desktop/menurc/resources * https://docs.microsoft.com/en-us/windows/desktop/menurc/resources
*/ */
class KGE_API Resource class KGE_API Resource
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 资源的二进制数据 /// @brief 资源的二进制数据
struct Data struct Data
{ {
void* buffer; ///< 资源数据 void* buffer; ///< 资源数据
uint32_t size; ///< 资源数据大小 uint32_t size; ///< 资源数据大小
Data(); Data();
@ -53,26 +53,26 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 构造资源 /// @brief 构造资源
Resource(); Resource();
/// \~chinese /// \~chinese
/// @brief 构造资源 /// @brief 构造资源
/// @param id 资源 ID /// @param id 资源 ID
/// @param type 资源类型 /// @param type 资源类型
Resource(uint32_t id, const wchar_t* type); Resource(uint32_t id, const wchar_t* type);
/// \~chinese /// \~chinese
/// @brief 获取资源的二进制数据 /// @brief 获取资源的二进制数据
/// @return 资源数据 /// @return 资源数据
Resource::Data GetData() const; Resource::Data GetData() const;
/// \~chinese /// \~chinese
/// @brief 获取资源 ID /// @brief 获取资源 ID
uint32_t GetId() const; uint32_t GetId() const;
/// \~chinese /// \~chinese
/// @brief 获取资源类型 /// @brief 获取资源类型
const wchar_t* GetType() const; const wchar_t* GetType() const;
private: private:

View File

@ -29,7 +29,7 @@ namespace kiwano
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
struct DefaultSmartPtrRefProxy struct DefaultSmartPtrRefProxy
{ {
@ -48,7 +48,7 @@ struct DefaultSmartPtrRefProxy
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
template <typename _Ty, typename _ProxyTy = DefaultSmartPtrRefProxy> template <typename _Ty, typename _ProxyTy = DefaultSmartPtrRefProxy>
class SmartPtr class SmartPtr

View File

@ -29,11 +29,6 @@ namespace strings
#if defined(KGE_PLATFORM_WINDOWS) #if defined(KGE_PLATFORM_WINDOWS)
//
// This 中文 comment will enable utf-8 encoding in Visual Studio
// Otherwise 'CP_UTF8' cannot work
//
String Format(const char* format, ...) String Format(const char* format, ...)
{ {
String result; String result;
@ -53,18 +48,37 @@ String Format(const char* format, ...)
return result; return result;
} }
WideString Format(const wchar_t* format, ...)
{
WideString result;
if (format)
{
va_list args = nullptr;
va_start(args, format);
const auto len = static_cast<size_t>(::_vscwprintf(format, args) + 1);
if (len)
{
result.resize(len);
::_vsnwprintf_s(&result[0], len, len, format, args);
}
va_end(args);
}
return result;
}
String ToNarrow(const WideString& str) String ToNarrow(const WideString& str)
{ {
if (str.empty()) if (str.empty())
return String(); return String();
int chars_num = ::WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, NULL, 0, NULL, NULL); int chars_num = ::WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, NULL, 0, NULL, NULL);
if (chars_num) if (chars_num)
{ {
String result; String result;
result.resize(chars_num); result.resize(chars_num);
::WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, &result[0], chars_num, NULL, NULL); ::WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, &result[0], chars_num, NULL, NULL);
return result; return result;
} }
return String(); return String();
@ -75,13 +89,13 @@ WideString ToWide(const String& str)
if (str.empty()) if (str.empty())
return WideString(); return WideString();
int chars_num = ::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0); int chars_num = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
if (chars_num) if (chars_num)
{ {
WideString result; WideString result;
result.resize(chars_num); result.resize(chars_num);
::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &result[0], chars_num); ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, &result[0], chars_num);
return result; return result;
} }
return WideString(); return WideString();

View File

@ -25,26 +25,30 @@ namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief 字符串容器 /// @brief 字符串容器
using String = std::string; using String = std::string;
/// \~chinese /// \~chinese
/// @brief 宽字符串容器 /// @brief 宽字符串容器
using WideString = std::wstring; using WideString = std::wstring;
namespace strings namespace strings
{ {
/// \~chinese /// \~chinese
/// @brief 格式化字符串 /// @brief 格式化字符串
String Format(const char* format, ...); String Format(const char* format, ...);
/// \~chinese /// \~chinese
/// @brief 宽字符串转窄字符串 /// @brief 格式化字符串
WideString Format(const wchar_t* format, ...);
/// \~chinese
/// @brief 宽字符串转窄字符串
String ToNarrow(const WideString& str); String ToNarrow(const WideString& str);
/// \~chinese /// \~chinese
/// @brief 窄字符串转宽字符串 /// @brief 窄字符串转宽字符串
WideString ToWide(const String& str); WideString ToWide(const String& str);
} }

View File

@ -366,7 +366,7 @@ Duration Duration::Parse(const String& format)
return ret; return ret;
} }
// 符号位 // 符号位
if (format[0] == '-' || format[0] == '+') if (format[0] == '-' || format[0] == '+')
{ {
negative = (format[0] == '-'); negative = (format[0] == '-');
@ -375,7 +375,7 @@ Duration Duration::Parse(const String& format)
while (pos < len) while (pos < len)
{ {
// 数值 // 数值
size_t i = pos; size_t i = pos;
for (; i < len; ++i) for (; i < len; ++i)
{ {
@ -393,7 +393,7 @@ Duration Duration::Parse(const String& format)
if (num_str.empty() || num_str == ".") if (num_str.empty() || num_str == ".")
KGE_THROW("Duration::Parse failed, invalid duration"); KGE_THROW("Duration::Parse failed, invalid duration");
// 单位 // 单位
for (; i < len; ++i) for (; i < len; ++i)
{ {
wchar_t ch = format[i]; wchar_t ch = format[i];

View File

@ -25,94 +25,94 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @par * @par
* : * :
* @code * @code
* time::Second * 5 // 5 秒 * time::Second * 5 // 5 秒
* time::Hour * 1.5 // 1.5 小时 * time::Hour * 1.5 // 1.5 小时
* time::Hour * 3 + time::Minute * 45 + time::Second * 15 // 3 小时 45 分 15 * time::Hour * 3 + time::Minute * 45 + time::Second * 15 // 3 小时 45 分 15
* *
* @endcode * @endcode
* VS2015 使 time literals: * VS2015 使 time literals:
* @code * @code
* using namespace kiwano; * using namespace kiwano;
* 5_sec // 5 秒 * 5_sec // 5 秒
* 1.5_hour // 1.5 小时 * 1.5_hour // 1.5 小时
* 3_hour + 45_min + 15_sec // 3 小时 45 分 15 秒 * 3_hour + 45_min + 15_sec // 3 小时 45 分 15 秒
* @endcode * @endcode
*/ */
struct KGE_API Duration struct KGE_API Duration
{ {
/// \~chinese /// \~chinese
/// @brief 构造时间段 /// @brief 构造时间段
Duration(); Duration();
/// \~chinese /// \~chinese
/// @brief 构造时间段 /// @brief 构造时间段
/// @param milliseconds 毫秒数 /// @param milliseconds 毫秒数
Duration(long milliseconds); Duration(long milliseconds);
/// \~chinese /// \~chinese
/// @brief 获取毫秒数 /// @brief 获取毫秒数
long Milliseconds() const; long Milliseconds() const;
/// \~chinese /// \~chinese
/// @brief 获取秒数 /// @brief 获取秒数
float Seconds() const; float Seconds() const;
/// \~chinese /// \~chinese
/// @brief 获取分钟数 /// @brief 获取分钟数
float Minutes() const; float Minutes() const;
/// \~chinese /// \~chinese
/// @brief 获取小时数 /// @brief 获取小时数
float Hours() const; float Hours() const;
/// \~chinese /// \~chinese
/// @brief 时长是否是零 /// @brief 时长是否是零
/// @return 若时长是零返回true /// @return 若时长是零返回true
bool IsZero() const; bool IsZero() const;
/// \~chinese /// \~chinese
/// @brief 设置毫秒数 /// @brief 设置毫秒数
/// @param ms 毫秒数 /// @param ms 毫秒数
void SetMilliseconds(long ms); void SetMilliseconds(long ms);
/// \~chinese /// \~chinese
/// @brief 设置秒数 /// @brief 设置秒数
/// @param seconds 秒数 /// @param seconds 秒数
void SetSeconds(float seconds); void SetSeconds(float seconds);
/// \~chinese /// \~chinese
/// @brief 设置分钟数 /// @brief 设置分钟数
/// @param minutes 分钟数 /// @param minutes 分钟数
void SetMinutes(float minutes); void SetMinutes(float minutes);
/// \~chinese /// \~chinese
/// @brief 设置小时数 /// @brief 设置小时数
/// @param hours 小时数 /// @param hours 小时数
void SetHours(float hours); void SetHours(float hours);
/// \~chinese /// \~chinese
/// @brief 转为字符串 /// @brief 转为字符串
String ToString() const; String ToString() const;
/// \~chinese /// \~chinese
/// @brief 解析时间段字符串 /// @brief 解析时间段字符串
/// @param str 时间段字符串 /// @param str 时间段字符串
/// @details /// @details
/// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀 /// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
/// 例如: "300ms", "-1.5h", "2h45m" /// 例如: "300ms", "-1.5h", "2h45m"
/// 允许的时间单位有 "ms", "s", "m", "h" /// 允许的时间单位有 "ms", "s", "m", "h"
/// @return 解析出的时间段 /// @return 解析出的时间段
/// @throw kiwano::RuntimeError 传入一个不合法的格式时抛出 /// @throw kiwano::RuntimeError 传入一个不合法的格式时抛出
static Duration Parse(const String& str); static Duration Parse(const String& str);
static const Duration Ms; ///< 毫秒 static const Duration Ms; ///< 毫秒
static const Duration Second; ///< 秒 static const Duration Second; ///< 秒
static const Duration Minute; ///< 分钟 static const Duration Minute; ///< 分钟
static const Duration Hour; ///< 小时 static const Duration Hour; ///< 小时
bool operator==(const Duration&) const; bool operator==(const Duration&) const;
bool operator!=(const Duration&) const; bool operator!=(const Duration&) const;
@ -158,28 +158,28 @@ private:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @par * @par
* @code * @code
* // 两时间相减, 可得到一个 Duration 对象 * // 两时间相减, 可得到一个 Duration 对象
* Time t1 = Time::Now(); * Time t1 = Time::Now();
* // 等待一段时间后 * // 等待一段时间后
* Time t2 = Time::Now(); * Time t2 = Time::Now();
* int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数 * int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
* @endcode * @endcode
* @note * @note
*/ */
struct KGE_API Time struct KGE_API Time
{ {
Time(); Time();
/// \~chinese /// \~chinese
/// @brief 是否是零时 /// @brief 是否是零时
/// @return 若是零时返回true /// @return 若是零时返回true
bool IsZero() const; bool IsZero() const;
/// \~chinese /// \~chinese
/// @brief 获取当前时间 /// @brief 获取当前时间
static Time Now() noexcept; static Time Now() noexcept;
const Duration operator-(const Time&) const; const Duration operator-(const Time&) const;

View File

@ -30,12 +30,12 @@ class TimerManager;
KGE_DECLARE_SMART_PTR(Timer); KGE_DECLARE_SMART_PTR(Timer);
/// \~chinese /// \~chinese
/// @brief 定时器列表 /// @brief 定时器列表
typedef IntrusiveList<TimerPtr> TimerList; typedef IntrusiveList<TimerPtr> TimerList;
/// \~chinese /// \~chinese
/// @brief 定时器 /// @brief 定时器
/// @details 定时器用于每隔一段时间执行一次回调函数,且可以指定执行总次数 /// @details 定时器用于每隔一段时间执行一次回调函数,且可以指定执行总次数
class KGE_API Timer class KGE_API Timer
: public ObjectBase : public ObjectBase
, protected IntrusiveListValue<TimerPtr> , protected IntrusiveListValue<TimerPtr>
@ -45,85 +45,85 @@ class KGE_API Timer
public: public:
/// \~chinese /// \~chinese
/// @brief 定时器回调函数 /// @brief 定时器回调函数
/// @details /// @details
/// 回调函数第一个参数是定时器自身,第二个参数是距离上次更新的时间间隔 /// 回调函数第一个参数是定时器自身,第二个参数是距离上次更新的时间间隔
using Callback = Function<void(Timer* /* self */, Duration /* dt */)>; using Callback = Function<void(Timer* /* self */, Duration /* dt */)>;
/// \~chinese /// \~chinese
/// @brief 创建定时器 /// @brief 创建定时器
/// @param cb 回调函数 /// @param cb 回调函数
/// @param interval 时间间隔 /// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行) /// @param times 执行次数(设 -1 为永久执行)
static TimerPtr Create(const Callback& cb, Duration interval, int times = -1); static TimerPtr Create(const Callback& cb, Duration interval, int times = -1);
/// \~chinese /// \~chinese
/// @brief 创建定时器 /// @brief 创建定时器
/// @param name 名称 /// @param name 名称
/// @param cb 回调函数 /// @param cb 回调函数
/// @param interval 时间间隔 /// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行) /// @param times 执行次数(设 -1 为永久执行)
static TimerPtr Create(const String& name, const Callback& cb, Duration interval, int times = -1); static TimerPtr Create(const String& name, const Callback& cb, Duration interval, int times = -1);
/// \~chinese /// \~chinese
/// @brief 构造空定时器 /// @brief 构造空定时器
Timer(); Timer();
/// \~chinese /// \~chinese
/// @brief 启动定时器 /// @brief 启动定时器
void Start(); void Start();
/// \~chinese /// \~chinese
/// @brief 停止定时器 /// @brief 停止定时器
void Stop(); void Stop();
/// \~chinese /// \~chinese
/// @brief 移除定时器 /// @brief 移除定时器
void Remove(); void Remove();
/// \~chinese /// \~chinese
/// @brief 定时器是否在运行 /// @brief 定时器是否在运行
bool IsRunning() const; bool IsRunning() const;
/// \~chinese /// \~chinese
/// @brief 定时器是否可移除 /// @brief 定时器是否可移除
bool IsRemoveable() const; bool IsRemoveable() const;
/// \~chinese /// \~chinese
/// @brief 获取定时器执行过回调函数的次数 /// @brief 获取定时器执行过回调函数的次数
int GetRunTimes() const; int GetRunTimes() const;
/// \~chinese /// \~chinese
/// @brief 获取定时器执行回调函数的总次数 /// @brief 获取定时器执行回调函数的总次数
int GetTotalRunTimes() const; int GetTotalRunTimes() const;
/// \~chinese /// \~chinese
/// @brief 设置定时器执行回调函数的总次数 /// @brief 设置定时器执行回调函数的总次数
void SetTotalRunTimes(int times); void SetTotalRunTimes(int times);
/// \~chinese /// \~chinese
/// @brief 获取定时器执行时间间隔 /// @brief 获取定时器执行时间间隔
Duration GetInterval() const; Duration GetInterval() const;
/// \~chinese /// \~chinese
/// @brief 设置定时器执行时间间隔 /// @brief 设置定时器执行时间间隔
void SetInterval(Duration interval); void SetInterval(Duration interval);
/// \~chinese /// \~chinese
/// @brief 获取定时器回调函数 /// @brief 获取定时器回调函数
Callback GetCallback() const; Callback GetCallback() const;
/// \~chinese /// \~chinese
/// @brief 设置定时器回调函数 /// @brief 设置定时器回调函数
void SetCallback(const Callback& callback); void SetCallback(const Callback& callback);
private: private:
/// \~chinese /// \~chinese
/// @brief 更新定时器 /// @brief 更新定时器
void Update(Duration dt); void Update(Duration dt);
/// \~chinese /// \~chinese
/// @brief 重置定时器 /// @brief 重置定时器
void Reset(); void Reset();
private: private:

View File

@ -25,61 +25,61 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API TimerManager class KGE_API TimerManager
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 添加定时器 /// @brief 添加定时器
/// @param cb 回调函数 /// @param cb 回调函数
/// @param interval 时间间隔 /// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行) /// @param times 执行次数(设 -1 为永久执行)
Timer* AddTimer(const Timer::Callback& cb, Duration interval, int times = -1); Timer* AddTimer(const Timer::Callback& cb, Duration interval, int times = -1);
/// \~chinese /// \~chinese
/// @brief 添加定时器 /// @brief 添加定时器
/// @param name 定时器名称 /// @param name 定时器名称
/// @param cb 回调函数 /// @param cb 回调函数
/// @param interval 时间间隔 /// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行) /// @param times 执行次数(设 -1 为永久执行)
Timer* AddTimer(const String& name, const Timer::Callback& cb, Duration interval, int times = -1); Timer* AddTimer(const String& name, const Timer::Callback& cb, Duration interval, int times = -1);
/// \~chinese /// \~chinese
/// @brief 添加定时器 /// @brief 添加定时器
Timer* AddTimer(TimerPtr timer); Timer* AddTimer(TimerPtr timer);
/// \~chinese /// \~chinese
/// @brief 启动定时器 /// @brief 启动定时器
void StartTimers(const String& timer_name); void StartTimers(const String& timer_name);
/// \~chinese /// \~chinese
/// @brief 停止定时器 /// @brief 停止定时器
void StopTimers(const String& timer_name); void StopTimers(const String& timer_name);
/// \~chinese /// \~chinese
/// @brief 移除定时器 /// @brief 移除定时器
void RemoveTimers(const String& timer_name); void RemoveTimers(const String& timer_name);
/// \~chinese /// \~chinese
/// @brief 启动所有定时器 /// @brief 启动所有定时器
void StartAllTimers(); void StartAllTimers();
/// \~chinese /// \~chinese
/// @brief 停止所有定时器 /// @brief 停止所有定时器
void StopAllTimers(); void StopAllTimers();
/// \~chinese /// \~chinese
/// @brief 移除所有定时器 /// @brief 移除所有定时器
void RemoveAllTimers(); void RemoveAllTimers();
/// \~chinese /// \~chinese
/// @brief 获取所有定时器 /// @brief 获取所有定时器
const TimerList& GetAllTimers() const; const TimerList& GetAllTimers() const;
protected: protected:
/// \~chinese /// \~chinese
/// @brief 更新定时器 /// @brief 更新定时器
void UpdateTimers(Duration dt); void UpdateTimers(Duration dt);
private: private:

View File

@ -26,11 +26,11 @@ namespace kiwano
{ {
/// \~chinese /// \~chinese
/// @brief XML文档 /// @brief XML文档
using XmlDocument = pugi::xml_document; using XmlDocument = pugi::xml_document;
/// \~chinese /// \~chinese
/// @brief XML文档 /// @brief XML文档
using XmlNode = pugi::xml_node; using XmlNode = pugi::xml_node;
} // namespace kiwano } // namespace kiwano

View File

@ -29,7 +29,7 @@ KGE_DECLARE_SMART_PTR(Event);
/** /**
* \~chinese * \~chinese
* \defgroup Events * \defgroup Events
*/ */
/** /**
@ -38,35 +38,35 @@ KGE_DECLARE_SMART_PTR(Event);
*/ */
/// \~chinese /// \~chinese
/// @brief 事件 /// @brief 事件
class KGE_API Event : public RefCounter class KGE_API Event : public RefCounter
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 构造事件 /// @brief 构造事件
Event(const EventType& type); Event(const EventType& type);
virtual ~Event(); virtual ~Event();
/// \~chinese /// \~chinese
/// @brief 获取类型事件 /// @brief 获取类型事件
const EventType& GetType() const; const EventType& GetType() const;
/// \~chinese /// \~chinese
/// @brief 判断事件类型 /// @brief 判断事件类型
/// @return 是否是指定事件类型 /// @return 是否是指定事件类型
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type> template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type>
bool IsType() const; bool IsType() const;
/// \~chinese /// \~chinese
/// @brief 安全转换为其他类型事件 /// @brief 安全转换为其他类型事件
/// @throw std::bad_cast 类型无法转换时抛出 /// @throw std::bad_cast 类型无法转换时抛出
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type> template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type>
const _Ty* SafeCast() const; const _Ty* SafeCast() const;
/// \~chinese /// \~chinese
/// @brief 安全转换为其他类型事件 /// @brief 安全转换为其他类型事件
/// @throw std::bad_cast 类型无法转换时抛出 /// @throw std::bad_cast 类型无法转换时抛出
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type> template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type>
_Ty* SafeCast(); _Ty* SafeCast();
@ -75,14 +75,14 @@ private:
}; };
/// \~chinese /// \~chinese
/// @brief 事件特性:判断指定类型是否是事件 /// @brief 事件特性:判断指定类型是否是事件
template <typename _Ty> template <typename _Ty>
struct IsEvent : public std::bool_constant<std::is_base_of<Event, _Ty>::value || std::is_same<Event, _Ty>::value> struct IsEvent : public std::bool_constant<std::is_base_of<Event, _Ty>::value || std::is_same<Event, _Ty>::value>
{ {
}; };
/// \~chinese /// \~chinese
/// @brief 事件特性:判断一个事件能否安全转换到另一事件类型 /// @brief 事件特性:判断一个事件能否安全转换到另一事件类型
template <typename _Ty, typename = typename std::enable_if<IsEvent<_Ty>::value, int>::type> template <typename _Ty, typename = typename std::enable_if<IsEvent<_Ty>::value, int>::type>
struct IsEventType struct IsEventType
{ {

View File

@ -31,7 +31,7 @@ namespace kiwano
*/ */
/// \~chinese /// \~chinese
/// @brief 事件类型 /// @brief 事件类型
class EventType : public std::type_index class EventType : public std::type_index
{ {
class Dummy class Dummy
@ -40,7 +40,7 @@ class EventType : public std::type_index
public: public:
/// \~chinese /// \~chinese
/// @brief 构建事件类型 /// @brief 构建事件类型
EventType(); EventType();
using std::type_index::type_index; using std::type_index::type_index;

View File

@ -35,7 +35,7 @@ KGE_DECLARE_SMART_PTR(KeyCharEvent);
*/ */
/// \~chinese /// \~chinese
/// @brief 键盘事件 /// @brief 键盘事件
class KGE_API KeyEvent : public Event class KGE_API KeyEvent : public Event
{ {
public: public:
@ -43,31 +43,31 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 键盘按下事件 /// @brief 键盘按下事件
class KGE_API KeyDownEvent : public KeyEvent class KGE_API KeyDownEvent : public KeyEvent
{ {
public: public:
KeyCode code; ///< 键值 KeyCode code; ///< 键值
KeyDownEvent(); KeyDownEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 键盘抬起事件 /// @brief 键盘抬起事件
class KGE_API KeyUpEvent : public KeyEvent class KGE_API KeyUpEvent : public KeyEvent
{ {
public: public:
KeyCode code; ///< 键值 KeyCode code; ///< 键值
KeyUpEvent(); KeyUpEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 键盘字符事件 /// @brief 键盘字符事件
class KGE_API KeyCharEvent : public KeyEvent class KGE_API KeyCharEvent : public KeyEvent
{ {
public: public:
char value; ///< 字符 char value; ///< 字符
KeyCharEvent(); KeyCharEvent();
}; };

View File

@ -40,17 +40,17 @@ KGE_DECLARE_SMART_PTR(MouseWheelEvent);
*/ */
/// \~chinese /// \~chinese
/// @brief 鼠标事件 /// @brief 鼠标事件
class KGE_API MouseEvent : public Event class KGE_API MouseEvent : public Event
{ {
public: public:
Point pos; ///< 鼠标位置 Point pos; ///< 鼠标位置
MouseEvent(const EventType& type); MouseEvent(const EventType& type);
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标移动事件 /// @brief 鼠标移动事件
class KGE_API MouseMoveEvent : public MouseEvent class KGE_API MouseMoveEvent : public MouseEvent
{ {
public: public:
@ -58,37 +58,37 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标按键按下事件 /// @brief 鼠标按键按下事件
class KGE_API MouseDownEvent : public MouseEvent class KGE_API MouseDownEvent : public MouseEvent
{ {
public: public:
MouseButton button; ///< 鼠标键值 MouseButton button; ///< 鼠标键值
MouseDownEvent(); MouseDownEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标按键抬起事件 /// @brief 鼠标按键抬起事件
class KGE_API MouseUpEvent : public MouseEvent class KGE_API MouseUpEvent : public MouseEvent
{ {
public: public:
MouseButton button; ///< 鼠标键值 MouseButton button; ///< 鼠标键值
MouseUpEvent(); MouseUpEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标点击事件 /// @brief 鼠标点击事件
class KGE_API MouseClickEvent : public MouseEvent class KGE_API MouseClickEvent : public MouseEvent
{ {
public: public:
MouseButton button; ///< 鼠标键值 MouseButton button; ///< 鼠标键值
MouseClickEvent(); MouseClickEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标移入事件 /// @brief 鼠标移入事件
class KGE_API MouseHoverEvent : public MouseEvent class KGE_API MouseHoverEvent : public MouseEvent
{ {
public: public:
@ -96,7 +96,7 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标移出事件 /// @brief 鼠标移出事件
class KGE_API MouseOutEvent : public MouseEvent class KGE_API MouseOutEvent : public MouseEvent
{ {
public: public:
@ -104,11 +104,11 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 鼠标滚轮事件 /// @brief 鼠标滚轮事件
class KGE_API MouseWheelEvent : public MouseEvent class KGE_API MouseWheelEvent : public MouseEvent
{ {
public: public:
float wheel; ///< 滚轮值 float wheel; ///< 滚轮值
MouseWheelEvent(); MouseWheelEvent();
}; };

View File

@ -36,7 +36,7 @@ KGE_DECLARE_SMART_PTR(WindowClosedEvent);
*/ */
/// \~chinese /// \~chinese
/// @brief 窗口事件 /// @brief 窗口事件
class KGE_API WindowEvent : public Event class KGE_API WindowEvent : public Event
{ {
public: public:
@ -44,49 +44,49 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 窗口移动事件 /// @brief 窗口移动事件
class KGE_API WindowMovedEvent : public WindowEvent class KGE_API WindowMovedEvent : public WindowEvent
{ {
public: public:
int x; ///< 窗口左上角 x 坐标 int x; ///< 窗口左上角 x 坐标
int y; ///< 窗口左上角 y 坐标 int y; ///< 窗口左上角 y 坐标
WindowMovedEvent(); WindowMovedEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 窗口大小变化事件 /// @brief 窗口大小变化事件
class KGE_API WindowResizedEvent : public WindowEvent class KGE_API WindowResizedEvent : public WindowEvent
{ {
public: public:
uint32_t width; ///< 窗口宽度 uint32_t width; ///< 窗口宽度
uint32_t height; ///< 窗口高度 uint32_t height; ///< 窗口高度
WindowResizedEvent(); WindowResizedEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 窗口焦点变化事件 /// @brief 窗口焦点变化事件
class KGE_API WindowFocusChangedEvent : public WindowEvent class KGE_API WindowFocusChangedEvent : public WindowEvent
{ {
public: public:
bool focus; ///< 是否获取到焦点 bool focus; ///< 是否获取到焦点
WindowFocusChangedEvent(); WindowFocusChangedEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 窗口标题更改事件 /// @brief 窗口标题更改事件
class KGE_API WindowTitleChangedEvent : public WindowEvent class KGE_API WindowTitleChangedEvent : public WindowEvent
{ {
public: public:
String title; ///< 标题 String title; ///< 标题
WindowTitleChangedEvent(); WindowTitleChangedEvent();
}; };
/// \~chinese /// \~chinese
/// @brief 窗口关闭事件 /// @brief 窗口关闭事件
class KGE_API WindowClosedEvent : public WindowEvent class KGE_API WindowClosedEvent : public WindowEvent
{ {
public: public:

View File

@ -26,11 +26,11 @@ namespace kiwano
namespace math namespace math
{ {
// //
// 随机数 // 随机数
// //
// 获取指定范围内的一个随机数, 如: // 获取指定范围内的一个随机数, 如:
// int n = math::Random(1, 5); // 获取 1~5 内的随机整数, 包含 1 和 5 // int n = math::Random(1, 5); // 获取 1~5 内的随机整数, 包含 1 和 5
// 产生的随机数类型取决于参数的类型, 如获取随机浮点数: // 产生的随机数类型取决于参数的类型, 如获取随机浮点数:
// float d = math::Random(1.2f, 1.5f); // float d = math::Random(1.2f, 1.5f);
// //

View File

@ -29,7 +29,7 @@ namespace math
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
template <typename _Ty> template <typename _Ty>
class TransformT class TransformT
@ -37,16 +37,16 @@ class TransformT
public: public:
using ValueType = _Ty; using ValueType = _Ty;
float rotation; ///< 旋转 float rotation; ///< 旋转
Vec2T<ValueType> position; ///< 坐标 Vec2T<ValueType> position; ///< 坐标
Vec2T<ValueType> scale; ///< 缩放 Vec2T<ValueType> scale; ///< 缩放
Vec2T<ValueType> skew; ///< 错切角度 Vec2T<ValueType> skew; ///< 错切角度
public: public:
TransformT(); TransformT();
/// \~chinese /// \~chinese
/// @brief 将二维放射变换转换为矩阵 /// @brief 将二维放射变换转换为矩阵
Matrix3x2T<ValueType> ToMatrix() const; Matrix3x2T<ValueType> ToMatrix() const;
bool operator==(const TransformT& rhs) const; bool operator==(const TransformT& rhs) const;

View File

@ -32,7 +32,7 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Application : public Singleton<Application> class KGE_API Application : public Singleton<Application>
{ {
@ -45,85 +45,85 @@ public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param runner * @param runner
* @param debug * @param debug
* @note * @note
*/ */
void Run(RunnerPtr runner, bool debug = false); void Run(RunnerPtr runner, bool debug = false);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
void Quit(); void Quit();
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
RunnerPtr GetRunner() const; RunnerPtr GetRunner() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
WindowPtr GetMainWindow() const; WindowPtr GetMainWindow() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
int GetVersion() const; int GetVersion() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param[in] module * @param[in] module
*/ */
void Use(Module& module); void Use(Module& module);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
* @param scale_factor * @param scale_factor
* @warning * @warning
*/ */
void SetTimeScale(float scale_factor); void SetTimeScale(float scale_factor);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
* @param evt * @param evt
*/ */
void DispatchEvent(Event* evt); void DispatchEvent(Event* evt);
/** /**
* \~chinese * \~chinese
* @brief 线 * @brief 线
* @details 线 Kiwano * @details 线 Kiwano
* @param func * @param func
*/ */
void PreformInMainThread(Function<void()> func); void PreformInMainThread(Function<void()> func);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param dt * @param dt
*/ */
void Update(Duration dt); void Update(Duration dt);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
void Render(); void Render();
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
void Destroy(); void Destroy();

View File

@ -25,7 +25,7 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API FileSystem : public Singleton<FileSystem> class KGE_API FileSystem : public Singleton<FileSystem>
{ {
@ -34,71 +34,71 @@ class KGE_API FileSystem : public Singleton<FileSystem>
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param path * @param path
*/ */
void AddSearchPath(const String& path); void AddSearchPath(const String& path);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param paths * @param paths
*/ */
void SetSearchPaths(const Vector<String>& paths); void SetSearchPaths(const Vector<String>& paths);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param file * @param file
* @return * @return
*/ */
String GetFullPathForFile(const String& file) const; String GetFullPathForFile(const String& file) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param key * @param key
* @param file_path * @param file_path
*/ */
void AddFileLookupRule(const String& key, const String& file_path); void AddFileLookupRule(const String& key, const String& file_path);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param dict * @param dict
*/ */
void SetFileLookupDictionary(const UnorderedMap<String, String>& dict); void SetFileLookupDictionary(const UnorderedMap<String, String>& dict);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param file_path * @param file_path
* @return true * @return true
*/ */
bool IsFileExists(const String& file_path) const; bool IsFileExists(const String& file_path) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param path * @param path
* @return true * @return true
*/ */
bool IsAbsolutePath(const String& path) const; bool IsAbsolutePath(const String& path) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param file_path * @param file_path
* @return * @return
*/ */
bool RemoveFile(const String& file_path) const; bool RemoveFile(const String& file_path) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param res * @param res
* @param dest_file_name * @param dest_file_name
* @return * @return
*/ */
bool ExtractResourceToFile(const Resource& res, const String& dest_file_name) const; bool ExtractResourceToFile(const Resource& res, const String& dest_file_name) const;

View File

@ -31,7 +31,7 @@ namespace kiwano
{ {
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Input class KGE_API Input
: public Singleton<Input> : public Singleton<Input>
@ -43,63 +43,63 @@ class KGE_API Input
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param key * @param key
*/ */
bool IsDown(KeyCode key) const; bool IsDown(KeyCode key) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param key * @param key
*/ */
bool WasPressed(KeyCode key) const; bool WasPressed(KeyCode key) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param key * @param key
*/ */
bool WasReleased(KeyCode key) const; bool WasReleased(KeyCode key) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param btn * @param btn
*/ */
bool IsDown(MouseButton btn) const; bool IsDown(MouseButton btn) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param btn * @param btn
*/ */
bool WasPressed(MouseButton btn) const; bool WasPressed(MouseButton btn) const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param btn * @param btn
*/ */
bool WasReleased(MouseButton btn) const; bool WasReleased(MouseButton btn) const;
/** /**
* \~chinese * \~chinese
* @brief x * @brief x
* @return x * @return x
*/ */
float GetMouseX() const; float GetMouseX() const;
/** /**
* \~chinese * \~chinese
* @brief y * @brief y
* @return y * @return y
*/ */
float GetMouseY() const; float GetMouseY() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @return * @return
*/ */
Point GetMousePos() const; Point GetMousePos() const;

View File

@ -32,7 +32,7 @@ KGE_DECLARE_SMART_PTR(Runner);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Runner : public ObjectBase class KGE_API Runner : public ObjectBase
{ {
@ -40,15 +40,15 @@ class KGE_API Runner : public ObjectBase
public: public:
/// \~chinese /// \~chinese
/// @brief 创建程序运行器 /// @brief 创建程序运行器
/// @param main_window 主窗口 /// @param main_window 主窗口
static RunnerPtr Create(WindowPtr main_window); static RunnerPtr Create(WindowPtr main_window);
/// \~chinese /// \~chinese
/// @brief 创建程序运行器 /// @brief 创建程序运行器
/// @param main_window 主窗口 /// @param main_window 主窗口
/// @param on_ready 应用程序初始化完成后执行的回调函数 /// @param on_ready 应用程序初始化完成后执行的回调函数
/// @param on_destroy 应用程序销毁时执行的回调函数 /// @param on_destroy 应用程序销毁时执行的回调函数
static RunnerPtr Create(WindowPtr main_window, Function<void()> on_ready, Function<void()> on_destroy = nullptr); static RunnerPtr Create(WindowPtr main_window, Function<void()> on_ready, Function<void()> on_destroy = nullptr);
Runner(); Runner();
@ -56,37 +56,37 @@ public:
virtual ~Runner(); virtual ~Runner();
/// \~chinese /// \~chinese
/// @brief 初始化完成处理 /// @brief 初始化完成处理
/// @details 重载该函数以在应用程序初始化完成后自动执行 /// @details 重载该函数以在应用程序初始化完成后自动执行
virtual void OnReady(); virtual void OnReady();
/// \~chinese /// \~chinese
/// @brief 应用程序销毁处理 /// @brief 应用程序销毁处理
/// @details 重载该函数以处理应用程序销毁时的行为,如完成资源回收等 /// @details 重载该函数以处理应用程序销毁时的行为,如完成资源回收等
virtual void OnDestroy(); virtual void OnDestroy();
/// \~chinese /// \~chinese
/// @brief 应用程序关闭处理 /// @brief 应用程序关闭处理
/// @details 重载该函数以处理用户关闭应用程序时的行为,如保存用户数据等 /// @details 重载该函数以处理用户关闭应用程序时的行为,如保存用户数据等
/// @return 返回true允许用户关闭程序否则阻止程序关闭 /// @return 返回true允许用户关闭程序否则阻止程序关闭
virtual bool OnClosing(); virtual bool OnClosing();
/// \~chinese /// \~chinese
/// @brief 应用程序主循环 /// @brief 应用程序主循环
/// @details 重载该函数以 /// @details 重载该函数以
/// @return 返回false退出主循环否则继续运行主循环 /// @return 返回false退出主循环否则继续运行主循环
virtual bool MainLoop(); virtual bool MainLoop();
/// \~chinese /// \~chinese
/// @brief 获取主窗口 /// @brief 获取主窗口
WindowPtr GetMainWindow() const; WindowPtr GetMainWindow() const;
/// \~chinese /// \~chinese
/// @brief 设置主窗口 /// @brief 设置主窗口
void SetMainWindow(WindowPtr window); void SetMainWindow(WindowPtr window);
/// \~chinese /// \~chinese
/// @brief 获取上一次更新时间 /// @brief 获取上一次更新时间
Time GetLastUpdateTime() const; Time GetLastUpdateTime() const;
private: private:

View File

@ -31,18 +31,18 @@ KGE_DECLARE_SMART_PTR(Window);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
enum class CursorType enum class CursorType
{ {
Arrow, ///< 指针 Arrow, ///< 指针
TextInput, ///< 文本 TextInput, ///< 文本
Hand, ///< 手 Hand, ///< 手
SizeAll, ///< 指向四个方向的箭头 SizeAll, ///< 指向四个方向的箭头
SizeWE, ///< 指向左右方向的箭头 SizeWE, ///< 指向左右方向的箭头
SizeNS, ///< 指向上下方向的箭头 SizeNS, ///< 指向上下方向的箭头
SizeNESW, ///< 指向左下到右上方向的箭头 SizeNESW, ///< 指向左下到右上方向的箭头
SizeNWSE, ///< 指向左上到右下方向的箭头 SizeNWSE, ///< 指向左上到右下方向的箭头
}; };
@ -53,133 +53,133 @@ typedef HWND WindowHandle;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Window : public ObjectBase class KGE_API Window : public ObjectBase
{ {
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param title * @param title
* @param width * @param width
* @param height * @param height
* @param icon ID * @param icon ID
* @param resizable * @param resizable
* @param fullscreen * @param fullscreen
* @throw kiwano::SystemError * @throw kiwano::SystemError
*/ */
static WindowPtr Create(const String& title, uint32_t width, uint32_t height, uint32_t icon = 0, static WindowPtr Create(const String& title, uint32_t width, uint32_t height, uint32_t icon = 0,
bool resizable = false, bool fullscreen = false); bool resizable = false, bool fullscreen = false);
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @return * @return
*/ */
String GetTitle() const; String GetTitle() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @return * @return
*/ */
Size GetSize() const; Size GetSize() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @return * @return
*/ */
uint32_t GetWidth() const; uint32_t GetWidth() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @return * @return
*/ */
uint32_t GetHeight() const; uint32_t GetHeight() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
WindowHandle GetHandle() const; WindowHandle GetHandle() const;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param title * @param title
*/ */
virtual void SetTitle(const String& title) = 0; virtual void SetTitle(const String& title) = 0;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param icon_resource ID * @param icon_resource ID
*/ */
virtual void SetIcon(uint32_t icon_resource) = 0; virtual void SetIcon(uint32_t icon_resource) = 0;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param width * @param width
* @param height * @param height
*/ */
virtual void Resize(uint32_t width, uint32_t height) = 0; virtual void Resize(uint32_t width, uint32_t height) = 0;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param fullscreen * @param fullscreen
* @param width * @param width
* @param height * @param height
*/ */
virtual void SetFullscreen(bool fullscreen) = 0; virtual void SetFullscreen(bool fullscreen) = 0;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param cursor * @param cursor
*/ */
virtual void SetCursor(CursorType cursor) = 0; virtual void SetCursor(CursorType cursor) = 0;
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @return \n * @return \n
* *
*/ */
EventPtr PollEvent(); EventPtr PollEvent();
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param evt * @param evt
*/ */
void PushEvent(EventPtr evt); void PushEvent(EventPtr evt);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
virtual void PumpEvents() = 0; virtual void PumpEvents() = 0;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
bool ShouldClose(); bool ShouldClose();
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
void SetShouldClose(bool should); void SetShouldClose(bool should);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
virtual void Destroy(); virtual void Destroy();

View File

@ -77,9 +77,9 @@ private:
bool resizable_; bool resizable_;
bool is_fullscreen_; bool is_fullscreen_;
CursorType mouse_cursor_; CursorType mouse_cursor_;
String device_name_;
std::unique_ptr<wchar_t[]> device_name_; std::array<KeyCode, 256> key_map_;
std::array<KeyCode, 256> key_map_;
}; };
WindowPtr Window::Create(const String& title, uint32_t width, uint32_t height, uint32_t icon, bool resizable, WindowPtr Window::Create(const String& title, uint32_t width, uint32_t height, uint32_t icon, bool resizable,
@ -104,14 +104,14 @@ namespace kiwano
namespace namespace
{ {
MONITORINFOEX GetMoniterInfoEx(HWND hwnd) MONITORINFOEXA GetMoniterInfoEx(HWND hwnd)
{ {
HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFOEX monitor_info; MONITORINFOEXA monitor_info;
memset(&monitor_info, 0, sizeof(MONITORINFOEX)); memset(&monitor_info, 0, sizeof(MONITORINFOEXA));
monitor_info.cbSize = sizeof(MONITORINFOEX); monitor_info.cbSize = sizeof(MONITORINFOEXA);
::GetMonitorInfoW(monitor, &monitor_info); ::GetMonitorInfoA(monitor, &monitor_info);
return monitor_info; return monitor_info;
} }
@ -125,7 +125,7 @@ void AdjustWindow(uint32_t width, uint32_t height, DWORD style, uint32_t* win_wi
*win_width = rc.right - rc.left; *win_width = rc.right - rc.left;
*win_height = rc.bottom - rc.top; *win_height = rc.bottom - rc.top;
MONITORINFOEX info = GetMoniterInfoEx(NULL); MONITORINFOEXA info = GetMoniterInfoEx(NULL);
uint32_t screenw = info.rcWork.right - info.rcWork.left; uint32_t screenw = info.rcWork.right - info.rcWork.left;
uint32_t screenh = info.rcWork.bottom - info.rcWork.top; uint32_t screenh = info.rcWork.bottom - info.rcWork.top;
@ -136,25 +136,24 @@ void AdjustWindow(uint32_t width, uint32_t height, DWORD style, uint32_t* win_wi
*win_height = screenh; *win_height = screenh;
} }
void ChangeFullScreenResolution(uint32_t width, uint32_t height, WCHAR* device_name) void ChangeFullScreenResolution(uint32_t width, uint32_t height, const CHAR* device_name)
{ {
DEVMODE mode; DEVMODEA mode;
memset(&mode, 0, sizeof(mode)); memset(&mode, 0, sizeof(mode));
mode.dmSize = sizeof(DEVMODE); mode.dmSize = sizeof(DEVMODEA);
mode.dmBitsPerPel = ::GetDeviceCaps(::GetDC(0), BITSPIXEL); mode.dmBitsPerPel = ::GetDeviceCaps(::GetDC(0), BITSPIXEL);
;
mode.dmPelsWidth = width; mode.dmPelsWidth = width;
mode.dmPelsHeight = height; mode.dmPelsHeight = height;
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (::ChangeDisplaySettingsExW(device_name, &mode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL) if (::ChangeDisplaySettingsExA(device_name, &mode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
KGE_ERROR("ChangeDisplaySettings failed"); KGE_ERROR("ChangeDisplaySettings failed");
} }
void RestoreResolution(WCHAR* device_name) void RestoreResolution(const CHAR* device_name)
{ {
::ChangeDisplaySettingsExW(device_name, NULL, NULL, 0, NULL); ::ChangeDisplaySettingsExA(device_name, NULL, NULL, 0, NULL);
} }
} // namespace } // namespace
@ -211,42 +210,39 @@ WindowWin32Impl::~WindowWin32Impl() {}
void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height, uint32_t icon, bool resizable, void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height, uint32_t icon, bool resizable,
bool fullscreen) bool fullscreen)
{ {
HINSTANCE hinst = GetModuleHandleW(nullptr); HINSTANCE hinst = GetModuleHandle(nullptr);
WNDCLASSEX wcex = { 0 }; WNDCLASSEXA wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX); wcex.cbSize = sizeof(WNDCLASSEX);
wcex.lpszClassName = L"KiwanoAppWnd"; wcex.lpszClassName = "KiwanoAppWnd";
wcex.style = CS_HREDRAW | CS_VREDRAW /* | CS_DBLCLKS */; wcex.style = CS_HREDRAW | CS_VREDRAW /* | CS_DBLCLKS */;
wcex.lpfnWndProc = WindowWin32Impl::StaticWndProc; wcex.lpfnWndProc = WindowWin32Impl::StaticWndProc;
wcex.hIcon = nullptr; wcex.hIcon = nullptr;
wcex.cbClsExtra = 0; wcex.cbClsExtra = 0;
wcex.cbWndExtra = sizeof(LONG_PTR); wcex.cbWndExtra = sizeof(LONG_PTR);
wcex.hInstance = hinst; wcex.hInstance = hinst;
wcex.hbrBackground = (HBRUSH)(::GetStockObject(BLACK_BRUSH)); wcex.hbrBackground = (HBRUSH)::GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = nullptr; wcex.lpszMenuName = nullptr;
wcex.hCursor = ::LoadCursorW(hinst, IDC_ARROW); wcex.hCursor = ::LoadCursor(hinst, IDC_ARROW);
if (icon) if (icon)
{ {
wcex.hIcon = (HICON)::LoadImageW(hinst, MAKEINTRESOURCE(icon), IMAGE_ICON, 0, 0, wcex.hIcon = (HICON)::LoadImage(hinst, MAKEINTRESOURCE(icon), IMAGE_ICON, 0, 0,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
} }
::RegisterClassExW(&wcex); ::RegisterClassExA(&wcex);
// Get the nearest monitor to this window // Get the nearest monitor to this window
HMONITOR monitor = ::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY); HMONITOR monitor = ::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
// Get the target monitor info // Get the target monitor info
MONITORINFOEX monitor_info_ex; MONITORINFOEXA monitor_info_ex;
memset(&monitor_info_ex, 0, sizeof(MONITORINFOEX)); memset(&monitor_info_ex, 0, sizeof(MONITORINFOEXA));
monitor_info_ex.cbSize = sizeof(MONITORINFOEX); monitor_info_ex.cbSize = sizeof(MONITORINFOEXA);
::GetMonitorInfoW(monitor, &monitor_info_ex); ::GetMonitorInfoA(monitor, &monitor_info_ex);
// Save the device name // Save the device name
int len = lstrlenW(monitor_info_ex.szDevice); device_name_ = monitor_info_ex.szDevice;
device_name_ = std::unique_ptr<wchar_t[]>(new wchar_t[len + 1]);
lstrcpyW(device_name_.get(), monitor_info_ex.szDevice);
int left = -1, top = -1; int left = -1, top = -1;
@ -278,14 +274,12 @@ void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height,
height = win_height; height = win_height;
} }
WideString wide_title = strings::ToWide(title); handle_ = ::CreateWindowExA(is_fullscreen_ ? WS_EX_TOPMOST : 0, "KiwanoAppWnd", title.c_str(), GetStyle(),
handle_ = ::CreateWindowExW(is_fullscreen_ ? WS_EX_TOPMOST : 0, L"KiwanoAppWnd", wide_title.c_str(), GetStyle(),
left, top, width, height, nullptr, nullptr, hinst, nullptr); left, top, width, height, nullptr, nullptr, hinst, nullptr);
if (handle_ == nullptr) if (handle_ == nullptr)
{ {
::UnregisterClassW(L"KiwanoAppWnd", hinst); ::UnregisterClassA("KiwanoAppWnd", hinst);
KGE_THROW_SYSTEM_ERROR(HRESULT_FROM_WIN32(GetLastError()), "Create window failed"); KGE_THROW_SYSTEM_ERROR(HRESULT_FROM_WIN32(GetLastError()), "Create window failed");
} }
@ -296,24 +290,24 @@ void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height,
::ImmAssociateContext(handle_, nullptr); ::ImmAssociateContext(handle_, nullptr);
// use Application instance in message loop // use Application instance in message loop
::SetWindowLongPtr(handle_, GWLP_USERDATA, LONG_PTR(this)); ::SetWindowLongPtrA(handle_, GWLP_USERDATA, LONG_PTR(this));
::ShowWindow(handle_, SW_SHOWNORMAL); ::ShowWindow(handle_, SW_SHOWNORMAL);
::UpdateWindow(handle_); ::UpdateWindow(handle_);
if (is_fullscreen_) if (is_fullscreen_)
{ {
ChangeFullScreenResolution(width, height, device_name_.get()); ChangeFullScreenResolution(width, height, device_name_.c_str());
} }
} }
void WindowWin32Impl::PumpEvents() void WindowWin32Impl::PumpEvents()
{ {
MSG msg; MSG msg;
while (::PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) while (::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
{ {
::TranslateMessage(&msg); ::TranslateMessage(&msg);
::DispatchMessageW(&msg); ::DispatchMessage(&msg);
} }
} }
@ -321,8 +315,7 @@ void WindowWin32Impl::SetTitle(const String& title)
{ {
if (handle_) if (handle_)
{ {
WideString wide_title = strings::ToWide(title); ::SetWindowTextA(handle_, title.c_str());
::SetWindowTextW(handle_, wide_title.c_str());
} }
} }
@ -330,9 +323,9 @@ void WindowWin32Impl::SetIcon(uint32_t icon_resource)
{ {
if (handle_) if (handle_)
{ {
HINSTANCE hinstance = GetModuleHandle(nullptr); HINSTANCE hinstance = ::GetModuleHandle(nullptr);
HICON icon = (HICON)::LoadImageW(hinstance, MAKEINTRESOURCE(icon_resource), IMAGE_ICON, 0, 0, HICON icon = (HICON)::LoadImage(hinstance, MAKEINTRESOURCE(icon_resource), IMAGE_ICON, 0, 0,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
::SendMessage(handle_, WM_SETICON, ICON_BIG, (LPARAM)icon); ::SendMessage(handle_, WM_SETICON, ICON_BIG, (LPARAM)icon);
::SendMessage(handle_, WM_SETICON, ICON_SMALL, (LPARAM)icon); ::SendMessage(handle_, WM_SETICON, ICON_SMALL, (LPARAM)icon);
@ -366,19 +359,19 @@ void WindowWin32Impl::SetFullscreen(bool fullscreen)
// move window to (0, 0) before display switch // move window to (0, 0) before display switch
::SetWindowPos(handle_, HWND_TOPMOST, 0, 0, width, height, SWP_NOACTIVATE); ::SetWindowPos(handle_, HWND_TOPMOST, 0, 0, width, height, SWP_NOACTIVATE);
ChangeFullScreenResolution(width, height, device_name_.get()); ChangeFullScreenResolution(width, height, device_name_.c_str());
MONITORINFOEX info = GetMoniterInfoEx(handle_); MONITORINFOEXA info = GetMoniterInfoEx(handle_);
::SetWindowLongPtr(handle_, GWL_STYLE, GetStyle()); ::SetWindowLongPtrA(handle_, GWL_STYLE, GetStyle());
::SetWindowPos(handle_, HWND_TOPMOST, info.rcMonitor.top, info.rcMonitor.left, width, height, ::SetWindowPos(handle_, HWND_TOPMOST, info.rcMonitor.top, info.rcMonitor.left, width, height,
SWP_NOACTIVATE); SWP_NOACTIVATE);
} }
else else
{ {
RestoreResolution(device_name_.get()); RestoreResolution(device_name_.c_str());
MONITORINFOEX info = GetMoniterInfoEx(handle_); MONITORINFOEXA info = GetMoniterInfoEx(handle_);
uint32_t screenw = uint32_t(info.rcWork.right - info.rcWork.left); uint32_t screenw = uint32_t(info.rcWork.right - info.rcWork.left);
uint32_t screenh = uint32_t(info.rcWork.bottom - info.rcWork.top); uint32_t screenh = uint32_t(info.rcWork.bottom - info.rcWork.top);
@ -386,7 +379,7 @@ void WindowWin32Impl::SetFullscreen(bool fullscreen)
int left = screenw > width ? ((screenw - width) / 2) : 0; int left = screenw > width ? ((screenw - width) / 2) : 0;
int top = screenh > height ? ((screenh - height) / 2) : 0; int top = screenh > height ? ((screenh - height) / 2) : 0;
::SetWindowLongPtr(handle_, GWL_STYLE, GetStyle()); ::SetWindowLongPtrA(handle_, GWL_STYLE, GetStyle());
::SetWindowPos(handle_, HWND_NOTOPMOST, left, top, width, height, SWP_DRAWFRAME | SWP_FRAMECHANGED); ::SetWindowPos(handle_, HWND_NOTOPMOST, left, top, width, height, SWP_DRAWFRAME | SWP_FRAMECHANGED);
} }
@ -402,9 +395,7 @@ void WindowWin32Impl::SetCursor(CursorType cursor)
void WindowWin32Impl::Destroy() void WindowWin32Impl::Destroy()
{ {
if (is_fullscreen_) if (is_fullscreen_)
RestoreResolution(device_name_.get()); RestoreResolution(device_name_.c_str());
device_name_.reset();
if (handle_) if (handle_)
{ {
@ -450,7 +441,7 @@ void WindowWin32Impl::UpdateCursor()
win32_cursor = IDC_HAND; win32_cursor = IDC_HAND;
break; break;
} }
::SetCursor(::LoadCursorW(nullptr, win32_cursor)); ::SetCursor(::LoadCursor(nullptr, win32_cursor));
} }
void WindowWin32Impl::SetActive(bool actived) void WindowWin32Impl::SetActive(bool actived)
@ -462,15 +453,15 @@ void WindowWin32Impl::SetActive(bool actived)
{ {
if (actived) if (actived)
{ {
ChangeFullScreenResolution(GetWidth(), GetHeight(), device_name_.get()); ChangeFullScreenResolution(GetWidth(), GetHeight(), device_name_.c_str());
MONITORINFOEX info = GetMoniterInfoEx(handle_); MONITORINFOEXA info = GetMoniterInfoEx(handle_);
::SetWindowPos(handle_, HWND_TOPMOST, info.rcMonitor.top, info.rcMonitor.left, GetWidth(), GetHeight(), ::SetWindowPos(handle_, HWND_TOPMOST, info.rcMonitor.top, info.rcMonitor.left, GetWidth(), GetHeight(),
SWP_NOACTIVATE); SWP_NOACTIVATE);
} }
else else
{ {
RestoreResolution(device_name_.get()); RestoreResolution(device_name_.c_str());
::SetWindowPos(handle_, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); ::SetWindowPos(handle_, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
::ShowWindow(handle_, SW_MINIMIZE); ::ShowWindow(handle_, SW_MINIMIZE);
@ -679,18 +670,18 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA
break; break;
} }
return ::DefWindowProcW(hwnd, msg, wparam, lparam); return ::DefWindowProcA(hwnd, msg, wparam, lparam);
} }
LRESULT CALLBACK WindowWin32Impl::StaticWndProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam) LRESULT CALLBACK WindowWin32Impl::StaticWndProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam)
{ {
LONG_PTR ptr = static_cast<LONG_PTR>(::GetWindowLongPtrW(hwnd, GWLP_USERDATA)); LONG_PTR ptr = static_cast<LONG_PTR>(::GetWindowLongPtrA(hwnd, GWLP_USERDATA));
if (ptr) if (ptr)
{ {
WindowWin32Impl* window = reinterpret_cast<WindowWin32Impl*>(ptr); WindowWin32Impl* window = reinterpret_cast<WindowWin32Impl*>(ptr);
return window->MessageProc(hwnd, msg, wparam, lparam); return window->MessageProc(hwnd, msg, wparam, lparam);
} }
return ::DefWindowProcW(hwnd, msg, wparam, lparam); return ::DefWindowProcA(hwnd, msg, wparam, lparam);
} }
} // namespace kiwano } // namespace kiwano

View File

@ -33,11 +33,11 @@ KGE_DECLARE_SMART_PTR(Brush);
*/ */
/// \~chinese /// \~chinese
/// @brief 渐变转换点 /// @brief 渐变转换点
struct GradientStop struct GradientStop
{ {
float offset; ///< 偏移距离 float offset; ///< 偏移距离
Color color; ///< 渐变点颜色 Color color; ///< 渐变点颜色
GradientStop(); GradientStop();
@ -45,37 +45,37 @@ struct GradientStop
}; };
/// \~chinese /// \~chinese
/// @brief 渐变扩充模式 /// @brief 渐变扩充模式
/// @details 该模式用于指定画笔如何绘制正常区域外的部分 /// @details 该模式用于指定画笔如何绘制正常区域外的部分
enum class GradientExtendMode enum class GradientExtendMode
{ {
Clamp, ///< 夹模式,重复绘制边界颜色 Clamp, ///< 夹模式,重复绘制边界颜色
Wrap, ///< 包裹模式,重复画笔内容 Wrap, ///< 包裹模式,重复画笔内容
Mirror ///< 镜像模式,反转画笔内容 Mirror ///< 镜像模式,反转画笔内容
}; };
/// \~chinese /// \~chinese
/// @brief 线性渐变样式 /// @brief 线性渐变样式
struct LinearGradientStyle struct LinearGradientStyle
{ {
Point begin; ///< 渐变起始点 Point begin; ///< 渐变起始点
Point end; ///< 渐变终止点 Point end; ///< 渐变终止点
Vector<GradientStop> stops; ///< 渐变转换点集合 Vector<GradientStop> stops; ///< 渐变转换点集合
GradientExtendMode extend_mode; ///< 渐变扩充模式 GradientExtendMode extend_mode; ///< 渐变扩充模式
LinearGradientStyle(const Point& begin, const Point& end, const Vector<GradientStop>& stops, LinearGradientStyle(const Point& begin, const Point& end, const Vector<GradientStop>& stops,
GradientExtendMode extend_mode = GradientExtendMode::Clamp); GradientExtendMode extend_mode = GradientExtendMode::Clamp);
}; };
/// \~chinese /// \~chinese
/// @brief 径向渐变样式 /// @brief 径向渐变样式
struct RadialGradientStyle struct RadialGradientStyle
{ {
Point center; ///< 径向渐变圆心 Point center; ///< 径向渐变圆心
Vec2 offset; ///< 径向渐变偏移 Vec2 offset; ///< 径向渐变偏移
Vec2 radius; ///< 径向渐变半径 Vec2 radius; ///< 径向渐变半径
Vector<GradientStop> stops; ///< 渐变转换点集合 Vector<GradientStop> stops; ///< 渐变转换点集合
GradientExtendMode extend_mode; ///< 渐变扩充模式 GradientExtendMode extend_mode; ///< 渐变扩充模式
RadialGradientStyle(const Point& center, const Vec2& offset, const Vec2& radius, const Vector<GradientStop>& stops, RadialGradientStyle(const Point& center, const Vec2& offset, const Vec2& radius, const Vector<GradientStop>& stops,
GradientExtendMode extend_mode = GradientExtendMode::Clamp); GradientExtendMode extend_mode = GradientExtendMode::Clamp);
@ -83,66 +83,66 @@ struct RadialGradientStyle
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Brush : public NativeObject class KGE_API Brush : public NativeObject
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建纯色画刷 /// @brief 创建纯色画刷
/// @param color 画刷颜色 /// @param color 画刷颜色
static BrushPtr Create(const Color& color); static BrushPtr Create(const Color& color);
/// \~chinese /// \~chinese
/// @brief 创建线性渐变样式 /// @brief 创建线性渐变样式
/// @param style 线性渐变样式 /// @param style 线性渐变样式
static BrushPtr Create(const LinearGradientStyle& style); static BrushPtr Create(const LinearGradientStyle& style);
/// \~chinese /// \~chinese
/// @brief 创建径向渐变样式 /// @brief 创建径向渐变样式
/// @param style 径向渐变样式 /// @param style 径向渐变样式
static BrushPtr Create(const RadialGradientStyle& style); static BrushPtr Create(const RadialGradientStyle& style);
Brush(); Brush();
/// \~chinese /// \~chinese
/// @brief 设置纯色画刷颜色 /// @brief 设置纯色画刷颜色
void SetColor(const Color& color); void SetColor(const Color& color);
/// \~chinese /// \~chinese
/// @brief 设置线性渐变样式 /// @brief 设置线性渐变样式
void SetStyle(const LinearGradientStyle& style); void SetStyle(const LinearGradientStyle& style);
/// \~chinese /// \~chinese
/// @brief 设置径向渐变样式 /// @brief 设置径向渐变样式
void SetStyle(const RadialGradientStyle& style); void SetStyle(const RadialGradientStyle& style);
/// \~chinese /// \~chinese
/// @brief 设置纹理 /// @brief 设置纹理
void SetTexture(TexturePtr texture); void SetTexture(TexturePtr texture);
/// \~chinese /// \~chinese
/// @brief 设置二维变换 /// @brief 设置二维变换
void SetTransform(const Transform& transform); void SetTransform(const Transform& transform);
/// \~chinese /// \~chinese
/// @brief 设置二维变换 /// @brief 设置二维变换
void SetTransform(const Matrix3x2& transform); void SetTransform(const Matrix3x2& transform);
public: public:
/// \~chinese /// \~chinese
/// @brief 画刷类型 /// @brief 画刷类型
enum class Type enum class Type
{ {
None, None,
SolidColor, ///< 纯色填充画刷 SolidColor, ///< 纯色填充画刷
LinearGradient, ///< 线性渐变画刷 LinearGradient, ///< 线性渐变画刷
RadialGradient, ///< 径向渐变画刷 RadialGradient, ///< 径向渐变画刷
Texture ///< 纹理画刷 Texture ///< 纹理画刷
}; };
/// \~chinese /// \~chinese
/// @brief 获取画刷类型 /// @brief 获取画刷类型
Type GetType() const; Type GetType() const;
private: private:

View File

@ -31,46 +31,46 @@ namespace kiwano
/* /*
* \~chinese * \~chinese
* @brief * @brief
* @details * @details
* 使: @code Color blue = Color::Blue; @endcode * 使: @code Color blue = Color::Blue; @endcode
* 使 RGB : @code Color red = Color(1.0f, 0.0f, 0.0f); @endcode * 使 RGB : @code Color red = Color(1.0f, 0.0f, 0.0f); @endcode
* 使 RGBA : @code Color not_white = Color(1.0f, 1.0f, * 使 RGBA : @code Color not_white = Color(1.0f, 1.0f,
* 1.0f, 0.5f); @endcode * 1.0f, 0.5f); @endcode
* 使16 RGB : @code Color black(0x000000); @endcode * 使16 RGB : @code Color black(0x000000); @endcode
*/ */
class KGE_API Color class KGE_API Color
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 构造颜色 /// @brief 构造颜色
/// @details 默认颜色为 R: 0.0, G: 0.0, B: 0.0, A: 1.0 /// @details 默认颜色为 R: 0.0, G: 0.0, B: 0.0, A: 1.0
Color(); Color();
/// \~chinese /// \~chinese
/// @brief 构造 RGB 颜色 /// @brief 构造 RGB 颜色
/// @param r 红色值,范围 0.0 - 1.0 /// @param r 红色值,范围 0.0 - 1.0
/// @param g 绿色值,范围 0.0 - 1.0 /// @param g 绿色值,范围 0.0 - 1.0
/// @param b 蓝色值,范围 0.0 - 1.0 /// @param b 蓝色值,范围 0.0 - 1.0
Color(float r, float g, float b); Color(float r, float g, float b);
/// \~chinese /// \~chinese
/// @brief 构造 RGBA 颜色 /// @brief 构造 RGBA 颜色
/// @param r 红色值,范围 0.0 - 1.0 /// @param r 红色值,范围 0.0 - 1.0
/// @param g 绿色值,范围 0.0 - 1.0 /// @param g 绿色值,范围 0.0 - 1.0
/// @param b 蓝色值,范围 0.0 - 1.0 /// @param b 蓝色值,范围 0.0 - 1.0
/// @param a Alpha值范围 0.0 - 1.0 /// @param a Alpha值范围 0.0 - 1.0
Color(float r, float g, float b, float alpha); Color(float r, float g, float b, float alpha);
/// \~chinese /// \~chinese
/// @brief 构造 RGB 颜色 /// @brief 构造 RGB 颜色
/// @param rgb 使用16进制整形值表示 RGB颜色 /// @param rgb 使用16进制整形值表示 RGB颜色
Color(uint32_t rgb); Color(uint32_t rgb);
/// \~chinese /// \~chinese
/// @brief 构造 RGBA 颜色 /// @brief 构造 RGBA 颜色
/// @param rgb 使用16进制整形值表示 RGB 颜色 /// @param rgb 使用16进制整形值表示 RGB 颜色
/// @param a Alpha值范围 0.0 - 1.0 /// @param a Alpha值范围 0.0 - 1.0
Color(uint32_t rgb, float alpha); Color(uint32_t rgb, float alpha);
bool operator==(const Color& rhs) const; bool operator==(const Color& rhs) const;
@ -79,7 +79,7 @@ public:
public: public:
/// \~chinese /// \~chinese
/// @brief 常见颜色枚举 /// @brief 常见颜色枚举
enum Value : uint32_t enum Value : uint32_t
{ {
Black = 0x000000, Black = 0x000000,
@ -124,14 +124,14 @@ public:
}; };
/// \~chinese /// \~chinese
/// @brief 透明色 /// @brief 透明色
static const Color Transparent; static const Color Transparent;
public: public:
float r; ///< 红色值 float r; ///< 红色值
float g; ///< 绿色值 float g; ///< 绿色值
float b; ///< 蓝色值 float b; ///< 蓝色值
float a; ///< Alpha值 float a; ///< Alpha值
}; };
/** @} */ /** @} */

View File

@ -159,7 +159,8 @@ HRESULT STDMETHODCALLTYPE FontCollectionLoader::CreateEnumeratorFromKey(
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
*fontFileEnumerator = DX::SafeAcquire(pEnumerator); DX::SafeRelease(*fontFileEnumerator);
(*fontFileEnumerator) = pEnumerator;
} }
} }
return hr; return hr;
@ -468,7 +469,8 @@ HRESULT STDMETHODCALLTYPE ResourceFontCollectionLoader::CreateEnumeratorFromKey(
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
*fontFileEnumerator = DX::SafeAcquire(pEnumerator); DX::SafeRelease(*fontFileEnumerator);
(*fontFileEnumerator) = pEnumerator;
} }
} }
return hr; return hr;
@ -574,7 +576,7 @@ HRESULT STDMETHODCALLTYPE ResourceFontFileLoader::CreateStreamFromKey(void const
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
DX::SafeRelease(*fontFileStream); DX::SafeRelease(*fontFileStream);
*fontFileStream = DX::SafeAcquire(pFileStream); (*fontFileStream) = pFileStream;
} }
} }
return hr; return hr;

View File

@ -88,15 +88,15 @@ public:
void Present() override; void Present() override;
/// \~chinese /// \~chinese
/// @brief 获取Direct2D设备资源 /// @brief 获取Direct2D设备资源
ID2DDeviceResources* GetD2DDeviceResources(); ID2DDeviceResources* GetD2DDeviceResources();
/// \~chinese /// \~chinese
/// @brief 获取Direct3D设备资源 /// @brief 获取Direct3D设备资源
ID3DDeviceResources* GetD3DDeviceResources(); ID3DDeviceResources* GetD3DDeviceResources();
/// \~chinese /// \~chinese
/// @brief 重设渲染输出大小 /// @brief 重设渲染输出大小
void Resize(uint32_t width, uint32_t height) override; void Resize(uint32_t width, uint32_t height) override;
protected: protected:

View File

@ -35,7 +35,7 @@ class Renderer;
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class Font : public NativeObject class Font : public NativeObject
{ {
@ -43,21 +43,21 @@ class Font : public NativeObject
public: public:
/// \~chinese /// \~chinese
/// @brief 创建字体 /// @brief 创建字体
static FontPtr Create(const String& file); static FontPtr Create(const String& file);
/// \~chinese /// \~chinese
/// @brief 创建字体 /// @brief 创建字体
static FontPtr Create(const Resource& resource); static FontPtr Create(const Resource& resource);
Font(); Font();
/// \~chinese /// \~chinese
/// @brief 加载字体文件 /// @brief 加载字体文件
bool Load(const String& file); bool Load(const String& file);
/// \~chinese /// \~chinese
/// @brief 加载字体资源 /// @brief 加载字体资源
bool Load(const Resource& resource); bool Load(const Resource& resource);
}; };

View File

@ -121,10 +121,10 @@ bool GifImage::GetGlobalMetadata()
PROPVARIANT prop_val; PROPVARIANT prop_val;
::PropVariantInit(&prop_val); ::PropVariantInit(&prop_val);
// 获取全局 frame 大小 // 获取全局 frame 大小
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
// 获取宽度 // 获取宽度
hr = metadata_reader->GetMetadataByName(L"/logscrdesc/Width", &prop_val); hr = metadata_reader->GetMetadataByName(L"/logscrdesc/Width", &prop_val);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
@ -140,7 +140,7 @@ bool GifImage::GetGlobalMetadata()
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
// 获取高度 // 获取高度
hr = metadata_reader->GetMetadataByName(L"/logscrdesc/Height", &prop_val); hr = metadata_reader->GetMetadataByName(L"/logscrdesc/Height", &prop_val);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
@ -156,7 +156,7 @@ bool GifImage::GetGlobalMetadata()
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
// 获得像素纵横比 // 获得像素纵横比
hr = metadata_reader->GetMetadataByName(L"/logscrdesc/PixelAspectRatio", &prop_val); hr = metadata_reader->GetMetadataByName(L"/logscrdesc/PixelAspectRatio", &prop_val);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
@ -166,11 +166,11 @@ bool GifImage::GetGlobalMetadata()
{ {
if (prop_val.bVal != 0) if (prop_val.bVal != 0)
{ {
// 需要计算比率 // 需要计算比率
// 最高像素 14最宽像素 41增量为 1/64 // 最高像素 14最宽像素 41增量为 1/64
float pixel_asp_ratio = (prop_val.bVal + 15.f) / 64.f; float pixel_asp_ratio = (prop_val.bVal + 15.f) / 64.f;
// 根据像素长宽比计算像素中的图像宽度和高度,只缩小图像 // 根据像素长宽比计算像素中的图像宽度和高度,只缩小图像
if (pixel_asp_ratio > 1.f) if (pixel_asp_ratio > 1.f)
{ {
size_in_pixels_ = { width, static_cast<uint32_t>(height / pixel_asp_ratio) }; size_in_pixels_ = { width, static_cast<uint32_t>(height / pixel_asp_ratio) };
@ -182,7 +182,7 @@ bool GifImage::GetGlobalMetadata()
} }
else else
{ {
// 值为 0, 所以像素比为 1 // 值为 0, 所以像素比为 1
size_in_pixels_ = { width, height }; size_in_pixels_ = { width, height };
} }
} }

View File

@ -33,71 +33,71 @@ KGE_DECLARE_SMART_PTR(GifImage);
/** /**
* \~chinese * \~chinese
* @brief GIF图像 * @brief GIF图像
*/ */
class KGE_API GifImage : public NativeObject class KGE_API GifImage : public NativeObject
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建GIF图片 /// @brief 创建GIF图片
static GifImagePtr Create(const String& file_path); static GifImagePtr Create(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 创建GIF图片 /// @brief 创建GIF图片
static GifImagePtr Create(const Resource& res); static GifImagePtr Create(const Resource& res);
GifImage(); GifImage();
/// \~chinese /// \~chinese
/// @brief 加载本地GIF图片 /// @brief 加载本地GIF图片
bool Load(const String& file_path); bool Load(const String& file_path);
/// \~chinese /// \~chinese
/// @brief 加载GIF资源 /// @brief 加载GIF资源
bool Load(const Resource& res); bool Load(const Resource& res);
/// \~chinese /// \~chinese
/// @brief 获取像素宽度 /// @brief 获取像素宽度
uint32_t GetWidthInPixels() const; uint32_t GetWidthInPixels() const;
/// \~chinese /// \~chinese
/// @brief 获取像素高度 /// @brief 获取像素高度
uint32_t GetHeightInPixels() const; uint32_t GetHeightInPixels() const;
/// \~chinese /// \~chinese
/// @brief 获取像素大小 /// @brief 获取像素大小
PixelSize GetSizeInPixels() const; PixelSize GetSizeInPixels() const;
/// \~chinese /// \~chinese
/// @brief 获取帧数量 /// @brief 获取帧数量
uint32_t GetFramesCount() const; uint32_t GetFramesCount() const;
public: public:
/// \~chinese /// \~chinese
/// @brief GIF帧的处置方式 /// @brief GIF帧的处置方式
enum class DisposalType enum class DisposalType
{ {
Unknown, ///< 未知 Unknown, ///< 未知
None, ///< 不处理 None, ///< 不处理
Background, ///< 背景 Background, ///< 背景
Previous ///< 恢复前一帧 Previous ///< 恢复前一帧
}; };
/// \~chinese /// \~chinese
/// @brief GIF帧 /// @brief GIF帧
struct Frame struct Frame
{ {
Duration delay; ///< 帧延迟 Duration delay; ///< 帧延迟
TexturePtr texture; ///< 帧图像 TexturePtr texture; ///< 帧图像
Rect rect; ///< 绘制区域 Rect rect; ///< 绘制区域
DisposalType disposal_type; ///< 处置方式 DisposalType disposal_type; ///< 处置方式
Frame(); Frame();
}; };
/// \~chinese /// \~chinese
/// @brief 获取GIF帧 /// @brief 获取GIF帧
/// @param index 帧下标 /// @param index 帧下标
Frame GetFrame(uint32_t index); Frame GetFrame(uint32_t index);
private: private:

View File

@ -33,7 +33,7 @@ KGE_DECLARE_SMART_PTR(Layer);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Layer : public NativeObject class KGE_API Layer : public NativeObject
{ {
@ -41,35 +41,35 @@ public:
Layer(); Layer();
/// \~chinese /// \~chinese
/// @brief 获取图层裁剪区域 /// @brief 삿혤暠꿔꼴숏혐堵
const Rect& GetClipRect() const; const Rect& GetClipRect() const;
/// \~chinese /// \~chinese
/// @brief 获取图层透明度 /// @brief 삿혤暠꿔拷츠똑
float GetOpacity() const; float GetOpacity() const;
/// \~chinese /// \~chinese
/// @brief 获取几何蒙层 /// @brief 삿혤섯부촁꿔
ShapePtr GetMaskShape() const; ShapePtr GetMaskShape() const;
/// \~chinese /// \~chinese
/// @brief 获取几何蒙层变换 /// @brief 삿혤섯부촁꿔긴뻣
const Matrix3x2& GetMaskTransform() const; const Matrix3x2& GetMaskTransform() const;
/// \~chinese /// \~chinese
/// @brief 设置图层裁剪区域 /// @brief <EFBFBD>零暠꿔꼴숏혐堵
void SetClipRect(const Rect& rect); void SetClipRect(const Rect& rect);
/// \~chinese /// \~chinese
/// @brief 设置图层透明度 /// @brief <EFBFBD>零暠꿔拷츠똑
void SetOpacity(float opacity); void SetOpacity(float opacity);
/// \~chinese /// \~chinese
/// @brief 设置几何蒙层 /// @brief <EFBFBD>零섯부촁꿔
void SetMaskShape(ShapePtr mask); void SetMaskShape(ShapePtr mask);
/// \~chinese /// \~chinese
/// @brief 设置几何蒙层变换 /// @brief <EFBFBD>零섯부촁꿔긴뻣
void SetMaskTransform(const Matrix3x2& matrix); void SetMaskTransform(const Matrix3x2& matrix);
private: private:

View File

@ -37,7 +37,7 @@ KGE_DECLARE_SMART_PTR(NativeObject);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API NativeObject : public ObjectBase class KGE_API NativeObject : public ObjectBase
{ {

View File

@ -37,218 +37,218 @@ KGE_DECLARE_SMART_PTR(RenderContext);
*/ */
/// \~chinese /// \~chinese
/// @brief 文字抗锯齿模式 /// @brief 文字抗锯齿模式
enum class TextAntialiasMode enum class TextAntialiasMode
{ {
Default, ///< 系统默认 Default, ///< 系统默认
ClearType, ///< ClearType 抗锯齿 ClearType, ///< ClearType 抗锯齿
GrayScale, ///< 灰度抗锯齿 GrayScale, ///< 灰度抗锯齿
None ///< 不启用抗锯齿 None ///< 不启用抗锯齿
}; };
/// \~chinese /// \~chinese
/// @brief 渲染上下文 /// @brief 渲染上下文
/// @details 渲染上下文将完成基础图元的绘制,并将绘制结果输出到特定的平面中 /// @details 渲染上下文将完成基础图元的绘制,并将绘制结果输出到特定的平面中
class KGE_API RenderContext : public NativeObject class KGE_API RenderContext : public NativeObject
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中 /// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中
/// @param texture 保存绘制结果的纹理 /// @param texture 保存绘制结果的纹理
static RenderContextPtr Create(Texture& texture); static RenderContextPtr Create(Texture& texture);
/// \~chinese /// \~chinese
/// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中 /// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中
/// @param texture 保存绘制结果的纹理 /// @param texture 保存绘制结果的纹理
/// @param size 渲染输出大小 /// @param size 渲染输出大小
static RenderContextPtr Create(Texture& texture, const Size& size); static RenderContextPtr Create(Texture& texture, const Size& size);
/// \~chinese /// \~chinese
/// @brief 开始渲染 /// @brief 开始渲染
virtual void BeginDraw(); virtual void BeginDraw();
/// \~chinese /// \~chinese
/// @brief 结束渲染 /// @brief 结束渲染
virtual void EndDraw(); virtual void EndDraw();
/// \~chinese /// \~chinese
/// @brief 绘制纹理 /// @brief 绘制纹理
/// @param texture 纹理 /// @param texture 纹理
/// @param src_rect 源纹理裁剪矩形 /// @param src_rect 源纹理裁剪矩形
/// @param dest_rect 绘制的目标区域 /// @param dest_rect 绘制的目标区域
virtual void DrawTexture(const Texture& texture, const Rect* src_rect = nullptr, virtual void DrawTexture(const Texture& texture, const Rect* src_rect = nullptr,
const Rect* dest_rect = nullptr) = 0; const Rect* dest_rect = nullptr) = 0;
/// \~chinese /// \~chinese
/// @brief 绘制文本布局 /// @brief 绘制文本布局
/// @param layout 文本布局 /// @param layout 文本布局
/// @param offset 偏移量 /// @param offset 偏移量
virtual void DrawTextLayout(const TextLayout& layout, const Point& offset = Point()) = 0; virtual void DrawTextLayout(const TextLayout& layout, const Point& offset = Point()) = 0;
/// \~chinese /// \~chinese
/// @brief 绘制形状轮廓 /// @brief 绘制形状轮廓
/// @param shape 形状 /// @param shape 形状
virtual void DrawShape(const Shape& shape) = 0; virtual void DrawShape(const Shape& shape) = 0;
/// \~chinese /// \~chinese
/// @brief 绘制线段 /// @brief 绘制线段
/// @param point1 线段起点 /// @param point1 线段起点
/// @param point2 线段终点 /// @param point2 线段终点
virtual void DrawLine(const Point& point1, const Point& point2) = 0; virtual void DrawLine(const Point& point1, const Point& point2) = 0;
/// \~chinese /// \~chinese
/// @brief 绘制矩形边框 /// @brief 绘制矩形边框
/// @param rect 矩形 /// @param rect 矩形
virtual void DrawRectangle(const Rect& rect) = 0; virtual void DrawRectangle(const Rect& rect) = 0;
/// \~chinese /// \~chinese
/// @brief 绘制圆角矩形边框 /// @brief 绘制圆角矩形边框
/// @param rect 矩形 /// @param rect 矩形
/// @param radius 圆角半径 /// @param radius 圆角半径
virtual void DrawRoundedRectangle(const Rect& rect, const Vec2& radius) = 0; virtual void DrawRoundedRectangle(const Rect& rect, const Vec2& radius) = 0;
/// \~chinese /// \~chinese
/// @brief 绘制椭圆边框 /// @brief 绘制椭圆边框
/// @param center 圆心 /// @param center 圆心
/// @param radius 椭圆半径 /// @param radius 椭圆半径
virtual void DrawEllipse(const Point& center, const Vec2& radius) = 0; virtual void DrawEllipse(const Point& center, const Vec2& radius) = 0;
/// \~chinese /// \~chinese
/// @brief 填充形状 /// @brief 填充形状
/// @param shape 形状 /// @param shape 形状
virtual void FillShape(const Shape& shape) = 0; virtual void FillShape(const Shape& shape) = 0;
/// \~chinese /// \~chinese
/// @brief 填充矩形 /// @brief 填充矩形
/// @param rect 矩形 /// @param rect 矩形
virtual void FillRectangle(const Rect& rect) = 0; virtual void FillRectangle(const Rect& rect) = 0;
/// \~chinese /// \~chinese
/// @brief 填充圆角矩形 /// @brief 填充圆角矩形
/// @param rect 矩形 /// @param rect 矩形
/// @param radius 圆角半径 /// @param radius 圆角半径
virtual void FillRoundedRectangle(const Rect& rect, const Vec2& radius) = 0; virtual void FillRoundedRectangle(const Rect& rect, const Vec2& radius) = 0;
/// \~chinese /// \~chinese
/// @brief 填充椭圆 /// @brief 填充椭圆
/// @param center 圆心 /// @param center 圆心
/// @param radius 椭圆半径 /// @param radius 椭圆半径
virtual void FillEllipse(const Point& center, const Vec2& radius) = 0; virtual void FillEllipse(const Point& center, const Vec2& radius) = 0;
/// \~chinese /// \~chinese
/// @brief 创建纹理 /// @brief 创建纹理
/// @param texture 纹理 /// @param texture 纹理
/// @param size 纹理像素大小 /// @param size 纹理像素大小
virtual void CreateTexture(Texture& texture, math::Vec2T<uint32_t> size) = 0; virtual void CreateTexture(Texture& texture, math::Vec2T<uint32_t> size) = 0;
/// \~chinese /// \~chinese
/// @brief 设置绘制的裁剪区域 /// @brief 设置绘制的裁剪区域
/// @param clip_rect 裁剪矩形 /// @param clip_rect 裁剪矩形
virtual void PushClipRect(const Rect& clip_rect) = 0; virtual void PushClipRect(const Rect& clip_rect) = 0;
/// \~chinese /// \~chinese
/// @brief 取消上一次设置的绘制裁剪区域 /// @brief 取消上一次设置的绘制裁剪区域
virtual void PopClipRect() = 0; virtual void PopClipRect() = 0;
/// \~chinese /// \~chinese
/// @brief 设置图层区域 /// @brief 设置图层区域
/// @param layer 图层区域 /// @param layer 图层区域
virtual void PushLayer(Layer& layer) = 0; virtual void PushLayer(Layer& layer) = 0;
/// \~chinese /// \~chinese
/// @brief 取消上一次设置的图层区域 /// @brief 取消上一次设置的图层区域
virtual void PopLayer() = 0; virtual void PopLayer() = 0;
/// \~chinese /// \~chinese
/// @brief 清空渲染内容 /// @brief 清空渲染内容
virtual void Clear() = 0; virtual void Clear() = 0;
/// \~chinese /// \~chinese
/// @brief 使用纯色清空渲染内容 /// @brief 使用纯色清空渲染内容
/// @param clear_color 清屏颜色 /// @param clear_color 清屏颜色
virtual void Clear(const Color& clear_color) = 0; virtual void Clear(const Color& clear_color) = 0;
/// \~chinese /// \~chinese
/// @brief 获取渲染区域大小 /// @brief 获取渲染区域大小
virtual Size GetSize() const = 0; virtual Size GetSize() const = 0;
/// \~chinese /// \~chinese
/// @brief 获取画刷透明度 /// @brief 获取画刷透明度
virtual float GetBrushOpacity() const; virtual float GetBrushOpacity() const;
/// \~chinese /// \~chinese
/// @brief 获取当前画刷 /// @brief 获取当前画刷
virtual BrushPtr GetCurrentBrush() const; virtual BrushPtr GetCurrentBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取全局二维变换 /// @brief 获取全局二维变换
virtual const Matrix3x2& GetGlobalTransform() const; virtual const Matrix3x2& GetGlobalTransform() const;
/// \~chinese /// \~chinese
/// @brief 设置画刷透明度 /// @brief 设置画刷透明度
virtual void SetBrushOpacity(float opacity); virtual void SetBrushOpacity(float opacity);
/// \~chinese /// \~chinese
/// @brief 设置当前使用的画刷 /// @brief 设置当前使用的画刷
virtual void SetCurrentBrush(BrushPtr brush); virtual void SetCurrentBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置当前使用的线条样式 /// @brief 设置当前使用的线条样式
virtual void SetCurrentStrokeStyle(StrokeStylePtr stroke); virtual void SetCurrentStrokeStyle(StrokeStylePtr stroke);
/// \~chinese /// \~chinese
/// @brief 设置抗锯齿模式 /// @brief 设置抗锯齿模式
virtual void SetAntialiasMode(bool enabled) = 0; virtual void SetAntialiasMode(bool enabled) = 0;
/// \~chinese /// \~chinese
/// @brief 设置文字抗锯齿模式 /// @brief 设置文字抗锯齿模式
virtual void SetTextAntialiasMode(TextAntialiasMode mode) = 0; virtual void SetTextAntialiasMode(TextAntialiasMode mode) = 0;
/// \~chinese /// \~chinese
/// @brief 检查边界是否在视区内 /// @brief 检查边界是否在视区内
virtual bool CheckVisibility(const Rect& bounds, const Matrix3x2& transform) = 0; virtual bool CheckVisibility(const Rect& bounds, const Matrix3x2& transform) = 0;
/// \~chinese /// \~chinese
/// @brief 重设渲染上下文大小 /// @brief 重设渲染上下文大小
virtual void Resize(const Size& size) = 0; virtual void Resize(const Size& size) = 0;
/// \~chinese /// \~chinese
/// @brief 设置上下文的二维变换 /// @brief 设置上下文的二维变换
virtual void SetTransform(const Matrix3x2& matrix) = 0; virtual void SetTransform(const Matrix3x2& matrix) = 0;
/// \~chinese /// \~chinese
/// @brief 设置全局二维变换 /// @brief 设置全局二维变换
virtual void SetGlobalTransform(const Matrix3x2& matrix); virtual void SetGlobalTransform(const Matrix3x2& matrix);
/// \~chinese /// \~chinese
/// @brief 设置全局二维变换 /// @brief 设置全局二维变换
virtual void SetGlobalTransform(const Matrix3x2* matrix); virtual void SetGlobalTransform(const Matrix3x2* matrix);
public: public:
/// \~chinese /// \~chinese
/// @brief 渲染上下文状态 /// @brief 渲染上下文状态
struct Status struct Status
{ {
uint32_t primitives; ///< 渲染图元数量 uint32_t primitives; ///< 渲染图元数量
Time start; ///< 渲染起始时间 Time start; ///< 渲染起始时间
Duration duration; ///< 渲染时长 Duration duration; ///< 渲染时长
Status(); Status();
}; };
/// \~chinese /// \~chinese
/// @brief 启用或禁用状态收集功能 /// @brief 启用或禁用状态收集功能
void SetCollectingStatus(bool enable); void SetCollectingStatus(bool enable);
/// \~chinese /// \~chinese
/// @brief 获取渲染上下文状态 /// @brief 获取渲染上下文状态
const Status& GetStatus() const; const Status& GetStatus() const;
protected: protected:
RenderContext(); RenderContext();
/// \~chinese /// \~chinese
/// @brief 增加渲染图元数量 /// @brief 增加渲染图元数量
void IncreasePrimitivesCount(uint32_t increase = 1) const; void IncreasePrimitivesCount(uint32_t increase = 1) const;
protected: protected:

View File

@ -31,7 +31,7 @@ namespace kiwano
/** /**
* \~chinese * \~chinese
* \defgroup Render * \defgroup Render
*/ */
/** /**
@ -41,197 +41,197 @@ namespace kiwano
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Renderer : public EventModule class KGE_API Renderer : public EventModule
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 获取实例 /// @brief 获取实例
static Renderer& GetInstance(); static Renderer& GetInstance();
/// \~chinese /// \~chinese
/// @brief 获取清屏颜色 /// @brief 获取清屏颜色
virtual Color GetClearColor() const; virtual Color GetClearColor() const;
/// \~chinese /// \~chinese
/// @brief 设置清屏颜色 /// @brief 设置清屏颜色
virtual void SetClearColor(const Color& clear_color); virtual void SetClearColor(const Color& clear_color);
/// \~chinese /// \~chinese
/// @brief 开启或关闭垂直同步 /// @brief 开启或关闭垂直同步
virtual void SetVSyncEnabled(bool enabled); virtual void SetVSyncEnabled(bool enabled);
/// \~chinese /// \~chinese
/// @brief 创建纹理内部资源 /// @brief 创建纹理内部资源
/// @param[out] texture 纹理 /// @param[out] texture 纹理
/// @param[in] file_path 图片路径 /// @param[in] file_path 图片路径
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateTexture(Texture& texture, const String& file_path) = 0; virtual void CreateTexture(Texture& texture, const String& file_path) = 0;
/// \~chinese /// \~chinese
/// @brief 创建纹理内部资源 /// @brief 创建纹理内部资源
/// @param[out] texture 纹理 /// @param[out] texture 纹理
/// @param[in] resource 图片资源 /// @param[in] resource 图片资源
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateTexture(Texture& texture, const Resource& resource) = 0; virtual void CreateTexture(Texture& texture, const Resource& resource) = 0;
/// \~chinese /// \~chinese
/// @brief 创建GIF图像内部资源 /// @brief 创建GIF图像内部资源
/// @param[out] gif GIF图像 /// @param[out] gif GIF图像
/// @param[in] file_path 图片路径 /// @param[in] file_path 图片路径
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateGifImage(GifImage& gif, const String& file_path) = 0; virtual void CreateGifImage(GifImage& gif, const String& file_path) = 0;
/// \~chinese /// \~chinese
/// @brief 创建GIF图像内部资源 /// @brief 创建GIF图像内部资源
/// @param[out] gif GIF图像 /// @param[out] gif GIF图像
/// @param[in] resource 图片资源 /// @param[in] resource 图片资源
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateGifImage(GifImage& gif, const Resource& resource) = 0; virtual void CreateGifImage(GifImage& gif, const Resource& resource) = 0;
/// \~chinese /// \~chinese
/// @brief 创建GIF图像帧内部资源 /// @brief 创建GIF图像帧内部资源
/// @param[out] frame GIF图像帧 /// @param[out] frame GIF图像帧
/// @param[in] gif GIF图像 /// @param[in] gif GIF图像
/// @param[in] frame_index 帧下标 /// @param[in] frame_index 帧下标
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateGifImageFrame(GifImage::Frame& frame, const GifImage& gif, size_t frame_index) = 0; virtual void CreateGifImageFrame(GifImage::Frame& frame, const GifImage& gif, size_t frame_index) = 0;
/// \~chinese /// \~chinese
/// @brief 创建字体集内部资源 /// @brief 创建字体集内部资源
/// @param[out] font 字体 /// @param[out] font 字体
/// @param[in] file_paths 字体文件路径 /// @param[in] file_paths 字体文件路径
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateFontCollection(Font& font, const String& file_path) = 0; virtual void CreateFontCollection(Font& font, const String& file_path) = 0;
/// \~chinese /// \~chinese
/// @brief 创建字体集内部资源 /// @brief 创建字体集内部资源
/// @param[out] font 字体 /// @param[out] font 字体
/// @param[in] res_arr 字体资源 /// @param[in] res_arr 字体资源
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateFontCollection(Font& font, const Resource& res) = 0; virtual void CreateFontCollection(Font& font, const Resource& res) = 0;
/// \~chinese /// \~chinese
/// @brief 创建文字布局内部资源 /// @brief 创建文字布局内部资源
/// @param[out] layout 字体布局 /// @param[out] layout 字体布局
/// @param text 文字内容 /// @param text 文字内容
/// @param style 文本样式 /// @param style 文本样式
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateTextLayout(TextLayout& layout, const String& content, const TextStyle& style) = 0; virtual void CreateTextLayout(TextLayout& layout, const String& content, const TextStyle& style) = 0;
/// \~chinese /// \~chinese
/// @brief 创建线段形状内部资源 /// @brief 创建线段形状内部资源
/// @param[out] shape 形状 /// @param[out] shape 形状
/// @param[in] begin_pos 线段起点 /// @param[in] begin_pos 线段起点
/// @param[in] end_pos 线段终点 /// @param[in] end_pos 线段终点
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateLineShape(Shape& shape, const Point& begin_pos, const Point& end_pos) = 0; virtual void CreateLineShape(Shape& shape, const Point& begin_pos, const Point& end_pos) = 0;
/// \~chinese /// \~chinese
/// @brief 创建矩形形状内部资源 /// @brief 创建矩形形状内部资源
/// @param[out] shape 形状 /// @param[out] shape 形状
/// @param[in] rect 矩形大小 /// @param[in] rect 矩形大小
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateRectShape(Shape& shape, const Rect& rect) = 0; virtual void CreateRectShape(Shape& shape, const Rect& rect) = 0;
/// \~chinese /// \~chinese
/// @brief 创建圆角矩形形状内部资源 /// @brief 创建圆角矩形形状内部资源
/// @param[out] shape 形状 /// @param[out] shape 形状
/// @param[in] rect 矩形大小 /// @param[in] rect 矩形大小
/// @param[in] radius 圆角半径 /// @param[in] radius 圆角半径
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateRoundedRectShape(Shape& shape, const Rect& rect, const Vec2& radius) = 0; virtual void CreateRoundedRectShape(Shape& shape, const Rect& rect, const Vec2& radius) = 0;
/// \~chinese /// \~chinese
/// @brief 创建椭圆形状内部资源 /// @brief 创建椭圆形状内部资源
/// @param[out] shape 形状 /// @param[out] shape 形状
/// @param[in] center 椭圆圆心 /// @param[in] center 椭圆圆心
/// @param[in] radius 椭圆半径 /// @param[in] radius 椭圆半径
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateEllipseShape(Shape& shape, const Point& center, const Vec2& radius) = 0; virtual void CreateEllipseShape(Shape& shape, const Point& center, const Vec2& radius) = 0;
/// \~chinese /// \~chinese
/// @brief 创建几何图形生成器内部资源 /// @brief 创建几何图形生成器内部资源
/// @param[out] maker 形状生成器 /// @param[out] maker 形状生成器
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateShapeSink(ShapeMaker& maker) = 0; virtual void CreateShapeSink(ShapeMaker& maker) = 0;
/// \~chinese /// \~chinese
/// @brief 创建纯色画刷内部资源 /// @brief 创建纯色画刷内部资源
/// @param[out] brush 画刷 /// @param[out] brush 画刷
/// @param[in] color 颜色 /// @param[in] color 颜色
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, const Color& color) = 0; virtual void CreateBrush(Brush& brush, const Color& color) = 0;
/// \~chinese /// \~chinese
/// @brief 创建线性渐变画刷内部资源 /// @brief 创建线性渐变画刷内部资源
/// @param[out] brush 画刷 /// @param[out] brush 画刷
/// @param[in] style 线性渐变样式 /// @param[in] style 线性渐变样式
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, const LinearGradientStyle& style) = 0; virtual void CreateBrush(Brush& brush, const LinearGradientStyle& style) = 0;
/// \~chinese /// \~chinese
/// @brief 创建径向渐变画刷内部资源 /// @brief 创建径向渐变画刷内部资源
/// @param[out] brush 画刷 /// @param[out] brush 画刷
/// @param[in] style 径向渐变样式 /// @param[in] style 径向渐变样式
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, const RadialGradientStyle& style) = 0; virtual void CreateBrush(Brush& brush, const RadialGradientStyle& style) = 0;
/// \~chinese /// \~chinese
/// @brief 创建纹理画刷内部资源 /// @brief 创建纹理画刷内部资源
/// @param[out] brush 画刷 /// @param[out] brush 画刷
/// @param[in] texture 纹理 /// @param[in] texture 纹理
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, TexturePtr texture) = 0; virtual void CreateBrush(Brush& brush, TexturePtr texture) = 0;
/// \~chinese /// \~chinese
/// @brief 创建线条样式内部资源 /// @brief 创建线条样式内部资源
/// @param[out] stroke_style 线条样式 /// @param[out] stroke_style 线条样式
/// @param[in] cap 线段端点样式 /// @param[in] cap 线段端点样式
/// @param[in] line_join 线段相交样式 /// @param[in] line_join 线段相交样式
/// @param[in] dash_array 虚线长度与间隙数组 /// @param[in] dash_array 虚线长度与间隙数组
/// @param[in] dash_size 虚线数组大小 /// @param[in] dash_size 虚线数组大小
/// @param[in] dash_offset 虚线偏移量 /// @param[in] dash_offset 虚线偏移量
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateStrokeStyle(StrokeStyle& stroke_style) = 0; virtual void CreateStrokeStyle(StrokeStyle& stroke_style) = 0;
/// \~chinese /// \~chinese
/// @brief 创建纹理渲染上下文,将上下文的渲染输出到纹理中 /// @brief 创建纹理渲染上下文,将上下文的渲染输出到纹理中
/// @param[in,out] texture 渲染输出的纹理 /// @param[in,out] texture 渲染输出的纹理
/// @param[in] desired_size 期望的输出大小 /// @param[in] desired_size 期望的输出大小
/// @return 纹理渲染上下文 /// @return 纹理渲染上下文
/// @throw kiwano::SystemError 创建失败时抛出 /// @throw kiwano::SystemError 创建失败时抛出
virtual RenderContextPtr CreateTextureRenderContext(Texture& texture, const Size* desired_size = nullptr) = 0; virtual RenderContextPtr CreateTextureRenderContext(Texture& texture, const Size* desired_size = nullptr) = 0;
public: public:
/// \~chinese /// \~chinese
/// @brief 获取渲染上下文 /// @brief 获取渲染上下文
RenderContext& GetContext(); RenderContext& GetContext();
/// \~chinese /// \~chinese
/// @brief 获取渲染输出大小 /// @brief 获取渲染输出大小
Size GetOutputSize() const; Size GetOutputSize() const;
/// \~chinese /// \~chinese
/// @brief 开始渲染 /// @brief 开始渲染
virtual void BeginDraw(); virtual void BeginDraw();
/// \~chinese /// \~chinese
/// @brief 结束渲染 /// @brief 结束渲染
virtual void EndDraw(); virtual void EndDraw();
/// \~chinese /// \~chinese
/// @brief 清除绘制内容 /// @brief 清除绘制内容
virtual void Clear() = 0; virtual void Clear() = 0;
/// \~chinese /// \~chinese
/// @brief 将绘制内容呈现至窗口 /// @brief 将绘制内容呈现至窗口
/// @throw kiwano::SystemError 呈现失败时抛出 /// @throw kiwano::SystemError 呈现失败时抛出
virtual void Present() = 0; virtual void Present() = 0;
/// \~chinese /// \~chinese
/// @brief 重设渲染输出大小 /// @brief 重设渲染输出大小
virtual void Resize(uint32_t width, uint32_t height) = 0; virtual void Resize(uint32_t width, uint32_t height) = 0;
public: public:

View File

@ -34,7 +34,7 @@ KGE_DECLARE_SMART_PTR(Shape);
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API Shape : public NativeObject class KGE_API Shape : public NativeObject
{ {
@ -42,68 +42,68 @@ class KGE_API Shape : public NativeObject
public: public:
/// \~chinese /// \~chinese
/// @brief 创建线段形状 /// @brief 创建线段形状
/// @param begin 线段起点 /// @param begin 线段起点
/// @param end 线段终点 /// @param end 线段终点
static ShapePtr CreateLine(const Point& begin, const Point& end); static ShapePtr CreateLine(const Point& begin, const Point& end);
/// \~chinese /// \~chinese
/// @brief 创建矩形 /// @brief 创建矩形
/// @param rect 矩形 /// @param rect 矩形
static ShapePtr CreateRect(const Rect& rect); static ShapePtr CreateRect(const Rect& rect);
/// \~chinese /// \~chinese
/// @brief 创建圆角矩形 /// @brief 创建圆角矩形
/// @param rect 矩形 /// @param rect 矩形
/// @param radius 矩形圆角半径 /// @param radius 矩形圆角半径
static ShapePtr CreateRoundedRect(const Rect& rect, const Vec2& radius); static ShapePtr CreateRoundedRect(const Rect& rect, const Vec2& radius);
/// \~chinese /// \~chinese
/// @brief 创建圆形 /// @brief 创建圆形
/// @param center 圆形原点 /// @param center 圆形原点
/// @param radius 圆形半径 /// @param radius 圆形半径
static ShapePtr CreateCircle(const Point& center, float radius); static ShapePtr CreateCircle(const Point& center, float radius);
/// \~chinese /// \~chinese
/// @brief 创建椭圆形 /// @brief 创建椭圆形
/// @param center 椭圆原点 /// @param center 椭圆原点
/// @param radius 椭圆半径 /// @param radius 椭圆半径
static ShapePtr CreateEllipse(const Point& center, const Vec2& radius); static ShapePtr CreateEllipse(const Point& center, const Vec2& radius);
Shape(); Shape();
/// \~chinese /// \~chinese
/// @brief 获取外切包围盒 /// @brief 获取外切包围盒
Rect GetBoundingBox() const; Rect GetBoundingBox() const;
/// \~chinese /// \~chinese
/// @brief 获取外切包围盒 /// @brief 获取外切包围盒
/// @param transform 二维变换 /// @param transform 二维变换
Rect GetBoundingBox(const Matrix3x2& transform) const; Rect GetBoundingBox(const Matrix3x2& transform) const;
/// \~chinese /// \~chinese
/// @brief 判断图形是否包含点 /// @brief 判断图形是否包含点
/// @param point 点 /// @param point 点
/// @param transform 应用到点上的二维变换 /// @param transform 应用到点上的二维变换
bool ContainsPoint(const Point& point, const Matrix3x2* transform = nullptr) const; bool ContainsPoint(const Point& point, const Matrix3x2* transform = nullptr) const;
/// \~chinese /// \~chinese
/// @brief 获取图形展开成一条直线的长度 /// @brief 获取图形展开成一条直线的长度
float GetLength() const; float GetLength() const;
/// \~chinese /// \~chinese
/// @brief 计算图形面积 /// @brief 计算图形面积
float ComputeArea() const; float ComputeArea() const;
/// \~chinese /// \~chinese
/// @brief 计算图形上点的位置和切线向量 /// @brief 计算图形上点的位置和切线向量
/// @param[in] length 点在图形上的位置,范围 [0.0 - 1.0] /// @param[in] length 点在图形上的位置,范围 [0.0 - 1.0]
/// @param[out] point 点的位置 /// @param[out] point 点的位置
/// @param[out] tangent 点的切线向量 /// @param[out] tangent 点的切线向量
bool ComputePointAtLength(float length, Point& point, Vec2& tangent) const; bool ComputePointAtLength(float length, Point& point, Vec2& tangent) const;
/// \~chinese /// \~chinese
/// @brief 清除形状 /// @brief 清除形状
void Clear(); void Clear();
}; };

View File

@ -32,22 +32,22 @@ KGE_DECLARE_SMART_PTR(ShapeMaker);
*/ */
/// \~chinese /// \~chinese
/// @brief 形状合并方式 /// @brief 形状合并方式
enum class CombineMode enum class CombineMode
{ {
Union, ///< 并集 (A + B) Union, ///< 并集 (A + B)
Intersect, ///< 交集 (A + B) Intersect, ///< 交集 (A + B)
Xor, ///< 对称差集 ((A - B) + (B - A)) Xor, ///< 对称差集 ((A - B) + (B - A))
Exclude ///< 差集 (A - B) Exclude ///< 差集 (A - B)
}; };
/// \~chinese /// \~chinese
/// @brief 形状生成器 /// @brief 形状生成器
class KGE_API ShapeMaker : public NativeObject class KGE_API ShapeMaker : public NativeObject
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建形状生成器 /// @brief 创建形状生成器
static ShapeMakerPtr Create(); static ShapeMakerPtr Create();
ShapeMaker(); ShapeMaker();
@ -55,83 +55,83 @@ public:
~ShapeMaker(); ~ShapeMaker();
/// \~chinese /// \~chinese
/// @brief 获取生成的形状 /// @brief 获取生成的形状
ShapePtr GetShape(); ShapePtr GetShape();
/// \~chinese /// \~chinese
/// @brief 清空图形 /// @brief 清空图形
void Clear(); void Clear();
/// \~chinese /// \~chinese
/// @brief 开始添加路径并打开输入流 /// @brief 开始添加路径并打开输入流
/// @param begin_pos 路径起始点 /// @param begin_pos 路径起始点
void BeginPath(const Point& begin_pos = Point()); void BeginPath(const Point& begin_pos = Point());
/// \~chinese /// \~chinese
/// @brief 结束路径并关闭输入流 /// @brief 结束路径并关闭输入流
/// @param closed 路径是否闭合 /// @param closed 路径是否闭合
void EndPath(bool closed = false); void EndPath(bool closed = false);
/// \~chinese /// \~chinese
/// @brief 添加一条线段 /// @brief 添加一条线段
/// @param point 端点 /// @param point 端点
void AddLine(const Point& point); void AddLine(const Point& point);
/// \~chinese /// \~chinese
/// @brief 添加多条线段 /// @brief 添加多条线段
/// @param points 端点集合 /// @param points 端点集合
void AddLines(const Vector<Point>& points); void AddLines(const Vector<Point>& points);
/// \~chinese /// \~chinese
/// @brief 添加多条线段 /// @brief 添加多条线段
/// @param points 端点数组 /// @param points 端点数组
/// @param count 端点数量 /// @param count 端点数量
void AddLines(const Point* points, size_t count); void AddLines(const Point* points, size_t count);
/// \~chinese /// \~chinese
/// @brief 添加一条三次方贝塞尔曲线 /// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点 /// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点 /// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点 /// @param point3 贝塞尔曲线的终点
void AddBezier(const Point& point1, const Point& point2, const Point& point3); void AddBezier(const Point& point1, const Point& point2, const Point& point3);
/// \~chinese /// \~chinese
/// @brief 添加弧线 /// @brief 添加弧线
/// @param point 终点 /// @param point 终点
/// @param radius 椭圆半径 /// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度 /// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针 /// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧 /// @param is_small 是否取小于 180° 的弧
void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true); void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true);
/// \~chinese /// \~chinese
/// @brief 合并形状 /// @brief 合并形状
/// @param shape_a 输入的形状A /// @param shape_a 输入的形状A
/// @param shape_b 输入的形状B /// @param shape_b 输入的形状B
/// @param mode 合并方式 /// @param mode 合并方式
/// @param matrix 应用到输入形状B上的二维变换 /// @param matrix 应用到输入形状B上的二维变换
/// @return 返回合并后的形状 /// @return 返回合并后的形状
static ShapePtr Combine(ShapePtr shape_a, ShapePtr shape_b, CombineMode mode, const Matrix3x2* matrix = nullptr); static ShapePtr Combine(ShapePtr shape_a, ShapePtr shape_b, CombineMode mode, const Matrix3x2* matrix = nullptr);
/// \~chinese /// \~chinese
/// @brief 设置生成的形状 /// @brief 设置生成的形状
/// @note 应由系统调用该函数 /// @note 应由系统调用该函数
void SetShape(ShapePtr shape); void SetShape(ShapePtr shape);
private: private:
/// \~chinese /// \~chinese
/// @brief 打开输入流 /// @brief 打开输入流
/// @note 应由系统调用该函数 /// @note 应由系统调用该函数
void OpenStream(); void OpenStream();
/// \~chinese /// \~chinese
/// @brief 关闭输入流 /// @brief 关闭输入流
/// @note 应由系统调用该函数 /// @note 应由系统调用该函数
void CloseStream(); void CloseStream();
/// \~chinese /// \~chinese
/// @brief 输入流是否已经打开 /// @brief 输入流是否已经打开
/// @note 应由系统调用该函数 /// @note 应由系统调用该函数
bool IsStreamOpened() const; bool IsStreamOpened() const;
private: private:

View File

@ -32,80 +32,80 @@ KGE_DECLARE_SMART_PTR(StrokeStyle);
*/ */
/// \~chinese /// \~chinese
/// @brief 线条端点样式 /// @brief 线条端点样式
/// @details 线条端点样式表示线段端点部分的形状 /// @details 线条端点样式表示线段端点部分的形状
enum class CapStyle enum class CapStyle
{ {
Flat, ///< 扁端点 Flat, ///< 扁端点
Square, ///< 方形端点,方形突出部分等于线段宽度的一半 Square, ///< 方形端点,方形突出部分等于线段宽度的一半
Round, ///< 圆形端点,圆直径等于线段宽度 Round, ///< 圆形端点,圆直径等于线段宽度
Triangle, ///< 三角样式,三角斜边长度等于线段宽度 Triangle, ///< 三角样式,三角斜边长度等于线段宽度
}; };
/// \~chinese /// \~chinese
/// @brief 线条交点样式 /// @brief 线条交点样式
/// @details 线条交点样式表示两条线相交部分的形状 /// @details 线条交点样式表示两条线相交部分的形状
enum class LineJoinStyle enum class LineJoinStyle
{ {
Miter, ///< 斜切样式 Miter, ///< 斜切样式
Bevel, ///< 斜角样式 Bevel, ///< 斜角样式
Round ///< 圆角样式 Round ///< 圆角样式
}; };
/// \~chinese /// \~chinese
/// @brief 线条虚线样式 /// @brief 线条虚线样式
/// @details 线条虚线样式表示线段的间隙 /// @details 线条虚线样式表示线段的间隙
enum class DashStyle enum class DashStyle
{ {
Solid, ///< 无间断的实线 Solid, ///< 无间断的实线
Dash, ///< 斜角样式 Dash, ///< 斜角样式
Dot, ///< 圆角样式 Dot, ///< 圆角样式
DashDot, ///< 圆角样式 DashDot, ///< 圆角样式
DashDotDot, ///< 圆角样式 DashDotDot, ///< 圆角样式
}; };
/// \~chinese /// \~chinese
/// @brief 线条样式 /// @brief 线条样式
class StrokeStyle : public NativeObject class StrokeStyle : public NativeObject
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建线条样式 /// @brief 创建线条样式
/// @param width 线条宽度 /// @param width 线条宽度
/// @param cap 线条端点样式 /// @param cap 线条端点样式
/// @param line_join 线条交点样式 /// @param line_join 线条交点样式
static StrokeStylePtr Create(float width, CapStyle cap = CapStyle::Flat, static StrokeStylePtr Create(float width, CapStyle cap = CapStyle::Flat,
LineJoinStyle line_join = LineJoinStyle::Miter); LineJoinStyle line_join = LineJoinStyle::Miter);
/// \~chinese /// \~chinese
/// @brief 创建线条样式 /// @brief 创建线条样式
/// @param width 线条宽度 /// @param width 线条宽度
/// @param cap 线条端点样式 /// @param cap 线条端点样式
/// @param line_join 线条交点样式 /// @param line_join 线条交点样式
/// @param dash 线条虚线样式 /// @param dash 线条虚线样式
/// @param dash_offset 线条虚线偏移量 /// @param dash_offset 线条虚线偏移量
static StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join, DashStyle dash, static StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join, DashStyle dash,
float dash_offset = 0.0f); float dash_offset = 0.0f);
/// \~chinese /// \~chinese
/// @brief 创建线条样式 /// @brief 创建线条样式
/// @param width 线条宽度 /// @param width 线条宽度
/// @param cap 线条端点样式 /// @param cap 线条端点样式
/// @param line_join 线条交点样式 /// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组 /// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小 /// @param dash_size 线条虚线数组大小
/// @param dash_offset 线条虚线偏移量 /// @param dash_offset 线条虚线偏移量
static StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join, const float* dash_array, static StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join, const float* dash_array,
size_t dash_size, float dash_offset = 0.0f); size_t dash_size, float dash_offset = 0.0f);
/// \~chinese /// \~chinese
/// @brief 创建线条样式 /// @brief 创建线条样式
/// @tparam _DashSize 线条虚线数组大小 /// @tparam _DashSize 线条虚线数组大小
/// @param width 线条宽度 /// @param width 线条宽度
/// @param cap 线条端点样式 /// @param cap 线条端点样式
/// @param line_join 线条交点样式 /// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组 /// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_offset 线条虚线偏移量 /// @param dash_offset 线条虚线偏移量
template <size_t _DashSize> template <size_t _DashSize>
static inline StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join, static inline StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join,
float (&dash_array)[_DashSize], float dash_offset = 0.0f) float (&dash_array)[_DashSize], float dash_offset = 0.0f)
@ -116,59 +116,59 @@ public:
StrokeStyle(); StrokeStyle();
/// \~chinese /// \~chinese
/// @brief 获取线条宽度 /// @brief 获取线条宽度
/// @param width 线条宽度 /// @param width 线条宽度
float GetStrokeWidth() const; float GetStrokeWidth() const;
/// \~chinese /// \~chinese
/// @brief 获取线条端点样式 /// @brief 获取线条端点样式
CapStyle GetCapStyle() const; CapStyle GetCapStyle() const;
/// \~chinese /// \~chinese
/// @brief 获取线条交点样式 /// @brief 获取线条交点样式
LineJoinStyle GetLineJoinStyle() const; LineJoinStyle GetLineJoinStyle() const;
/// \~chinese /// \~chinese
/// @brief 获取线条虚线的长度与间隙数组 /// @brief 获取线条虚线的长度与间隙数组
const Vector<float>& GetDashArray() const; const Vector<float>& GetDashArray() const;
/// \~chinese /// \~chinese
/// @brief 获取虚线偏移量 /// @brief 获取虚线偏移量
float GetDashOffset() const; float GetDashOffset() const;
/// \~chinese /// \~chinese
/// @brief 设置线条宽度 /// @brief 设置线条宽度
/// @param width 线条宽度 /// @param width 线条宽度
void SetStrokeWidth(float width); void SetStrokeWidth(float width);
/// \~chinese /// \~chinese
/// @brief 设置线条端点样式 /// @brief 设置线条端点样式
void SetCapStyle(CapStyle cap); void SetCapStyle(CapStyle cap);
/// \~chinese /// \~chinese
/// @brief 设置线条交点样式 /// @brief 设置线条交点样式
void SetLineJoinStyle(LineJoinStyle line_join); void SetLineJoinStyle(LineJoinStyle line_join);
/// \~chinese /// \~chinese
/// @brief 设置虚线样式 /// @brief 设置虚线样式
/// @param dash_style 线条虚线样式 /// @param dash_style 线条虚线样式
void SetDashStyle(DashStyle dash_style); void SetDashStyle(DashStyle dash_style);
/// \~chinese /// \~chinese
/// @brief 设置虚线样式 /// @brief 设置虚线样式
/// @param dash_array 线条虚线的长度与间隙数组 /// @param dash_array 线条虚线的长度与间隙数组
void SetDashStyle(const Vector<float>& dash_array); void SetDashStyle(const Vector<float>& dash_array);
/// \~chinese /// \~chinese
/// @brief 设置虚线样式 /// @brief 设置虚线样式
/// @param dash_array 线条虚线的长度与间隙数组 /// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小 /// @param dash_size 线条虚线数组大小
void SetDashStyle(const float* dash_array, size_t dash_size); void SetDashStyle(const float* dash_array, size_t dash_size);
/// \~chinese /// \~chinese
/// @brief 设置虚线样式 /// @brief 设置虚线样式
/// @tparam _DashSize 线条虚线数组大小 /// @tparam _DashSize 线条虚线数组大小
/// @param dash_array 线条虚线的长度与间隙数组 /// @param dash_array 线条虚线的长度与间隙数组
template <size_t _DashSize> template <size_t _DashSize>
inline void SetDashStyle(float (&dash_array)[_DashSize]) inline void SetDashStyle(float (&dash_array)[_DashSize])
{ {
@ -176,8 +176,8 @@ public:
} }
/// \~chinese /// \~chinese
/// @brief 设置虚线偏移量 /// @brief 设置虚线偏移量
/// @param dash_offset 线条虚线偏移量 /// @param dash_offset 线条虚线偏移量
void SetDashOffset(float dash_offset); void SetDashOffset(float dash_offset);
private: private:

View File

@ -34,186 +34,186 @@ KGE_DECLARE_SMART_PTR(TextLayout);
*/ */
/// \~chinese /// \~chinese
/// @brief 文本布局 /// @brief 文本布局
class KGE_API TextLayout : public NativeObject class KGE_API TextLayout : public NativeObject
{ {
public: public:
/// \~chinese /// \~chinese
/// @brief 创建文本布局 /// @brief 创建文本布局
static TextLayoutPtr Create(); static TextLayoutPtr Create();
/// \~chinese /// \~chinese
/// @brief 创建文本布局 /// @brief 创建文本布局
/// @param content 文字内容 /// @param content 文字内容
/// @param style 文本样式 /// @param style 文本样式
static TextLayoutPtr Create(const String& content, const TextStyle& style); static TextLayoutPtr Create(const String& content, const TextStyle& style);
/// \~chinese /// \~chinese
/// @brief 构造空的文本布局 /// @brief 构造空的文本布局
TextLayout(); TextLayout();
/// \~chinese /// \~chinese
/// @brief 文本布局是否陈旧 /// @brief 文本布局是否陈旧
bool IsDirty() const; bool IsDirty() const;
/// \~chinese /// \~chinese
/// @brief 清空文本布局 /// @brief 清空文本布局
void Clear(); void Clear();
/// \~chinese /// \~chinese
/// @brief 重设文本布局 /// @brief 重设文本布局
/// @param style 文本样式 /// @param style 文本样式
void Reset(const TextStyle& style); void Reset(const TextStyle& style);
/// \~chinese /// \~chinese
/// @brief 重设文本布局 /// @brief 重设文本布局
/// @param content 文字内容 /// @param content 文字内容
/// @param style 文本样式 /// @param style 文本样式
void Reset(const String& content, const TextStyle& style); void Reset(const String& content, const TextStyle& style);
/// \~chinese /// \~chinese
/// @brief 获取文字内容 /// @brief 获取文字内容
String GetContent() const; String GetContent() const;
/// \~chinese /// \~chinese
/// @brief 获取文字内容的长度 /// @brief 获取文字内容的长度
uint32_t GetContentLength() const; uint32_t GetContentLength() const;
/// \~chinese /// \~chinese
/// @brief 获取文本布局大小 /// @brief 获取文本布局大小
Size GetSize() const; Size GetSize() const;
/// \~chinese /// \~chinese
/// @brief 获取文本行数 /// @brief 获取文本行数
uint32_t GetLineCount() const; uint32_t GetLineCount() const;
/// \~chinese /// \~chinese
/// @brief 获取默认填充画刷 /// @brief 获取默认填充画刷
BrushPtr GetDefaultFillBrush() const; BrushPtr GetDefaultFillBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取默认描边画刷 /// @brief 获取默认描边画刷
BrushPtr GetDefaultOutlineBrush() const; BrushPtr GetDefaultOutlineBrush() const;
/// \~chinese /// \~chinese
/// @brief 获取默认描边线条样式 /// @brief 获取默认描边线条样式
StrokeStylePtr GetDefaultOutlineStrokeStyle() const; StrokeStylePtr GetDefaultOutlineStrokeStyle() const;
/// \~chinese /// \~chinese
/// @brief 文字范围 /// @brief 文字范围
struct TextRange struct TextRange
{ {
uint32_t start; ///< 起始位置 uint32_t start; ///< 起始位置
uint32_t length; ///< 长度 uint32_t length; ///< 长度
}; };
/// \~chinese /// \~chinese
/// @brief 设置字体 /// @brief 设置字体
/// @param font 字体 /// @param font 字体
/// @param range 文字范围 /// @param range 文字范围
void SetFont(FontPtr font, TextRange range); void SetFont(FontPtr font, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置字体族 /// @brief 设置字体族
/// @param family 字体族 /// @param family 字体族
/// @param range 文字范围 /// @param range 文字范围
void SetFontFamily(const String& family, TextRange range); void SetFontFamily(const String& family, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置字号(默认值为 18 /// @brief 设置字号(默认值为 18
/// @param size 字号 /// @param size 字号
/// @param range 文字范围 /// @param range 文字范围
void SetFontSize(float size, TextRange range); void SetFontSize(float size, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal /// @brief 设置字体粗细值(默认值为 FontWeight::Normal
/// @param weight 粗细值 /// @param weight 粗细值
/// @param range 文字范围 /// @param range 文字范围
void SetFontWeight(uint32_t weight, TextRange range); void SetFontWeight(uint32_t weight, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置文字斜体(默认值为 false /// @brief 设置文字斜体(默认值为 false
/// @param italic 是否是斜体 /// @param italic 是否是斜体
/// @param range 文字范围 /// @param range 文字范围
void SetItalic(bool italic, TextRange range); void SetItalic(bool italic, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置下划线 /// @brief 设置下划线
/// @param enable 是否显示下划线 /// @param enable 是否显示下划线
/// @param range 文字范围 /// @param range 文字范围
void SetUnderline(bool enable, TextRange range); void SetUnderline(bool enable, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置删除线 /// @brief 设置删除线
/// @param enable 是否显示删除线 /// @param enable 是否显示删除线
/// @param range 文字范围 /// @param range 文字范围
void SetStrikethrough(bool enable, TextRange range); void SetStrikethrough(bool enable, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置文字填充画刷,描边画刷和描边线宽 /// @brief 设置文字填充画刷,描边画刷和描边线宽
/// @param brush 画刷 /// @param brush 画刷
/// @param range 文字范围 /// @param range 文字范围
void SetFillBrush(BrushPtr brush, TextRange range); void SetFillBrush(BrushPtr brush, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置文字描边画刷 /// @brief 设置文字描边画刷
/// @param brush 画刷 /// @param brush 画刷
/// @param range 文字范围 /// @param range 文字范围
void SetOutlineBrush(BrushPtr brush, TextRange range); void SetOutlineBrush(BrushPtr brush, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置描边线条样式 /// @brief 设置描边线条样式
/// @param stroke 线条样式 /// @param stroke 线条样式
/// @param range 文字范围 /// @param range 文字范围
void SetOutlineStrokeStyle(StrokeStylePtr stroke, TextRange range); void SetOutlineStrokeStyle(StrokeStylePtr stroke, TextRange range);
/// \~chinese /// \~chinese
/// @brief 设置对齐方式 /// @brief 设置对齐方式
/// @param align 对齐方式 /// @param align 对齐方式
void SetAlignment(TextAlign align); void SetAlignment(TextAlign align);
/// \~chinese /// \~chinese
/// @brief 设置文本自动换行的宽度 /// @brief 设置文本自动换行的宽度
void SetWrapWidth(float wrap_width); void SetWrapWidth(float wrap_width);
/// \~chinese /// \~chinese
/// @brief 设置行间距(默认为 0 /// @brief 设置行间距(默认为 0
void SetLineSpacing(float line_spacing); void SetLineSpacing(float line_spacing);
/// \~chinese /// \~chinese
/// @brief 设置默认文字填充画刷 /// @brief 设置默认文字填充画刷
/// @param brush 画刷 /// @param brush 画刷
void SetDefaultFillBrush(BrushPtr brush); void SetDefaultFillBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置默认文字描边画刷 /// @brief 设置默认文字描边画刷
/// @param brush 画刷 /// @param brush 画刷
void SetDefaultOutlineBrush(BrushPtr brush); void SetDefaultOutlineBrush(BrushPtr brush);
/// \~chinese /// \~chinese
/// @brief 设置默认描边线条样式 /// @brief 设置默认描边线条样式
/// @param stroke 线条样式 /// @param stroke 线条样式
void SetDefaultOutlineStrokeStyle(StrokeStylePtr stroke); void SetDefaultOutlineStrokeStyle(StrokeStylePtr stroke);
/// \~chinese /// \~chinese
/// @brief 脏布局标志 /// @brief 脏布局标志
enum class DirtyFlag : uint8_t enum class DirtyFlag : uint8_t
{ {
Clean = 0, ///< 干净布局 Clean = 0, ///< 干净布局
Dirty = 1 << 0 ///< 脏布局 Dirty = 1 << 0 ///< 脏布局
}; };
/// \~chinese /// \~chinese
/// @brief 获取脏布局标志 /// @brief 获取脏布局标志
DirtyFlag GetDirtyFlag() const; DirtyFlag GetDirtyFlag() const;
/// \~chinese /// \~chinese
/// @brief 设置脏布局标志 /// @brief 设置脏布局标志
void SetDirtyFlag(DirtyFlag flag); void SetDirtyFlag(DirtyFlag flag);
/// \~chinese /// \~chinese
/// @brief 更新脏布局 /// @brief 更新脏布局
/// @return 是否需要更新 /// @return 是否需要更新
bool UpdateWhenDirty(); bool UpdateWhenDirty();
private: private:

View File

@ -33,19 +33,19 @@ namespace kiwano
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
enum class TextAlign enum class TextAlign
{ {
Left, ///< 左对齐 Left, ///< 左对齐
Right, ///< 右对齐 Right, ///< 右对齐
Center, ///< 居中对齐 Center, ///< 居中对齐
Justified ///< 两端对齐 Justified ///< 两端对齐
}; };
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
struct FontWeight struct FontWeight
{ {
@ -54,7 +54,7 @@ struct FontWeight
Thin = 100U, Thin = 100U,
ExtraLight = 200U, ExtraLight = 200U,
Light = 300U, Light = 300U,
Normal = 400U, ///< 正常 Normal = 400U, ///< 正常
Medium = 500U, Medium = 500U,
Bold = 700U, Bold = 700U,
ExtraBold = 800U, ExtraBold = 800U,
@ -65,38 +65,38 @@ struct FontWeight
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API TextStyle class KGE_API TextStyle
{ {
public: public:
FontPtr font; ///< 字体 FontPtr font; ///< 字体
String font_family; ///< 字体族 String font_family; ///< 字体族
float font_size; ///< 字号 float font_size; ///< 字号
uint32_t font_weight; ///< 粗细值 uint32_t font_weight; ///< 粗细值
bool italic; ///< 是否斜体 bool italic; ///< 是否斜体
TextAlign alignment; ///< 对齐方式 TextAlign alignment; ///< 对齐方式
BrushPtr fill_brush; ///< 填充画刷 BrushPtr fill_brush; ///< 填充画刷
BrushPtr outline_brush; ///< 描边画刷 BrushPtr outline_brush; ///< 描边画刷
StrokeStylePtr outline_stroke; ///< 描边样式 StrokeStylePtr outline_stroke; ///< 描边样式
float wrap_width; ///< 自动换行宽度 float wrap_width; ///< 自动换行宽度
float line_spacing; ///< 行间距 float line_spacing; ///< 行间距
bool show_underline; ///< 显示下划线 bool show_underline; ///< 显示下划线
bool show_strikethrough; ///< 显示删除线 bool show_strikethrough; ///< 显示删除线
public: public:
/** /**
* \~chinese * \~chinese
* @brief * @brief
*/ */
TextStyle(); TextStyle();
/** /**
* \~chinese * \~chinese
* @brief * @brief
* @param font_family * @param font_family
* @param font_size * @param font_size
* @param font_weight * @param font_weight
*/ */
TextStyle(const String& font_family, float font_size, uint32_t font_weight = FontWeight::Normal); TextStyle(const String& font_family, float font_size, uint32_t font_weight = FontWeight::Normal);
}; };

Some files were not shown because too many files have changed in this diff Show More