Change source charset to utf-8

This commit is contained in:
Nomango 2020-02-10 17:32:04 +08:00
parent 56ae199587
commit fa142b64c9
97 changed files with 2597 additions and 2560 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -79,6 +79,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -97,6 +98,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -223,6 +223,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -241,6 +242,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,31 +37,31 @@ KGE_DECLARE_SMART_PTR(Body);
*/
/// \~chinese
/// @brief 物体
/// @brief 物体
class KGE_API Body : public virtual ObjectBase
{
public:
/// \~chinese
/// @brief 物体类型
/// @brief 物体类型
enum class Type
{
Static = 0, ///< 静态物体
Kinematic, ///< 动力学物体
Dynamic, ///< 动态物体
Static = 0, ///< 静态物体
Kinematic, ///< 动力学物体
Dynamic, ///< 动态物体
};
/// \~chinese
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
/// @param[in] type 物体类型
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
/// @param[in] type 物体类型
static BodyPtr Create(World* world, ActorPtr actor, Type type);
/// \~chinese
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
/// @param[in] type 物体类型
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
/// @param[in] type 物体类型
static BodyPtr Create(World* world, Actor* actor, Type type);
Body();
@ -69,250 +69,250 @@ public:
virtual ~Body();
/// \~chinese
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
bool InitBody(World* world, ActorPtr actor);
/// \~chinese
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
/// @brief 初始化
/// @param[in] world 物理世界
/// @param[in] actor 绑定的角色
bool InitBody(World* world, Actor* actor);
/// \~chinese
/// @brief 添加夹具
/// @brief 添加夹具
void AddFixture(FixturePtr fixture);
/// \~chinese
/// @brief 添加圆形夹具
/// @param radius 圆形半径
/// @param density 物体密度
/// @brief 添加圆形夹具
/// @param radius 圆形半径
/// @param density 物体密度
/// @param
Fixture* AddCircleShape(float radius, float density, float friction = 0.2f, float restitution = 0.f,
bool is_sensor = false);
/// \~chinese
/// @brief 添加矩形夹具
/// @param size 矩形大小
/// @param density 物体密度
/// @brief 添加矩形夹具
/// @param size 矩形大小
/// @param density 物体密度
Fixture* AddRectShape(Vec2 const& size, float density, float friction = 0.2f, float restitution = 0.f,
bool is_sensor = false);
/// \~chinese
/// @brief 添加多边形夹具
/// @param vertexs 多边形端点
/// @param density 物体密度
/// @brief 添加多边形夹具
/// @param vertexs 多边形端点
/// @param density 物体密度
Fixture* AddPolygonShape(Vector<Point> const& vertexs, float density, float friction = 0.2f,
float restitution = 0.f, bool is_sensor = false);
/// \~chinese
/// @brief 添加线段形夹具
/// @param p1 线段起点
/// @param p2 线段终点
/// @param density 物体密度
/// @brief 添加线段形夹具
/// @param p1 线段起点
/// @param p2 线段终点
/// @param density 物体密度
Fixture* AddEdgeShape(Point const& p1, Point const& p2, float density, float friction = 0.2f,
float restitution = 0.f, bool is_sensor = false);
/// \~chinese
/// @brief 添加链条形夹具
/// @param vertexs 链条端点
/// @param loop 是否闭合
/// @param density 物体密度
/// @brief 添加链条形夹具
/// @param vertexs 链条端点
/// @param loop 是否闭合
/// @param density 物体密度
Fixture* AddChainShape(Vector<Point> const& vertexs, bool loop, float density, float friction = 0.2f,
float restitution = 0.f, bool is_sensor = false);
/// \~chinese
/// @brief 移除夹具
/// @brief 移除夹具
void RemoveFixture(FixturePtr fixture);
/// \~chinese
/// @brief 获取夹具列表
/// @brief 获取夹具列表
FixtureList GetFixtureList() const;
/// \~chinese
/// @brief 获取接触边列表
/// @brief 获取接触边列表
ContactEdgeList GetContactList() const;
/// \~chinese
/// @brief 获取类别码
/// @brief 获取类别码
uint16_t GetCategoryBits() const;
/// \~chinese
/// @brief 设置类别码
/// @brief 设置类别码
void SetCategoryBits(uint16_t category_bits);
/// \~chinese
/// @brief 获取碰撞掩码
/// @brief 获取碰撞掩码
uint16_t GetMaskBits() const;
/// \~chinese
/// @brief 设置碰撞掩码
/// @brief 设置碰撞掩码
void SetMaskBits(uint16_t mask_bits);
/// \~chinese
/// @brief 获取组索引
/// @brief 获取组索引
int16_t GetGroupIndex() const;
/// \~chinese
/// @brief 设置组索引
/// @brief 设置组索引
void SetGroupIndex(int16_t index);
/// \~chinese
/// @brief 获取旋转角度
/// @brief 获取旋转角度
float GetBodyRotation() const;
/// \~chinese
/// @brief 设置旋转角度
/// @brief 设置旋转角度
void SetBodyRotation(float angle);
/// \~chinese
/// @brief 获取物体位置
/// @brief 获取物体位置
Point GetBodyPosition() const;
/// \~chinese
/// @brief 设置物体位置
/// @brief 设置物体位置
void SetBodyPosition(Point const& pos);
/// \~chinese
/// @brief 位置和旋转变换
/// @brief 位置和旋转变换
void SetBodyTransform(Point const& pos, float angle);
/// \~chinese
/// @brief 获取质量 [kg]
/// @brief 获取质量 [kg]
float GetMass() const;
/// \~chinese
/// @brief 获取惯性
/// @brief 获取惯性
float GetInertia() const;
/// \~chinese
/// @brief 获取质量数据
/// @param[out] mass 物体质量 [kg]
/// @param[out] center 质心位置
/// @param[out] inertia 惯性
/// @brief 获取质量数据
/// @param[out] mass 物体质量 [kg]
/// @param[out] center 质心位置
/// @param[out] inertia 惯性
void GetMassData(float* mass, Point* center, float* inertia) const;
/// \~chinese
/// @brief 设置质量数据
/// @param mass 物体质量 [kg]
/// @param center 质心位置
/// @param inertia 惯性
/// @brief 设置质量数据
/// @param mass 物体质量 [kg]
/// @param center 质心位置
/// @param inertia 惯性
void SetMassData(float mass, Point const& center, float inertia);
/// \~chinese
/// @brief 重置质量数据
/// @brief 重置质量数据
void ResetMassData();
/// \~chinese
/// @brief 获取世界坐标系上的点在物体上的位置
/// @brief 获取世界坐标系上的点在物体上的位置
Point GetLocalPoint(Point const& world) const;
/// \~chinese
/// @brief 获取物体上的点在世界坐标系的位置
/// @brief 获取物体上的点在世界坐标系的位置
Point GetWorldPoint(Point const& local) const;
/// \~chinese
/// @brief 获取物体质心相对于物体的位置
/// @brief 获取物体质心相对于物体的位置
Point GetLocalCenter() const;
/// \~chinese
/// @brief 获取物体质心位置
/// @brief 获取物体质心位置
Point GetWorldCenter() const;
/// \~chinese
/// @brief 获取物体类型
/// @brief 获取物体类型
Type GetType() const;
/// \~chinese
/// @brief 设置物体类型
/// @brief 设置物体类型
void SetType(Type type);
/// \~chinese
/// @brief 获取物体受重力的比例
/// @brief 获取物体受重力的比例
float GetGravityScale() const;
/// \~chinese
/// @brief 设置物体受重力的比例
/// @brief 设置物体受重力的比例
void SetGravityScale(float scale);
/// \~chinese
/// @brief 施力
/// @param force 力的大小和方向
/// @param point 施力点
/// @param wake 是否唤醒物体
/// @brief 施力
/// @param force 力的大小和方向
/// @param point 施力点
/// @param wake 是否唤醒物体
void ApplyForce(Vec2 const& force, Point const& point, bool wake = true);
/// \~chinese
/// @brief 给物体中心施力
/// @param force 力的大小和方向
/// @param wake 是否唤醒物体
/// @brief 给物体中心施力
/// @param force 力的大小和方向
/// @param wake 是否唤醒物体
void ApplyForceToCenter(Vec2 const& force, bool wake = true);
/// \~chinese
/// @brief 施加扭矩
/// @param torque 扭矩
/// @param wake 是否唤醒物体
/// @brief 施加扭矩
/// @param torque 扭矩
/// @param wake 是否唤醒物体
void ApplyTorque(float torque, bool wake = false);
/// \~chinese
/// @brief 旋转角度是否固定
/// @brief 旋转角度是否固定
bool IsIgnoreRotation() const;
/// \~chinese
/// @brief 设置是否固定旋转角度
/// @brief 设置是否固定旋转角度
void SetIgnoreRotation(bool flag);
/// \~chinese
/// @brief 是否是子弹物体
/// @brief 是否是子弹物体
bool IsBullet() const;
/// \~chinese
/// @brief 设置物体是否是子弹物体
/// @brief 设置物体是否是子弹物体
void SetBullet(bool flag);
/// \~chinese
/// @brief 是否处于唤醒状态
/// @brief 是否处于唤醒状态
bool IsAwake() const;
/// \~chinese
/// @brief 设置唤醒状态
/// @brief 设置唤醒状态
void SetAwake(bool flag);
/// \~chinese
/// @brief 是否启用休眠
/// @brief 是否启用休眠
bool IsSleepingAllowed() const;
/// \~chinese
/// @brief 设置是否允许休眠
/// @brief 设置是否允许休眠
void SetSleepingAllowed(bool flag);
/// \~chinese
/// @brief 是否启用
/// @brief 是否启用
bool IsActive() const;
/// \~chinese
/// @brief 设置启用状态
/// @brief 设置启用状态
void SetActive(bool flag);
/// \~chinese
/// @brief 获取物体所在物理世界
/// @brief 获取物体所在物理世界
World* GetWorld() const;
/// \~chinese
/// @brief 获取物体绑定的角色
/// @brief 获取物体绑定的角色
Actor* GetActor() const;
/// \~chinese
/// @brief 设置物体绑定的角色
/// @brief 设置物体绑定的角色
void SetActor(Actor* actor);
/// \~chinese
/// @brief 将物体信息更新到角色
/// @brief 将物体信息更新到角色
void UpdateActor();
/// \~chinese
/// @brief 将角色信息更新到物体
/// @brief 将角色信息更新到物体
void UpdateFromActor();
b2Body* GetB2Body() const;
@ -320,11 +320,11 @@ public:
private:
/// \~chinese
/// @brief 销毁物体
/// @brief 销毁物体
void UpdateFixtureFilter(b2Fixture* fixture);
/// \~chinese
/// @brief 销毁物体
/// @brief 销毁物体
void Destroy();
private:

View File

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

View File

@ -31,7 +31,7 @@ namespace physics
*/
/// \~chinese
/// @brief 接触边
/// @brief 接触边
class KGE_API ContactEdge
{
public:
@ -40,15 +40,15 @@ public:
ContactEdge(b2ContactEdge* edge);
/// \~chinese
/// @brief 是否有效
/// @brief 是否有效
bool IsValid() const;
/// \~chinese
/// @brief 获取接触物体
/// @brief 获取接触物体
Body* GetOtherBody() const;
/// \~chinese
/// @brief 获取接触
/// @brief 获取接触
Contact GetContact() const;
b2ContactEdge* GetB2ContactEdge() const;
@ -63,7 +63,7 @@ private:
};
/// \~chinese
/// @brief 物理接触边列表
/// @brief 物理接触边列表
class ContactEdgeList
{
template <typename _Ty>

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ KGE_DECLARE_SMART_PTR(World);
/**
* \~chinese
* \defgroup Physics
* \defgroup Physics
*/
/**
@ -40,7 +40,7 @@ KGE_DECLARE_SMART_PTR(World);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API World : public Stage
{
@ -53,53 +53,53 @@ public:
virtual ~World();
/// \~chinese
/// @brief 获取重力 [N]
/// @brief 获取重力 [N]
Vec2 GetGravity() const;
/// \~chinese
/// @brief 设置重力 [N]
/// @brief 设置重力 [N]
void SetGravity(Vec2 gravity);
/// \~chinese
/// @brief 获取物理接触列表
/// @brief 获取物理接触列表
ContactList GetContactList();
/// \~chinese
/// @brief 获取全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
/// @brief 获取全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
float GetGlobalScale() const;
/// \~chinese
/// @brief 设置全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
/// @brief 设置全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
void SetGlobalScale(float scale);
/// \~chinese
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
float World2Stage(float value) const;
/// \~chinese
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
Vec2 World2Stage(const b2Vec2& pos) const;
/// \~chinese
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
float Stage2World(float value) const;
/// \~chinese
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
b2Vec2 Stage2World(const Vec2& pos) const;
/// \~chinese
/// @brief 设置速度迭代次数, 默认为 6
/// @brief 设置速度迭代次数, 默认为 6
void SetVelocityIterations(int vel_iter);
/// \~chinese
/// @brief 设置位置迭代次数, 默认为 2
/// @brief 设置位置迭代次数, 默认为 2
void SetPositionIterations(int pos_iter);
b2World* GetB2World();
@ -108,27 +108,27 @@ public:
private:
/// \~chinese
/// @brief 移除物体
/// @brief 移除物体
void RemoveBody(Body* body);
/// \~chinese
/// @brief 移除所有物体
/// @brief 移除所有物体
void RemoveAllBodies();
/// \~chinese
/// @brief 添加关节
/// @brief 添加关节
void AddJoint(Joint* joint);
/// \~chinese
/// @brief 移除关节
/// @brief 移除关节
void RemoveJoint(Joint* joint);
/// \~chinese
/// @brief 移除所有关节
/// @brief 移除所有关节
void RemoveAllJoints();
/// \~chinese
/// @brief 关节被移除
/// @brief 关节被移除
void JointRemoved(b2Joint* joint);
protected:

View File

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

View File

@ -30,13 +30,13 @@ KGE_DECLARE_SMART_PTR(TextButton);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Button : public virtual ObjectBase
{
public:
/// \~chinese
/// @brief 按钮回调函数
/// @brief 按钮回调函数
using Callback = Function<void(Button* /* self */)>;
Button();
@ -44,53 +44,53 @@ public:
virtual ~Button();
/// \~chinese
/// @brief 获取按钮状态是启用还是禁用
/// @brief 获取按钮状态是启用还是禁用
bool IsEnable() const;
/// \~chinese
/// @brief 设置按钮启用或禁用
/// @brief 设置按钮启用或禁用
void SetEnabled(bool enabled);
/// \~chinese
/// @brief 设置按钮点击后的回调函数
/// @brief 设置按钮点击后的回调函数
void SetClickCallback(const Callback& func);
/// \~chinese
/// @brief 设置按钮被按下时的回调函数
/// @brief 设置按钮被按下时的回调函数
void SetPressedCallback(const Callback& func);
/// \~chinese
/// @brief 设置按钮被抬起时的回调函数
/// @brief 设置按钮被抬起时的回调函数
void SetReleasedCallback(const Callback& func);
/// \~chinese
/// @brief 设置鼠标移入按钮时的回调函数
/// @brief 设置鼠标移入按钮时的回调函数
void SetMouseOverCallback(const Callback& func);
/// \~chinese
/// @brief 设置鼠标移出按钮时的回调函数
/// @brief 设置鼠标移出按钮时的回调函数
void SetMouseOutCallback(const Callback& func);
/// \~chinese
/// @brief 按钮状态
/// @brief 按钮状态
enum class Status
{
Normal, ///< 普通
Hover, ///< 鼠标在按钮内
Pressed ///< 被按下
Normal, ///< 普通
Hover, ///< 鼠标在按钮内
Pressed ///< 被按下
};
/// \~chinese
/// @brief 设置按钮状态
/// @brief 设置按钮状态
void SetStatus(Status status);
/// \~chinese
/// @brief 获取按钮状态
/// @brief 获取按钮状态
Status GetStatus() const;
protected:
/// \~chinese
/// @brief 更新按钮状态
/// @brief 更新按钮状态
void UpdateStatus(Event* evt);
private:
@ -104,7 +104,7 @@ private:
};
/// \~chinese
/// @brief 精灵按钮
/// @brief 精灵按钮
class SpriteButton
: public Sprite
, public Button
@ -113,22 +113,22 @@ public:
SpriteButton();
/// \~chinese
/// @brief 创建精灵按钮
/// @param click 按钮点击回调函数
/// @brief 创建精灵按钮
/// @param click 按钮点击回调函数
static SpriteButtonPtr Create(Callback const& click);
/// \~chinese
/// @brief 创建精灵按钮
/// @param click 按钮点击回调函数
/// @param pressed 按钮按下回调函数
/// @param mouse_over 按钮移入回调函数
/// @param mouse_out 按钮移出回调函数
/// @brief 创建精灵按钮
/// @param click 按钮点击回调函数
/// @param pressed 按钮按下回调函数
/// @param mouse_over 按钮移入回调函数
/// @param mouse_out 按钮移出回调函数
static SpriteButtonPtr Create(Callback const& click, Callback const& pressed, Callback const& mouse_over,
Callback const& mouse_out);
};
/// \~chinese
/// @brief 文字按钮
/// @brief 文字按钮
class TextButton
: public TextActor
, public Button
@ -137,16 +137,16 @@ public:
TextButton();
/// \~chinese
/// @brief 创建文字按钮
/// @param click 按钮点击回调函数
/// @brief 创建文字按钮
/// @param click 按钮点击回调函数
static TextButtonPtr Create(Callback const& click);
/// \~chinese
/// @brief 创建文字按钮
/// @param click 按钮点击回调函数
/// @param pressed 按钮按下回调函数
/// @param mouse_over 按钮移入回调函数
/// @param mouse_out 按钮移出回调函数
/// @brief 创建文字按钮
/// @param click 按钮点击回调函数
/// @param pressed 按钮按下回调函数
/// @param mouse_over 按钮移入回调函数
/// @param mouse_out 按钮移出回调函数
static TextButtonPtr Create(Callback const& click, Callback const& pressed, Callback const& mouse_over, Callback const& mouse_out);
};
} // namespace kiwano

View File

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

View File

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

View File

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

View File

@ -29,51 +29,51 @@ KGE_DECLARE_SMART_PTR(FrameSequence);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API FrameSequence : public virtual ObjectBase
{
public:
/// \~chinese
/// @brief 创建序列帧
/// @param frames 图像帧集合
/// @brief 创建序列帧
/// @param frames 图像帧集合
static FrameSequencePtr Create(Vector<FramePtr> const& frames);
/// \~chinese
/// @brief 构建空序列帧
/// @brief 构建空序列帧
FrameSequence();
virtual ~FrameSequence();
/// \~chinese
/// @brief 添加关键帧
/// @param frame 图像帧
/// @brief 添加关键帧
/// @param frame 图像帧
void AddFrame(FramePtr frame);
/// \~chinese
/// @brief 添加多个关键帧
/// @param frames 图像帧集合
/// @brief 添加多个关键帧
/// @param frames 图像帧集合
void AddFrames(Vector<FramePtr> const& frames);
/// \~chinese
/// @brief 获取关键帧
/// @param index 图像帧下标
/// @brief 获取关键帧
/// @param index 图像帧下标
FramePtr GetFrame(size_t index) const;
/// \~chinese
/// @brief 获取所有关键帧
/// @brief 获取所有关键帧
Vector<FramePtr> const& GetFrames() const;
/// \~chinese
/// @brief 获取关键帧数量
/// @brief 获取关键帧数量
size_t GetFramesCount() const;
/// \~chinese
/// @brief 获取序列帧的拷贝对象
/// @brief 获取序列帧的拷贝对象
FrameSequencePtr Clone() const;
/// \~chinese
/// @brief 获取序列帧的倒转
/// @brief 获取序列帧的倒转
FrameSequencePtr Reverse() const;
private:

View File

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

View File

@ -34,13 +34,13 @@ KGE_DECLARE_SMART_PTR(Layer);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Layer : public Actor
{
public:
/// \~chinese
/// @brief 创建图层
/// @brief 创建图层
static LayerPtr Create();
Layer();
@ -48,41 +48,41 @@ public:
virtual ~Layer();
/// \~chinese
/// @brief 是否开启消息吞没
/// @brief 是否开启消息吞没
bool IsSwallowEventsEnabled() const;
/// \~chinese
/// @brief 设置消息吞没功能
/// @param enabled 是否启用
/// @brief 设置消息吞没功能
/// @param enabled 是否启用
void SetSwallowEvents(bool enabled);
/// \~chinese
/// @brief 设置裁剪区域
/// @param clip_rect 裁剪矩形
/// @brief 设置裁剪区域
/// @param clip_rect 裁剪矩形
void SetClipRect(Rect const& clip_rect);
/// \~chinese
/// @brief 设置图层透明度
/// @param opacity 透明度
/// @brief 设置图层透明度
/// @param opacity 透明度
void SetOpacity(float opacity) override;
/// \~chinese
/// @brief 设置几何蒙层
/// @param mask 蒙层的形状
/// @brief 设置几何蒙层
/// @param mask 蒙层的形状
void SetMaskShape(ShapePtr mask);
/// \~chinese
/// @brief 设置几何蒙层的二维变换
/// @param transform 应用于蒙层的二维变换
/// @brief 设置几何蒙层的二维变换
/// @param transform 应用于蒙层的二维变换
void SetMaskTransform(Matrix3x2 const& transform);
/// \~chinese
/// @brief 设置图层区域
/// @param area 图层区域属性
/// @brief 设置图层区域
/// @param area 图层区域属性
void SetArea(LayerArea const& area);
/// \~chinese
/// @brief 获取图层区域
/// @brief 获取图层区域
LayerArea const& GetArea() const;
bool DispatchEvent(Event* evt) override;

View File

@ -43,83 +43,83 @@ KGE_DECLARE_SMART_PTR(PolygonActor);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API ShapeActor : public Actor
{
public:
/// \~chinese
/// @brief 创建形状角色
/// @brief 创建形状角色
static ShapeActorPtr Create();
/// \~chinese
/// @brief 构造形状角色
/// @brief 构造形状角色
ShapeActor();
virtual ~ShapeActor();
/// \~chinese
/// @brief 获取填充画刷
/// @brief 获取填充画刷
BrushPtr GetFillBrush() const;
/// \~chinese
/// @brief 获取轮廓画刷
/// @brief 获取轮廓画刷
BrushPtr GetStrokeBrush() const;
/// \~chinese
/// @brief 获取线条宽度
/// @brief 获取线条宽度
float GetStrokeWidth() const;
/// \~chinese
/// @brief 获取线条样式
/// @brief 获取线条样式
StrokeStylePtr GetStrokeStyle() const;
/// \~chinese
/// @brief 获取形状
/// @brief 获取形状
ShapePtr GetShape() const;
/// \~chinese
/// @brief 获取边界
/// @brief 获取边界
Rect GetBounds() const override;
/// \~chinese
/// @brief 获取外切包围盒
/// @brief 获取外切包围盒
Rect GetBoundingBox() const override;
/// \~chinese
/// @brief 判断点是否在形状内
/// @brief 判断点是否在形状内
bool ContainsPoint(const Point& point) const override;
/// \~chinese
/// @brief 设置填充颜色
/// @param color 填充颜色
/// @brief 设置填充颜色
/// @param color 填充颜色
void SetFillColor(Color const& color);
/// \~chinese
/// @brief 设置填充画刷
/// @param[in] brush 填充画刷
/// @brief 设置填充画刷
/// @param[in] brush 填充画刷
void SetFillBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置轮廓颜色
/// @param color 轮廓颜色
/// @brief 设置轮廓颜色
/// @param color 轮廓颜色
void SetStrokeColor(Color const& color);
/// \~chinese
/// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷
/// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷
void SetStrokeBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置线条宽度,默认为 1.0
/// @brief 设置线条宽度,默认为 1.0
void SetStrokeWidth(float width);
/// \~chinese
/// @brief 设置线条样式
/// @brief 设置线条样式
void SetStrokeStyle(StrokeStylePtr stroke_style);
/// \~chinese
/// @brief 设置形状
/// @brief 设置形状
void SetShape(ShapePtr shape);
void OnRender(RenderContext& ctx) override;
@ -137,14 +137,14 @@ private:
};
/// \~chinese
/// @brief 线段角色
/// @brief 线段角色
class KGE_API LineActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建线段角色
/// @param begin 线段起点
/// @param end 线段终点
/// @brief 创建线段角色
/// @param begin 线段起点
/// @param end 线段终点
static LineActorPtr Create(Point const& begin, Point const& end);
LineActor();
@ -152,27 +152,27 @@ public:
virtual ~LineActor();
/// \~chinese
/// @brief 获取线段起点
/// @brief 获取线段起点
Point const& GetBeginPoint() const;
/// \~chinese
/// @brief 获取线段终点
/// @brief 获取线段终点
Point const& GetEndPoint() const;
/// \~chinese
/// @brief 设置线段起点
/// @param begin 线段起点
/// @brief 设置线段起点
/// @param begin 线段起点
void SetBeginPoint(Point const& begin);
/// \~chinese
/// @brief 设置线段终点
/// @param end 线段终点
/// @brief 设置线段终点
/// @param end 线段终点
void SetEndPoint(Point const& end);
/// \~chinese
/// @brief 设置线段起点和终点
/// @param begin 线段起点
/// @param end 线段终点
/// @brief 设置线段起点和终点
/// @param begin 线段起点
/// @param end 线段终点
void SetLine(Point const& begin, Point const& end);
private:
@ -181,13 +181,13 @@ private:
};
/// \~chinese
/// @brief 矩形角色
/// @brief 矩形角色
class KGE_API RectActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建矩形角色
/// @param size 矩形大小
/// @brief 创建矩形角色
/// @param size 矩形大小
static RectActorPtr Create(Size const& size);
RectActor();
@ -195,12 +195,12 @@ public:
virtual ~RectActor();
/// \~chinese
/// @brief 获取矩形大小
/// @brief 获取矩形大小
Size const& GetRectSize() const;
/// \~chinese
/// @brief 设置矩形大小
/// @param size 矩形大小
/// @brief 设置矩形大小
/// @param size 矩形大小
void SetRectSize(Size const& size);
private:
@ -208,14 +208,14 @@ private:
};
/// \~chinese
/// @brief 圆角矩形角色
/// @brief 圆角矩形角色
class KGE_API RoundedRectActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建圆角矩形角色
/// @param size 圆角矩形大小
/// @param radius 圆角半径
/// @brief 创建圆角矩形角色
/// @param size 圆角矩形大小
/// @param radius 圆角半径
static RoundedRectActorPtr Create(Size const& size, Vec2 const& radius);
RoundedRectActor();
@ -223,27 +223,27 @@ public:
virtual ~RoundedRectActor();
/// \~chinese
/// @brief 获取圆角半径
/// @brief 获取圆角半径
Vec2 GetRadius() const;
/// \~chinese
/// @brief 获取圆角矩形大小
/// @brief 获取圆角矩形大小
Size GetRectSize() const;
/// \~chinese
/// @brief 设置圆角半径
/// @param radius 圆角半径
/// @brief 设置圆角半径
/// @param radius 圆角半径
void SetRadius(Vec2 const& radius);
/// \~chinese
/// @brief 设置圆角矩形大小
/// @param size 圆角矩形大小
/// @brief 设置圆角矩形大小
/// @param size 圆角矩形大小
void SetRectSize(Size const& size);
/// \~chinese
/// @brief 设置圆角矩形
/// @param size 圆角矩形大小
/// @param radius 圆角半径
/// @brief 设置圆角矩形
/// @param size 圆角矩形大小
/// @param radius 圆角半径
void SetRoundedRect(Size const& size, Vec2 const& radius);
private:
@ -252,13 +252,13 @@ private:
};
/// \~chinese
/// @brief 圆形角色
/// @brief 圆形角色
class KGE_API CircleActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建圆形角色
/// @param radius 圆形半径
/// @brief 创建圆形角色
/// @param radius 圆形半径
static CircleActorPtr Create(float radius);
CircleActor();
@ -266,12 +266,12 @@ public:
virtual ~CircleActor();
/// \~chinese
/// @brief 获取圆形半径
/// @brief 获取圆形半径
float GetRadius() const;
/// \~chinese
/// @brief 设置圆形半径
/// @param radius 圆形半径
/// @brief 设置圆形半径
/// @param radius 圆形半径
void SetRadius(float radius);
private:
@ -279,13 +279,13 @@ private:
};
/// \~chinese
/// @brief 椭圆角色
/// @brief 椭圆角色
class KGE_API EllipseActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建椭圆角色
/// @param radius 椭圆半径
/// @brief 创建椭圆角色
/// @param radius 椭圆半径
static EllipseActorPtr Create(Vec2 const& radius);
EllipseActor();
@ -293,12 +293,12 @@ public:
virtual ~EllipseActor();
/// \~chinese
/// @brief 获取椭圆半径
/// @brief 获取椭圆半径
Vec2 GetRadius() const;
/// \~chinese
/// @brief 设置椭圆半径
/// @param radius 椭圆半径
/// @brief 设置椭圆半径
/// @param radius 椭圆半径
void SetRadius(Vec2 const& radius);
private:
@ -306,13 +306,13 @@ private:
};
/// \~chinese
/// @brief 多边形角色
/// @brief 多边形角色
class KGE_API PolygonActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建多边形角色
/// @param points 多边形端点集合
/// @brief 创建多边形角色
/// @param points 多边形端点集合
static PolygonActorPtr Create(Vector<Point> const& points);
PolygonActor();
@ -320,8 +320,8 @@ public:
virtual ~PolygonActor();
/// \~chinese
/// @brief 设置多边形端点
/// @param points 多边形端点集合
/// @brief 设置多边形端点
/// @param points 多边形端点集合
void SetVertices(Vector<Point> const& points);
};

View File

@ -33,24 +33,24 @@ KGE_DECLARE_SMART_PTR(Sprite);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Sprite : public Actor
{
public:
/// \~chinese
/// @brief 创建精灵
/// @param file_path 本地图片路径
/// @brief 创建精灵
/// @param file_path 本地图片路径
static SpritePtr Create(String const& file_path);
/// \~chinese
/// @brief 创建精灵
/// @param res 图片资源
/// @brief 创建精灵
/// @param res 图片资源
static SpritePtr Create(Resource const& res);
/// \~chinese
/// @brief 创建精灵
/// @param frame 图像帧
/// @brief 创建精灵
/// @param frame 图像帧
static SpritePtr Create(FramePtr frame);
Sprite();
@ -58,27 +58,27 @@ public:
virtual ~Sprite();
/// \~chinese
/// @brief 加载本地图片
/// @param file_path 本地图片路径
/// @brief 加载本地图片
/// @param file_path 本地图片路径
bool Load(String const& file_path);
/// \~chinese
/// @brief 加载图像资源
/// @param res 图片资源
/// @brief 加载图像资源
/// @param res 图片资源
bool Load(Resource const& res);
/// \~chinese
/// @brief 使用矩形区域裁剪精灵
/// @param crop_rect 裁剪矩形
/// @brief 使用矩形区域裁剪精灵
/// @param crop_rect 裁剪矩形
void SetCropRect(const Rect& crop_rect);
/// \~chinese
/// @brief 获取帧图像
/// @brief 获取帧图像
FramePtr GetFrame() const;
/// \~chinese
/// @brief 设置图像帧
/// @param[in] frame 图像帧
/// @brief 设置图像帧
/// @param[in] frame 图像帧
void SetFrame(FramePtr frame);
void OnRender(RenderContext& ctx) override;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,27 +25,27 @@
namespace kiwano
{
/// \~chinese
/// @brief 缓动函数
/// @brief 缓动函数
using EaseFunc = Function<float(float)>;
/// \~chinese
/// @brief 缓动函数枚举
/// @details 查看 https://easings.net 获取更多信息
/// @brief 缓动函数枚举
/// @details 查看 https://easings.net 获取更多信息
struct Ease
{
static KGE_API EaseFunc Linear; ///< 线性
static KGE_API EaseFunc EaseIn; ///< 由慢变快
static KGE_API EaseFunc EaseOut; ///< 由快变慢
static KGE_API EaseFunc EaseInOut; ///< 由慢变快, 再由快变慢
static KGE_API EaseFunc ExpoIn; ///< 由慢变极快
static KGE_API EaseFunc ExpoOut; ///< 由极快变慢
static KGE_API EaseFunc ExpoInOut; ///< 由慢至极快, 再由极快边慢
static KGE_API EaseFunc ElasticIn; ///< 自起点赋予弹性
static KGE_API EaseFunc ElasticOut; ///< 自终点赋予弹性
static KGE_API EaseFunc ElasticInOut; ///< 再起点和终点赋予弹性
static KGE_API EaseFunc BounceIn; ///< 自起点赋予反弹力
static KGE_API EaseFunc BounceOut; ///< 自终点赋予反弹力
static KGE_API EaseFunc BounceInOut; ///< 在起点和终点赋予反弹力
static KGE_API EaseFunc Linear; ///< 线性
static KGE_API EaseFunc EaseIn; ///< 由慢变快
static KGE_API EaseFunc EaseOut; ///< 由快变慢
static KGE_API EaseFunc EaseInOut; ///< 由慢变快, 再由快变慢
static KGE_API EaseFunc ExpoIn; ///< 由慢变极快
static KGE_API EaseFunc ExpoOut; ///< 由极快变慢
static KGE_API EaseFunc ExpoInOut; ///< 由慢至极快, 再由极快边慢
static KGE_API EaseFunc ElasticIn; ///< 自起点赋予弹性
static KGE_API EaseFunc ElasticOut; ///< 自终点赋予弹性
static KGE_API EaseFunc ElasticInOut; ///< 再起点和终点赋予弹性
static KGE_API EaseFunc BounceIn; ///< 自起点赋予反弹力
static KGE_API EaseFunc BounceOut; ///< 自终点赋予反弹力
static KGE_API EaseFunc BounceInOut; ///< 在起点和终点赋予反弹力
static KGE_API EaseFunc BackIn;
static KGE_API EaseFunc BackOut;
static KGE_API EaseFunc BackInOut;
@ -86,32 +86,32 @@ KGE_DECLARE_SMART_PTR(ActionCustom);
*/
/// \~chinese
/// @brief 补间动画
/// @brief 补间动画
class KGE_API ActionTween : public Action
{
public:
ActionTween();
/// \~chinese
/// @brief 补间动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
/// @brief 补间动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
ActionTween(Duration duration, EaseFunc func);
/// \~chinese
/// @brief 获取动画时长
/// @brief 获取动画时长
Duration GetDuration() const;
/// \~chinese
/// @brief 设置动画时长
/// @brief 设置动画时长
void SetDuration(Duration duration);
/// \~chinese
/// @brief 获取动画速度缓动函数
/// @brief 获取动画速度缓动函数
EaseFunc const& GetEaseFunc() const;
/// \~chinese
/// @brief 设置动画速度缓动函数
/// @brief 设置动画速度缓动函数
void SetEaseFunc(EaseFunc const& func);
protected:
@ -125,23 +125,23 @@ private:
};
/// \~chinese
/// @brief 相对位移动画
/// @brief 相对位移动画
class KGE_API ActionMoveBy : public ActionTween
{
public:
/// \~chinese
/// @brief 构造相对位移动画
/// @param duration 动画时长
/// @param vector 移动向量
/// @param func 动画速度缓动函数
/// @brief 构造相对位移动画
/// @param duration 动画时长
/// @param vector 移动向量
/// @param func 动画速度缓动函数
ActionMoveBy(Duration duration, Vec2 const& vector, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -156,23 +156,23 @@ protected:
};
/// \~chinese
/// @brief 位移动画
/// @brief 位移动画
class KGE_API ActionMoveTo : public ActionMoveBy
{
public:
/// \~chinese
/// @brief 构造位移动画
/// @param duration 动画时长
/// @param pos 目的坐标
/// @param func 动画速度缓动函数
/// @brief 构造位移动画
/// @param duration 动画时长
/// @param pos 目的坐标
/// @param func 动画速度缓动函数
ActionMoveTo(Duration duration, Point const& pos, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionMoveTo");
@ -187,25 +187,25 @@ private:
};
/// \~chinese
/// @brief 相对跳跃动画
/// @brief 相对跳跃动画
class KGE_API ActionJumpBy : public ActionTween
{
public:
/// \~chinese
/// @brief 构造相对跳跃动画
/// @param duration 动画时长
/// @param vec 跳跃位移向量
/// @param height 跳跃高度
/// @param jumps 跳跃次数
/// @param func 动画速度缓动函数
/// @brief 构造相对跳跃动画
/// @param duration 动画时长
/// @param vec 跳跃位移向量
/// @param height 跳跃高度
/// @param jumps 跳跃次数
/// @param func 动画速度缓动函数
ActionJumpBy(Duration duration, Vec2 const& vec, float height, int jumps = 1, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -222,25 +222,25 @@ protected:
};
/// \~chinese
/// @brief 跳跃动画
/// @brief 跳跃动画
class KGE_API ActionJumpTo : public ActionJumpBy
{
public:
/// \~chinese
/// @brief 构造跳跃动画
/// @param duration 动画时长
/// @param pos 目的坐标
/// @param height 跳跃高度
/// @param jumps 跳跃次数
/// @param func 动画速度缓动函数
/// @brief 构造跳跃动画
/// @param duration 动画时长
/// @param pos 目的坐标
/// @param height 跳跃高度
/// @param jumps 跳跃次数
/// @param func 动画速度缓动函数
ActionJumpTo(Duration duration, Point const& pos, float height, int jumps = 1, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionJumpTo");
@ -255,24 +255,24 @@ private:
};
/// \~chinese
/// @brief 相对缩放动画
/// @brief 相对缩放动画
class KGE_API ActionScaleBy : public ActionTween
{
public:
/// \~chinese
/// @brief 构造相对缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值
/// @param func 动画速度缓动函数
/// @brief 构造相对缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值
/// @param func 动画速度缓动函数
ActionScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -288,24 +288,24 @@ protected:
};
/// \~chinese
/// @brief 缩放动画
/// @brief 缩放动画
class KGE_API ActionScaleTo : public ActionScaleBy
{
public:
/// \~chinese
/// @brief 构造缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值
/// @param func 动画速度缓动函数
/// @brief 构造缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值
/// @param func 动画速度缓动函数
ActionScaleTo(Duration duration, float scale_x, float scale_y, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionScaleTo");
@ -321,23 +321,23 @@ private:
};
/// \~chinese
/// @brief 透明度渐变动画
/// @brief 透明度渐变动画
class KGE_API ActionFadeTo : public ActionTween
{
public:
/// \~chinese
/// @brief 构造透明度渐变动画
/// @param duration 动画时长
/// @param opacity 目标透明度
/// @param func 动画速度缓动函数
/// @brief 构造透明度渐变动画
/// @param duration 动画时长
/// @param opacity 目标透明度
/// @param func 动画速度缓动函数
ActionFadeTo(Duration duration, float opacity, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionFadeTo");
@ -356,47 +356,47 @@ private:
};
/// \~chinese
/// @brief 淡入动画
/// @brief 淡入动画
class KGE_API ActionFadeIn : public ActionFadeTo
{
public:
/// \~chinese
/// @brief 构造淡入动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
/// @brief 构造淡入动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
explicit ActionFadeIn(Duration duration, EaseFunc func = nullptr);
};
/// \~chinese
/// @brief 淡出动画
/// @brief 淡出动画
class KGE_API ActionFadeOut : public ActionFadeTo
{
public:
/// \~chinese
/// @brief 构造淡出动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
/// @brief 构造淡出动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
explicit ActionFadeOut(Duration duration, EaseFunc func = nullptr);
};
/// \~chinese
/// @brief 相对旋转动画
/// @brief 相对旋转动画
class KGE_API ActionRotateBy : public ActionTween
{
public:
/// \~chinese
/// @brief 构造相对旋转动画
/// @param duration 动画时长
/// @param rotation 角度相对变化值
/// @param func 动画速度缓动函数
/// @brief 构造相对旋转动画
/// @param duration 动画时长
/// @param rotation 角度相对变化值
/// @param func 动画速度缓动函数
ActionRotateBy(Duration duration, float rotation, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -410,23 +410,23 @@ protected:
};
/// \~chinese
/// @brief 旋转动画
/// @brief 旋转动画
class KGE_API ActionRotateTo : public ActionRotateBy
{
public:
/// \~chinese
/// @brief 构造旋转动画
/// @param duration 动画时长
/// @param rotation 目标角度
/// @param func 动画速度缓动函数
/// @brief 构造旋转动画
/// @param duration 动画时长
/// @param rotation 目标角度
/// @param func 动画速度缓动函数
ActionRotateTo(Duration duration, float rotation, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionRotateTo");
@ -441,28 +441,28 @@ private:
};
/// \~chinese
/// @brief 自定义动画
/// @brief 自定义动画
class KGE_API ActionCustom : public ActionTween
{
public:
/// \~chinese
/// @brief 动画回调函数
/// @details 在动画更新时回调该函数第一个参数是执行动画的目标第二个参数是动画进度0.0 - 1.0
/// @brief 动画回调函数
/// @details 在动画更新时回调该函数第一个参数是执行动画的目标第二个参数是动画进度0.0 - 1.0
using TweenFunc = Function<void(Actor* /* target */, float /* percent */)>;
/// \~chinese
/// @brief 构造自定义动画
/// @param duration 动画时长
/// @param tween_func 动画回调函数
/// @param func 动画速度缓动函数
/// @brief 构造自定义动画
/// @param duration 动画时长
/// @param tween_func 动画回调函数
/// @param func 动画速度缓动函数
ActionCustom(Duration duration, TweenFunc tween_func, EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionCustom");

View File

@ -33,44 +33,44 @@ KGE_DECLARE_SMART_PTR(ActionWalk);
*/
/// \~chinese
/// @brief 路径行走动画
/// @brief 路径行走动画
class KGE_API ActionWalk : public ActionTween
{
public:
/// \~chinese
/// @brief 构造路径行走动画
/// @param duration 持续时长
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
/// @param func 动画速度缓动函数
/// @brief 构造路径行走动画
/// @param duration 持续时长
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
/// @param func 动画速度缓动函数
ActionWalk(Duration duration, bool rotating = false, float start = 0.f, float end = 1.f, EaseFunc func = nullptr);
/// \~chinese
/// @brief 构造路径行走动画
/// @param duration 持续时长
/// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
/// @param func 动画速度缓动函数
/// @brief 构造路径行走动画
/// @param duration 持续时长
/// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
/// @param func 动画速度缓动函数
ActionWalk(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f, float end = 1.f,
EaseFunc func = nullptr);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
/// \~chinese
/// @brief 获取路线
/// @brief 获取路线
ShapePtr const& GetPath() const;
/// \~chinese
/// @brief 设置路径形状
/// @brief 设置路径形状
void SetPath(ShapePtr path);
protected:

View File

@ -32,36 +32,36 @@ KGE_DECLARE_SMART_PTR(Animation);
*/
/// \~chinese
/// @brief 帧动画
/// @brief 帧动画
class KGE_API Animation : public ActionTween
{
public:
Animation();
/// \~chinese
/// @brief 构建帧动画
/// @param duration 动画时长
/// @param[in] frame_seq 序列帧
/// @param func 动画速度缓动函数
/// @brief 构建帧动画
/// @param duration 动画时长
/// @param[in] frame_seq 序列帧
/// @param func 动画速度缓动函数
Animation(Duration duration, FrameSequencePtr frame_seq, EaseFunc func = nullptr);
virtual ~Animation();
/// \~chinese
/// @brief 获取序列帧
/// @brief 获取序列帧
FrameSequencePtr GetFrameSequence() const;
/// \~chinese
/// @brief 设置序列帧
/// @param[in] frame_seq 序列帧
/// @brief 设置序列帧
/// @param[in] frame_seq 序列帧
void SetFrameSequence(FrameSequencePtr frame_seq);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:

View File

@ -31,8 +31,8 @@ typedef Function<void()> AsyncTaskFunc;
typedef Function<void()> AsyncTaskCallback;
/// \~chinese
/// @brief 异步任务
/// @details 在多线程下执行任务并返回
/// @brief 异步任务
/// @details 在多线程下执行任务并返回
/// @code
/// AsyncTaskPtr task = new AsyncTask;
/// task->Then(DoSomething);
@ -42,27 +42,27 @@ class AsyncTask : public virtual ObjectBase
{
public:
/// \~chinese
/// @brief 创建异步任务
/// @param func 异步回调函数
/// @brief 创建异步任务
/// @param func 异步回调函数
static AsyncTaskPtr Create(AsyncTaskFunc func);
/// \~chinese
/// @brief 构造异步任务
/// @brief 构造异步任务
AsyncTask();
virtual ~AsyncTask();
/// \~chinese
/// @brief 添加异步任务链
/// @brief 添加异步任务链
AsyncTask& Then(AsyncTaskFunc func);
/// \~chinese
/// @brief 设置任务执行完成后的回调函数
/// @note 该函数在 Kiwano 主线程中执行
/// @brief 设置任务执行完成后的回调函数
/// @note 该函数在 Kiwano 主线程中执行
AsyncTask& SetCallback(AsyncTaskCallback callback);
/// \~chinese
/// @brief 启动异步任务
/// @brief 启动异步任务
void Start();
private:

View File

@ -25,6 +25,7 @@
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <kiwano/macros.h>
@ -36,108 +37,108 @@ namespace kiwano
{
/// \~chinese
/// @brief 输入流
/// @brief 输入流
using InputStream = std::istream;
/// \~chinese
/// @brief 输出流
/// @brief 输出流
using OutputStream = std::ostream;
/// \~chinese
/// @brief 字符串容器
/// @brief 字符串容器
using String = oc::string;
/// \~chinese
/// @brief 宽字符串容器
/// @brief 宽字符串容器
using WideString = oc::wstring;
/// \~chinese
/// @brief 字符串流
/// @brief 字符串流
using StringStream = std::stringstream;
/// \~chinese
/// @brief 宽字符串流
/// @brief 宽字符串流
using WideStringStream = std::wstringstream;
/// \~chinese
/// @brief 线性数组容器
/// @brief 线性数组容器
template <typename _Ty, typename... _Args>
using Vector = std::vector<_Ty, _Args...>;
/// \~chinese
/// @brief 链表容器
/// @brief 链表容器
template <typename _Ty, typename... _Args>
using List = std::list<_Ty, _Args...>;
/// \~chinese
/// @brief 队列容器
/// @brief 队列容器
template <typename _Ty, typename... _Args>
using Queue = std::queue<_Ty, _Args...>;
/// \~chinese
/// @brief 集合容器
/// @brief 集合容器
template <typename _Ty, typename... _Args>
using Set = std::set<_Ty, _Args...>;
/// \~chinese
/// @brief 对容器
/// @brief 对容器
template <typename _Ty1, typename _Ty2>
using Pair = std::pair<_Ty1, _Ty2>;
/// \~chinese
/// @brief 无序集合容器
/// @brief 无序集合容器
template <typename _Ty, typename... _Args>
using UnorderedSet = std::unordered_set<_Ty, _Args...>;
/// \~chinese
/// @brief 栈容器
/// @brief 栈容器
template <typename _Ty, typename... _Args>
using Stack = std::stack<_Ty, _Args...>;
/// \~chinese
/// @brief 字符串容器
/// @brief 字符串容器
template <typename _Kty, typename _Ty, typename... _Args>
using Map = std::map<_Kty, _Ty, _Args...>;
/// \~chinese
/// @brief 字符串容器
/// @brief 字符串容器
template <typename _Kty, typename _Ty, typename... _Args>
using UnorderedMap = std::unordered_map<_Kty, _Ty, _Args...>;
/// \~chinese
/// @brief 函数封装器
/// @brief 函数封装器
template <typename _FuncTy>
using Function = oc::function<_FuncTy>;
/// \~chinese
/// @brief 单值容器
/// @brief 单值容器
using Any = oc::any;
/// \~chinese
/// @brief 侵入式链表容器
/// @brief 侵入式链表容器
template <typename _Ty>
using IntrusiveList = oc::intrusive_list<_Ty>;
/// \~chinese
/// @brief 侵入式链表元素
/// @brief 侵入式链表元素
template <typename _Ty>
using IntrusiveListItem = oc::intrusive_list_item<_Ty>;
/// \~chinese
/// @brief 侵入式智能指针
/// @brief 侵入式智能指针
template <typename _Ty, typename _RefProxyTy>
using IntrusivePtr = oc::intrusive_ptr<_Ty, _RefProxyTy>;
/// \~chinese
/// @brief JSON对象容器
/// @brief JSON对象容器
using Json = nlohmann::basic_json<Map, Vector, String>;
/// \~chinese
/// @brief 不可拷贝对象
/// @brief 不可拷贝对象
using Noncopyable = oc::noncopyable;
/// \~chinese
/// @brief 闭包函数
/// @brief 闭包函数
template <typename _Ty, typename _Uty, typename _Ret, typename... _Args>
inline Function<_Ret(_Args...)> Closure(_Uty* ptr, _Ret (_Ty::*func)(_Args...))
{
@ -145,21 +146,43 @@ inline Function<_Ret(_Args...)> Closure(_Uty* ptr, _Ret (_Ty::*func)(_Args...))
}
/// \~chinese
/// @brief 闭包函数
/// @brief 闭包函数
template <typename _Ty, typename _Uty, typename _Ret, typename... _Args>
inline Function<_Ret(_Args...)> Closure(_Uty* ptr, _Ret (_Ty::*func)(_Args...) const)
{
return oc::closure(ptr, func);
}
#if defined(KGE_WIN32)
inline String WideToMultiByte(const WideString& str)
{
return oc::wide_to_string(str);
int chars_num = ::WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, NULL, 0, NULL, NULL);
if (chars_num)
{
String result;
result.resize(chars_num);
::WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, &result[0], chars_num, NULL, NULL);
return result;
}
return String();
}
inline WideString MultiByteToWide(const String& str)
{
return oc::string_to_wide(str);
int wchars_num = ::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
if (wchars_num)
{
WideString result;
result.resize(wchars_num);
::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &result[0], wchars_num);
return result;
}
return WideString();
}
#endif // KGE_WIN32
} // namespace kiwano

View File

@ -29,17 +29,17 @@ class Event;
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API ComponentBase
{
public:
/// \~chinese
/// @brief 启动组件
/// @brief 启动组件
virtual void SetupComponent() = 0;
/// \~chinese
/// @brief 销毁组件
/// @brief 销毁组件
virtual void DestroyComponent() = 0;
bool Check(const int flag);
@ -53,22 +53,22 @@ protected:
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API RenderComponent : public virtual ComponentBase
{
public:
/// \~chinese
/// @brief 渲染前
/// @brief 渲染前
virtual void BeforeRender() {}
/// \~chinese
/// @brief 渲染时
/// @param ctx 渲染上下文
/// @brief 渲染时
/// @param ctx 渲染上下文
virtual void OnRender(RenderContext& ctx) {}
/// \~chinese
/// @brief 渲染后
/// @brief 渲染后
virtual void AfterRender() {}
public:
@ -79,22 +79,22 @@ public:
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API UpdateComponent : public virtual ComponentBase
{
public:
/// \~chinese
/// @brief 更新前
/// @brief 更新前
virtual void BeforeUpdate() {}
/// \~chinese
/// @brief 更新时
/// @param dt 间隔时间
/// @brief 更新时
/// @param dt 间隔时间
virtual void OnUpdate(Duration dt) {}
/// \~chinese
/// @brief 更新后
/// @brief 更新后
virtual void AfterUpdate() {}
public:
@ -105,14 +105,14 @@ public:
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API EventComponent : public virtual ComponentBase
{
public:
/// \~chinese
/// @brief 事件处理
/// @param evt 事件
/// @brief 事件处理
/// @param evt 事件
virtual void HandleEvent(Event* evt) {}
public:

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Exception : public std::exception
{
@ -36,18 +36,18 @@ public:
Exception();
/// \~chinese
/// @brief 构造异常
/// @param message 描述异常的信息
/// @brief 构造异常
/// @param message 描述异常的信息
explicit Exception(String const& message);
virtual ~Exception();
/// \~chinese
/// @brief 转为解释性字符串
/// @brief 转为解释性字符串
const String& ToString() const;
/// \~chinese
/// @brief 转为解释性字符串
/// @brief 转为解释性字符串
virtual const char* what() const override;
protected:
@ -56,27 +56,27 @@ protected:
/**
* \~chinese
* @brief
* @brief
*/
class SystemException : public Exception
{
public:
#if defined(KGE_WIN32)
/// \~chinese
/// @brief 错误代码类型
/// @brief 错误代码类型
typedef HRESULT ErrorCodeType;
#endif
SystemException();
/// \~chinese
/// @brief 构造系统异常
/// @param code 错误代码
/// @param message 描述异常的信息
/// @brief 构造系统异常
/// @param code 错误代码
/// @param message 描述异常的信息
SystemException(ErrorCodeType code, String const& message);
/// \~chinese
/// @brief 获取错误代码
/// @brief 获取错误代码
ErrorCodeType GetErrorCode() const;
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
struct DefaultSmartPtrRefProxy
{
@ -45,7 +45,7 @@ struct DefaultSmartPtrRefProxy
/**
* \~chinese
* @brief
* @brief
*/
template <typename _Ty>
using SmartPtr = IntrusivePtr<_Ty, DefaultSmartPtrRefProxy>;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,28 +21,28 @@
#pragma once
#ifndef __cplusplus
#error Kiwano only supports C++
# error Kiwano only supports C++
#endif
#ifdef _WIN32
#define KGE_WIN32
#ifdef _WIN64
#define KGE_WIN64
#endif
# define KGE_WIN32
# ifdef _WIN64
# define KGE_WIN64
# endif
#elif __ANDROID__
#define KGE_ANDROID
# define KGE_ANDROID
#elif __linux__
#define KGE_LINUX
# define KGE_LINUX
#elif __APPLE__
#if TARGET_OS_IPHONE
#define KGE_IPHONE
#elif TARGET_OS_MAC
#define KGE_MACOS
# if TARGET_OS_IPHONE
# define KGE_IPHONE
# elif TARGET_OS_MAC
# define KGE_MACOS
# else
# error "Unsupported Apple platform"
# endif
#else
#error "Unsupported Apple platform"
#endif
#else
#error "Unsupported compiler"
# error "Unsupported compiler"
#endif
// C++ RunTime Header Files
@ -56,48 +56,48 @@
#ifdef KGE_WIN32
#ifndef _MSC_VER
#error Kiwano only supports MSVC compiler
# error Kiwano only supports MSVC compiler
#endif
#ifndef KGE_VS_VER
#define KGE_VS_VER _MSC_VER
#define KGE_VS_2013 1800
#define KGE_VS_2015 1900
#define KGE_VS_2017 1900
#define KGE_VS_2019 1920
# define KGE_VS_VER _MSC_VER
# define KGE_VS_2013 1800
# define KGE_VS_2015 1900
# define KGE_VS_2017 1900
# define KGE_VS_2019 1920
#endif
#if KGE_VS_VER < KGE_VS_2015
#error Kiwano only supports Visual Studio 2015 and above
# error Kiwano only supports Visual Studio 2015 and above
#endif
#ifndef WINVER
#define WINVER 0x0700 // Allow use of features specific to Windows 7 or later
# define WINVER 0x0700 // Allow use of features specific to Windows 7 or later
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0700 // Allow use of features specific to Windows 7 or later
# define _WIN32_WINNT 0x0700 // Allow use of features specific to Windows 7 or later
#endif
#ifndef NTDDI_VERSION
#define NTDDI_VERSION NTDDI_WIN7
# define NTDDI_VERSION NTDDI_WIN7
#endif
#ifndef UNICODE
#define UNICODE
# define UNICODE
#endif
// Exclude rarely-used items from Windows headers
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX
#define NOMINMAX
# define NOMINMAX
#endif
#if defined(DEBUG) || defined(_DEBUG)
#define KGE_DEBUG
# define KGE_DEBUG
#endif
#define KGE_SUPPRESS_WARNING_PUSH __pragma(warning(push))
@ -105,28 +105,28 @@
#define KGE_SUPPRESS_WARNING_POP __pragma(warning(pop))
#ifndef KGE_ASSERT
#ifdef KGE_DEBUG
#define KGE_ASSERT(EXPR) \
do \
{ \
(void)((!!(EXPR)) || (_wassert(_CRT_WIDE(#EXPR), _CRT_WIDE(__FUNCTION__), (unsigned)(__LINE__)), 0)); \
} while (0)
#else
#define KGE_ASSERT __noop
#endif
# ifdef KGE_DEBUG
# define KGE_ASSERT(EXPR) \
do \
{ \
(void)((!!(EXPR)) || (_wassert(_CRT_WIDE(#EXPR), _CRT_WIDE(__FUNCTION__), (unsigned)(__LINE__)), 0)); \
} while (0)
# else
# define KGE_ASSERT __noop
# endif
#endif
#ifndef KGE_API
#if defined(KGE_USE_DLL)
#define KGE_API __declspec(dllimport)
#elif defined(KGE_EXPORT_DLL)
#define KGE_API __declspec(dllexport)
#endif
# if defined(KGE_USE_DLL)
# define KGE_API __declspec(dllimport)
# elif defined(KGE_EXPORT_DLL)
# define KGE_API __declspec(dllexport)
# endif
#endif
#ifndef KGE_API
/* Building or calling Kiwano as a static library */
#define KGE_API
# define KGE_API
#else
/*
* C4251 can be ignored if you are deriving from a type in the
@ -136,8 +136,6 @@
KGE_SUPPRESS_WARNING(4251)
#endif
#define KGE_NOT_USED(VAR) ((void)VAR)
#define KGE_DEPRECATED(...) __declspec(deprecated(__VA_ARGS__))
// Windows Header Files
@ -145,3 +143,5 @@ KGE_SUPPRESS_WARNING(4251)
#include <windows.h>
#endif // KGE_WIN32
#define KGE_NOT_USED(VAR) ((void)VAR)

View File

@ -26,11 +26,11 @@ namespace kiwano
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);
//

View File

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

View File

@ -33,7 +33,7 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Application : protected Noncopyable
{
@ -44,81 +44,81 @@ public:
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
virtual void OnReady();
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
virtual void OnDestroy();
/**
* \~chinese
* @brief
* @details OnReady
* @param debug
* @note
* @brief
* @details OnReady
* @param debug
* @note
*/
void Run(bool debug = false);
/**
* \~chinese
* @brief
* @brief
*/
void Quit();
/**
* \~chinese
* @brief
* @brief
*/
void Destroy();
/**
* \~chinese
* @brief
* @param[in] component
* @brief
* @param[in] component
*/
void Use(ComponentBase* component);
/**
* \~chinese
* @brief
* @details
* @param scale_factor
* @warning
* @brief
* @details
* @param scale_factor
* @warning
*/
void SetTimeScale(float scale_factor);
/**
* \~chinese
* @brief
* @details
* @param evt
* @brief
* @details
* @param evt
*/
void DispatchEvent(Event* evt);
/**
* \~chinese
* @brief 线
* @details 线 Kiwano
* @param func
* @brief 线
* @details 线 Kiwano
* @param func
*/
static void PreformInMainThread(Function<void()> func);
private:
/**
* \~chinese
* @brief
* @brief
*/
void Update();
/**
* \~chinese
* @brief
* @brief
*/
void Render();

View File

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

View File

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

View File

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

View File

@ -39,7 +39,6 @@
namespace kiwano
{
Window& Window::GetInstance()
{
return WindowImpl::GetInstance();
@ -229,8 +228,10 @@ void WindowImpl::Create(String const& title, uint32_t width, uint32_t height, ui
height = win_height;
}
handle_ = ::CreateWindowExA(is_fullscreen_ ? WS_EX_TOPMOST : 0, "KiwanoAppWnd", title.c_str(), GetStyle(), left,
top, width, height, nullptr, nullptr, hinst, nullptr);
WideString wide_title = MultiByteToWide(title);
handle_ = ::CreateWindowExW(is_fullscreen_ ? WS_EX_TOPMOST : 0, L"KiwanoAppWnd", wide_title.c_str(), GetStyle(),
left, top, width, height, nullptr, nullptr, hinst, nullptr);
if (handle_ == nullptr)
{
@ -240,7 +241,7 @@ void WindowImpl::Create(String const& title, uint32_t width, uint32_t height, ui
throw SystemException(HRESULT_FROM_WIN32(GetLastError()), "Create window failed");
}
width_ = width;
width_ = width;
height_ = height;
// disable imm
@ -276,7 +277,10 @@ void WindowImpl::PumpEvents()
void WindowImpl::SetTitle(String const& title)
{
if (handle_)
::SetWindowTextA(handle_, title.c_str());
{
WideString wide_title = MultiByteToWide(title);
::SetWindowTextW(handle_, wide_title.c_str());
}
}
void WindowImpl::SetIcon(uint32_t icon_resource)
@ -557,7 +561,7 @@ LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA
{
// KGE_SYS_LOG("Window resized");
window->width_ = ((uint32_t)(short)LOWORD(lparam));
window->width_ = ((uint32_t)(short)LOWORD(lparam));
window->height_ = ((uint32_t)(short)HIWORD(lparam));
WindowResizedEventPtr evt = new WindowResizedEvent;

View File

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

View File

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

View File

@ -161,7 +161,7 @@ void RendererImpl::Present()
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET)
{
// 如果 Direct3D 设备在执行过程中消失,将丢弃当前的设备相关资源
// 如果 Direct3D 设备在执行过程中消失,将丢弃当前的设备相关资源
hr = HandleDeviceLost();
}

View File

@ -95,11 +95,11 @@ public:
RenderContext& GetContext();
/// \~chinese
/// @brief 获取Direct2D设备资源
/// @brief 获取Direct2D设备资源
ID2DDeviceResources* GetD2DDeviceResources();
/// \~chinese
/// @brief 获取Direct3D设备资源
/// @brief 获取Direct3D设备资源
ID3DDeviceResources* GetD3DDeviceResources();
public:

View File

@ -37,7 +37,7 @@ class Renderer;
/**
* \~chinese
* @brief
* @brief
*/
class Font : public virtual ObjectBase
{
@ -45,21 +45,21 @@ class Font : public virtual ObjectBase
public:
/// \~chinese
/// @brief 创建字体
/// @brief 创建字体
static FontPtr Create(String const& file);
/// \~chinese
/// @brief 创建字体
/// @brief 创建字体
static FontPtr Create(Resource const& resource);
Font();
/// \~chinese
/// @brief 加载字体文件
/// @brief 加载字体文件
bool Load(String const& file);
/// \~chinese
/// @brief 加载字体资源
/// @brief 加载字体资源
bool Load(Resource const& resource);
#if defined(KGE_WIN32)

View File

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

View File

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

View File

@ -31,7 +31,7 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API LayerArea
{
@ -39,39 +39,39 @@ public:
LayerArea();
/// \~chinese
/// @brief 是否有效
/// @brief 是否有效
bool IsValid() const;
/// \~chinese
/// @brief 获取图层区域
/// @brief 获取图层区域
Rect const& GetAreaRect() const;
/// \~chinese
/// @brief 获取图层透明度
/// @brief 获取图层透明度
float GetOpacity() const;
/// \~chinese
/// @brief 获取几何蒙层
/// @brief 获取几何蒙层
ShapePtr GetMaskShape() const;
/// \~chinese
/// @brief 获取几何蒙层变换
/// @brief 获取几何蒙层变换
Matrix3x2 const& GetMaskTransform() const;
/// \~chinese
/// @brief 设置图层区域
/// @brief 设置图层区域
void SetAreaRect(Rect const& area);
/// \~chinese
/// @brief 设置图层透明度
/// @brief 设置图层透明度
void SetOpacity(float opacity);
/// \~chinese
/// @brief 设置几何蒙层
/// @brief 设置几何蒙层
void SetMaskShape(ShapePtr mask);
/// \~chinese
/// @brief 设置几何蒙层变换
/// @brief 设置几何蒙层变换
void SetMaskTransform(Matrix3x2 const& matrix);
private:

View File

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

View File

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

View File

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

View File

@ -30,17 +30,17 @@ namespace kiwano
*/
/// \~chinese
/// @brief 形状组合方式
/// @brief 形状组合方式
enum class CombineMode
{
Union, ///< 并集 (A + B)
Intersect, ///< 交集 (A + B)
Xor, ///< 对称差集 ((A - B) + (B - A))
Exclude ///< 差集 (A - B)
Union, ///< 并集 (A + B)
Intersect, ///< 交集 (A + B)
Xor, ///< 对称差集 ((A - B) + (B - A))
Exclude ///< 差集 (A - B)
};
/// \~chinese
/// @brief 形状生成器
/// @brief 形状生成器
class KGE_API ShapeSink : protected Noncopyable
{
public:
@ -49,84 +49,84 @@ public:
~ShapeSink();
/// \~chinese
/// @brief 打开输入流
/// @brief 打开输入流
void Open();
/// \~chinese
/// @brief 关闭输入流
/// @brief 关闭输入流
void Close();
/// \~chinese
/// @brief 输入流是否已经打开
/// @brief 输入流是否已经打开
bool IsOpened() const;
/// \~chinese
/// @brief 获取生成的形状
/// @note 若还未关闭输入流,则自动关闭
/// @brief 获取生成的形状
/// @note 若还未关闭输入流,则自动关闭
ShapePtr GetShape();
/// \~chinese
/// @brief 添加形状的轮廓
/// @param input 输入的形状
/// @param input_matrix 应用到输入形状上的二维变换
/// @note 若还未打开输入流,则自动打开
/// @brief 添加形状的轮廓
/// @param input 输入的形状
/// @param input_matrix 应用到输入形状上的二维变换
/// @note 若还未打开输入流,则自动打开
ShapeSink& AddShape(ShapePtr input, const Matrix3x2* input_matrix = nullptr);
/// \~chinese
/// @brief 开始添加路径
/// @param begin_pos 路径起始点
/// @note 若还未打开输入流,则自动打开
/// @brief 开始添加路径
/// @param begin_pos 路径起始点
/// @note 若还未打开输入流,则自动打开
ShapeSink& BeginPath(Point const& begin_pos = Point());
/// \~chinese
/// @brief 结束路径
/// @param closed 路径是否闭合
/// @brief 结束路径
/// @param closed 路径是否闭合
ShapeSink& EndPath(bool closed = false);
/// \~chinese
/// @brief 添加一条线段
/// @param point 端点
/// @brief 添加一条线段
/// @param point 端点
ShapeSink& AddLine(Point const& point);
/// \~chinese
/// @brief 添加多条线段
/// @param points 端点集合
/// @brief 添加多条线段
/// @param points 端点集合
ShapeSink& AddLines(Vector<Point> const& points);
/// \~chinese
/// @brief 添加多条线段
/// @param points 端点数组
/// @param count 端点数量
/// @brief 添加多条线段
/// @param points 端点数组
/// @param count 端点数量
ShapeSink& AddLines(const Point* points, size_t count);
/// \~chinese
/// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点
/// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点
ShapeSink& AddBezier(Point const& point1, Point const& point2, Point const& point3);
/// \~chinese
/// @brief 添加弧线
/// @param point 终点
/// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧
/// @brief 添加弧线
/// @param point 终点
/// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧
ShapeSink& AddArc(Point const& point, Size const& radius, float rotation, bool clockwise = true,
bool is_small = true);
/// \~chinese
/// @brief 组合形状,并将结果输出到流中
/// @param shape_a 输入的形状A
/// @param shape_b 输入的形状B
/// @param mode 组合方式
/// @param matrix 应用到输入形状B上的二维变换
/// @note 若还未打开输入流,则自动打开
/// @brief 组合形状,并将结果输出到流中
/// @param shape_a 输入的形状A
/// @param shape_b 输入的形状B
/// @param mode 组合方式
/// @param matrix 应用到输入形状B上的二维变换
/// @note 若还未打开输入流,则自动打开
ShapeSink& Combine(ShapePtr shape_a, ShapePtr shape_b, CombineMode mode, const Matrix3x2* matrix = nullptr);
/// \~chinese
/// @brief 清空图形
/// @brief 清空图形
void Clear();
private:

View File

@ -33,69 +33,69 @@ KGE_DECLARE_SMART_PTR(StrokeStyle);
*/
/// \~chinese
/// @brief 线条端点样式
/// @details 线条端点样式表示线段端点部分的形状
/// @brief 线条端点样式
/// @details 线条端点样式表示线段端点部分的形状
enum class CapStyle
{
Flat, ///< 扁端点
Square, ///< 方形端点,方形突出部分等于线段宽度的一半
Round, ///< 圆形端点,圆直径等于线段宽度
Triangle, ///< 三角样式,三角斜边长度等于线段宽度
Flat, ///< 扁端点
Square, ///< 方形端点,方形突出部分等于线段宽度的一半
Round, ///< 圆形端点,圆直径等于线段宽度
Triangle, ///< 三角样式,三角斜边长度等于线段宽度
};
/// \~chinese
/// @brief 线条交点样式
/// @details 线条交点样式表示两条线相交部分的形状
/// @brief 线条交点样式
/// @details 线条交点样式表示两条线相交部分的形状
enum class LineJoinStyle
{
Miter, ///< 斜切样式
Bevel, ///< 斜角样式
Round ///< 圆角样式
Miter, ///< 斜切样式
Bevel, ///< 斜角样式
Round ///< 圆角样式
};
/// \~chinese
/// @brief 线条虚线样式
/// @details 线条虚线样式表示线段的间隙
/// @brief 线条虚线样式
/// @details 线条虚线样式表示线段的间隙
enum class DashStyle
{
Solid, ///< 无间断的实线
Dash, ///< 斜角样式
Dot, ///< 圆角样式
DashDot, ///< 圆角样式
DashDotDot, ///< 圆角样式
Solid, ///< 无间断的实线
Dash, ///< 斜角样式
Dot, ///< 圆角样式
DashDot, ///< 圆角样式
DashDotDot, ///< 圆角样式
};
/// \~chinese
/// @brief 线条样式
/// @brief 线条样式
class StrokeStyle : public virtual ObjectBase
{
public:
/// \~chinese
/// @brief 创建线条样式
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash 线条虚线样式
/// @param dash_offset 线条虚线偏移量
/// @brief 创建线条样式
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash 线条虚线样式
/// @param dash_offset 线条虚线偏移量
static StrokeStylePtr Create(CapStyle cap, LineJoinStyle line_join = LineJoinStyle::Miter,
DashStyle dash = DashStyle::Solid, float dash_offset = 0.0f);
/// \~chinese
/// @brief 创建线条样式
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小
/// @param dash_offset 线条虚线偏移量
/// @brief 创建线条样式
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小
/// @param dash_offset 线条虚线偏移量
static StrokeStylePtr Create(CapStyle cap, LineJoinStyle line_join = LineJoinStyle::Miter,
const float* dash_array = nullptr, size_t dash_size = 0, float dash_offset = 0.0f);
/// \~chinese
/// @brief 创建线条样式
/// @tparam _DashSize 线条虚线数组大小
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_offset 线条虚线偏移量
/// @brief 创建线条样式
/// @tparam _DashSize 线条虚线数组大小
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_offset 线条虚线偏移量
template <size_t _DashSize>
static StrokeStylePtr Create(CapStyle cap, LineJoinStyle line_join = LineJoinStyle::Miter,
float (&dash_array)[_DashSize] = nullptr, float dash_offset = 0.0f)
@ -106,7 +106,7 @@ public:
StrokeStyle();
/// \~chinese
/// @brief 是否有效
/// @brief 是否有效
bool IsValid() const;
#if defined(KGE_WIN32)

View File

@ -31,129 +31,129 @@ namespace kiwano
*/
/// \~chinese
/// @brief 文本布局
/// @brief 文本布局
class KGE_API TextLayout
{
public:
/// \~chinese
/// @brief 构造空的文本布局
/// @brief 构造空的文本布局
TextLayout();
/// \~chinese
/// @brief 文本布局是否有效
/// @brief 文本布局是否有效
bool IsValid() const;
/// \~chinese
/// @brief 文本布局是否陈旧
/// @brief 文本布局是否陈旧
bool IsDirty() const;
/// \~chinese
/// @brief 更新文本布局
/// @note 文本布局是懒更新的,在修改文本布局的属性后需要手动更新
/// @brief 更新文本布局
/// @note 文本布局是懒更新的,在修改文本布局的属性后需要手动更新
void Update();
/// \~chinese
/// @brief 获取文本
/// @brief 获取文本
const String& GetText() const;
/// \~chinese
/// @brief 获取文本样式
/// @brief 获取文本样式
const TextStyle& GetStyle() const;
/// \~chinese
/// @brief 获取文本行数
/// @brief 获取文本行数
uint32_t GetLineCount() const;
/// \~chinese
/// @brief 获取文本布局大小
/// @brief 获取文本布局大小
Size GetLayoutSize() const;
/// \~chinese
/// @brief 获取填充画刷
/// @brief 获取填充画刷
BrushPtr GetFillBrush() const;
/// \~chinese
/// @brief 获取描边画刷
/// @brief 获取描边画刷
BrushPtr GetOutlineBrush() const;
/// \~chinese
/// @brief 设置文本
/// @brief 设置文本
void SetText(const String& text);
/// \~chinese
/// @brief 设置文本样式
/// @brief 设置文本样式
void SetStyle(const TextStyle& style);
/// \~chinese
/// @brief 设置字体
/// @brief 设置字体
void SetFont(FontPtr font);
/// \~chinese
/// @brief 设置字体族
/// @brief 设置字体族
void SetFontFamily(String const& family);
/// \~chinese
/// @brief 设置字号(默认值为 18
/// @brief 设置字号(默认值为 18
void SetFontSize(float size);
/// \~chinese
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal
void SetFontWeight(uint32_t weight);
/// \~chinese
/// @brief 设置文字填充画刷
/// @brief 设置文字填充画刷
void SetFillBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置文字斜体(默认值为 false
/// @brief 设置文字斜体(默认值为 false
void SetItalic(bool italic);
/// \~chinese
/// @brief 设置文本自动换行的宽度
/// @brief 设置文本自动换行的宽度
void SetWrapWidth(float wrap_width);
/// \~chinese
/// @brief 设置行间距(默认为 0
/// @brief 设置行间距(默认为 0
void SetLineSpacing(float line_spacing);
/// \~chinese
/// @brief 设置对齐方式
/// @brief 设置对齐方式
void SetAlignment(TextAlign align);
/// \~chinese
/// @brief 设置文字描边画刷
/// @brief 设置文字描边画刷
void SetOutlineBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置文字描边线宽
/// @brief 设置文字描边线宽
void SetOutlineWidth(float outline_width);
/// \~chinese
/// @brief 设置文字描边线相交样式
/// @brief 设置文字描边线相交样式
void SetOutlineStroke(StrokeStylePtr outline_stroke);
/// \~chinese
/// @brief 设置下划线
/// @param enable 是否显示下划线
/// @param start 起始位置
/// @param length 长度
/// @brief 设置下划线
/// @param enable 是否显示下划线
/// @param start 起始位置
/// @param length 长度
void SetUnderline(bool enable, uint32_t start, uint32_t length);
/// \~chinese
/// @brief 设置删除线
/// @param enable 是否显示删除线
/// @param start 起始位置
/// @param length 长度
/// @brief 设置删除线
/// @param enable 是否显示删除线
/// @param start 起始位置
/// @param length 长度
void SetStrikethrough(bool enable, uint32_t start, uint32_t length);
/// \~chinese
/// @brief 脏数据标志
/// @brief 脏数据标志
enum DirtyFlag : uint8_t
{
Clean = 0, ///< 干净数据
DirtyFormat = 1, ///< 文字格式待更新
DirtyLayout = 1 << 1, ///< 文字布局待更新
Updated = 1 << 2, ///< 数据已更新
Clean = 0, ///< 干净数据
DirtyFormat = 1, ///< 文字格式待更新
DirtyLayout = 1 << 1, ///< 文字布局待更新
Updated = 1 << 2, ///< 数据已更新
};
uint8_t GetDirtyFlag() const;

View File

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

View File

@ -35,28 +35,28 @@ KGE_DECLARE_SMART_PTR(Texture);
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
enum class InterpolationMode
{
Linear, ///< 双线性插值,对周围四个像素进行两次线性插值计算,在图像放大时可能会模糊
Nearest ///< 最邻近插值,取最邻近的像素点的颜色值
Linear, ///< 双线性插值,对周围四个像素进行两次线性插值计算,在图像放大时可能会模糊
Nearest ///< 最邻近插值,取最邻近的像素点的颜色值
};
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Texture : public virtual ObjectBase
{
public:
/// \~chinese
/// @brief 从本地文件创建纹理
/// @brief 从本地文件创建纹理
static TexturePtr Create(String const& file_path);
/// \~chinese
/// @brief 从资源创建纹理
/// @brief 从资源创建纹理
static TexturePtr Create(Resource const& res);
Texture();
@ -64,67 +64,67 @@ public:
virtual ~Texture();
/// \~chinese
/// @brief 加载本地文件
/// @brief 加载本地文件
bool Load(String const& file_path);
/// \~chinese
/// @brief 加载资源
/// @brief 加载资源
bool Load(Resource const& res);
/// \~chinese
/// @brief 是否有效
/// @brief 是否有效
bool IsValid() const;
/// \~chinese
/// @brief 获取纹理宽度
/// @brief 获取纹理宽度
float GetWidth() const;
/// \~chinese
/// @brief 获取纹理高度
/// @brief 获取纹理高度
float GetHeight() const;
/// \~chinese
/// @brief 获取纹理大小
/// @brief 获取纹理大小
Size GetSize() const;
/// \~chinese
/// @brief 获取像素宽度
/// @brief 获取像素宽度
uint32_t GetWidthInPixels() const;
/// \~chinese
/// @brief 获取像素高度
/// @brief 获取像素高度
uint32_t GetHeightInPixels() const;
/// \~chinese
/// @brief 获取像素大小
/// @brief 获取像素大小
math::Vec2T<uint32_t> GetSizeInPixels() const;
/// \~chinese
/// @brief 获取像素插值方式
/// @brief 获取像素插值方式
InterpolationMode GetBitmapInterpolationMode() const;
/// \~chinese
/// @brief 拷贝纹理
/// @param copy_from 源纹理
/// @brief 拷贝纹理
/// @param copy_from 源纹理
void CopyFrom(TexturePtr copy_from);
/// \~chinese
/// @brief 拷贝纹理
/// @param copy_from 源纹理
/// @param src_rect 源纹理裁剪矩形
/// @param dest_point 拷贝至目标位置
/// @brief 拷贝纹理
/// @param copy_from 源纹理
/// @param src_rect 源纹理裁剪矩形
/// @param dest_point 拷贝至目标位置
void CopyFrom(TexturePtr copy_from, Rect const& src_rect, Point const& dest_point);
/// \~chinese
/// @brief 设置像素插值方式
/// @brief 设置像素插值方式
void SetInterpolationMode(InterpolationMode mode);
/// \~chinese
/// @brief 设置默认的像素插值方式
/// @brief 设置默认的像素插值方式
static void SetDefaultInterpolationMode(InterpolationMode mode);
/// \~chinese
/// @brief 获取默认的像素插值方式
/// @brief 获取默认的像素插值方式
static InterpolationMode GetDefaultInterpolationMode();
private:
@ -135,11 +135,11 @@ private:
#if defined(KGE_WIN32)
public:
/// \~chinese
/// @brief 获取源位图
/// @brief 获取源位图
ComPtr<ID2D1Bitmap> GetBitmap() const;
/// \~chinese
/// @brief 设置源位图
/// @brief 设置源位图
void SetBitmap(ComPtr<ID2D1Bitmap> bitmap);
private:

View File

@ -31,7 +31,7 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API TextureCache : public Singleton<TextureCache>
{
@ -39,39 +39,39 @@ class KGE_API TextureCache : public Singleton<TextureCache>
public:
/// \~chinese
/// @brief 添加或获取纹理
/// @brief 添加或获取纹理
TexturePtr AddOrGetTexture(String const& file_path);
/// \~chinese
/// @brief 添加或获取纹理
/// @brief 添加或获取纹理
TexturePtr AddOrGetTexture(Resource const& res);
/// \~chinese
/// @brief 添加或获取GIF图像
/// @brief 添加或获取GIF图像
GifImagePtr AddOrGetGifImage(String const& file_path);
/// \~chinese
/// @brief 添加或获取GIF图像
/// @brief 添加或获取GIF图像
GifImagePtr AddOrGetGifImage(Resource const& res);
/// \~chinese
/// @brief 移除纹理缓存
/// @brief 移除纹理缓存
void RemoveTexture(String const& file_path);
/// \~chinese
/// @brief 移除纹理缓存
/// @brief 移除纹理缓存
void RemoveTexture(Resource const& res);
/// \~chinese
/// @brief 移除GIF图像缓存
/// @brief 移除GIF图像缓存
void RemoveGifImage(String const& file_path);
/// \~chinese
/// @brief 移除GIF图像缓存
/// @brief 移除GIF图像缓存
void RemoveGifImage(Resource const& res);
/// \~chinese
/// @brief 清空缓存
/// @brief 清空缓存
void Clear();
private:

View File

@ -31,24 +31,24 @@ KGE_DECLARE_SMART_PTR(TextureRenderContext);
*/
/// \~chinese
/// @brief 纹理渲染上下文
/// @details 纹理渲染上下文将渲染输出到一个纹理对象中
/// @brief 纹理渲染上下文
/// @details 纹理渲染上下文将渲染输出到一个纹理对象中
class KGE_API TextureRenderContext : public virtual RenderContext
{
public:
/// \~chinese
/// @brief 创建纹理渲染上下文
/// @brief 创建纹理渲染上下文
static TextureRenderContextPtr Create();
/// \~chinese
/// @brief 创建纹理渲染上下文
/// @param size 期望的输出大小
/// @brief 创建纹理渲染上下文
/// @param size 期望的输出大小
static TextureRenderContextPtr Create(Size const& desired_size);
/// \~chinese
/// @brief 获取渲染输出
/// @param[out] texture 纹理输出
/// @return 操作是否成功
/// @brief 获取渲染输出
/// @param[out] texture 纹理输出
/// @return 操作是否成功
virtual bool GetOutput(Texture& texture) = 0;
};

View File

@ -28,112 +28,112 @@ namespace kiwano
KGE_DECLARE_SMART_PTR(LocalStorage);
/// \~chinese
/// @brief 本地存储
/// @details LocalStorage是一个简易的持久化工具存放字符串-值)的键值对
/// 支持的数据类型包括 (bool | int | float | double | String)
/// 例如, 保存游戏最高分, 以便下次进行游戏时读取:
/// @brief 本地存储
/// @details LocalStorage是一个简易的持久化工具存放字符串-值)的键值对
/// 支持的数据类型包括 (bool | int | float | double | String)
/// 例如, 保存游戏最高分, 以便下次进行游戏时读取:
/// @code
/// LocalStorage data; // 创建数据对象
/// data.SaveInt("best-score", 20); // 保存最高分 20
/// int best = data.GetInt("best-score"); // 读取之前储存的最高分
/// LocalStorage data; // 创建数据对象
/// data.SaveInt("best-score", 20); // 保存最高分 20
/// int best = data.GetInt("best-score"); // 读取之前储存的最高分
/// @endcode
class KGE_API LocalStorage : public virtual ObjectBase
{
public:
/// \~chinese
/// @brief 构建本地存储对象
/// @param file_path 文件储存路径
/// @param field 字段名
/// @brief 构建本地存储对象
/// @param file_path 文件储存路径
/// @param field 字段名
LocalStorage(String const& file_path = "data.ini", String const& field = "defalut");
/// \~chinese
/// @brief 获取文件储存路径
/// @brief 获取文件储存路径
String const& GetFilePath() const;
/// \~chinese
/// @brief 设置文件储存路径
/// @brief 设置文件储存路径
void SetFilePath(String const& file_path);
/// \~chinese
/// @brief 获取字段名
/// @brief 获取字段名
String const& GetFieldName() const;
/// \~chinese
/// @brief 设置字段名
/// @brief 设置字段名
void SetFieldName(String const& field);
/// \~chinese
/// @brief 判断键对应的数据是否存在
/// @brief 判断键对应的数据是否存在
bool Exists(String const& key) const;
/// \~chinese
/// @brief 保存 int 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
/// @brief 保存 int 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
bool SaveInt(String const& key, int val) const;
/// \~chinese
/// @brief 保存 float 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
/// @brief 保存 float 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
bool SaveFloat(String const& key, float val) const;
/// \~chinese
/// @brief 保存 double 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
/// @brief 保存 double 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
bool SaveDouble(String const& key, double val) const;
/// \~chinese
/// @brief 保存 bool 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
/// @brief 保存 bool 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
bool SaveBool(String const& key, bool val) const;
/// \~chinese
/// @brief 保存 String 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
/// @brief 保存 String 类型的值
/// @param key 键
/// @param val 值
/// @return 操作是否成功
bool SaveString(String const& key, String const& val) const;
/// \~chinese
/// @brief 获取 int 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
/// @brief 获取 int 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
int GetInt(String const& key, int default_value = 0) const;
/// \~chinese
/// @brief 获取 float 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
/// @brief 获取 float 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
float GetFloat(String const& key, float default_value = 0.0f) const;
/// \~chinese
/// @brief 获取 double 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
/// @brief 获取 double 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
double GetDouble(String const& key, double default_value = 0.0) const;
/// \~chinese
/// @brief 获取 bool 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
/// @brief 获取 bool 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
bool GetBool(String const& key, bool default_value = false) const;
/// \~chinese
/// @brief 获取 字符串 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
/// @brief 获取 字符串 类型的值
/// @param key 键
/// @param default_value 值不存在时返回的默认值
/// @return 值
String GetString(String const& key, String const& default_value = String()) const;
private:

View File

@ -320,7 +320,7 @@ bool LoadTexturesFromData(ResourceCache* loader, GlobalData* gdata, const String
}
}
if (file.empty())
if (!file.empty())
{
// Simple image
FramePtr frame = new (std::nothrow) Frame;

View File

@ -29,43 +29,43 @@
namespace kiwano
{
/// \~chinese
/// @brief 资源缓存
/// @details 资源缓存
/// @brief 资源缓存
/// @details 资源缓存
class KGE_API ResourceCache : public Singleton<ResourceCache>
{
friend Singleton<ResourceCache>;
public:
/// \~chinese
/// @brief 从 JSON 文件加载资源信息
/// @param file_path JSON文件路径
/// @brief 从 JSON 文件加载资源信息
/// @param file_path JSON文件路径
bool LoadFromJsonFile(String const& file_path);
/// \~chinese
/// @brief 从 JSON 加载资源信息
/// @param json_data JSON对象
/// @brief 从 JSON 加载资源信息
/// @param json_data JSON对象
bool LoadFromJson(Json const& json_data);
/// \~chinese
/// @brief 从 XML 文件加载资源信息
/// @param file_path XML文件路径
/// @brief 从 XML 文件加载资源信息
/// @param file_path XML文件路径
bool LoadFromXmlFile(String const& file_path);
/// \~chinese
/// @brief 从 XML 文档对象加载资源信息
/// @param doc XML文档对象
/// @brief 从 XML 文档对象加载资源信息
/// @param doc XML文档对象
bool LoadFromXml(pugi::xml_document const& doc);
/// \~chinese
/// @brief 获取资源
/// @param id 对象ID
/// @brief 获取资源
/// @param id 对象ID
ObjectBasePtr Get(String const& id) const;
/// \~chinese
/// @brief 获取资源
/// @tparam _Ty 对象类型
/// @param id 对象ID
/// @return 指定对象类型的指针
/// @brief 获取资源
/// @tparam _Ty 对象类型
/// @param id 对象ID
/// @return 指定对象类型的指针
template <typename _Ty>
SmartPtr<_Ty> Get(String const& id) const
{
@ -73,52 +73,52 @@ public:
}
/// \~chinese
/// @brief 将对象放入缓存
/// @param id 对象ID
/// @param obj 对象
/// @brief 将对象放入缓存
/// @param id 对象ID
/// @param obj 对象
bool AddObject(String const& id, ObjectBasePtr obj);
/// \~chinese
/// @brief 从多个本地图片构建序列帧,并放入缓存
/// @param id 对象ID
/// @param files 本地图片路径集合
/// @return 序列帧的帧数量
/// @brief 从多个本地图片构建序列帧,并放入缓存
/// @param id 对象ID
/// @param files 本地图片路径集合
/// @return 序列帧的帧数量
size_t AddFrameSequence(String const& id, Vector<String> const& files);
/// \~chinese
/// @brief 从多个图片资源构建序列帧,并放入缓存
/// @param id 对象ID
/// @param resources 图片资源集合
/// @return 序列帧的帧数量
/// @brief 从多个图片资源构建序列帧,并放入缓存
/// @param id 对象ID
/// @param resources 图片资源集合
/// @return 序列帧的帧数量
size_t AddFrameSequence(String const& id, Vector<Resource> const& resources);
/// \~chinese
/// @brief 从多个图像帧构建序列帧,并放入缓存
/// @param id 对象ID
/// @param frames 图像帧集合
/// @return 序列帧的帧数量
/// @brief 从多个图像帧构建序列帧,并放入缓存
/// @param id 对象ID
/// @param frames 图像帧集合
/// @return 序列帧的帧数量
size_t AddFrameSequence(String const& id, Vector<FramePtr> const& frames);
/// \~chinese
/// @brief 将图像帧按行列分割构建序列帧,并放入缓存
/// @brief 按行列数裁剪图片
/// @param id 对象ID
/// @param frame 图像帧
/// @param cols 列
/// @param rows 行
/// @param padding_x X方向间隔
/// @param padding_y Y方向间隔
/// @return 序列帧的帧数量
/// @brief 将图像帧按行列分割构建序列帧,并放入缓存
/// @brief 按行列数裁剪图片
/// @param id 对象ID
/// @param frame 图像帧
/// @param cols 列
/// @param rows 行
/// @param padding_x X方向间隔
/// @param padding_y Y方向间隔
/// @return 序列帧的帧数量
size_t AddFrameSequence(String const& id, FramePtr frame, int cols, int rows = 1, float padding_x = 0,
float padding_y = 0);
/// \~chinese
/// @brief 删除指定资源
/// @param id 对象ID
/// @brief 删除指定资源
/// @param id 对象ID
void Remove(String const& id);
/// \~chinese
/// @brief 清空所有资源
/// @brief 清空所有资源
void Clear();
private:

View File

@ -24,61 +24,61 @@
namespace kiwano
{
/// \~chinese
/// @brief 用户数据
/// @brief 用户数据
/// @details
/// UserData是一个简易的运行时数据库存放字符串-值)的键值对,无持久化
/// UserData是一个简易的运行时数据库存放字符串-值)的键值对,无持久化
class KGE_API UserData : public Singleton<UserData>
{
friend Singleton<UserData>;
public:
/// \~chinese
/// @brief 数据字典
/// @brief 数据字典
using DataMap = UnorderedMap<String, Any>;
/// \~chinese
/// @brief 键值对
/// @brief 键值对
using DataPair = Pair<const String, Any>;
/// \~chinese
/// @brief 取数据
/// @param key 键
/// @param default_data 数据不存在时返回的默认值
/// @return 键对应的值数据
/// @brief 取数据
/// @param key 键
/// @param default_data 数据不存在时返回的默认值
/// @return 键对应的值数据
Any Get(String const& key, Any const& default_data = Any()) const;
/// \~chinese
/// @brief 存数据
/// @param key 键
/// @param data 值
/// @brief 存数据
/// @param key 键
/// @param data 值
void Set(String const& key, Any const& data);
/// \~chinese
/// @brief 存数据
/// @param pair 键值对
/// @brief 存数据
/// @param pair 键值对
void Set(DataPair const& pair);
/// \~chinese
/// @brief 存数据
/// @param list 键值对列表
/// @brief 存数据
/// @param list 键值对列表
void Set(std::initializer_list<DataPair> const& list);
/// \~chinese
/// @brief 存数据
/// @param map 数据字典
/// @brief 存数据
/// @param map 数据字典
void Set(DataMap const& map);
/// \~chinese
/// @brief 判断是否包含键对应的数据
/// @param key 键
/// @brief 判断是否包含键对应的数据
/// @param key 键
bool Contains(String const& key) const;
/// \~chinese
/// @brief 获取数据字典
/// @brief 获取数据字典
const DataMap& GetDataMap() const;
/// \~chinese
/// @brief 清空所有数据
/// @brief 清空所有数据
void Clear();
private: