diff --git a/.editorconfig b/.editorconfig index 552be4bf..03bd2fa1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/projects/kiwano-audio/kiwano-audio.vcxproj b/projects/kiwano-audio/kiwano-audio.vcxproj index 7836bc77..54a0883a 100644 --- a/projects/kiwano-audio/kiwano-audio.vcxproj +++ b/projects/kiwano-audio/kiwano-audio.vcxproj @@ -74,6 +74,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows @@ -92,6 +93,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows diff --git a/projects/kiwano-imgui/kiwano-imgui.vcxproj b/projects/kiwano-imgui/kiwano-imgui.vcxproj index 55833de5..2f1b8d03 100644 --- a/projects/kiwano-imgui/kiwano-imgui.vcxproj +++ b/projects/kiwano-imgui/kiwano-imgui.vcxproj @@ -73,6 +73,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows @@ -91,6 +92,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows diff --git a/projects/kiwano-network/kiwano-network.vcxproj b/projects/kiwano-network/kiwano-network.vcxproj index 6883d0be..4f6fbd77 100644 --- a/projects/kiwano-network/kiwano-network.vcxproj +++ b/projects/kiwano-network/kiwano-network.vcxproj @@ -69,6 +69,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows @@ -87,6 +88,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows diff --git a/projects/kiwano-physics/kiwano-physics.vcxproj b/projects/kiwano-physics/kiwano-physics.vcxproj index 8b9bb3d4..a7c96cec 100644 --- a/projects/kiwano-physics/kiwano-physics.vcxproj +++ b/projects/kiwano-physics/kiwano-physics.vcxproj @@ -79,6 +79,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows @@ -97,6 +98,7 @@ true ../../src; false + /utf-8 %(AdditionalOptions) Windows diff --git a/projects/kiwano/kiwano.vcxproj b/projects/kiwano/kiwano.vcxproj index 7199f26f..4270463a 100644 --- a/projects/kiwano/kiwano.vcxproj +++ b/projects/kiwano/kiwano.vcxproj @@ -223,6 +223,7 @@ true false ../../src; + /utf-8 %(AdditionalOptions) Windows @@ -241,6 +242,7 @@ true false ../../src; + /utf-8 %(AdditionalOptions) Windows diff --git a/src/kiwano-audio/AudioEngine.h b/src/kiwano-audio/AudioEngine.h index fd877360..c41aa2b7 100644 --- a/src/kiwano-audio/AudioEngine.h +++ b/src/kiwano-audio/AudioEngine.h @@ -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 @@ -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: diff --git a/src/kiwano-audio/Sound.h b/src/kiwano-audio/Sound.h index 50634eec..ab17bbf4 100644 --- a/src/kiwano-audio/Sound.h +++ b/src/kiwano-audio/Sound.h @@ -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 鏄惁姝e湪鎾斁 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: diff --git a/src/kiwano-audio/SoundPlayer.h b/src/kiwano-audio/SoundPlayer.h index e52a8a3c..740b6de0 100644 --- a/src/kiwano-audio/SoundPlayer.h +++ b/src/kiwano-audio/SoundPlayer.h @@ -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: diff --git a/src/kiwano-audio/Transcoder.cpp b/src/kiwano-audio/Transcoder.cpp index 2386d406..a2962446 100644 --- a/src/kiwano-audio/Transcoder.cpp +++ b/src/kiwano-audio/Transcoder.cpp @@ -147,25 +147,25 @@ HRESULT Transcoder::ReadSource(IMFSourceReader* reader) hr = partial_type->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM); } - // 设置 source reader 的媒体类型,它将使用合适的解码器去解码这个音频 + // 璁剧疆 source reader 鐨勫獟浣撶被鍨嬶紝瀹冨皢浣跨敤鍚堥傜殑瑙g爜鍣ㄥ幓瑙g爜杩欎釜闊抽 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; diff --git a/src/kiwano-audio/Transcoder.h b/src/kiwano-audio/Transcoder.h index 7b69cdb8..6549dcbc 100644 --- a/src/kiwano-audio/Transcoder.h +++ b/src/kiwano-audio/Transcoder.h @@ -37,7 +37,7 @@ class Sound; /** * \~chinese - * @brief 音频解码器 + * @brief 闊抽瑙g爜鍣 */ 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 瑙g爜鏈湴闊抽鏂囦欢 HRESULT LoadMediaFile(String const& file_path); /// \~chinese - /// @brief 解码音频资源 + /// @brief 瑙g爜闊抽璧勬簮 HRESULT LoadMediaResource(Resource const& res); /// \~chinese - /// @brief 读取音频源数据 + /// @brief 璇诲彇闊抽婧愭暟鎹 HRESULT ReadSource(IMFSourceReader* reader); private: diff --git a/src/kiwano-imgui/ImGuiLayer.h b/src/kiwano-imgui/ImGuiLayer.h index dfd3b8f0..ffd83774 100644 --- a/src/kiwano-imgui/ImGuiLayer.h +++ b/src/kiwano-imgui/ImGuiLayer.h @@ -28,24 +28,24 @@ namespace imgui KGE_DECLARE_SMART_PTR(ImGuiLayer); /// \~chinese -/// @brief ImGui管道 +/// @brief ImGui绠¢亾 using ImGuiPipeline = Function; /** * \~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: diff --git a/src/kiwano-imgui/ImGuiModule.h b/src/kiwano-imgui/ImGuiModule.h index 60a005ca..700826e1 100644 --- a/src/kiwano-imgui/ImGuiModule.h +++ b/src/kiwano-imgui/ImGuiModule.h @@ -29,7 +29,7 @@ namespace imgui /** * \~chinese - * @brief ImGui模块 + * @brief ImGui妯″潡 */ class ImGuiModule : public Singleton diff --git a/src/kiwano-network/HttpClient.h b/src/kiwano-network/HttpClient.h index c1a29b9b..7cd5dcb0 100644 --- a/src/kiwano-network/HttpClient.h +++ b/src/kiwano-network/HttpClient.h @@ -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 @@ -50,33 +50,33 @@ class KGE_API HttpClient public: /// \~chinese - /// @brief 发送HTTP请求 - /// @param[in] request HTTP请求 - /// @details 发送请求后,无论结束或失败都将调用请求的响应回调函数 + /// @brief 鍙戦丠TTP璇锋眰 + /// @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: diff --git a/src/kiwano-network/HttpRequest.h b/src/kiwano-network/HttpRequest.h index 69efbbf0..d95106e2 100644 --- a/src/kiwano-network/HttpRequest.h +++ b/src/kiwano-network/HttpRequest.h @@ -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; /// \~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 璇锋眰鐨凧SON鏁版嵁 + /// @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 璁剧疆璇锋眰鐨凧SON鏁版嵁 void SetJsonData(Json const& json); /// \~chinese - /// @brief 设置HTTP头 + /// @brief 璁剧疆HTTP澶 void SetHeaders(Map 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& GetHeaders(); /// \~chinese - /// @brief 获取HTTP头 + /// @brief 鑾峰彇HTTP澶 String const& GetHeader(String const& header) const; /// \~chinese - /// @brief 获取响应回调函数 + /// @brief 鑾峰彇鍝嶅簲鍥炶皟鍑芥暟 ResponseCallback const& GetResponseCallback() const; private: diff --git a/src/kiwano-network/HttpResponse.hpp b/src/kiwano-network/HttpResponse.hpp index 0c91baa2..c54005eb 100644 --- a/src/kiwano-network/HttpResponse.hpp +++ b/src/kiwano-network/HttpResponse.hpp @@ -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 鑾峰彇瀵瑰簲鐨凥TTP璇锋眰 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: diff --git a/src/kiwano-physics/Body.h b/src/kiwano-physics/Body.h index cc570efd..172835b4 100644 --- a/src/kiwano-physics/Body.h +++ b/src/kiwano-physics/Body.h @@ -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 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 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: diff --git a/src/kiwano-physics/Contact.h b/src/kiwano-physics/Contact.h index c5398878..5598cf57 100644 --- a/src/kiwano-physics/Contact.h +++ b/src/kiwano-physics/Contact.h @@ -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 diff --git a/src/kiwano-physics/ContactEdge.h b/src/kiwano-physics/ContactEdge.h index 270e832c..d43b8cbd 100644 --- a/src/kiwano-physics/ContactEdge.h +++ b/src/kiwano-physics/ContactEdge.h @@ -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 diff --git a/src/kiwano-physics/ContactEvent.h b/src/kiwano-physics/ContactEvent.h index 72fa1710..d19f0262 100644 --- a/src/kiwano-physics/ContactEvent.h +++ b/src/kiwano-physics/ContactEvent.h @@ -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(); diff --git a/src/kiwano-physics/Fixture.h b/src/kiwano-physics/Fixture.h index 5c827467..b8c261fa 100644 --- a/src/kiwano-physics/Fixture.h +++ b/src/kiwano-physics/Fixture.h @@ -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 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 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 diff --git a/src/kiwano-physics/Joint.h b/src/kiwano-physics/Joint.h index fde87cc2..1e63e1a1 100644 --- a/src/kiwano-physics/Joint.h +++ b/src/kiwano-physics/Joint.h @@ -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; ///< 鍏宠妭杩炴帴鐨勭墿浣揂 + Body* body_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 鑾峰彇鍏宠妭杩炴帴鐨勭墿浣揂 BodyPtr GetBodyA() const; /// \~chinese - /// @brief 获取关节连接的物体B + /// @brief 鑾峰彇鍏宠妭杩炴帴鐨勭墿浣揃 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; ///< 鍏宠妭鍦ㄧ墿浣揂涓婄殑杩炴帴鐐 + Point anchor_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; ///< 绉诲姩鐨勬渶灏忛檺鍒讹紝涓庢柟鍚戝悓鍚戜负姝o紝鍙嶅悜涓鸿礋锛屽惎鐢ㄩ檺鍒跺悗鎵嶆湁鏁堟灉 + float upper_translation; ///< 绉诲姩鐨勬渶澶ч檺鍒讹紝涓庢柟鍚戝悓鍚戜负姝o紝鍙嶅悜涓鸿礋锛屽惎鐢ㄩ檺鍒跺悗鎵嶆湁鏁堟灉 + 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; ///< 鍏宠妭鍦ㄧ墿浣揂涓婄殑浣滅敤鐐 + Point anchor_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; ///< 绉诲姩鐨勬渶灏忛檺鍒讹紝涓庢柟鍚戝悓鍚戜负姝o紝鍙嶅悜涓鸿礋锛屽惎鐢ㄩ檺鍒跺悗鎵嶆湁鏁堟灉 + float upper_angle; ///< 绉诲姩鐨勬渶澶ч檺鍒讹紝涓庢柟鍚戝悓鍚戜负姝o紝鍙嶅悜涓鸿礋锛屽惎鐢ㄩ檺鍒跺悗鎵嶆湁鏁堟灉 + 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; ///< 鍏宠妭鍦ㄧ墿浣揂涓婄殑杩炴帴鐐 + Point local_anchor_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鐩稿浜庣墿浣揂鐨勮搴 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; ///< 浣滅敤鍦ㄧ墿浣揂涓婄殑鏈澶у姏 + 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: diff --git a/src/kiwano-physics/World.h b/src/kiwano-physics/World.h index 335f5069..6b5a4a49 100644 --- a/src/kiwano-physics/World.h +++ b/src/kiwano-physics/World.h @@ -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: diff --git a/src/kiwano/2d/Actor.h b/src/kiwano/2d/Actor.h index 1892183c..49cd0c92 100644 --- a/src/kiwano/2d/Actor.h +++ b/src/kiwano/2d/Actor.h @@ -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; /// \~chinese - /// @brief 角色更新回调函数 + /// @brief 瑙掕壊鏇存柊鍥炶皟鍑芥暟 using UpdateCallback = Function; /// \~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 const& children); /// \~chinese - /// @brief 获取名称相同的子角色 + /// @brief 鑾峰彇鍚嶇О鐩稿悓鐨勫瓙瑙掕壊 Actor* GetChild(String const& name) const; /// \~chinese - /// @brief 获取所有名称相同的子角色 + /// @brief 鑾峰彇鎵鏈夊悕绉扮浉鍚岀殑瀛愯鑹 Vector 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 灏嗘墍鏈夊瓙瑙掕壊鎸塟杞撮『搴忔帓搴 void Reorder(); /// \~chinese - /// @brief 设置节点所在舞台 + /// @brief 璁剧疆鑺傜偣鎵鍦ㄨ垶鍙 void SetStage(Stage* stage); /// \~chinese - /// @brief 处理事件 + /// @brief 澶勭悊浜嬩欢 void HandleEvent(Event* evt); private: diff --git a/src/kiwano/2d/Button.h b/src/kiwano/2d/Button.h index 68fa60b9..5746e0ed 100644 --- a/src/kiwano/2d/Button.h +++ b/src/kiwano/2d/Button.h @@ -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; 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 diff --git a/src/kiwano/2d/Canvas.h b/src/kiwano/2d/Canvas.h index fcc34ade..06d31ed4 100644 --- a/src/kiwano/2d/Canvas.h +++ b/src/kiwano/2d/Canvas.h @@ -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 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; diff --git a/src/kiwano/2d/DebugActor.h b/src/kiwano/2d/DebugActor.h index 16cca51d..2a0a9c73 100644 --- a/src/kiwano/2d/DebugActor.h +++ b/src/kiwano/2d/DebugActor.h @@ -31,7 +31,7 @@ namespace kiwano /** * \~chinese - * @brief 调试节点 + * @brief 璋冭瘯鑺傜偣 */ class KGE_API DebugActor : public Actor { diff --git a/src/kiwano/2d/Frame.h b/src/kiwano/2d/Frame.h index 3f47cd59..6e00f428 100644 --- a/src/kiwano/2d/Frame.h +++ b/src/kiwano/2d/Frame.h @@ -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: diff --git a/src/kiwano/2d/FrameSequence.h b/src/kiwano/2d/FrameSequence.h index a067a355..b4fa6bb6 100644 --- a/src/kiwano/2d/FrameSequence.h +++ b/src/kiwano/2d/FrameSequence.h @@ -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 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 const& frames); /// \~chinese - /// @brief 获取关键帧 - /// @param index 图像帧下标 + /// @brief 鑾峰彇鍏抽敭甯 + /// @param index 鍥惧儚甯т笅鏍 FramePtr GetFrame(size_t index) const; /// \~chinese - /// @brief 获取所有关键帧 + /// @brief 鑾峰彇鎵鏈夊叧閿抚 Vector const& GetFrames() const; /// \~chinese - /// @brief 获取关键帧数量 + /// @brief 鑾峰彇鍏抽敭甯ф暟閲 size_t GetFramesCount() const; /// \~chinese - /// @brief 获取序列帧的拷贝对象 + /// @brief 鑾峰彇搴忓垪甯х殑鎷疯礉瀵硅薄 FrameSequencePtr Clone() const; /// \~chinese - /// @brief 获取序列帧的倒转 + /// @brief 鑾峰彇搴忓垪甯х殑鍊掕浆 FrameSequencePtr Reverse() const; private: diff --git a/src/kiwano/2d/GifSprite.h b/src/kiwano/2d/GifSprite.h index 145f7af4..64754b09 100644 --- a/src/kiwano/2d/GifSprite.h +++ b/src/kiwano/2d/GifSprite.h @@ -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; /// \~chinese - /// @brief GIF播放结束回调 + /// @brief GIF鎾斁缁撴潫鍥炶皟 using DoneCallback = Function; /// \~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 瑙f瀽褰撳墠鍥惧儚甯 void DisposeCurrentFrame(); /// \~chinese - /// @brief 覆盖下一帧 + /// @brief 瑕嗙洊涓嬩竴甯 void OverlayNextFrame(); /// \~chinese - /// @brief 保存合成后的图像帧 + /// @brief 淇濆瓨鍚堟垚鍚庣殑鍥惧儚甯 void SaveComposedFrame(); /// \~chinese - /// @brief 恢复已保存的图像帧 + /// @brief 鎭㈠宸蹭繚瀛樼殑鍥惧儚甯 void RestoreSavedFrame(); /// \~chinese - /// @brief 清空当前图像区域 + /// @brief 娓呯┖褰撳墠鍥惧儚鍖哄煙 void ClearCurrentFrameArea(); private: diff --git a/src/kiwano/2d/Layer.h b/src/kiwano/2d/Layer.h index 95fddb14..6b2d10ae 100644 --- a/src/kiwano/2d/Layer.h +++ b/src/kiwano/2d/Layer.h @@ -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; diff --git a/src/kiwano/2d/ShapeActor.h b/src/kiwano/2d/ShapeActor.h index cfe9b3b1..4d11ebe7 100644 --- a/src/kiwano/2d/ShapeActor.h +++ b/src/kiwano/2d/ShapeActor.h @@ -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 const& points); PolygonActor(); @@ -320,8 +320,8 @@ public: virtual ~PolygonActor(); /// \~chinese - /// @brief 设置多边形端点 - /// @param points 多边形端点集合 + /// @brief 璁剧疆澶氳竟褰㈢鐐 + /// @param points 澶氳竟褰㈢鐐归泦鍚 void SetVertices(Vector const& points); }; diff --git a/src/kiwano/2d/Sprite.h b/src/kiwano/2d/Sprite.h index ec006057..08784310 100644 --- a/src/kiwano/2d/Sprite.h +++ b/src/kiwano/2d/Sprite.h @@ -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; diff --git a/src/kiwano/2d/Stage.h b/src/kiwano/2d/Stage.h index 4f92704e..1e05fa0a 100644 --- a/src/kiwano/2d/Stage.h +++ b/src/kiwano/2d/Stage.h @@ -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: diff --git a/src/kiwano/2d/TextActor.h b/src/kiwano/2d/TextActor.h index 21f36eee..e4210be7 100644 --- a/src/kiwano/2d/TextActor.h +++ b/src/kiwano/2d/TextActor.h @@ -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; diff --git a/src/kiwano/2d/Transition.h b/src/kiwano/2d/Transition.h index d99a18d6..c6f1e0d7 100644 --- a/src/kiwano/2d/Transition.h +++ b/src/kiwano/2d/Transition.h @@ -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); diff --git a/src/kiwano/2d/action/Action.h b/src/kiwano/2d/action/Action.h index 639f4cb0..487869c4 100644 --- a/src/kiwano/2d/action/Action.h +++ b/src/kiwano/2d/action/Action.h @@ -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 @@ -54,7 +54,7 @@ class KGE_API Action public: /// \~chinese - /// @brief 动画结束时的回调函数 + /// @brief 鍔ㄧ敾缁撴潫鏃剁殑鍥炶皟鍑芥暟 using DoneCallback = Function; 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: diff --git a/src/kiwano/2d/action/ActionDelay.h b/src/kiwano/2d/action/ActionDelay.h index dcf7204c..53e01405 100644 --- a/src/kiwano/2d/action/ActionDelay.h +++ b/src/kiwano/2d/action/ActionDelay.h @@ -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; }; diff --git a/src/kiwano/2d/action/ActionGroup.h b/src/kiwano/2d/action/ActionGroup.h index 8ff0a964..2a7f3cdb 100644 --- a/src/kiwano/2d/action/ActionGroup.h +++ b/src/kiwano/2d/action/ActionGroup.h @@ -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 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 const& actions); /// \~chinese - /// @brief 获取所有动画 + /// @brief 鑾峰彇鎵鏈夊姩鐢 ActionList const& GetActions() const; /// \~chinese - /// @brief 获取该动画的拷贝对象 + /// @brief 鑾峰彇璇ュ姩鐢荤殑鎷疯礉瀵硅薄 ActionPtr Clone() const override; /// \~chinese - /// @brief 获取该动画的倒转 + /// @brief 鑾峰彇璇ュ姩鐢荤殑鍊掕浆 ActionPtr Reverse() const override; protected: diff --git a/src/kiwano/2d/action/ActionHelper.h b/src/kiwano/2d/action/ActionHelper.h index 4f69bdea..d5fa8235 100644 --- a/src/kiwano/2d/action/ActionHelper.h +++ b/src/kiwano/2d/action/ActionHelper.h @@ -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 const& actions, bool sync = false) { return ActionHelper(new kiwano::ActionGroup(actions, sync)); diff --git a/src/kiwano/2d/action/ActionManager.h b/src/kiwano/2d/action/ActionManager.h index ea7fac93..e46987e7 100644 --- a/src/kiwano/2d/action/ActionManager.h +++ b/src/kiwano/2d/action/ActionManager.h @@ -30,47 +30,47 @@ namespace kiwano /** * \~chinese - * @brief 动画管理器 + * @brief 鍔ㄧ敾绠$悊鍣 */ class KGE_API ActionManager { public: /// \~chinese - /// @brief 动画列表 + /// @brief 鍔ㄧ敾鍒楄〃 using Actions = IntrusiveList; /// \~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: diff --git a/src/kiwano/2d/action/ActionTween.h b/src/kiwano/2d/action/ActionTween.h index dc930aac..6db704f3 100644 --- a/src/kiwano/2d/action/ActionTween.h +++ b/src/kiwano/2d/action/ActionTween.h @@ -25,27 +25,27 @@ namespace kiwano { /// \~chinese -/// @brief 缓动函数 +/// @brief 缂撳姩鍑芥暟 using EaseFunc = Function; /// \~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; /// \~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"); diff --git a/src/kiwano/2d/action/ActionWalk.h b/src/kiwano/2d/action/ActionWalk.h index d6471eed..d583852e 100644 --- a/src/kiwano/2d/action/ActionWalk.h +++ b/src/kiwano/2d/action/ActionWalk.h @@ -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: diff --git a/src/kiwano/2d/action/Animation.h b/src/kiwano/2d/action/Animation.h index 9125bd0c..9675bb8b 100644 --- a/src/kiwano/2d/action/Animation.h +++ b/src/kiwano/2d/action/Animation.h @@ -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: diff --git a/src/kiwano/core/AsyncTask.h b/src/kiwano/core/AsyncTask.h index 3fb9fb70..35c7528a 100644 --- a/src/kiwano/core/AsyncTask.h +++ b/src/kiwano/core/AsyncTask.h @@ -31,8 +31,8 @@ typedef Function AsyncTaskFunc; typedef Function 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: diff --git a/src/kiwano/core/Common.h b/src/kiwano/core/Common.h index f24cbe75..283970a7 100644 --- a/src/kiwano/core/Common.h +++ b/src/kiwano/core/Common.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -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 using Vector = std::vector<_Ty, _Args...>; /// \~chinese -/// @brief 链表容器 +/// @brief 閾捐〃瀹瑰櫒 template using List = std::list<_Ty, _Args...>; /// \~chinese -/// @brief 队列容器 +/// @brief 闃熷垪瀹瑰櫒 template using Queue = std::queue<_Ty, _Args...>; /// \~chinese -/// @brief 集合容器 +/// @brief 闆嗗悎瀹瑰櫒 template using Set = std::set<_Ty, _Args...>; /// \~chinese -/// @brief 对容器 +/// @brief 瀵瑰鍣 template using Pair = std::pair<_Ty1, _Ty2>; /// \~chinese -/// @brief 无序集合容器 +/// @brief 鏃犲簭闆嗗悎瀹瑰櫒 template using UnorderedSet = std::unordered_set<_Ty, _Args...>; /// \~chinese -/// @brief 栈容器 +/// @brief 鏍堝鍣 template using Stack = std::stack<_Ty, _Args...>; /// \~chinese -/// @brief 字符串容器 +/// @brief 瀛楃涓插鍣 template using Map = std::map<_Kty, _Ty, _Args...>; /// \~chinese -/// @brief 字符串容器 +/// @brief 瀛楃涓插鍣 template using UnorderedMap = std::unordered_map<_Kty, _Ty, _Args...>; /// \~chinese -/// @brief 函数封装器 +/// @brief 鍑芥暟灏佽鍣 template using Function = oc::function<_FuncTy>; /// \~chinese -/// @brief 单值容器 +/// @brief 鍗曞煎鍣 using Any = oc::any; /// \~chinese -/// @brief 侵入式链表容器 +/// @brief 渚靛叆寮忛摼琛ㄥ鍣 template using IntrusiveList = oc::intrusive_list<_Ty>; /// \~chinese -/// @brief 侵入式链表元素 +/// @brief 渚靛叆寮忛摼琛ㄥ厓绱 template using IntrusiveListItem = oc::intrusive_list_item<_Ty>; /// \~chinese -/// @brief 侵入式智能指针 +/// @brief 渚靛叆寮忔櫤鑳芥寚閽 template using IntrusivePtr = oc::intrusive_ptr<_Ty, _RefProxyTy>; /// \~chinese -/// @brief JSON对象容器 +/// @brief JSON瀵硅薄瀹瑰櫒 using Json = nlohmann::basic_json; /// \~chinese -/// @brief 不可拷贝对象 +/// @brief 涓嶅彲鎷疯礉瀵硅薄 using Noncopyable = oc::noncopyable; /// \~chinese -/// @brief 闭包函数 +/// @brief 闂寘鍑芥暟 template 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 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 diff --git a/src/kiwano/core/Component.h b/src/kiwano/core/Component.h index c6d25a89..d1c8f45e 100644 --- a/src/kiwano/core/Component.h +++ b/src/kiwano/core/Component.h @@ -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: diff --git a/src/kiwano/core/Director.h b/src/kiwano/core/Director.h index 82fcadd4..da744ea6 100644 --- a/src/kiwano/core/Director.h +++ b/src/kiwano/core/Director.h @@ -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(); diff --git a/src/kiwano/core/EventDispatcher.h b/src/kiwano/core/EventDispatcher.h index 625e64b0..42b1b19f 100644 --- a/src/kiwano/core/EventDispatcher.h +++ b/src/kiwano/core/EventDispatcher.h @@ -25,40 +25,40 @@ namespace kiwano { /** * \~chinese - * @brief 事件分发系统 + * @brief 浜嬩欢鍒嗗彂绯荤粺 */ class KGE_API EventDispatcher { public: /// \~chinese - /// @brief 监听器列表 + /// @brief 鐩戝惉鍣ㄥ垪琛 using Listeners = IntrusiveList; /// \~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 ::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 ::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: diff --git a/src/kiwano/core/EventListener.h b/src/kiwano/core/EventListener.h index ea50fa0c..233ef52e 100644 --- a/src/kiwano/core/EventListener.h +++ b/src/kiwano/core/EventListener.h @@ -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; /// \~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 ::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 ::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 鏄惁姝e湪杩愯 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 ::value, int>::type> inline void SetEventType() { @@ -142,7 +142,7 @@ public: } /// \~chinese - /// @brief 接收消息 + /// @brief 鎺ユ敹娑堟伅 void Receive(Event* evt); private: diff --git a/src/kiwano/core/Exception.h b/src/kiwano/core/Exception.h index b616f1a1..9d147adc 100644 --- a/src/kiwano/core/Exception.h +++ b/src/kiwano/core/Exception.h @@ -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 杞负瑙i噴鎬у瓧绗︿覆 const String& ToString() const; /// \~chinese - /// @brief 转为解释性字符串 + /// @brief 杞负瑙i噴鎬у瓧绗︿覆 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 閿欒浠g爜绫诲瀷 typedef HRESULT ErrorCodeType; #endif SystemException(); /// \~chinese - /// @brief 构造系统异常 - /// @param code 错误代码 - /// @param message 描述异常的信息 + /// @brief 鏋勯犵郴缁熷紓甯 + /// @param code 閿欒浠g爜 + /// @param message 鎻忚堪寮傚父鐨勪俊鎭 SystemException(ErrorCodeType code, String const& message); /// \~chinese - /// @brief 获取错误代码 + /// @brief 鑾峰彇閿欒浠g爜 ErrorCodeType GetErrorCode() const; private: diff --git a/src/kiwano/core/Keys.h b/src/kiwano/core/Keys.h index 76d13785..086b0338 100644 --- a/src/kiwano/core/Keys.h +++ b/src/kiwano/core/Keys.h @@ -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 }; diff --git a/src/kiwano/core/Library.h b/src/kiwano/core/Library.h index f000a968..329951e7 100644 --- a/src/kiwano/core/Library.h +++ b/src/kiwano/core/Library.h @@ -25,43 +25,43 @@ namespace kiwano { /** * \~chinese - * @brief DLL库 + * @brief DLL搴 */ class KGE_API Library { public: /// \~chinese - /// @brief 构造DLL库 + /// @brief 鏋勯燚LL搴 Library(); /// \~chinese - /// @brief 构造DLL库 - /// @param lib DLL文件路径 + /// @brief 鏋勯燚LL搴 + /// @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 inline _Proc GetProcess(String const& proc_name) { diff --git a/src/kiwano/core/Logger.h b/src/kiwano/core/Logger.h index 55bbe973..847010c0 100644 --- a/src/kiwano/core/Logger.h +++ b/src/kiwano/core/Logger.h @@ -53,7 +53,7 @@ namespace kiwano { /** * \~chinese - * @brief 日志 + * @brief 鏃ュ織 */ class KGE_API Logger : public Singleton { @@ -61,66 +61,66 @@ class KGE_API Logger : public Singleton 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 void Print(Level level, _Args&&... args); /// \~chinese - /// @brief 打印一行日志 - /// @param level 日志级别 - /// @param args 参数 + /// @brief 鎵撳嵃涓琛屾棩蹇 + /// @param level 鏃ュ織绾у埆 + /// @param args 鍙傛暟 template 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: diff --git a/src/kiwano/core/ObjectBase.h b/src/kiwano/core/ObjectBase.h index 0160a3c2..048ce53f 100644 --- a/src/kiwano/core/ObjectBase.h +++ b/src/kiwano/core/ObjectBase.h @@ -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& GetTracingObjects(); private: diff --git a/src/kiwano/core/RefCounter.h b/src/kiwano/core/RefCounter.h index 00742dc0..cff116c9 100644 --- a/src/kiwano/core/RefCounter.h +++ b/src/kiwano/core/RefCounter.h @@ -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: diff --git a/src/kiwano/core/Resource.h b/src/kiwano/core/Resource.h index b8394d34..bd3a1da9 100644 --- a/src/kiwano/core/Resource.h +++ b/src/kiwano/core/Resource.h @@ -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: diff --git a/src/kiwano/core/SmartPtr.hpp b/src/kiwano/core/SmartPtr.hpp index 83c36dad..8cf32c6c 100644 --- a/src/kiwano/core/SmartPtr.hpp +++ b/src/kiwano/core/SmartPtr.hpp @@ -26,7 +26,7 @@ namespace kiwano { /** * \~chinese - * @brief 默认的智能指针代理 + * @brief 榛樿鐨勬櫤鑳芥寚閽堜唬鐞 */ struct DefaultSmartPtrRefProxy { @@ -45,7 +45,7 @@ struct DefaultSmartPtrRefProxy /** * \~chinese - * @brief 智能指针 + * @brief 鏅鸿兘鎸囬拡 */ template using SmartPtr = IntrusivePtr<_Ty, DefaultSmartPtrRefProxy>; diff --git a/src/kiwano/core/Time.cpp b/src/kiwano/core/Time.cpp index 7072d98e..520192e4 100644 --- a/src/kiwano/core/Time.cpp +++ b/src/kiwano/core/Time.cpp @@ -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]; diff --git a/src/kiwano/core/Time.h b/src/kiwano/core/Time.h index b7306962..920c9617 100644 --- a/src/kiwano/core/Time.h +++ b/src/kiwano/core/Time.h @@ -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 瑙f瀽鏃堕棿娈靛瓧绗︿覆 + /// @param str 鏃堕棿娈靛瓧绗︿覆 /// @details - /// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀 - /// 例如: "300ms", "-1.5h", "2h45m" - /// 允许的时间单位有 "ms", "s", "m", "h" - /// @return 解析出的时间段 - /// @throw kiwano::Exception 传入一个不合法的格式时抛出 + /// 鏃堕棿娈靛瓧绗︿覆鍏佽鏄湁绗﹀彿鐨勬诞鐐规暟, 骞朵笖甯︽湁鏃堕棿鍗曚綅鍚庣紑 + /// 渚嬪: "300ms", "-1.5h", "2h45m" + /// 鍏佽鐨勬椂闂村崟浣嶆湁 "ms", "s", "m", "h" + /// @return 瑙f瀽鍑虹殑鏃堕棿娈 + /// @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 鑻ユ槸闆舵椂锛岃繑鍥瀟rue bool IsZero() const; /// \~chinese - /// @brief 获取当前时间 + /// @brief 鑾峰彇褰撳墠鏃堕棿 static Time Now() noexcept; const Duration operator-(const Time&) const; diff --git a/src/kiwano/core/Timer.h b/src/kiwano/core/Timer.h index 29f25d53..52d92780 100644 --- a/src/kiwano/core/Timer.h +++ b/src/kiwano/core/Timer.h @@ -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 @@ -40,85 +40,85 @@ class KGE_API Timer public: /// \~chinese - /// @brief 定时器回调函数 + /// @brief 瀹氭椂鍣ㄥ洖璋冨嚱鏁 /// @details - /// 回调函数第一个参数是定时器自身,第二个参数是距离上次更新的时间间隔 + /// 鍥炶皟鍑芥暟绗竴涓弬鏁版槸瀹氭椂鍣ㄨ嚜韬紝绗簩涓弬鏁版槸璺濈涓婃鏇存柊鐨勬椂闂撮棿闅 using Callback = Function; /// \~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: diff --git a/src/kiwano/core/TimerManager.h b/src/kiwano/core/TimerManager.h index 84148b17..9a53c9c6 100644 --- a/src/kiwano/core/TimerManager.h +++ b/src/kiwano/core/TimerManager.h @@ -25,65 +25,65 @@ namespace kiwano { /** * \~chinese - * @brief 定时器管理器 + * @brief 瀹氭椂鍣ㄧ鐞嗗櫒 */ class KGE_API TimerManager { public: /// \~chinese - /// @brief 定时器列表 + /// @brief 瀹氭椂鍣ㄥ垪琛 using Timers = IntrusiveList; /// \~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: diff --git a/src/kiwano/core/event/Event.h b/src/kiwano/core/event/Event.h index 496c5707..f168e5df 100644 --- a/src/kiwano/core/event/Event.h +++ b/src/kiwano/core/event/Event.h @@ -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 ::value, int>::type> bool IsType() const; /// \~chinese - /// @brief 安全转换为其他类型事件 - /// @throw std::bad_cast 类型无法转换时抛出 + /// @brief 瀹夊叏杞崲涓哄叾浠栫被鍨嬩簨浠 + /// @throw std::bad_cast 绫诲瀷鏃犳硶杞崲鏃舵姏鍑 template ::value, int>::type> const _Ty* SafeCast() const; /// \~chinese - /// @brief 安全转换为其他类型事件 - /// @throw std::bad_cast 类型无法转换时抛出 + /// @brief 瀹夊叏杞崲涓哄叾浠栫被鍨嬩簨浠 + /// @throw std::bad_cast 绫诲瀷鏃犳硶杞崲鏃舵姏鍑 template ::value, int>::type> _Ty* SafeCast(); @@ -75,14 +75,14 @@ private: }; /// \~chinese -/// @brief 事件特性:判断指定类型是否是事件 +/// @brief 浜嬩欢鐗规э細鍒ゆ柇鎸囧畾绫诲瀷鏄惁鏄簨浠 template struct IsEvent : public std::bool_constant::value || std::is_same::value> { }; /// \~chinese -/// @brief 事件特性:判断一个事件能否安全转换到另一事件类型 +/// @brief 浜嬩欢鐗规э細鍒ゆ柇涓涓簨浠惰兘鍚﹀畨鍏ㄨ浆鎹㈠埌鍙︿竴浜嬩欢绫诲瀷 template ::value, int>::type> struct IsEventType { diff --git a/src/kiwano/core/event/EventType.h b/src/kiwano/core/event/EventType.h index 53dd8d24..4970b48f 100644 --- a/src/kiwano/core/event/EventType.h +++ b/src/kiwano/core/event/EventType.h @@ -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; diff --git a/src/kiwano/core/event/KeyEvent.h b/src/kiwano/core/event/KeyEvent.h index 66ac2cb7..2740b5b4 100644 --- a/src/kiwano/core/event/KeyEvent.h +++ b/src/kiwano/core/event/KeyEvent.h @@ -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(); }; diff --git a/src/kiwano/core/event/MouseEvent.h b/src/kiwano/core/event/MouseEvent.h index ebdcafbc..015d3cdd 100644 --- a/src/kiwano/core/event/MouseEvent.h +++ b/src/kiwano/core/event/MouseEvent.h @@ -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(); }; diff --git a/src/kiwano/core/event/WindowEvent.h b/src/kiwano/core/event/WindowEvent.h index 26a28e0d..328af64c 100644 --- a/src/kiwano/core/event/WindowEvent.h +++ b/src/kiwano/core/event/WindowEvent.h @@ -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: diff --git a/src/kiwano/macros.h b/src/kiwano/macros.h index 5621a51d..b90537ef 100644 --- a/src/kiwano/macros.h +++ b/src/kiwano/macros.h @@ -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 #endif // KGE_WIN32 + +#define KGE_NOT_USED(VAR) ((void)VAR) diff --git a/src/kiwano/math/Random.h b/src/kiwano/math/Random.h index 34e44451..cc3b21f3 100644 --- a/src/kiwano/math/Random.h +++ b/src/kiwano/math/Random.h @@ -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); // diff --git a/src/kiwano/math/Transform.hpp b/src/kiwano/math/Transform.hpp index d9b375f0..007318d7 100644 --- a/src/kiwano/math/Transform.hpp +++ b/src/kiwano/math/Transform.hpp @@ -29,7 +29,7 @@ namespace math /** * \~chinese - * @brief 二维放射变换 + * @brief 浜岀淮鏀惧皠鍙樻崲 */ template class TransformT @@ -37,16 +37,16 @@ class TransformT public: using ValueType = _Ty; - float rotation; ///< 旋转 - Vec2T position; ///< 坐标 - Vec2T scale; ///< 缩放 - Vec2T skew; ///< 错切角度 + float rotation; ///< 鏃嬭浆 + Vec2T position; ///< 鍧愭爣 + Vec2T scale; ///< 缂╂斁 + Vec2T skew; ///< 閿欏垏瑙掑害 public: TransformT(); /// \~chinese - /// @brief 将二维放射变换转换为矩阵 + /// @brief 灏嗕簩缁存斁灏勫彉鎹㈣浆鎹负鐭╅樀 Matrix3x2T ToMatrix() const; bool operator==(const TransformT& rhs) const; diff --git a/src/kiwano/platform/Application.h b/src/kiwano/platform/Application.h index 8edad25d..d61e8285 100644 --- a/src/kiwano/platform/Application.h +++ b/src/kiwano/platform/Application.h @@ -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 func); private: /** * \~chinese - * @brief 更新所有组件 + * @brief 鏇存柊鎵鏈夌粍浠 */ void Update(); /** * \~chinese - * @brief 渲染所有组件 + * @brief 娓叉煋鎵鏈夌粍浠 */ void Render(); diff --git a/src/kiwano/platform/FileSystem.h b/src/kiwano/platform/FileSystem.h index 2434c527..89eae902 100644 --- a/src/kiwano/platform/FileSystem.h +++ b/src/kiwano/platform/FileSystem.h @@ -25,7 +25,7 @@ namespace kiwano { /** * \~chinese - * @brief 文件系统,为其他模块提供文件搜索规则等 + * @brief 鏂囦欢绯荤粺锛屼负鍏朵粬妯″潡鎻愪緵鏂囦欢鎼滅储瑙勫垯绛 */ class KGE_API FileSystem : public Singleton { @@ -34,71 +34,71 @@ class KGE_API FileSystem : public Singleton public: /** * \~chinese - * @brief 添加文件搜索路径 - * @param path 文件搜索路径 + * @brief 娣诲姞鏂囦欢鎼滅储璺緞 + * @param path 鏂囦欢鎼滅储璺緞 */ void AddSearchPath(String const& path); /** * \~chinese - * @brief 设置文件搜索路径 - * @param paths 搜索路径数组 + * @brief 璁剧疆鏂囦欢鎼滅储璺緞 + * @param paths 鎼滅储璺緞鏁扮粍 */ void SetSearchPaths(Vector 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 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; diff --git a/src/kiwano/platform/Input.h b/src/kiwano/platform/Input.h index adf81904..e4854c56 100644 --- a/src/kiwano/platform/Input.h +++ b/src/kiwano/platform/Input.h @@ -30,7 +30,7 @@ namespace kiwano { /** * \~chinese - * @brief 输入设备实例,可获取鼠标和键盘的按键状态 + * @brief 杈撳叆璁惧瀹炰緥锛屽彲鑾峰彇榧犳爣鍜岄敭鐩樼殑鎸夐敭鐘舵 */ class KGE_API Input : public Singleton @@ -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; diff --git a/src/kiwano/platform/Window.h b/src/kiwano/platform/Window.h index 3fdd6c25..95ca8e64 100644 --- a/src/kiwano/platform/Window.h +++ b/src/kiwano/platform/Window.h @@ -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 灏嗙獥鍙d簨浠舵斁鍏ラ槦鍒 + * @param evt 绐楀彛浜嬩欢 */ void PushEvent(EventPtr evt); /** * \~chinese - * @brief 窗口是否需要关闭 + * @brief 绐楀彛鏄惁闇瑕佸叧闂 */ bool ShouldClose(); /** * \~chinese - * @brief 销毁窗口 + * @brief 閿姣佺獥鍙 */ virtual void Destroy(); diff --git a/src/kiwano/platform/win32/WindowImpl.cpp b/src/kiwano/platform/win32/WindowImpl.cpp index 6ae6ebe2..0ce597ef 100644 --- a/src/kiwano/platform/win32/WindowImpl.cpp +++ b/src/kiwano/platform/win32/WindowImpl.cpp @@ -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; diff --git a/src/kiwano/render/Brush.h b/src/kiwano/render/Brush.h index 2d9c977e..3826065a 100644 --- a/src/kiwano/render/Brush.h +++ b/src/kiwano/render/Brush.h @@ -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, ///< 鍖呰9妯″紡锛岄噸澶嶇敾绗斿唴瀹 + Mirror ///< 闀滃儚妯″紡锛屽弽杞敾绗斿唴瀹 }; /// \~chinese -/// @brief 线性渐变样式 +/// @brief 绾挎ф笎鍙樻牱寮 struct LinearGradientStyle { - Point begin; ///< 渐变起始点 - Point end; ///< 渐变终止点 - Vector stops; ///< 渐变转换点集合 - GradientExtendMode extend_mode; ///< 渐变扩充模式 + Point begin; ///< 娓愬彉璧峰鐐 + Point end; ///< 娓愬彉缁堟鐐 + Vector stops; ///< 娓愬彉杞崲鐐归泦鍚 + GradientExtendMode extend_mode; ///< 娓愬彉鎵╁厖妯″紡 LinearGradientStyle(Point const& begin, Point const& end, Vector const& stops, GradientExtendMode extend_mode = GradientExtendMode::Clamp); }; /// \~chinese -/// @brief 径向渐变样式 +/// @brief 寰勫悜娓愬彉鏍峰紡 struct RadialGradientStyle { - Point center; ///< 径向渐变圆心 - Vec2 offset; ///< 径向渐变偏移 - Vec2 radius; ///< 径向渐变半径 - Vector stops; ///< 渐变转换点集合 - GradientExtendMode extend_mode; ///< 渐变扩充模式 + Point center; ///< 寰勫悜娓愬彉鍦嗗績 + Vec2 offset; ///< 寰勫悜娓愬彉鍋忕Щ + Vec2 radius; ///< 寰勫悜娓愬彉鍗婂緞 + Vector stops; ///< 娓愬彉杞崲鐐归泦鍚 + GradientExtendMode extend_mode; ///< 娓愬彉鎵╁厖妯″紡 RadialGradientStyle(Point const& center, Vec2 const& offset, Vec2 const& radius, Vector 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: diff --git a/src/kiwano/render/Color.h b/src/kiwano/render/Color.h index dec63edf..546937d7 100644 --- a/src/kiwano/render/Color.h +++ b/src/kiwano/render/Color.h @@ -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鍊 }; /** @} */ diff --git a/src/kiwano/render/DirectX/RendererImpl.cpp b/src/kiwano/render/DirectX/RendererImpl.cpp index 6aba373a..24ffbb31 100644 --- a/src/kiwano/render/DirectX/RendererImpl.cpp +++ b/src/kiwano/render/DirectX/RendererImpl.cpp @@ -161,7 +161,7 @@ void RendererImpl::Present() if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) { - // 如果 Direct3D 设备在执行过程中消失,将丢弃当前的设备相关资源 + // 濡傛灉 Direct3D 璁惧鍦ㄦ墽琛岃繃绋嬩腑娑堝け锛屽皢涓㈠純褰撳墠鐨勮澶囩浉鍏宠祫婧 hr = HandleDeviceLost(); } diff --git a/src/kiwano/render/DirectX/RendererImpl.h b/src/kiwano/render/DirectX/RendererImpl.h index 0b8ecccd..2ca69e6d 100644 --- a/src/kiwano/render/DirectX/RendererImpl.h +++ b/src/kiwano/render/DirectX/RendererImpl.h @@ -95,11 +95,11 @@ public: RenderContext& GetContext(); /// \~chinese - /// @brief 获取Direct2D设备资源 + /// @brief 鑾峰彇Direct2D璁惧璧勬簮 ID2DDeviceResources* GetD2DDeviceResources(); /// \~chinese - /// @brief 获取Direct3D设备资源 + /// @brief 鑾峰彇Direct3D璁惧璧勬簮 ID3DDeviceResources* GetD3DDeviceResources(); public: diff --git a/src/kiwano/render/Font.h b/src/kiwano/render/Font.h index e4d2e5b5..39550468 100644 --- a/src/kiwano/render/Font.h +++ b/src/kiwano/render/Font.h @@ -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) diff --git a/src/kiwano/render/GifImage.cpp b/src/kiwano/render/GifImage.cpp index 1d526667..0b574472 100644 --- a/src/kiwano/render/GifImage.cpp +++ b/src/kiwano/render/GifImage.cpp @@ -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) { - // 需要计算比率 - // 最高像素 1:4,最宽像素 4:1,增量为 1/64 + // 闇瑕佽绠楁瘮鐜 + // 鏈楂樺儚绱 1锛4锛屾渶瀹藉儚绱 4锛1锛屽閲忎负 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; } diff --git a/src/kiwano/render/GifImage.h b/src/kiwano/render/GifImage.h index bd8e082c..3c4993c2 100644 --- a/src/kiwano/render/GifImage.h +++ b/src/kiwano/render/GifImage.h @@ -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: diff --git a/src/kiwano/render/LayerArea.h b/src/kiwano/render/LayerArea.h index e88db1f3..92a28020 100644 --- a/src/kiwano/render/LayerArea.h +++ b/src/kiwano/render/LayerArea.h @@ -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: diff --git a/src/kiwano/render/RenderContext.h b/src/kiwano/render/RenderContext.h index 0c8a853e..55f5d292 100644 --- a/src/kiwano/render/RenderContext.h +++ b/src/kiwano/render/RenderContext.h @@ -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 -/// 渲染上下文将完成基础图元的绘制,并将绘制结果输出到特定的目标中(如窗口或纹理) +/// 娓叉煋涓婁笅鏂囧皢瀹屾垚鍩虹鍥惧厓鐨勭粯鍒讹紝骞跺皢缁樺埗缁撴灉杈撳嚭鍒扮壒瀹氱殑鐩爣涓紙濡傜獥鍙f垨绾圭悊锛 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 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: diff --git a/src/kiwano/render/Renderer.h b/src/kiwano/render/Renderer.h index 69594ecc..7ca73cc1 100644 --- a/src/kiwano/render/Renderer.h +++ b/src/kiwano/render/Renderer.h @@ -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: diff --git a/src/kiwano/render/Shape.h b/src/kiwano/render/Shape.h index 768bfba8..94da7405 100644 --- a/src/kiwano/render/Shape.h +++ b/src/kiwano/render/Shape.h @@ -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) diff --git a/src/kiwano/render/ShapeSink.h b/src/kiwano/render/ShapeSink.h index 280b09cc..f56963d4 100644 --- a/src/kiwano/render/ShapeSink.h +++ b/src/kiwano/render/ShapeSink.h @@ -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 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 杈撳叆鐨勫舰鐘禔 + /// @param shape_b 杈撳叆鐨勫舰鐘禕 + /// @param mode 缁勫悎鏂瑰紡 + /// @param matrix 搴旂敤鍒拌緭鍏ュ舰鐘禕涓婄殑浜岀淮鍙樻崲 + /// @note 鑻ヨ繕鏈墦寮杈撳叆娴侊紝鍒欒嚜鍔ㄦ墦寮 ShapeSink& Combine(ShapePtr shape_a, ShapePtr shape_b, CombineMode mode, const Matrix3x2* matrix = nullptr); /// \~chinese - /// @brief 清空图形 + /// @brief 娓呯┖鍥惧舰 void Clear(); private: diff --git a/src/kiwano/render/StrokeStyle.h b/src/kiwano/render/StrokeStyle.h index f4da804c..7d8a129f 100644 --- a/src/kiwano/render/StrokeStyle.h +++ b/src/kiwano/render/StrokeStyle.h @@ -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 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) diff --git a/src/kiwano/render/TextLayout.h b/src/kiwano/render/TextLayout.h index 0652b98d..c847edfd 100644 --- a/src/kiwano/render/TextLayout.h +++ b/src/kiwano/render/TextLayout.h @@ -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; diff --git a/src/kiwano/render/TextStyle.hpp b/src/kiwano/render/TextStyle.hpp index e8ccd9f2..424fe9a0 100644 --- a/src/kiwano/render/TextStyle.hpp +++ b/src/kiwano/render/TextStyle.hpp @@ -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, ///< 姝e父 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); }; diff --git a/src/kiwano/render/Texture.h b/src/kiwano/render/Texture.h index 152d4548..53dc6dd4 100644 --- a/src/kiwano/render/Texture.h +++ b/src/kiwano/render/Texture.h @@ -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 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 GetBitmap() const; /// \~chinese - /// @brief 设置源位图 + /// @brief 璁剧疆婧愪綅鍥 void SetBitmap(ComPtr bitmap); private: diff --git a/src/kiwano/render/TextureCache.h b/src/kiwano/render/TextureCache.h index 7e5d2162..a4004317 100644 --- a/src/kiwano/render/TextureCache.h +++ b/src/kiwano/render/TextureCache.h @@ -31,7 +31,7 @@ namespace kiwano /** * \~chinese - * @brief 纹理缓存 + * @brief 绾圭悊缂撳瓨 */ class KGE_API TextureCache : public Singleton { @@ -39,39 +39,39 @@ class KGE_API TextureCache : public Singleton public: /// \~chinese - /// @brief 添加或获取纹理 + /// @brief 娣诲姞鎴栬幏鍙栫汗鐞 TexturePtr AddOrGetTexture(String const& file_path); /// \~chinese - /// @brief 添加或获取纹理 + /// @brief 娣诲姞鎴栬幏鍙栫汗鐞 TexturePtr AddOrGetTexture(Resource const& res); /// \~chinese - /// @brief 添加或获取GIF图像 + /// @brief 娣诲姞鎴栬幏鍙朑IF鍥惧儚 GifImagePtr AddOrGetGifImage(String const& file_path); /// \~chinese - /// @brief 添加或获取GIF图像 + /// @brief 娣诲姞鎴栬幏鍙朑IF鍥惧儚 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: diff --git a/src/kiwano/render/TextureRenderContext.h b/src/kiwano/render/TextureRenderContext.h index 27746a06..7b4e81f5 100644 --- a/src/kiwano/render/TextureRenderContext.h +++ b/src/kiwano/render/TextureRenderContext.h @@ -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; }; diff --git a/src/kiwano/utils/LocalStorage.h b/src/kiwano/utils/LocalStorage.h index 25977eb3..322cacf2 100644 --- a/src/kiwano/utils/LocalStorage.h +++ b/src/kiwano/utils/LocalStorage.h @@ -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: diff --git a/src/kiwano/utils/ResourceCache.cpp b/src/kiwano/utils/ResourceCache.cpp index 58f39b6e..5bc9c8ad 100644 --- a/src/kiwano/utils/ResourceCache.cpp +++ b/src/kiwano/utils/ResourceCache.cpp @@ -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; diff --git a/src/kiwano/utils/ResourceCache.h b/src/kiwano/utils/ResourceCache.h index c2ac90bb..a2211f81 100644 --- a/src/kiwano/utils/ResourceCache.h +++ b/src/kiwano/utils/ResourceCache.h @@ -29,43 +29,43 @@ namespace kiwano { /// \~chinese -/// @brief 资源缓存 -/// @details 资源缓存 +/// @brief 璧勬簮缂撳瓨 +/// @details 璧勬簮缂撳瓨 class KGE_API ResourceCache : public Singleton { friend Singleton; 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 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 const& files); /// \~chinese - /// @brief 从多个图片资源构建序列帧,并放入缓存 - /// @param id 对象ID - /// @param resources 图片资源集合 - /// @return 序列帧的帧数量 + /// @brief 浠庡涓浘鐗囪祫婧愭瀯寤哄簭鍒楀抚锛屽苟鏀惧叆缂撳瓨 + /// @param id 瀵硅薄ID + /// @param resources 鍥剧墖璧勬簮闆嗗悎 + /// @return 搴忓垪甯х殑甯ф暟閲 size_t AddFrameSequence(String const& id, Vector const& resources); /// \~chinese - /// @brief 从多个图像帧构建序列帧,并放入缓存 - /// @param id 对象ID - /// @param frames 图像帧集合 - /// @return 序列帧的帧数量 + /// @brief 浠庡涓浘鍍忓抚鏋勫缓搴忓垪甯э紝骞舵斁鍏ョ紦瀛 + /// @param id 瀵硅薄ID + /// @param frames 鍥惧儚甯ч泦鍚 + /// @return 搴忓垪甯х殑甯ф暟閲 size_t AddFrameSequence(String const& id, Vector 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: diff --git a/src/kiwano/utils/UserData.h b/src/kiwano/utils/UserData.h index d0b98500..2652cd94 100644 --- a/src/kiwano/utils/UserData.h +++ b/src/kiwano/utils/UserData.h @@ -24,61 +24,61 @@ namespace kiwano { /// \~chinese -/// @brief 用户数据 +/// @brief 鐢ㄦ埛鏁版嵁 /// @details -/// UserData是一个简易的运行时数据库,存放(字符串-值)的键值对,无持久化 +/// UserData鏄竴涓畝鏄撶殑杩愯鏃舵暟鎹簱锛屽瓨鏀撅紙瀛楃涓-鍊硷級鐨勯敭鍊煎锛屾棤鎸佷箙鍖 class KGE_API UserData : public Singleton { friend Singleton; public: /// \~chinese - /// @brief 数据字典 + /// @brief 鏁版嵁瀛楀吀 using DataMap = UnorderedMap; /// \~chinese - /// @brief 键值对 + /// @brief 閿煎 using DataPair = Pair; /// \~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 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: