[deploy] Merge pull request #47 from KiwanoEngine/dev
Remove tinyxml2 & add pugixml
This commit is contained in:
commit
3da3cc6022
|
|
@ -0,0 +1,108 @@
|
||||||
|
# Clang-format version v9.0.0
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: Google
|
||||||
|
|
||||||
|
ColumnLimit: 120
|
||||||
|
|
||||||
|
##
|
||||||
|
## Indent Style
|
||||||
|
##
|
||||||
|
|
||||||
|
IndentWidth: 4
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
IndentCaseLabels: false
|
||||||
|
NamespaceIndentation: None
|
||||||
|
|
||||||
|
##
|
||||||
|
## Align Style
|
||||||
|
##
|
||||||
|
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: true
|
||||||
|
AlignConsecutiveDeclarations: true
|
||||||
|
AlignEscapedNewlinesLeft: true
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
PointerAlignment: Left
|
||||||
|
|
||||||
|
##
|
||||||
|
## SingleLine Style
|
||||||
|
##
|
||||||
|
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: true
|
||||||
|
AfterControlStatement: true
|
||||||
|
AfterEnum: true
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterObjCDeclaration: true
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: true
|
||||||
|
BeforeCatch: true
|
||||||
|
BeforeElse: true
|
||||||
|
IndentBraces: true
|
||||||
|
BreakBeforeBinaryOperators: NonAssignment
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
CommentPragmas: "^ IWYU pragma:"
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
|
||||||
|
##
|
||||||
|
## Others
|
||||||
|
##
|
||||||
|
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakInheritanceList: BeforeComma
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: false
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH]
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
- Regex: ".*"
|
||||||
|
Priority: 1
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ""
|
||||||
|
MacroBlockEnd: ""
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Cpp11
|
||||||
|
|
@ -14,7 +14,7 @@ insert_final_newline = true
|
||||||
charset = gb2312
|
charset = gb2312
|
||||||
|
|
||||||
# 4 space indentation
|
# 4 space indentation
|
||||||
indent_style = tab
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
# Matches the exact files
|
# Matches the exact files
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|

|
||||||
|
|
||||||
|
# Kiwano 游戏引擎
|
||||||
|
|
||||||
|
[](https://ci.appveyor.com/project/Nomango/kiwano/branch/master)
|
||||||
|
[](https://github.com/Nomango/Kiwano/releases/latest)
|
||||||
|
[](https://github.com/Nomango/Kiwano/blob/master/LICENSE)
|
||||||
|
|
||||||
|
[English](./README.md) | 简体中文
|
||||||
|
|
||||||
|
## 介绍
|
||||||
|
|
||||||
|
Kiwano 是一个使用 C++ 开发的 2D 游戏引擎,目前仅支持 Windows 平台。
|
||||||
|
|
||||||
|
Kiwano-Core 是一个提供了一系列实用工具的游戏无关库,它的目的是简化 C++ 开发过程。
|
||||||
|
|
||||||
|
这个仓库仍处于开发过程中,我创建这个仓库用来学习游戏引擎知识和开发自己的小游戏。
|
||||||
|
|
||||||
|
你可以到 [Kiwano Demos](https://github.com/kiwanogame/KiwanoDemos) 仓库查看和学习如何使用 Kiwano 引擎实现小游戏。
|
||||||
|
|
||||||
|
欢迎您任何形式的贡献。
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
|
||||||
|
* 舞台和角色管理
|
||||||
|
* 舞台过渡动画
|
||||||
|
* 动作行为
|
||||||
|
* 按钮等简易UI元素
|
||||||
|
* 音频支持
|
||||||
|
* 网络通信支持
|
||||||
|
* 数据持久化
|
||||||
|
* 物理引擎 (基于 Box2D)
|
||||||
|
* GUI 引擎 (基于 ImGui)
|
||||||
|
|
||||||
|
## 安装
|
||||||
|
|
||||||
|
### 开发环境
|
||||||
|
|
||||||
|
- Win8 或更高 (推荐 Win10)
|
||||||
|
- Visual Studio 2015 或更高
|
||||||
|
|
||||||
|
### 通过 NuGet 安装
|
||||||
|
|
||||||
|
1. 打开你的 Visual Studio 解决方案
|
||||||
|
2. 在解决方案资源管理器, 右击 `引用` 并选择 `管理 NuGet 程序包`
|
||||||
|
3. 选择 `浏览` 选项卡, 搜索 `kiwano`, 选中列表中的包然后点击 `安装`
|
||||||
|
4. 开始使用 Kiwano 进行开发吧!
|
||||||
|
|
||||||
|
### 通过源代码安装
|
||||||
|
|
||||||
|
1. 从 Github 仓库克隆或下载源代码
|
||||||
|
2. 打开你的 Visual Studio 解决方案, 在解决方案资源管理器中右键你的解决方案, 选择 `添加` => `现有项`
|
||||||
|
3. 选中源代码目录下 /projects 文件夹中所有的 `.vcxproj` 文件,并确认添加
|
||||||
|
4. 右键你的项目,打开 `属性`, 选中 C\C++ => 常规, 并将源代码文件夹下的 src 目录添加到 `附加包含目录` 中
|
||||||
|
5. 右键你的项目 `引用` 并选择 `添加引用`, 选中 `kiwano` 项目和其他你需要的项目
|
||||||
|
6. 开始使用 Kiwano 进行开发吧!
|
||||||
|
|
||||||
|
## 开发计划
|
||||||
|
|
||||||
|
* 跨平台支持
|
||||||
|
* 粒子系统
|
||||||
|
|
||||||
|
## 社交媒体
|
||||||
|
|
||||||
|
* 网站: [kiwanoengine.com](https://kiwanoengine.com)
|
||||||
|
* QQ群: 608406540
|
||||||
10
README.md
10
README.md
|
|
@ -6,6 +6,8 @@
|
||||||
[](https://github.com/Nomango/Kiwano/releases/latest)
|
[](https://github.com/Nomango/Kiwano/releases/latest)
|
||||||
[](https://github.com/Nomango/Kiwano/blob/master/LICENSE)
|
[](https://github.com/Nomango/Kiwano/blob/master/LICENSE)
|
||||||
|
|
||||||
|
English | [简体中文](./README-zh.md)
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
Kiwano is a open-source 2D C++ game engine, only support win32 platform.
|
Kiwano is a open-source 2D C++ game engine, only support win32 platform.
|
||||||
|
|
||||||
|
|
@ -20,12 +22,13 @@ More docs and examples will be added later.
|
||||||
## Features
|
## Features
|
||||||
* Scene management
|
* Scene management
|
||||||
* Transitions between scenes
|
* Transitions between scenes
|
||||||
* Actions behaviours
|
* Action behaviours
|
||||||
* Buttons and menus
|
* Buttons and menus
|
||||||
* Texture atlas support
|
* Texture atlas support
|
||||||
* Audio support
|
* Audio support
|
||||||
* Custom data storage
|
* Custom data storage
|
||||||
* Direct2D based
|
* Physical engine (based on Box2D)
|
||||||
|
* GUI system (based on ImGui)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
|
@ -51,8 +54,7 @@ More docs and examples will be added later.
|
||||||
6. Now you can build your own applications based on Kiwano source code !
|
6. Now you can build your own applications based on Kiwano source code !
|
||||||
|
|
||||||
## Next plan
|
## Next plan
|
||||||
* GUI system
|
* Cross-platform
|
||||||
* Physical engine
|
|
||||||
* Particle system
|
* Particle system
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
|
||||||
19
appveyor.yml
19
appveyor.yml
|
|
@ -19,7 +19,6 @@ pull_requests:
|
||||||
environment:
|
environment:
|
||||||
global:
|
global:
|
||||||
time_out_mins: 5
|
time_out_mins: 5
|
||||||
job_to_deploy: 6 # 3(images) * 1(platform) * 2(configuration)
|
|
||||||
flag_to_deploy: false
|
flag_to_deploy: false
|
||||||
appveyor_api_token:
|
appveyor_api_token:
|
||||||
secure: UJFCbRNHMOqQg3e3Kv/ZnaIqqwXAt+5HDldetaZsZ5E=
|
secure: UJFCbRNHMOqQg3e3Kv/ZnaIqqwXAt+5HDldetaZsZ5E=
|
||||||
|
|
@ -48,11 +47,10 @@ for:
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
VS_PLATFORM_TOOLSET: v142
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
VS_PLATFORM_TOOLSET: v141
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
VS_PLATFORM_TOOLSET: v140
|
global:
|
||||||
|
job_to_deploy: 6 # 3(images) * 1(platform) * 2(configuration)
|
||||||
-
|
-
|
||||||
branches:
|
branches:
|
||||||
except:
|
except:
|
||||||
|
|
@ -62,7 +60,8 @@ for:
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
VS_PLATFORM_TOOLSET: v142
|
global:
|
||||||
|
job_to_deploy: 2 # 1(images) * 1(platform) * 2(configuration)
|
||||||
|
|
||||||
configuration:
|
configuration:
|
||||||
- Debug
|
- Debug
|
||||||
|
|
@ -90,9 +89,9 @@ after_build:
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: projects/output/**/*.lib
|
- path: projects/output/**/*.lib
|
||||||
name: $(appveyor_project_name)-v$(appveyor_build_version)-$(VS_PLATFORM_TOOLSET).$(platform).$(configuration)
|
name: PublishedLibraries
|
||||||
- path: projects/output/**/*.pdb
|
- path: projects/output/**/*.pdb
|
||||||
name: $(appveyor_project_name)-v$(appveyor_build_version)-$(VS_PLATFORM_TOOLSET).$(platform).$(configuration)
|
name: PublishedSymbols
|
||||||
|
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- ps: .\scripts\appveyor\coapp_make.ps1
|
- ps: .\scripts\appveyor\coapp_make.ps1
|
||||||
|
|
@ -100,9 +99,9 @@ before_deploy:
|
||||||
deploy:
|
deploy:
|
||||||
- provider: GitHub
|
- provider: GitHub
|
||||||
repository: KiwanoEngine/Kiwano
|
repository: KiwanoEngine/Kiwano
|
||||||
tag: v$(appveyor_build_version)
|
tag: v$(APPVEYOR_BUILD_VERSION)
|
||||||
release: v$(appveyor_build_version)
|
release: v$(APPVEYOR_BUILD_VERSION)
|
||||||
description: Kiwano-v$(appveyor_build_version) releases.
|
description: Kiwano-v$(APPVEYOR_BUILD_VERSION) releases.
|
||||||
auth_token:
|
auth_token:
|
||||||
secure: pDsK6i03d4qRjtrNXcbhLpAquso/muJWgDSWJHnxP7b6p54kXEvptB67J+1kJOhq
|
secure: pDsK6i03d4qRjtrNXcbhLpAquso/muJWgDSWJHnxP7b6p54kXEvptB67J+1kJOhq
|
||||||
artifact: /.*\.nupkg/
|
artifact: /.*\.nupkg/
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
<ClInclude Include="..\..\..\src\3rd-party\curl\typecheck-gcc.h">
|
<ClInclude Include="..\..\..\src\3rd-party\curl\typecheck-gcc.h">
|
||||||
<Filter>include</Filter>
|
<Filter>include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\..\src\3rd-party\curl\tinyxml2.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Library Include="..\..\..\src\3rd-party\curl\libs\libcurl.lib">
|
<Library Include="..\..\..\src\3rd-party\curl\libs\libcurl.lib">
|
||||||
|
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\..\src\3rd-party\tinyxml2\tinyxml2.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\..\..\src\3rd-party\tinyxml2\tinyxml2.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{AB47E875-85E5-4105-A71E-88930EAAB910}</ProjectGuid>
|
|
||||||
<RootNamespace>libtinyxml2</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="Shared">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<OutDir>$(SolutionDir)\output\$(PlatformToolset)\$(Platform)\$(Configuration)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)\build\$(PlatformToolset)\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<AdditionalIncludeDirectories>../../../src/3rd-party;</AdditionalIncludeDirectories>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
|
||||||
<TreatWarningAsError>true</TreatWarningAsError>
|
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<AdditionalIncludeDirectories>../../../src/3rd-party;</AdditionalIncludeDirectories>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\..\..\src\3rd-party\tinyxml2\tinyxml2.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="..\..\..\src\3rd-party\tinyxml2\tinyxml2.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
@ -14,8 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-physics", "kiwano-ph
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rd-party", "3rd-party", "{2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rd-party", "3rd-party", "{2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtinyxml2", "3rd-party\tinyxml2\libtinyxml2.vcxproj", "{AB47E875-85E5-4105-A71E-88930EAAB910}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libimgui", "3rd-party\imgui\libimgui.vcxproj", "{7FA1E56D-62AC-47D1-97D1-40B302724198}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libimgui", "3rd-party\imgui\libimgui.vcxproj", "{7FA1E56D-62AC-47D1-97D1-40B302724198}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcurl", "3rd-party\curl\libcurl.vcxproj", "{A9ABACC7-75A1-46BA-8E48-4105346D9719}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcurl", "3rd-party\curl\libcurl.vcxproj", "{A9ABACC7-75A1-46BA-8E48-4105346D9719}"
|
||||||
|
|
@ -49,10 +47,6 @@ Global
|
||||||
{DF599AFB-744F-41E5-AF0C-2146F90575C8}.Debug|Win32.Build.0 = Debug|Win32
|
{DF599AFB-744F-41E5-AF0C-2146F90575C8}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{DF599AFB-744F-41E5-AF0C-2146F90575C8}.Release|Win32.ActiveCfg = Release|Win32
|
{DF599AFB-744F-41E5-AF0C-2146F90575C8}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{DF599AFB-744F-41E5-AF0C-2146F90575C8}.Release|Win32.Build.0 = Release|Win32
|
{DF599AFB-744F-41E5-AF0C-2146F90575C8}.Release|Win32.Build.0 = Release|Win32
|
||||||
{AB47E875-85E5-4105-A71E-88930EAAB910}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{AB47E875-85E5-4105-A71E-88930EAAB910}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{AB47E875-85E5-4105-A71E-88930EAAB910}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{AB47E875-85E5-4105-A71E-88930EAAB910}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{7FA1E56D-62AC-47D1-97D1-40B302724198}.Debug|Win32.ActiveCfg = Debug|Win32
|
{7FA1E56D-62AC-47D1-97D1-40B302724198}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{7FA1E56D-62AC-47D1-97D1-40B302724198}.Debug|Win32.Build.0 = Debug|Win32
|
{7FA1E56D-62AC-47D1-97D1-40B302724198}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{7FA1E56D-62AC-47D1-97D1-40B302724198}.Release|Win32.ActiveCfg = Release|Win32
|
{7FA1E56D-62AC-47D1-97D1-40B302724198}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
|
@ -70,7 +64,6 @@ Global
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{AB47E875-85E5-4105-A71E-88930EAAB910} = {2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}
|
|
||||||
{7FA1E56D-62AC-47D1-97D1-40B302724198} = {2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}
|
{7FA1E56D-62AC-47D1-97D1-40B302724198} = {2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}
|
||||||
{A9ABACC7-75A1-46BA-8E48-4105346D9719} = {2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}
|
{A9ABACC7-75A1-46BA-8E48-4105346D9719} = {2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}
|
||||||
{0CBA9295-F14D-4966-A7C4-1DD68158176C} = {2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}
|
{0CBA9295-F14D-4966-A7C4-1DD68158176C} = {2D8919F2-8922-4B3F-8F68-D4127C6BCBB7}
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,20 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\action\ActionWalk.h" />
|
<ClInclude Include="..\..\src\kiwano\2d\action\ActionWalk.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\action\ActionTween.h" />
|
<ClInclude Include="..\..\src\kiwano\2d\action\ActionTween.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\action\Animation.h" />
|
<ClInclude Include="..\..\src\kiwano\2d\action\Animation.h" />
|
||||||
|
<ClInclude Include="..\..\src\kiwano\2d\Button.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\Frame.h" />
|
<ClInclude Include="..\..\src\kiwano\2d\Frame.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\GifSprite.h" />
|
<ClInclude Include="..\..\src\kiwano\2d\GifSprite.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\common.h" />
|
<ClInclude Include="..\..\src\kiwano\core\Common.h" />
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Director.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\event\Event.h" />
|
<ClInclude Include="..\..\src\kiwano\core\event\Event.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\event\EventType.h" />
|
<ClInclude Include="..\..\src\kiwano\core\event\EventType.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\event\KeyEvent.h" />
|
<ClInclude Include="..\..\src\kiwano\core\event\KeyEvent.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\event\MouseEvent.h" />
|
<ClInclude Include="..\..\src\kiwano\core\event\MouseEvent.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\event\WindowEvent.h" />
|
<ClInclude Include="..\..\src\kiwano\core\event\WindowEvent.h" />
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Keys.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\Library.h" />
|
<ClInclude Include="..\..\src\kiwano\core\Library.h" />
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Singleton.h" />
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Time.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\kiwano.h" />
|
<ClInclude Include="..\..\src\kiwano\kiwano.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\config.h" />
|
<ClInclude Include="..\..\src\kiwano\config.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\macros.h" />
|
<ClInclude Include="..\..\src\kiwano\macros.h" />
|
||||||
|
|
@ -36,7 +41,6 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\core\Component.h" />
|
<ClInclude Include="..\..\src\kiwano\core\Component.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\EventDispatcher.h" />
|
<ClInclude Include="..\..\src\kiwano\core\EventDispatcher.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\EventListener.h" />
|
<ClInclude Include="..\..\src\kiwano\core\EventListener.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\keys.h" />
|
|
||||||
<ClInclude Include="..\..\src\kiwano\core\Logger.h" />
|
<ClInclude Include="..\..\src\kiwano\core\Logger.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\ObjectBase.h" />
|
<ClInclude Include="..\..\src\kiwano\core\ObjectBase.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\RefCounter.h" />
|
<ClInclude Include="..\..\src\kiwano\core\RefCounter.h" />
|
||||||
|
|
@ -44,7 +48,6 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\core\SmartPtr.hpp" />
|
<ClInclude Include="..\..\src\kiwano\core\SmartPtr.hpp" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\Timer.h" />
|
<ClInclude Include="..\..\src\kiwano\core\Timer.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\TimerManager.h" />
|
<ClInclude Include="..\..\src\kiwano\core\TimerManager.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\core\time.h" />
|
|
||||||
<ClInclude Include="..\..\src\kiwano\math\constants.h" />
|
<ClInclude Include="..\..\src\kiwano\math\constants.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\math\ease.h" />
|
<ClInclude Include="..\..\src\kiwano\math\ease.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\math\math.h" />
|
<ClInclude Include="..\..\src\kiwano\math\math.h" />
|
||||||
|
|
@ -54,36 +57,33 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\math\scalar.h" />
|
<ClInclude Include="..\..\src\kiwano\math\scalar.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\math\Vec2.hpp" />
|
<ClInclude Include="..\..\src\kiwano\math\Vec2.hpp" />
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\Application.h" />
|
<ClInclude Include="..\..\src\kiwano\platform\Application.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\Director.h" />
|
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\FileSystem.h" />
|
<ClInclude Include="..\..\src\kiwano\platform\FileSystem.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\Input.h" />
|
<ClInclude Include="..\..\src\kiwano\platform\Input.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\win32\ComPtr.hpp" />
|
<ClInclude Include="..\..\src\kiwano\platform\win32\ComPtr.hpp" />
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\win32\helper.h" />
|
<ClInclude Include="..\..\src\kiwano\platform\win32\helper.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\win32\libraries.h" />
|
<ClInclude Include="..\..\src\kiwano\platform\win32\libraries.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\Window.h" />
|
<ClInclude Include="..\..\src\kiwano\platform\Window.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Brush.h" />
|
<ClInclude Include="..\..\src\kiwano\render\Brush.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Color.h" />
|
<ClInclude Include="..\..\src\kiwano\render\Color.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Font.h" />
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D2DDeviceResources.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Geometry.h" />
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D3D10DeviceResources.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\GeometrySink.h" />
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D3D11DeviceResources.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\GifImage.h" />
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D3DDeviceResourcesBase.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\StrokeStyle.h" />
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\FontCollectionLoader.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\TextStyle.hpp" />
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\helper.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Texture.h" />
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\TextRenderer.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\TextureCache.h" />
|
<ClInclude Include="..\..\src\kiwano\render\Font.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\LayerArea.h" />
|
<ClInclude Include="..\..\src\kiwano\render\Geometry.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Renderer.h" />
|
<ClInclude Include="..\..\src\kiwano\render\GeometrySink.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\RenderTarget.h" />
|
<ClInclude Include="..\..\src\kiwano\render\GifImage.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\TextLayout.h" />
|
<ClInclude Include="..\..\src\kiwano\render\LayerArea.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D2DDeviceResources.h" />
|
<ClInclude Include="..\..\src\kiwano\render\RenderContext.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D3D10DeviceResources.h" />
|
<ClInclude Include="..\..\src\kiwano\render\Renderer.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D3D11DeviceResources.h" />
|
<ClInclude Include="..\..\src\kiwano\render\StrokeStyle.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D3DDeviceResourcesBase.h" />
|
<ClInclude Include="..\..\src\kiwano\render\TextLayout.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\FontCollectionLoader.h" />
|
<ClInclude Include="..\..\src\kiwano\render\TextStyle.hpp" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\helper.h" />
|
<ClInclude Include="..\..\src\kiwano\render\Texture.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\TextRenderer.h" />
|
<ClInclude Include="..\..\src\kiwano\render\TextureCache.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\ui\Button.h" />
|
|
||||||
<ClInclude Include="..\..\src\kiwano\ui\Menu.h" />
|
|
||||||
<ClInclude Include="..\..\src\kiwano\utils\LocalStorage.h" />
|
<ClInclude Include="..\..\src\kiwano\utils\LocalStorage.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\utils\ResourceCache.h" />
|
<ClInclude Include="..\..\src\kiwano\utils\ResourceCache.h" />
|
||||||
<ClInclude Include="..\..\src\kiwano\utils\UserData.h" />
|
<ClInclude Include="..\..\src\kiwano\utils\UserData.h" />
|
||||||
|
|
@ -96,6 +96,7 @@
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\action\ActionWalk.cpp" />
|
<ClCompile Include="..\..\src\kiwano\2d\action\ActionWalk.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\action\ActionTween.cpp" />
|
<ClCompile Include="..\..\src\kiwano\2d\action\ActionTween.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\action\Animation.cpp" />
|
<ClCompile Include="..\..\src\kiwano\2d\action\Animation.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\kiwano\2d\Button.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp" />
|
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\DebugActor.cpp" />
|
<ClCompile Include="..\..\src\kiwano\2d\DebugActor.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\Frame.cpp" />
|
<ClCompile Include="..\..\src\kiwano\2d\Frame.cpp" />
|
||||||
|
|
@ -111,6 +112,7 @@
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\Transition.cpp" />
|
<ClCompile Include="..\..\src\kiwano\2d\Transition.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\AsyncTask.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\AsyncTask.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\Component.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\Component.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\kiwano\core\Director.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\EventDispatcher.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\EventDispatcher.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\EventListener.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\EventListener.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\event\Event.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\event\Event.cpp" />
|
||||||
|
|
@ -122,35 +124,34 @@
|
||||||
<ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\RefCounter.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\RefCounter.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\Resource.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\Resource.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\kiwano\core\Time.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\Timer.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\Timer.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\TimerManager.cpp" />
|
<ClCompile Include="..\..\src\kiwano\core\TimerManager.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\core\time.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\Application.cpp" />
|
<ClCompile Include="..\..\src\kiwano\platform\Application.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\Director.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\FileSystem.cpp" />
|
<ClCompile Include="..\..\src\kiwano\platform\FileSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\Input.cpp" />
|
<ClCompile Include="..\..\src\kiwano\platform\Input.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\win32\libraries.cpp" />
|
<ClCompile Include="..\..\src\kiwano\platform\win32\libraries.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\win32\StackWalker.cpp" />
|
<ClCompile Include="..\..\src\kiwano\platform\win32\StackWalker.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\kiwano\platform\win32\WindowImpl.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\Window.cpp" />
|
<ClCompile Include="..\..\src\kiwano\platform\Window.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Brush.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\Brush.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Color.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\Color.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Font.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\D2DDeviceResources.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Geometry.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\D3D10DeviceResources.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\GeometrySink.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\D3D11DeviceResources.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\GifImage.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\FontCollectionLoader.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Texture.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\TextRenderer.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\TextureCache.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\Font.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\LayerArea.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\Geometry.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Renderer.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\GeometrySink.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\RenderTarget.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\GifImage.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\TextLayout.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\LayerArea.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\D2DDeviceResources.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\RenderContext.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\D3D10DeviceResources.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\Renderer.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\D3D11DeviceResources.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\StrokeStyle.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\FontCollectionLoader.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\TextLayout.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\TextRenderer.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\Texture.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\ui\Button.cpp" />
|
<ClCompile Include="..\..\src\kiwano\render\TextureCache.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\ui\Menu.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\kiwano\utils\LocalStorage.cpp" />
|
<ClCompile Include="..\..\src\kiwano\utils\LocalStorage.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\utils\ResourceCache.cpp" />
|
<ClCompile Include="..\..\src\kiwano\utils\ResourceCache.cpp" />
|
||||||
<ClCompile Include="..\..\src\kiwano\utils\UserData.cpp" />
|
<ClCompile Include="..\..\src\kiwano\utils\UserData.cpp" />
|
||||||
|
|
@ -165,11 +166,6 @@
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\3rd-party\tinyxml2\libtinyxml2.vcxproj">
|
|
||||||
<Project>{ab47e875-85e5-4105-a71e-88930eaab910}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}</ProjectGuid>
|
<ProjectGuid>{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}</ProjectGuid>
|
||||||
<RootNamespace>kiwano</RootNamespace>
|
<RootNamespace>kiwano</RootNamespace>
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@
|
||||||
<Filter Include="utils">
|
<Filter Include="utils">
|
||||||
<UniqueIdentifier>{68eac919-ee87-4030-a033-c251731928f5}</UniqueIdentifier>
|
<UniqueIdentifier>{68eac919-ee87-4030-a033-c251731928f5}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="ui">
|
|
||||||
<UniqueIdentifier>{07b6d541-4a1b-472a-aae0-daf9d082fe84}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="platform">
|
<Filter Include="platform">
|
||||||
<UniqueIdentifier>{c2654ccc-59f6-4c17-bb6b-99b07fc78702}</UniqueIdentifier>
|
<UniqueIdentifier>{c2654ccc-59f6-4c17-bb6b-99b07fc78702}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
@ -19,29 +16,23 @@
|
||||||
<Filter Include="core">
|
<Filter Include="core">
|
||||||
<UniqueIdentifier>{2e18d99a-e906-499a-9e29-4e0783202644}</UniqueIdentifier>
|
<UniqueIdentifier>{2e18d99a-e906-499a-9e29-4e0783202644}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="renderer">
|
|
||||||
<UniqueIdentifier>{7897afce-24cb-42b4-9443-56508e4ec89c}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="2d\action">
|
<Filter Include="2d\action">
|
||||||
<UniqueIdentifier>{9314f30d-5742-48b6-94e5-e3b4284106f6}</UniqueIdentifier>
|
<UniqueIdentifier>{9314f30d-5742-48b6-94e5-e3b4284106f6}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="renderer\win32">
|
|
||||||
<UniqueIdentifier>{30333461-e9bc-4709-84bd-ce6e0e1a3079}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="platform\win32">
|
<Filter Include="platform\win32">
|
||||||
<UniqueIdentifier>{e84dcf9a-e650-473e-8c9c-193804ab9e76}</UniqueIdentifier>
|
<UniqueIdentifier>{e84dcf9a-e650-473e-8c9c-193804ab9e76}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="core\event">
|
<Filter Include="core\event">
|
||||||
<UniqueIdentifier>{c629aedd-ffb9-4bc1-82c3-f50e77c82e77}</UniqueIdentifier>
|
<UniqueIdentifier>{c629aedd-ffb9-4bc1-82c3-f50e77c82e77}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="render">
|
||||||
|
<UniqueIdentifier>{adb44ca9-674a-4b77-993f-d65193d8ab06}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="render\DirectX">
|
||||||
|
<UniqueIdentifier>{fd281702-0006-46d2-8fd1-28c502464164}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\src\kiwano\ui\Button.h">
|
|
||||||
<Filter>ui</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\ui\Menu.h">
|
|
||||||
<Filter>ui</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\Canvas.h">
|
<ClInclude Include="..\..\src\kiwano\2d\Canvas.h">
|
||||||
<Filter>2d</Filter>
|
<Filter>2d</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -66,9 +57,6 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\core\Resource.h">
|
<ClInclude Include="..\..\src\kiwano\core\Resource.h">
|
||||||
<Filter>core</Filter>
|
<Filter>core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\core\time.h">
|
|
||||||
<Filter>core</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\math\Matrix.hpp">
|
<ClInclude Include="..\..\src\kiwano\math\Matrix.hpp">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -156,63 +144,9 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\core\ObjectBase.h">
|
<ClInclude Include="..\..\src\kiwano\core\ObjectBase.h">
|
||||||
<Filter>core</Filter>
|
<Filter>core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Color.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Font.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Geometry.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\GifImage.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\LayerArea.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Renderer.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\TextLayout.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D2DDeviceResources.h">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D3D10DeviceResources.h">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D3D11DeviceResources.h">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\D3DDeviceResourcesBase.h">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\FontCollectionLoader.h">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\TextRenderer.h">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\RenderTarget.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\Transform.h">
|
<ClInclude Include="..\..\src\kiwano\2d\Transform.h">
|
||||||
<Filter>2d</Filter>
|
<Filter>2d</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Texture.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\TextureCache.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\StrokeStyle.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\Brush.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\math\constants.h">
|
<ClInclude Include="..\..\src\kiwano\math\constants.h">
|
||||||
<Filter>math</Filter>
|
<Filter>math</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -234,36 +168,18 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\FileSystem.h">
|
<ClInclude Include="..\..\src\kiwano\platform\FileSystem.h">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\core\keys.h">
|
|
||||||
<Filter>core</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\Input.h">
|
<ClInclude Include="..\..\src\kiwano\platform\Input.h">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\Window.h">
|
<ClInclude Include="..\..\src\kiwano\platform\Window.h">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\Director.h">
|
|
||||||
<Filter>platform</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\2d\TextActor.h">
|
<ClInclude Include="..\..\src\kiwano\2d\TextActor.h">
|
||||||
<Filter>2d</Filter>
|
<Filter>2d</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\core\common.h">
|
|
||||||
<Filter>core</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\core\RefCounter.h">
|
<ClInclude Include="..\..\src\kiwano\core\RefCounter.h">
|
||||||
<Filter>core</Filter>
|
<Filter>core</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\TextStyle.hpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\win32\helper.h">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\renderer\GeometrySink.h">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\kiwano\platform\win32\ComPtr.hpp">
|
<ClInclude Include="..\..\src\kiwano\platform\win32\ComPtr.hpp">
|
||||||
<Filter>platform\win32</Filter>
|
<Filter>platform\win32</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -288,14 +204,89 @@
|
||||||
<ClInclude Include="..\..\src\kiwano\core\event\WindowEvent.h">
|
<ClInclude Include="..\..\src\kiwano\core\event\WindowEvent.h">
|
||||||
<Filter>core\event</Filter>
|
<Filter>core\event</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\2d\Button.h">
|
||||||
|
<Filter>2d</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Director.h">
|
||||||
|
<Filter>core</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Singleton.h">
|
||||||
|
<Filter>core</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Common.h">
|
||||||
|
<Filter>core</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Keys.h">
|
||||||
|
<Filter>core</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\core\Time.h">
|
||||||
|
<Filter>core</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\Brush.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\Color.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\Font.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\Geometry.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\GeometrySink.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\GifImage.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\LayerArea.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\RenderContext.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\Renderer.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\StrokeStyle.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\TextLayout.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\TextStyle.hpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\Texture.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\TextureCache.h">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D2DDeviceResources.h">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D3D10DeviceResources.h">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D3D11DeviceResources.h">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\D3DDeviceResourcesBase.h">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\FontCollectionLoader.h">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\helper.h">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kiwano\render\DirectX\TextRenderer.h">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\src\kiwano\ui\Button.cpp">
|
|
||||||
<Filter>ui</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\ui\Menu.cpp">
|
|
||||||
<Filter>ui</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp">
|
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp">
|
||||||
<Filter>2d</Filter>
|
<Filter>2d</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -317,9 +308,6 @@
|
||||||
<ClCompile Include="..\..\src\kiwano\core\Resource.cpp">
|
<ClCompile Include="..\..\src\kiwano\core\Resource.cpp">
|
||||||
<Filter>core</Filter>
|
<Filter>core</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\kiwano\core\time.cpp">
|
|
||||||
<Filter>core</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\Application.cpp">
|
<ClCompile Include="..\..\src\kiwano\platform\Application.cpp">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -383,57 +371,9 @@
|
||||||
<ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp">
|
<ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp">
|
||||||
<Filter>core</Filter>
|
<Filter>core</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Color.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Font.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Geometry.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\GifImage.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\LayerArea.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Renderer.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\TextLayout.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\D2DDeviceResources.cpp">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\D3D10DeviceResources.cpp">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\D3D11DeviceResources.cpp">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\FontCollectionLoader.cpp">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\win32\TextRenderer.cpp">
|
|
||||||
<Filter>renderer\win32</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\RenderTarget.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\Transform.cpp">
|
<ClCompile Include="..\..\src\kiwano\2d\Transform.cpp">
|
||||||
<Filter>2d</Filter>
|
<Filter>2d</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Texture.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\TextureCache.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\Brush.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\core\Component.cpp">
|
<ClCompile Include="..\..\src\kiwano\core\Component.cpp">
|
||||||
<Filter>core</Filter>
|
<Filter>core</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -455,18 +395,12 @@
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\Window.cpp">
|
<ClCompile Include="..\..\src\kiwano\platform\Window.cpp">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\Director.cpp">
|
|
||||||
<Filter>platform</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\2d\TextActor.cpp">
|
<ClCompile Include="..\..\src\kiwano\2d\TextActor.cpp">
|
||||||
<Filter>2d</Filter>
|
<Filter>2d</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\kiwano\core\RefCounter.cpp">
|
<ClCompile Include="..\..\src\kiwano\core\RefCounter.cpp">
|
||||||
<Filter>core</Filter>
|
<Filter>core</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\kiwano\renderer\GeometrySink.cpp">
|
|
||||||
<Filter>renderer</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\kiwano\platform\win32\libraries.cpp">
|
<ClCompile Include="..\..\src\kiwano\platform\win32\libraries.cpp">
|
||||||
<Filter>platform\win32</Filter>
|
<Filter>platform\win32</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -485,5 +419,71 @@
|
||||||
<ClCompile Include="..\..\src\kiwano\core\event\WindowEvent.cpp">
|
<ClCompile Include="..\..\src\kiwano\core\event\WindowEvent.cpp">
|
||||||
<Filter>core\event</Filter>
|
<Filter>core\event</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\2d\Button.cpp">
|
||||||
|
<Filter>2d</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\core\Director.cpp">
|
||||||
|
<Filter>core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\platform\win32\WindowImpl.cpp">
|
||||||
|
<Filter>platform\win32</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\core\Time.cpp">
|
||||||
|
<Filter>core</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\Brush.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\Color.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\Font.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\Geometry.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\GeometrySink.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\GifImage.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\LayerArea.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\RenderContext.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\Renderer.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\StrokeStyle.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\TextLayout.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\Texture.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\TextureCache.cpp">
|
||||||
|
<Filter>render</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\D2DDeviceResources.cpp">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\D3D10DeviceResources.cpp">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\D3D11DeviceResources.cpp">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\FontCollectionLoader.cpp">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\kiwano\render\DirectX\TextRenderer.cpp">
|
||||||
|
<Filter>render\DirectX</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# clang-format-all: a tool to run clang-format on an entire project
|
||||||
|
# Copyright (C) 2016 Evan Klitzke <evan@eklitzke.org>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "Usage: $0 DIR..."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Variable that will hold the name of the clang-format command
|
||||||
|
FMT=""
|
||||||
|
|
||||||
|
# Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent
|
||||||
|
# that the version number be part of the command. We prefer clang-format if
|
||||||
|
# that's present, otherwise we work backwards from highest version to lowest
|
||||||
|
# version.
|
||||||
|
for clangfmt in clang-format{,-{4,3}.{9,8,7,6,5,4,3,2,1,0}}; do
|
||||||
|
if which "$clangfmt" &>/dev/null; then
|
||||||
|
FMT="$clangfmt"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if we found a working clang-format
|
||||||
|
if [ -z "$FMT" ]; then
|
||||||
|
echo "failed to find clang-format"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check all of the arguments first to make sure they're all directories
|
||||||
|
for dir in "$@"; do
|
||||||
|
if [ ! -d "${dir}" ]; then
|
||||||
|
echo "${dir} is not a directory"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Find a dominating file, starting from a given directory and going up.
|
||||||
|
find-dominating-file() {
|
||||||
|
if [ -r "$1"/"$2" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ "$1" = "/" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
find-dominating-file "$(realpath "$1"/..)" "$2"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run clang-format -i on all of the things
|
||||||
|
for dir in "$@"; do
|
||||||
|
pushd "${dir}" &>/dev/null
|
||||||
|
if ! find-dominating-file . .clang-format; then
|
||||||
|
echo "Failed to find dominating .clang-format starting at $PWD"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
find . \
|
||||||
|
\( -name '*.c' \
|
||||||
|
-o -name '*.cc' \
|
||||||
|
-o -name '*.cpp' \
|
||||||
|
-o -name '*.h' \
|
||||||
|
-o -name '*.hh' \
|
||||||
|
-o -name '*.hpp' \) \
|
||||||
|
-exec "${FMT}" -i '{}' \;
|
||||||
|
popd &>/dev/null
|
||||||
|
done
|
||||||
|
|
@ -115,23 +115,23 @@ public:
|
||||||
|
|
||||||
virtual _Ret invoke(_Args... args) const override
|
virtual _Ret invoke(_Args... args) const override
|
||||||
{
|
{
|
||||||
return (static_cast<_Ty*>(ptr_)->*func_)(::std::forward<_Args>(args)...);
|
return (ptr_->*func_)(::std::forward<_Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline callable<_Ret, _Args...>* make(void* ptr, _FuncType func)
|
static inline callable<_Ret, _Args...>* make(_Ty* ptr, _FuncType func)
|
||||||
{
|
{
|
||||||
return new (::std::nothrow) proxy_mem_callable<_Ty, _Ret, _Args...>(ptr, func);
|
return new (::std::nothrow) proxy_mem_callable<_Ty, _Ret, _Args...>(ptr, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
proxy_mem_callable(void* ptr, _FuncType func)
|
proxy_mem_callable(_Ty* ptr, _FuncType func)
|
||||||
: ptr_(ptr)
|
: ptr_(ptr)
|
||||||
, func_(func)
|
, func_(func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void* ptr_;
|
_Ty* ptr_;
|
||||||
_FuncType func_;
|
_FuncType func_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -144,23 +144,23 @@ public:
|
||||||
|
|
||||||
virtual _Ret invoke(_Args... args) const override
|
virtual _Ret invoke(_Args... args) const override
|
||||||
{
|
{
|
||||||
return (static_cast<_Ty*>(ptr_)->*func_)(::std::forward<_Args>(args)...);
|
return (ptr_->*func_)(::std::forward<_Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline callable<_Ret, _Args...>* make(void* ptr, _FuncType func)
|
static inline callable<_Ret, _Args...>* make(_Ty* ptr, _FuncType func)
|
||||||
{
|
{
|
||||||
return new (::std::nothrow) proxy_const_mem_callable<_Ty, _Ret, _Args...>(ptr, func);
|
return new (::std::nothrow) proxy_const_mem_callable<_Ty, _Ret, _Args...>(ptr, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
proxy_const_mem_callable(void* ptr, _FuncType func)
|
proxy_const_mem_callable(_Ty* ptr, _FuncType func)
|
||||||
: ptr_(ptr)
|
: ptr_(ptr)
|
||||||
, func_(func)
|
, func_(func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void* ptr_;
|
_Ty* ptr_;
|
||||||
_FuncType func_;
|
_FuncType func_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,20 +16,19 @@ template <typename _Ty, typename _PTy = typename std::pointer_traits<_Ty>::point
|
||||||
class intrusive_list_item
|
class intrusive_list_item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using pointer_type = _PTy;
|
using pointer = _PTy;
|
||||||
using const_pointer_type = const _PTy;
|
|
||||||
|
|
||||||
intrusive_list_item() : prev_(nullptr), next_(nullptr) {}
|
intrusive_list_item() : prev_(nullptr), next_(nullptr) {}
|
||||||
intrusive_list_item(pointer_type rhs) : prev_(nullptr), next_(nullptr) { if (rhs) { prev_ = rhs->prev_; next_ = rhs->next_; } }
|
intrusive_list_item(pointer rhs) : prev_(nullptr), next_(nullptr) { if (rhs) { prev_ = rhs->prev_; next_ = rhs->next_; } }
|
||||||
|
|
||||||
const_pointer_type prev_item() const { return prev_; }
|
const pointer prev_item() const { return prev_; }
|
||||||
pointer_type prev_item() { return prev_; }
|
pointer prev_item() { return prev_; }
|
||||||
const_pointer_type next_item() const { return next_; }
|
const pointer next_item() const { return next_; }
|
||||||
pointer_type next_item() { return next_; }
|
pointer next_item() { return next_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pointer_type prev_;
|
pointer prev_;
|
||||||
pointer_type next_;
|
pointer next_;
|
||||||
|
|
||||||
friend class intrusive_list<_Ty, _PTy>;
|
friend class intrusive_list<_Ty, _PTy>;
|
||||||
};
|
};
|
||||||
|
|
@ -39,23 +38,24 @@ template <typename _Ty, typename _PTy>
|
||||||
class intrusive_list
|
class intrusive_list
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using pointer_type = _PTy;
|
using value_type = typename std::pointer_traits<_PTy>::element_type;
|
||||||
using const_pointer_type = const _PTy;
|
using pointer = _PTy;
|
||||||
|
using reference = value_type&;
|
||||||
|
|
||||||
intrusive_list() : first_(), last_() {}
|
intrusive_list() : first_(), last_() {}
|
||||||
~intrusive_list() { clear(); }
|
~intrusive_list() { clear(); }
|
||||||
|
|
||||||
const_pointer_type first_item() const { return first_; }
|
const pointer first_item() const { return first_; }
|
||||||
pointer_type first_item() { return first_; }
|
pointer first_item() { return first_; }
|
||||||
const_pointer_type last_item() const { return last_; }
|
const pointer last_item() const { return last_; }
|
||||||
pointer_type last_item() { return last_; }
|
pointer last_item() { return last_; }
|
||||||
|
|
||||||
inline bool empty() const
|
inline bool empty() const
|
||||||
{
|
{
|
||||||
return first_ == nullptr;
|
return first_ == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back(pointer_type child)
|
void push_back(pointer child)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -77,7 +77,7 @@ public:
|
||||||
last_ = child;
|
last_ = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_front(pointer_type child)
|
void push_front(pointer child)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -99,7 +99,7 @@ public:
|
||||||
first_ = child;
|
first_ = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_before(pointer_type child, pointer_type before)
|
void insert_before(pointer child, pointer before)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -116,7 +116,7 @@ public:
|
||||||
before->prev_ = child;
|
before->prev_ = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert_after(pointer_type child, pointer_type after)
|
void insert_after(pointer child, pointer after)
|
||||||
{
|
{
|
||||||
if (child->prev_)
|
if (child->prev_)
|
||||||
child->prev_->next_ = child->next_;
|
child->prev_->next_ = child->next_;
|
||||||
|
|
@ -133,7 +133,7 @@ public:
|
||||||
after->next_ = child;
|
after->next_ = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(pointer_type child)
|
void remove(pointer child)
|
||||||
{
|
{
|
||||||
if (child->next_)
|
if (child->next_)
|
||||||
{
|
{
|
||||||
|
|
@ -159,10 +159,10 @@ public:
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
pointer_type p = first_;
|
pointer p = first_;
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
pointer_type tmp = p;
|
pointer tmp = p;
|
||||||
p = p->next_;
|
p = p->next_;
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
|
|
@ -180,8 +180,8 @@ public:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
pointer_type p = first_;
|
pointer p = first_;
|
||||||
pointer_type tmp = p;
|
pointer tmp = p;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
tmp = p;
|
tmp = p;
|
||||||
|
|
@ -205,15 +205,19 @@ public:
|
||||||
struct iterator_impl
|
struct iterator_impl
|
||||||
{
|
{
|
||||||
using iterator_category = std::bidirectional_iterator_tag;
|
using iterator_category = std::bidirectional_iterator_tag;
|
||||||
using pointer_type = _PTy;
|
using value_type = typename std::pointer_traits<_PTy>::element_type;
|
||||||
using const_pointer_type = const _PTy;
|
using difference_type = ptrdiff_t;
|
||||||
|
using pointer = _PTy;
|
||||||
|
using reference = value_type&;
|
||||||
|
|
||||||
inline iterator_impl(pointer_type ptr = nullptr, bool is_end = false) : base_(ptr), is_end_(is_end) {}
|
inline iterator_impl(pointer ptr = nullptr, bool is_end = false) : base_(ptr), is_end_(is_end) {}
|
||||||
|
|
||||||
inline pointer_type operator*() const { OC_ASSERT(base_ && !is_end_); return base_; }
|
inline pointer base() const { OC_ASSERT(!is_end_); return const_cast<pointer&>(base_); }
|
||||||
inline iterator_impl& operator++() { OC_ASSERT(base_ && !is_end_); pointer_type next = base_->next_item(); if (next) base_ = next; else is_end_ = true; return (*this); }
|
inline reference operator*() const { OC_ASSERT(base_ && !is_end_); return const_cast<reference>(*base_); }
|
||||||
|
inline pointer operator->() const { OC_ASSERT(base_ && !is_end_); return const_cast<pointer&>(base_); }
|
||||||
|
inline iterator_impl& operator++() { OC_ASSERT(base_ && !is_end_); pointer next = base_->next_item(); if (next) base_ = next; else is_end_ = true; return (*this); }
|
||||||
inline iterator_impl operator++(int) { iterator_impl old = (*this); ++(*this); return old; }
|
inline iterator_impl operator++(int) { iterator_impl old = (*this); ++(*this); return old; }
|
||||||
inline iterator_impl& operator--() { OC_ASSERT(base_); if (is_end_) is_end_ = false; else base_ = pointer_type(base_->prev_item()); return (*this); }
|
inline iterator_impl& operator--() { OC_ASSERT(base_); if (is_end_) is_end_ = false; else base_ = pointer(base_->prev_item()); return (*this); }
|
||||||
inline iterator_impl operator--(int) { iterator_impl old = (*this); --(*this); return old; }
|
inline iterator_impl operator--(int) { iterator_impl old = (*this); --(*this); return old; }
|
||||||
inline bool operator==(iterator_impl const& other) const { return base_ == other.base_ && is_end_ == other.is_end_; }
|
inline bool operator==(iterator_impl const& other) const { return base_ == other.base_ && is_end_ == other.is_end_; }
|
||||||
inline bool operator!=(iterator_impl const& other) const { return !(*this == other); }
|
inline bool operator!=(iterator_impl const& other) const { return !(*this == other); }
|
||||||
|
|
@ -221,11 +225,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_end_;
|
bool is_end_;
|
||||||
pointer_type base_;
|
pointer base_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using iterator = iterator_impl<pointer_type>;
|
using iterator = iterator_impl<pointer>;
|
||||||
using const_iterator = iterator_impl<const pointer_type>;
|
using const_iterator = iterator_impl<const pointer>;
|
||||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
|
|
||||||
|
|
@ -241,14 +245,14 @@ public:
|
||||||
inline reverse_iterator rend() { return reverse_iterator(begin()); }
|
inline reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||||
inline const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
inline const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
||||||
inline const_reverse_iterator crend() const { return rend(); }
|
inline const_reverse_iterator crend() const { return rend(); }
|
||||||
inline pointer_type front() { if (empty()) throw std::out_of_range("front() called on empty intrusive_list"); return first_item(); }
|
inline pointer front() { if (empty()) throw std::out_of_range("front() called on empty intrusive_list"); return first_item(); }
|
||||||
inline const_pointer_type front() const { if (empty()) throw std::out_of_range("front() called on empty intrusive_list"); return first_item(); }
|
inline const pointer front() const { if (empty()) throw std::out_of_range("front() called on empty intrusive_list"); return first_item(); }
|
||||||
inline pointer_type back() { if (empty()) throw std::out_of_range("back() called on empty intrusive_list"); return last_item(); }
|
inline pointer back() { if (empty()) throw std::out_of_range("back() called on empty intrusive_list"); return last_item(); }
|
||||||
inline const_pointer_type back() const { if (empty()) throw std::out_of_range("back() called on empty intrusive_list"); return last_item(); }
|
inline const pointer back() const { if (empty()) throw std::out_of_range("back() called on empty intrusive_list"); return last_item(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pointer_type first_;
|
pointer first_;
|
||||||
pointer_type last_;
|
pointer last_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace oc
|
} // namespace oc
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
* pugixml parser - version 1.10
|
||||||
|
* --------------------------------------------------------
|
||||||
|
* Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
|
||||||
|
* Report bugs and download new versions at https://pugixml.org/
|
||||||
|
*
|
||||||
|
* This library is distributed under the MIT License. See notice at the end
|
||||||
|
* of this file.
|
||||||
|
*
|
||||||
|
* This work is based on the pugxml parser, which is:
|
||||||
|
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_PUGICONFIG_HPP
|
||||||
|
#define HEADER_PUGICONFIG_HPP
|
||||||
|
|
||||||
|
// Uncomment this to enable wchar_t mode
|
||||||
|
#define PUGIXML_WCHAR_MODE
|
||||||
|
|
||||||
|
// Uncomment this to enable compact mode
|
||||||
|
// #define PUGIXML_COMPACT
|
||||||
|
|
||||||
|
// Uncomment this to disable XPath
|
||||||
|
// #define PUGIXML_NO_XPATH
|
||||||
|
|
||||||
|
// Uncomment this to disable STL
|
||||||
|
// #define PUGIXML_NO_STL
|
||||||
|
|
||||||
|
// Uncomment this to disable exceptions
|
||||||
|
#define PUGIXML_NO_EXCEPTIONS
|
||||||
|
|
||||||
|
// Set this to control attributes for public classes/functions, i.e.:
|
||||||
|
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
|
||||||
|
// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
|
||||||
|
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
|
||||||
|
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
|
||||||
|
|
||||||
|
// Tune these constants to adjust memory-related behavior
|
||||||
|
// #define PUGIXML_MEMORY_PAGE_SIZE 32768
|
||||||
|
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240
|
||||||
|
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
|
||||||
|
|
||||||
|
// Uncomment this to switch to header-only version
|
||||||
|
#define PUGIXML_HEADER_ONLY
|
||||||
|
|
||||||
|
// Uncomment this to enable long long support
|
||||||
|
// #define PUGIXML_HAS_LONG_LONG
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2019 Arseny Kapoulkine
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,18 +0,0 @@
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any
|
|
||||||
damages arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any
|
|
||||||
purpose, including commercial applications, and to alter it and
|
|
||||||
redistribute it freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
|
||||||
must not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
|
||||||
distribution.
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -18,10 +18,10 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/platform/win32/helper.h> // win32::ThrowIfFailed
|
|
||||||
#include <kiwano/core/Logger.h>
|
|
||||||
#include <kiwano-audio/libraries.h>
|
|
||||||
#include <kiwano-audio/AudioEngine.h>
|
#include <kiwano-audio/AudioEngine.h>
|
||||||
|
#include <kiwano-audio/libraries.h>
|
||||||
|
#include <kiwano/core/Logger.h>
|
||||||
|
#include <kiwano/platform/win32/helper.h> // win32::ThrowIfFailed
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -33,9 +33,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEngine::~AudioEngine()
|
AudioEngine::~AudioEngine() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioEngine::SetupComponent()
|
void AudioEngine::SetupComponent()
|
||||||
{
|
{
|
||||||
|
|
@ -121,5 +119,5 @@ namespace kiwano
|
||||||
if (x_audio2_)
|
if (x_audio2_)
|
||||||
x_audio2_->StopEngine();
|
x_audio2_->StopEngine();
|
||||||
}
|
}
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,17 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/common.h>
|
|
||||||
#include <kiwano/core/Component.h>
|
|
||||||
#include <kiwano-audio/Transcoder.h>
|
|
||||||
#include <kiwano-audio/Sound.h>
|
#include <kiwano-audio/Sound.h>
|
||||||
|
#include <kiwano-audio/Transcoder.h>
|
||||||
|
#include <kiwano/core/Common.h>
|
||||||
|
#include <kiwano/core/Component.h>
|
||||||
#include <xaudio2.h>
|
#include <xaudio2.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
namespace audio
|
namespace audio
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* \defgroup Audio ÒôƵÒýÇæ
|
* \defgroup Audio ÒôƵÒýÇæ
|
||||||
|
|
@ -78,5 +79,6 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
|
||||||
}
|
} // namespace audio
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#include <kiwano-audio/AudioEngine.h>
|
||||||
|
#include <kiwano-audio/Sound.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
#include <kiwano/platform/FileSystem.h>
|
#include <kiwano/platform/FileSystem.h>
|
||||||
#include <kiwano-audio/Sound.h>
|
|
||||||
#include <kiwano-audio/AudioEngine.h>
|
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -42,7 +42,7 @@ namespace kiwano
|
||||||
|
|
||||||
bool Sound::Load(String const& file_path)
|
bool Sound::Load(String const& file_path)
|
||||||
{
|
{
|
||||||
if (!FileSystem::instance().IsFileExists(file_path))
|
if (!FileSystem::Instance().IsFileExists(file_path))
|
||||||
{
|
{
|
||||||
KGE_WARN(L"Media file '%s' not found", file_path.c_str());
|
KGE_WARN(L"Media file '%s' not found", file_path.c_str());
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -53,7 +53,7 @@ namespace kiwano
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
String full_path = FileSystem::instance().GetFullPathForFile(file_path);
|
String full_path = FileSystem::Instance().GetFullPathForFile(file_path);
|
||||||
|
|
||||||
HRESULT hr = transcoder_.LoadMediaFile(full_path);
|
HRESULT hr = transcoder_.LoadMediaFile(full_path);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
|
@ -62,7 +62,7 @@ namespace kiwano
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AudioEngine::instance().CreateSound(*this, transcoder_.GetBuffer()))
|
if (!AudioEngine::Instance().CreateSound(*this, transcoder_.GetBuffer()))
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -86,7 +86,7 @@ namespace kiwano
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AudioEngine::instance().CreateSound(*this, transcoder_.GetBuffer()))
|
if (!AudioEngine::Instance().CreateSound(*this, transcoder_.GetBuffer()))
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -223,5 +223,5 @@ namespace kiwano
|
||||||
volume = std::min(std::max(volume, -224.f), 224.f);
|
volume = std::min(std::max(volume, -224.f), 224.f);
|
||||||
voice_->SetVolume(volume);
|
voice_->SetVolume(volume);
|
||||||
}
|
}
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <kiwano-audio/Transcoder.h>
|
||||||
#include <kiwano/core/ObjectBase.h>
|
#include <kiwano/core/ObjectBase.h>
|
||||||
#include <kiwano/core/Resource.h>
|
#include <kiwano/core/Resource.h>
|
||||||
#include <kiwano/platform/win32/ComPtr.hpp>
|
#include <kiwano/platform/win32/ComPtr.hpp>
|
||||||
#include <kiwano-audio/Transcoder.h>
|
|
||||||
#include <xaudio2.h>
|
#include <xaudio2.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -42,8 +42,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 񙮵
|
* @brief 񙮵
|
||||||
*/
|
*/
|
||||||
class KGE_API Sound
|
class KGE_API Sound : public virtual ObjectBase
|
||||||
: public ObjectBase
|
|
||||||
{
|
{
|
||||||
friend class AudioEngine;
|
friend class AudioEngine;
|
||||||
|
|
||||||
|
|
@ -114,7 +113,6 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
inline IXAudio2SourceVoice* Sound::GetXAudio2Voice() const
|
inline IXAudio2SourceVoice* Sound::GetXAudio2Voice() const
|
||||||
{
|
{
|
||||||
return voice_;
|
return voice_;
|
||||||
|
|
@ -124,5 +122,5 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
voice_ = voice;
|
voice_ = voice;
|
||||||
}
|
}
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -152,5 +152,5 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
sound_cache_.clear();
|
sound_cache_.clear();
|
||||||
}
|
}
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/ObjectBase.h>
|
|
||||||
#include <kiwano-audio/Sound.h>
|
#include <kiwano-audio/Sound.h>
|
||||||
|
#include <kiwano/core/ObjectBase.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -37,8 +37,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 音频播放器
|
* @brief 音频播放器
|
||||||
*/
|
*/
|
||||||
class KGE_API SoundPlayer
|
class KGE_API SoundPlayer : public virtual ObjectBase
|
||||||
: public ObjectBase
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoundPlayer();
|
SoundPlayer();
|
||||||
|
|
@ -116,5 +115,5 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,14 @@
|
||||||
#define INITGUID // MFAudioFormat_PCM, MF_MT_MAJOR_TYPE, MF_MT_SUBTYPE, MFMediaType_Audio
|
#define INITGUID // MFAudioFormat_PCM, MF_MT_MAJOR_TYPE, MF_MT_SUBTYPE, MFMediaType_Audio
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <kiwano/macros.h>
|
#include <kiwano-audio/Transcoder.h>
|
||||||
#include <kiwano/core/common.h>
|
#include <kiwano-audio/libraries.h>
|
||||||
#include <kiwano/core/Resource.h>
|
#include <kiwano/core/Common.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
|
#include <kiwano/core/Resource.h>
|
||||||
|
#include <kiwano/macros.h>
|
||||||
#include <kiwano/platform/win32/ComPtr.hpp>
|
#include <kiwano/platform/win32/ComPtr.hpp>
|
||||||
#include <kiwano/platform/win32/libraries.h>
|
#include <kiwano/platform/win32/libraries.h>
|
||||||
#include <kiwano-audio/libraries.h>
|
|
||||||
#include <kiwano-audio/Transcoder.h>
|
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -76,11 +76,7 @@ namespace kiwano
|
||||||
|
|
||||||
ComPtr<IMFSourceReader> reader;
|
ComPtr<IMFSourceReader> reader;
|
||||||
|
|
||||||
hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromURL(
|
hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromURL(file_path.c_str(), nullptr, &reader);
|
||||||
file_path.c_str(),
|
|
||||||
nullptr,
|
|
||||||
&reader
|
|
||||||
);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
|
@ -99,12 +95,13 @@ namespace kiwano
|
||||||
ComPtr<IMFSourceReader> reader;
|
ComPtr<IMFSourceReader> reader;
|
||||||
|
|
||||||
Resource::Data data = res.GetData();
|
Resource::Data data = res.GetData();
|
||||||
if (!data) { return E_FAIL; }
|
if (!data)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
stream = win32::dlls::Shlwapi::Get().SHCreateMemStream(
|
stream = win32::dlls::Shlwapi::Get().SHCreateMemStream(static_cast<const BYTE*>(data.buffer),
|
||||||
static_cast<const BYTE*>(data.buffer),
|
static_cast<uint32_t>(data.size));
|
||||||
static_cast<uint32_t>(data.size)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (stream == nullptr)
|
if (stream == nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -119,11 +116,7 @@ namespace kiwano
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromByteStream(
|
hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromByteStream(byte_stream.get(), nullptr, &reader);
|
||||||
byte_stream.get(),
|
|
||||||
nullptr,
|
|
||||||
&reader
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
|
|
@ -157,29 +150,19 @@ namespace kiwano
|
||||||
// 设置 source reader 的媒体类型,它将使用合适的解码器去解码这个音频
|
// 设置 source reader 的媒体类型,它将使用合适的解码器去解码这个音频
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = reader->SetCurrentMediaType(
|
hr = reader->SetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, partial_type.get());
|
||||||
(DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM,
|
|
||||||
0,
|
|
||||||
partial_type.get()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从 IMFMediaType 中获取 WAVEFORMAT 结构
|
// 从 IMFMediaType 中获取 WAVEFORMAT 结构
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = reader->GetCurrentMediaType(
|
hr = reader->GetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, &uncompressed_type);
|
||||||
(DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM,
|
|
||||||
&uncompressed_type
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指定音频流
|
// 指定音频流
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = reader->SetStreamSelection(
|
hr = reader->SetStreamSelection((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, true);
|
||||||
(DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取 WAVEFORMAT 数据
|
// 获取 WAVEFORMAT 数据
|
||||||
|
|
@ -187,11 +170,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
hr = dlls::MediaFoundation::Get().MFCreateWaveFormatExFromMFMediaType(
|
hr = dlls::MediaFoundation::Get().MFCreateWaveFormatExFromMFMediaType(
|
||||||
uncompressed_type.get(),
|
uncompressed_type.get(), &wave_format_, &size, (DWORD)MFWaveFormatExConvertFlag_Normal);
|
||||||
&wave_format_,
|
|
||||||
&size,
|
|
||||||
(DWORD)MFWaveFormatExConvertFlag_Normal
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 估算音频流大小
|
// 估算音频流大小
|
||||||
|
|
@ -200,16 +179,10 @@ namespace kiwano
|
||||||
PROPVARIANT prop;
|
PROPVARIANT prop;
|
||||||
PropVariantInit(&prop);
|
PropVariantInit(&prop);
|
||||||
|
|
||||||
hr = reader->GetPresentationAttribute(
|
hr = reader->GetPresentationAttribute((DWORD)MF_SOURCE_READER_MEDIASOURCE, MF_PD_DURATION, &prop);
|
||||||
(DWORD)MF_SOURCE_READER_MEDIASOURCE,
|
|
||||||
MF_PD_DURATION,
|
|
||||||
&prop
|
|
||||||
);
|
|
||||||
|
|
||||||
LONGLONG duration = prop.uhVal.QuadPart;
|
LONGLONG duration = prop.uhVal.QuadPart;
|
||||||
max_stream_size = static_cast<DWORD>(
|
max_stream_size = static_cast<DWORD>((duration * wave_format_->nAvgBytesPerSec) / 10000000 + 1);
|
||||||
(duration * wave_format_->nAvgBytesPerSec) / 10000000 + 1
|
|
||||||
);
|
|
||||||
PropVariantClear(&prop);
|
PropVariantClear(&prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -232,18 +205,18 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
hr = reader->ReadSample(
|
hr = reader->ReadSample((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, nullptr, &flags, nullptr,
|
||||||
(DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM,
|
&sample);
|
||||||
0,
|
|
||||||
nullptr,
|
|
||||||
&flags,
|
|
||||||
nullptr,
|
|
||||||
&sample
|
|
||||||
);
|
|
||||||
|
|
||||||
if (flags & MF_SOURCE_READERF_ENDOFSTREAM) { break; }
|
if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (sample == nullptr) { continue; }
|
if (sample == nullptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
|
@ -254,11 +227,7 @@ namespace kiwano
|
||||||
BYTE* audio_data = nullptr;
|
BYTE* audio_data = nullptr;
|
||||||
DWORD sample_buffer_length = 0;
|
DWORD sample_buffer_length = 0;
|
||||||
|
|
||||||
hr = buffer->Lock(
|
hr = buffer->Lock(&audio_data, nullptr, &sample_buffer_length);
|
||||||
&audio_data,
|
|
||||||
nullptr,
|
|
||||||
&sample_buffer_length
|
|
||||||
);
|
|
||||||
|
|
||||||
if (position + sample_buffer_length >= max_stream_size)
|
if (position + sample_buffer_length >= max_stream_size)
|
||||||
{
|
{
|
||||||
|
|
@ -276,7 +245,10 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
sample = nullptr;
|
sample = nullptr;
|
||||||
|
|
||||||
if (FAILED(hr)) { break; }
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
|
|
@ -294,5 +266,5 @@ namespace kiwano
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -87,5 +87,5 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/core/Logger.h>
|
|
||||||
#include <kiwano-audio/libraries.h>
|
#include <kiwano-audio/libraries.h>
|
||||||
|
#include <kiwano/core/Logger.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -31,8 +31,7 @@ namespace kiwano
|
||||||
: xaudio2()
|
: xaudio2()
|
||||||
, XAudio2Create(nullptr)
|
, XAudio2Create(nullptr)
|
||||||
{
|
{
|
||||||
const auto xaudio2_dll_names =
|
const auto xaudio2_dll_names = {
|
||||||
{
|
|
||||||
"xaudio2_9.dll", // for Windows 10
|
"xaudio2_9.dll", // for Windows 10
|
||||||
"xaudio2_8.dll", // for Windows 8
|
"xaudio2_8.dll", // for Windows 8
|
||||||
"xaudio2_7.dll" // for DirectX SDK
|
"xaudio2_7.dll" // for DirectX SDK
|
||||||
|
|
@ -73,8 +72,10 @@ namespace kiwano
|
||||||
MFStartup = mfplat.GetProcess<PFN_MFStartup>("MFStartup");
|
MFStartup = mfplat.GetProcess<PFN_MFStartup>("MFStartup");
|
||||||
MFShutdown = mfplat.GetProcess<PFN_MFShutdown>("MFShutdown");
|
MFShutdown = mfplat.GetProcess<PFN_MFShutdown>("MFShutdown");
|
||||||
MFCreateMediaType = mfplat.GetProcess<PFN_MFCreateMediaType>("MFCreateMediaType");
|
MFCreateMediaType = mfplat.GetProcess<PFN_MFCreateMediaType>("MFCreateMediaType");
|
||||||
MFCreateWaveFormatExFromMFMediaType = mfplat.GetProcess<PFN_MFCreateWaveFormatExFromMFMediaType>("MFCreateWaveFormatExFromMFMediaType");
|
MFCreateWaveFormatExFromMFMediaType =
|
||||||
MFCreateMFByteStreamOnStream = mfplat.GetProcess<PFN_MFCreateMFByteStreamOnStream>("MFCreateMFByteStreamOnStream");
|
mfplat.GetProcess<PFN_MFCreateWaveFormatExFromMFMediaType>("MFCreateWaveFormatExFromMFMediaType");
|
||||||
|
MFCreateMFByteStreamOnStream =
|
||||||
|
mfplat.GetProcess<PFN_MFCreateMFByteStreamOnStream>("MFCreateMFByteStreamOnStream");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -84,8 +85,10 @@ namespace kiwano
|
||||||
|
|
||||||
if (mfreadwrite.Load("Mfreadwrite.dll"))
|
if (mfreadwrite.Load("Mfreadwrite.dll"))
|
||||||
{
|
{
|
||||||
MFCreateSourceReaderFromURL = mfreadwrite.GetProcess<PFN_MFCreateSourceReaderFromURL>("MFCreateSourceReaderFromURL");
|
MFCreateSourceReaderFromURL =
|
||||||
MFCreateSourceReaderFromByteStream = mfreadwrite.GetProcess<PFN_MFCreateSourceReaderFromByteStream>("MFCreateSourceReaderFromByteStream");
|
mfreadwrite.GetProcess<PFN_MFCreateSourceReaderFromURL>("MFCreateSourceReaderFromURL");
|
||||||
|
MFCreateSourceReaderFromByteStream =
|
||||||
|
mfreadwrite.GetProcess<PFN_MFCreateSourceReaderFromByteStream>("MFCreateSourceReaderFromByteStream");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -93,6 +96,6 @@ namespace kiwano
|
||||||
throw std::runtime_error("Load Mfreadwrite.dll failed");
|
throw std::runtime_error("Load Mfreadwrite.dll failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace dlls
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/Library.h>
|
#include <kiwano/core/Library.h>
|
||||||
#include <xaudio2.h>
|
|
||||||
#include <mfapi.h>
|
#include <mfapi.h>
|
||||||
#include <mfidl.h>
|
#include <mfidl.h>
|
||||||
#include <mfreadwrite.h>
|
#include <mfreadwrite.h>
|
||||||
|
#include <xaudio2.h>
|
||||||
|
|
||||||
#ifndef KGE_DOXYGEN_DO_NOT_INCLUDE
|
#ifndef KGE_DOXYGEN_DO_NOT_INCLUDE
|
||||||
|
|
||||||
|
|
@ -56,7 +56,6 @@ namespace kiwano
|
||||||
Library xaudio2;
|
Library xaudio2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class KGE_API MediaFoundation
|
class KGE_API MediaFoundation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -92,8 +91,8 @@ namespace kiwano
|
||||||
Library mfplat;
|
Library mfplat;
|
||||||
Library mfreadwrite;
|
Library mfreadwrite;
|
||||||
};
|
};
|
||||||
}
|
} // namespace dlls
|
||||||
}
|
} // namespace audio
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -29,20 +29,22 @@ namespace kiwano
|
||||||
SetSwallowEvents(true);
|
SetSwallowEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiLayer::~ImGuiLayer()
|
ImGuiLayer::~ImGuiLayer() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGuiLayer::OnRender(RenderTarget* rt)
|
void ImGuiLayer::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
PrepareToRender(rt);
|
|
||||||
for (const auto& pipeline : pipelines_)
|
for (const auto& pipeline : pipelines_)
|
||||||
{
|
{
|
||||||
pipeline.second();
|
pipeline.second();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiLayer::AddItem(ImGuiPipeline const& item, String const& name)
|
bool ImGuiLayer::CheckVisibility(RenderContext& ctx) const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGuiLayer::AddItem(String const& name, ImGuiPipeline const& item)
|
||||||
{
|
{
|
||||||
pipelines_.insert(std::make_pair(name, item));
|
pipelines_.insert(std::make_pair(name, item));
|
||||||
}
|
}
|
||||||
|
|
@ -60,5 +62,5 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
pipelines_.clear();
|
pipelines_.clear();
|
||||||
}
|
}
|
||||||
}
|
} // namespace imgui
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief ImGuiͼ²ã
|
* @brief ImGuiͼ²ã
|
||||||
*/
|
*/
|
||||||
class ImGuiLayer
|
class ImGuiLayer : public Layer
|
||||||
: public Layer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImGuiLayer();
|
ImGuiLayer();
|
||||||
|
|
@ -45,9 +44,9 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief Ìí¼Ó ImGui ÔªËØ
|
/// @brief Ìí¼Ó ImGui ÔªËØ
|
||||||
/// @param item ¹ÜµÀ
|
|
||||||
/// @param name ÔªËØÃû³Æ
|
/// @param name ÔªËØÃû³Æ
|
||||||
void AddItem(ImGuiPipeline const& item, String const& name);
|
/// @param item ¹ÜµÀ
|
||||||
|
void AddItem(String const& name, ImGuiPipeline const& item);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief ÒÆ³ý ImGui ÔªËØ
|
/// @brief ÒÆ³ý ImGui ÔªËØ
|
||||||
|
|
@ -60,10 +59,12 @@ namespace kiwano
|
||||||
void RemoveAllItems();
|
void RemoveAllItems();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void OnRender(RenderTarget* rt) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
||||||
|
bool CheckVisibility(RenderContext& ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Map<String, ImGuiPipeline> pipelines_;
|
Map<String, ImGuiPipeline> pipelines_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace imgui
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,21 @@
|
||||||
// Copyright (C) 2019 Nomango
|
// Copyright (C) 2019 Nomango
|
||||||
|
|
||||||
#include <kiwano/core/common.h>
|
|
||||||
#include <kiwano/platform/Window.h>
|
#include <kiwano/core/Common.h>
|
||||||
|
#include <kiwano/core/event/KeyEvent.h>
|
||||||
|
#include <kiwano/core/event/MouseEvent.h>
|
||||||
#include <kiwano/platform/Input.h>
|
#include <kiwano/platform/Input.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/platform/Window.h>
|
||||||
|
#include <kiwano/render/Renderer.h>
|
||||||
#include <kiwano-imgui/ImGuiModule.h>
|
#include <kiwano-imgui/ImGuiModule.h>
|
||||||
#include <kiwano-imgui/imgui_impl.h>
|
#include <kiwano-imgui/imgui_impl.h>
|
||||||
|
|
||||||
#include <XInput.h>
|
|
||||||
#pragma comment(lib, "xinput")
|
|
||||||
|
|
||||||
// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
|
|
||||||
#ifndef WM_MOUSEHWHEEL
|
|
||||||
# define WM_MOUSEHWHEEL 0x020E
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DBT_DEVNODES_CHANGED
|
|
||||||
# define DBT_DEVNODES_CHANGED 0x0007
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
namespace imgui
|
namespace imgui
|
||||||
{
|
{
|
||||||
ImGuiModule::ImGuiModule()
|
ImGuiModule::ImGuiModule()
|
||||||
: has_gamepad_(false)
|
: target_window_(nullptr)
|
||||||
, want_update_has_gamepad_(false)
|
|
||||||
, target_window_(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,17 +24,41 @@ namespace kiwano
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
(void)io;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsClassic();
|
|
||||||
|
|
||||||
// Setup Platform/Renderer bindings
|
// Setup Platform/Renderer bindings
|
||||||
Init(Window::instance().GetHandle());
|
target_window_ = Renderer::Instance().GetTargetWindow();
|
||||||
|
|
||||||
target_window_ = Renderer::instance().GetTargetWindow();
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
|
io.BackendFlags |=
|
||||||
|
ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
io.BackendPlatformName = "imgui_impl_win32";
|
||||||
|
io.ImeWindowHandle = target_window_;
|
||||||
|
|
||||||
|
// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array that we will update during
|
||||||
|
// the application lifetime.
|
||||||
|
io.KeyMap[ImGuiKey_Tab] = (int)KeyCode::Tab;
|
||||||
|
io.KeyMap[ImGuiKey_LeftArrow] = (int)KeyCode::Left;
|
||||||
|
io.KeyMap[ImGuiKey_RightArrow] = (int)KeyCode::Right;
|
||||||
|
io.KeyMap[ImGuiKey_UpArrow] = (int)KeyCode::Up;
|
||||||
|
io.KeyMap[ImGuiKey_DownArrow] = (int)KeyCode::Down;
|
||||||
|
io.KeyMap[ImGuiKey_Delete] = (int)KeyCode::Delete;
|
||||||
|
io.KeyMap[ImGuiKey_Backspace] = (int)KeyCode::Back;
|
||||||
|
io.KeyMap[ImGuiKey_Space] = (int)KeyCode::Space;
|
||||||
|
io.KeyMap[ImGuiKey_Enter] = (int)KeyCode::Enter;
|
||||||
|
io.KeyMap[ImGuiKey_Escape] = (int)KeyCode::Esc;
|
||||||
|
io.KeyMap[ImGuiKey_A] = (int)KeyCode::A;
|
||||||
|
io.KeyMap[ImGuiKey_C] = (int)KeyCode::C;
|
||||||
|
io.KeyMap[ImGuiKey_V] = (int)KeyCode::V;
|
||||||
|
io.KeyMap[ImGuiKey_X] = (int)KeyCode::X;
|
||||||
|
io.KeyMap[ImGuiKey_Y] = (int)KeyCode::Y;
|
||||||
|
io.KeyMap[ImGuiKey_Z] = (int)KeyCode::Z;
|
||||||
|
|
||||||
|
ImGui_Impl_Init(Renderer::Instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiModule::DestroyComponent()
|
void ImGuiModule::DestroyComponent()
|
||||||
|
|
@ -62,49 +75,17 @@ namespace kiwano
|
||||||
io.DeltaTime = dt.Seconds();
|
io.DeltaTime = dt.Seconds();
|
||||||
|
|
||||||
// Read keyboard modifiers inputs
|
// Read keyboard modifiers inputs
|
||||||
io.KeyCtrl = Input::instance().IsDown(KeyCode::Ctrl);
|
io.KeyCtrl = Input::Instance().IsDown(KeyCode::Ctrl);
|
||||||
io.KeyShift = Input::instance().IsDown(KeyCode::Shift);
|
io.KeyShift = Input::Instance().IsDown(KeyCode::Shift);
|
||||||
io.KeyAlt = Input::instance().IsDown(KeyCode::Alt);
|
io.KeyAlt = Input::Instance().IsDown(KeyCode::Alt);
|
||||||
io.KeySuper = false;
|
io.KeySuper = Input::Instance().IsDown(KeyCode::Super);
|
||||||
// io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below.
|
// io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the HandleEvent function below.
|
||||||
|
|
||||||
// Update OS mouse position
|
// Update OS mouse position
|
||||||
UpdateMousePos();
|
UpdateMousePos();
|
||||||
|
|
||||||
// Update OS mouse cursor with the cursor requested by imgui
|
// Update OS mouse cursor with the cursor requested by imgui
|
||||||
UpdateMouseCursor();
|
UpdateMouseCursor();
|
||||||
|
|
||||||
// Update game controllers (if enabled and available)
|
|
||||||
UpdateGamepads();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGuiModule::Init(HWND hwnd)
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
|
||||||
io.BackendPlatformName = "imgui_impl_win32";
|
|
||||||
io.ImeWindowHandle = hwnd;
|
|
||||||
|
|
||||||
// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
|
|
||||||
io.KeyMap[ImGuiKey_Tab] = KeyCode::Tab;
|
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = KeyCode::Left;
|
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = KeyCode::Right;
|
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = KeyCode::Up;
|
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = KeyCode::Down;
|
|
||||||
io.KeyMap[ImGuiKey_Delete] = KeyCode::Delete;
|
|
||||||
io.KeyMap[ImGuiKey_Backspace] = KeyCode::Back;
|
|
||||||
io.KeyMap[ImGuiKey_Space] = KeyCode::Space;
|
|
||||||
io.KeyMap[ImGuiKey_Enter] = KeyCode::Enter;
|
|
||||||
io.KeyMap[ImGuiKey_Escape] = KeyCode::Esc;
|
|
||||||
io.KeyMap[ImGuiKey_A] = KeyCode::A;
|
|
||||||
io.KeyMap[ImGuiKey_C] = KeyCode::C;
|
|
||||||
io.KeyMap[ImGuiKey_V] = KeyCode::V;
|
|
||||||
io.KeyMap[ImGuiKey_X] = KeyCode::X;
|
|
||||||
io.KeyMap[ImGuiKey_Y] = KeyCode::Y;
|
|
||||||
io.KeyMap[ImGuiKey_Z] = KeyCode::Z;
|
|
||||||
|
|
||||||
ImGui_Impl_Init(&Renderer::instance());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiModule::BeforeRender()
|
void ImGuiModule::BeforeRender()
|
||||||
|
|
@ -117,88 +98,61 @@ namespace kiwano
|
||||||
Render();
|
Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiModule::HandleMessage(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam)
|
void ImGuiModule::HandleEvent(Event* evt)
|
||||||
{
|
{
|
||||||
if (ImGui::GetCurrentContext() == NULL)
|
if (ImGui::GetCurrentContext() == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
switch (msg)
|
if (evt->IsType<MouseEvent>())
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
if (evt->IsType<MouseDownEvent>())
|
||||||
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
|
||||||
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
|
|
||||||
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK:
|
|
||||||
{
|
{
|
||||||
int button = 0;
|
MouseButton button = dynamic_cast<MouseDownEvent*>(evt)->button;
|
||||||
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; }
|
int index = 0;
|
||||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
|
if (button == MouseButton::Left)
|
||||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
|
index = 0;
|
||||||
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wparam) == XBUTTON1) ? 3 : 4; }
|
else if (button == MouseButton::Right)
|
||||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
index = 1;
|
||||||
::SetCapture(hwnd);
|
else if (button == MouseButton::Middle)
|
||||||
|
index = 2;
|
||||||
io.MouseDown[button] = true;
|
io.MouseDown[index] = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case WM_LBUTTONUP:
|
else if (evt->IsType<MouseUpEvent>())
|
||||||
case WM_RBUTTONUP:
|
|
||||||
case WM_MBUTTONUP:
|
|
||||||
case WM_XBUTTONUP:
|
|
||||||
{
|
{
|
||||||
int button = 0;
|
MouseButton button = dynamic_cast<MouseUpEvent*>(evt)->button;
|
||||||
if (msg == WM_LBUTTONUP) { button = 0; }
|
int index = 0;
|
||||||
if (msg == WM_RBUTTONUP) { button = 1; }
|
if (button == MouseButton::Left)
|
||||||
if (msg == WM_MBUTTONUP) { button = 2; }
|
index = 0;
|
||||||
if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wparam) == XBUTTON1) ? 3 : 4; }
|
else if (button == MouseButton::Right)
|
||||||
io.MouseDown[button] = false;
|
index = 1;
|
||||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
else if (button == MouseButton::Middle)
|
||||||
::ReleaseCapture();
|
index = 2;
|
||||||
break;
|
io.MouseDown[index] = false;
|
||||||
}
|
}
|
||||||
case WM_MOUSEWHEEL:
|
else if (evt->IsType<MouseWheelEvent>())
|
||||||
{
|
{
|
||||||
io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wparam) / (float)WHEEL_DELTA;
|
float wheel = dynamic_cast<MouseWheelEvent*>(evt)->wheel;
|
||||||
break;
|
io.MouseWheel += wheel;
|
||||||
}
|
}
|
||||||
case WM_MOUSEHWHEEL:
|
}
|
||||||
|
else if (evt->IsType<KeyEvent>())
|
||||||
{
|
{
|
||||||
io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wparam) / (float)WHEEL_DELTA;
|
if (evt->IsType<KeyDownEvent>())
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
{
|
{
|
||||||
if (wparam < 256)
|
KeyCode key = dynamic_cast<KeyDownEvent*>(evt)->code;
|
||||||
io.KeysDown[wparam] = 1;
|
io.KeysDown[(int)key] = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case WM_KEYUP:
|
else if (evt->IsType<KeyUpEvent>())
|
||||||
case WM_SYSKEYUP:
|
|
||||||
{
|
{
|
||||||
if (wparam < 256)
|
KeyCode key = dynamic_cast<KeyUpEvent*>(evt)->code;
|
||||||
io.KeysDown[wparam] = 0;
|
io.KeysDown[(int)key] = false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case WM_CHAR:
|
else if (evt->IsType<KeyCharEvent>())
|
||||||
{
|
{
|
||||||
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
||||||
io.AddInputCharacter((uint32_t)wparam);
|
char ch = dynamic_cast<KeyCharEvent*>(evt)->value;
|
||||||
break;
|
io.AddInputCharacter(static_cast<ImWchar>(ch));
|
||||||
}
|
|
||||||
case WM_SETCURSOR:
|
|
||||||
{
|
|
||||||
if (LOWORD(lparam) == HTCLIENT)
|
|
||||||
{
|
|
||||||
UpdateMouseCursor();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WM_DEVICECHANGE:
|
|
||||||
{
|
|
||||||
if ((uint32_t)wparam == DBT_DEVNODES_CHANGED)
|
|
||||||
want_update_has_gamepad_ = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +165,7 @@ namespace kiwano
|
||||||
KGE_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built!");
|
KGE_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built!");
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
Size display_size = Renderer::instance().GetOutputSize();
|
Size display_size = Renderer::Instance().GetOutputSize();
|
||||||
io.DisplaySize = ImVec2(display_size.x, display_size.y);
|
io.DisplaySize = ImVec2(display_size.x, display_size.y);
|
||||||
|
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
@ -228,7 +182,8 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by
|
||||||
|
// user)
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
{
|
{
|
||||||
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
|
|
@ -236,7 +191,7 @@ namespace kiwano
|
||||||
::SetCursorPos(pos.x, pos.y);
|
::SetCursorPos(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point pos = Input::instance().GetMousePos();
|
Point pos = Input::Instance().GetMousePos();
|
||||||
io.MousePos = ImVec2(pos.x, pos.y);
|
io.MousePos = ImVec2(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,62 +203,34 @@ namespace kiwano
|
||||||
CursorType cursor = CursorType::Arrow;
|
CursorType cursor = CursorType::Arrow;
|
||||||
switch (ImGui::GetMouseCursor())
|
switch (ImGui::GetMouseCursor())
|
||||||
{
|
{
|
||||||
case ImGuiMouseCursor_Arrow: cursor = CursorType::Arrow; break;
|
case ImGuiMouseCursor_Arrow:
|
||||||
case ImGuiMouseCursor_TextInput: cursor = CursorType::TextInput; break;
|
cursor = CursorType::Arrow;
|
||||||
case ImGuiMouseCursor_ResizeAll: cursor = CursorType::SizeAll; break;
|
break;
|
||||||
case ImGuiMouseCursor_ResizeEW: cursor = CursorType::SizeWE; break;
|
case ImGuiMouseCursor_TextInput:
|
||||||
case ImGuiMouseCursor_ResizeNS: cursor = CursorType::SizeNS; break;
|
cursor = CursorType::TextInput;
|
||||||
case ImGuiMouseCursor_ResizeNESW: cursor = CursorType::SizeNESW; break;
|
break;
|
||||||
case ImGuiMouseCursor_ResizeNWSE: cursor = CursorType::SizeNWSE; break;
|
case ImGuiMouseCursor_ResizeAll:
|
||||||
case ImGuiMouseCursor_Hand: cursor = CursorType::Hand; break;
|
cursor = CursorType::SizeAll;
|
||||||
|
break;
|
||||||
|
case ImGuiMouseCursor_ResizeEW:
|
||||||
|
cursor = CursorType::SizeWE;
|
||||||
|
break;
|
||||||
|
case ImGuiMouseCursor_ResizeNS:
|
||||||
|
cursor = CursorType::SizeNS;
|
||||||
|
break;
|
||||||
|
case ImGuiMouseCursor_ResizeNESW:
|
||||||
|
cursor = CursorType::SizeNESW;
|
||||||
|
break;
|
||||||
|
case ImGuiMouseCursor_ResizeNWSE:
|
||||||
|
cursor = CursorType::SizeNWSE;
|
||||||
|
break;
|
||||||
|
case ImGuiMouseCursor_Hand:
|
||||||
|
cursor = CursorType::Hand;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::instance().SetCursor(cursor);
|
Window::Instance().SetCursor(cursor);
|
||||||
}
|
|
||||||
void ImGuiModule::UpdateGamepads()
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow.
|
|
||||||
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
|
|
||||||
if (want_update_has_gamepad_)
|
|
||||||
{
|
|
||||||
XINPUT_CAPABILITIES caps;
|
|
||||||
has_gamepad_ = (XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS);
|
|
||||||
want_update_has_gamepad_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XINPUT_STATE xinput_state;
|
} // namespace imgui
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
} // namespace kiwano
|
||||||
if (has_gamepad_ && XInputGetState(0, &xinput_state) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
|
||||||
|
|
||||||
#define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; }
|
|
||||||
#define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
|
|
||||||
MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A
|
|
||||||
MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B
|
|
||||||
MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X
|
|
||||||
MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y
|
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left
|
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right
|
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up
|
|
||||||
MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down
|
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
|
|
||||||
MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
|
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
|
|
||||||
MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
|
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
|
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
|
||||||
MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767);
|
|
||||||
#undef MAP_BUTTON
|
|
||||||
#undef MAP_ANALOG
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/common.h>
|
#include <kiwano/core/Common.h>
|
||||||
#include <kiwano/core/Component.h>
|
#include <kiwano/core/Component.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -49,13 +49,11 @@ namespace kiwano
|
||||||
|
|
||||||
void AfterRender() override;
|
void AfterRender() override;
|
||||||
|
|
||||||
void HandleMessage(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam) override;
|
void HandleEvent(Event* evt) override;
|
||||||
|
|
||||||
void OnUpdate(Duration dt) override;
|
void OnUpdate(Duration dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init(HWND hwnd);
|
|
||||||
|
|
||||||
void NewFrame();
|
void NewFrame();
|
||||||
|
|
||||||
void Render();
|
void Render();
|
||||||
|
|
@ -64,12 +62,8 @@ namespace kiwano
|
||||||
|
|
||||||
void UpdateMouseCursor();
|
void UpdateMouseCursor();
|
||||||
|
|
||||||
void UpdateGamepads();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool has_gamepad_;
|
WindowHandle target_window_;
|
||||||
bool want_update_has_gamepad_;
|
|
||||||
HWND target_window_;
|
|
||||||
};
|
};
|
||||||
}
|
} // namespace imgui
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -8,25 +8,62 @@
|
||||||
|
|
||||||
#include <kiwano-imgui/imgui_impl_dx11.h>
|
#include <kiwano-imgui/imgui_impl_dx11.h>
|
||||||
|
|
||||||
inline bool ImGui_Impl_Init(::kiwano::Renderer* renderer) { return ImGui_ImplDX11_Init(renderer->GetD3DDeviceResources()->GetDevice(), renderer->GetD3DDeviceResources()->GetDeviceContext()); }
|
inline bool ImGui_Impl_Init(::kiwano::Renderer& renderer)
|
||||||
inline void ImGui_Impl_Shutdown() { ImGui_ImplDX11_Shutdown(); }
|
{
|
||||||
inline void ImGui_Impl_NewFrame() { ImGui_ImplDX11_NewFrame(); }
|
return ImGui_ImplDX11_Init(renderer.GetD3DDeviceResources()->GetDevice(),
|
||||||
inline void ImGui_Impl_RenderDrawData(ImDrawData* draw_data) { ImGui_ImplDX11_RenderDrawData(draw_data); }
|
renderer.GetD3DDeviceResources()->GetDeviceContext());
|
||||||
|
}
|
||||||
|
inline void ImGui_Impl_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_Shutdown();
|
||||||
|
}
|
||||||
|
inline void ImGui_Impl_NewFrame()
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_NewFrame();
|
||||||
|
}
|
||||||
|
inline void ImGui_Impl_RenderDrawData(ImDrawData* draw_data)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_RenderDrawData(draw_data);
|
||||||
|
}
|
||||||
|
|
||||||
inline void ImGui_Impl_InvalidateDeviceObjects() { ImGui_ImplDX11_InvalidateDeviceObjects(); }
|
inline void ImGui_Impl_InvalidateDeviceObjects()
|
||||||
inline bool ImGui_Impl_CreateDeviceObjects() { return ImGui_ImplDX11_CreateDeviceObjects(); }
|
{
|
||||||
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
|
}
|
||||||
|
inline bool ImGui_Impl_CreateDeviceObjects()
|
||||||
|
{
|
||||||
|
return ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <kiwano-imgui/imgui_impl_dx10.h>
|
#include <kiwano-imgui/imgui_impl_dx10.h>
|
||||||
|
|
||||||
inline bool ImGui_Impl_Init(::kiwano::Renderer* renderer) { return ImGui_ImplDX10_Init(renderer->GetD3DDeviceResources()->GetDevice()); }
|
inline bool ImGui_Impl_Init(::kiwano::Renderer& renderer)
|
||||||
inline void ImGui_Impl_Shutdown() { ImGui_ImplDX10_Shutdown(); }
|
{
|
||||||
inline void ImGui_Impl_NewFrame() { ImGui_ImplDX10_NewFrame(); }
|
return ImGui_ImplDX10_Init(renderer.GetD3DDeviceResources()->GetDevice());
|
||||||
inline void ImGui_Impl_RenderDrawData(ImDrawData* draw_data) { ImGui_ImplDX10_RenderDrawData(draw_data); }
|
}
|
||||||
|
inline void ImGui_Impl_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_Shutdown();
|
||||||
|
}
|
||||||
|
inline void ImGui_Impl_NewFrame()
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_NewFrame();
|
||||||
|
}
|
||||||
|
inline void ImGui_Impl_RenderDrawData(ImDrawData* draw_data)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_RenderDrawData(draw_data);
|
||||||
|
}
|
||||||
|
|
||||||
inline void ImGui_Impl_InvalidateDeviceObjects() { ImGui_ImplDX10_InvalidateDeviceObjects(); }
|
inline void ImGui_Impl_InvalidateDeviceObjects()
|
||||||
inline bool ImGui_Impl_CreateDeviceObjects() { return ImGui_ImplDX10_CreateDeviceObjects(); }
|
{
|
||||||
|
ImGui_ImplDX10_InvalidateDeviceObjects();
|
||||||
|
}
|
||||||
|
inline bool ImGui_Impl_CreateDeviceObjects()
|
||||||
|
{
|
||||||
|
return ImGui_ImplDX10_CreateDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
#include <kiwano-imgui/imgui_impl_dx10.h>
|
#include <kiwano-imgui/imgui_impl_dx10.h>
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
#include <stdio.h>
|
|
||||||
#include <d3d10_1.h>
|
#include <d3d10_1.h>
|
||||||
#include <d3d10.h>
|
#include <d3d10.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
|
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
|
||||||
|
|
@ -36,7 +36,8 @@ struct VERTEX_CONSTANT_BUFFER
|
||||||
};
|
};
|
||||||
|
|
||||||
// Render Function
|
// Render Function
|
||||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from
|
||||||
|
// your main loop)
|
||||||
void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
ID3D10Device* ctx = g_pd3dDevice;
|
ID3D10Device* ctx = g_pd3dDevice;
|
||||||
|
|
@ -44,7 +45,11 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
// Create and grow vertex/index buffers if needed
|
// Create and grow vertex/index buffers if needed
|
||||||
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
{
|
{
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (g_pVB)
|
||||||
|
{
|
||||||
|
g_pVB->Release();
|
||||||
|
g_pVB = NULL;
|
||||||
|
}
|
||||||
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D10_BUFFER_DESC desc;
|
D3D10_BUFFER_DESC desc;
|
||||||
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
|
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
|
||||||
|
|
@ -59,7 +64,11 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
|
|
||||||
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
{
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (g_pIB)
|
||||||
|
{
|
||||||
|
g_pIB->Release();
|
||||||
|
g_pIB = NULL;
|
||||||
|
}
|
||||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D10_BUFFER_DESC desc;
|
D3D10_BUFFER_DESC desc;
|
||||||
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
|
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
|
||||||
|
|
@ -88,7 +97,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
g_pIB->Unmap();
|
g_pIB->Unmap();
|
||||||
|
|
||||||
// Setup orthographic projection matrix into our constant buffer
|
// Setup orthographic projection matrix into our constant buffer
|
||||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right).
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to
|
||||||
|
// draw_data->DisplayPos+data_data->DisplaySize (bottom right).
|
||||||
{
|
{
|
||||||
void* mapped_resource;
|
void* mapped_resource;
|
||||||
if (g_pVertexConstantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
if (g_pVertexConstantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
||||||
|
|
@ -98,8 +108,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||||
float T = draw_data->DisplayPos.y;
|
float T = draw_data->DisplayPos.y;
|
||||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||||
float mvp[4][4] =
|
float mvp[4][4] = {
|
||||||
{
|
|
||||||
{ 2.0f / (R - L), 0.0f, 0.0f, 0.0f },
|
{ 2.0f / (R - L), 0.0f, 0.0f, 0.0f },
|
||||||
{ 0.0f, 2.0f / (T - B), 0.0f, 0.0f },
|
{ 0.0f, 2.0f / (T - B), 0.0f, 0.0f },
|
||||||
{ 0.0f, 0.0f, 0.5f, 0.0f },
|
{ 0.0f, 0.0f, 0.5f, 0.0f },
|
||||||
|
|
@ -109,7 +118,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
g_pVertexConstantBuffer->Unmap();
|
g_pVertexConstantBuffer->Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
|
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and
|
||||||
|
// verbose. Close your eyes!)
|
||||||
struct BACKUP_DX10_STATE
|
struct BACKUP_DX10_STATE
|
||||||
{
|
{
|
||||||
UINT ScissorRectsCount, ViewportsCount;
|
UINT ScissorRectsCount, ViewportsCount;
|
||||||
|
|
@ -194,7 +204,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
const D3D10_RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y), (LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y)};
|
const D3D10_RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y),
|
||||||
|
(LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y) };
|
||||||
ctx->RSSetScissorRects(1, &r);
|
ctx->RSSetScissorRects(1, &r);
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
|
|
@ -210,18 +221,40 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||||
// Restore modified DX state
|
// Restore modified DX state
|
||||||
ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
||||||
ctx->RSSetViewports(old.ViewportsCount, old.Viewports);
|
ctx->RSSetViewports(old.ViewportsCount, old.Viewports);
|
||||||
ctx->RSSetState(old.RS); if (old.RS) old.RS->Release();
|
ctx->RSSetState(old.RS);
|
||||||
ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release();
|
if (old.RS)
|
||||||
ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release();
|
old.RS->Release();
|
||||||
ctx->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release();
|
ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask);
|
||||||
ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
|
if (old.BlendState)
|
||||||
ctx->PSSetShader(old.PS); if (old.PS) old.PS->Release();
|
old.BlendState->Release();
|
||||||
ctx->VSSetShader(old.VS); if (old.VS) old.VS->Release();
|
ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef);
|
||||||
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
if (old.DepthStencilState)
|
||||||
|
old.DepthStencilState->Release();
|
||||||
|
ctx->PSSetShaderResources(0, 1, &old.PSShaderResource);
|
||||||
|
if (old.PSShaderResource)
|
||||||
|
old.PSShaderResource->Release();
|
||||||
|
ctx->PSSetSamplers(0, 1, &old.PSSampler);
|
||||||
|
if (old.PSSampler)
|
||||||
|
old.PSSampler->Release();
|
||||||
|
ctx->PSSetShader(old.PS);
|
||||||
|
if (old.PS)
|
||||||
|
old.PS->Release();
|
||||||
|
ctx->VSSetShader(old.VS);
|
||||||
|
if (old.VS)
|
||||||
|
old.VS->Release();
|
||||||
|
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
||||||
|
if (old.VSConstantBuffer)
|
||||||
|
old.VSConstantBuffer->Release();
|
||||||
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
||||||
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset);
|
||||||
ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release();
|
if (old.IndexBuffer)
|
||||||
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
old.IndexBuffer->Release();
|
||||||
|
ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
||||||
|
if (old.VertexBuffer)
|
||||||
|
old.VertexBuffer->Release();
|
||||||
|
ctx->IASetInputLayout(old.InputLayout);
|
||||||
|
if (old.InputLayout)
|
||||||
|
old.InputLayout->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplDX10_CreateFontsTexture()
|
static void ImGui_ImplDX10_CreateFontsTexture()
|
||||||
|
|
@ -290,16 +323,17 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
||||||
if (g_pFontSampler)
|
if (g_pFontSampler)
|
||||||
ImGui_ImplDX10_InvalidateDeviceObjects();
|
ImGui_ImplDX10_InvalidateDeviceObjects();
|
||||||
|
|
||||||
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
|
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of
|
||||||
// If you would like to use this DX10 sample code but remove this dependency you can:
|
// d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A) If you would like to use this DX10 sample code but remove this
|
||||||
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
|
// dependency you can:
|
||||||
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
|
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to
|
||||||
|
// CreateVertexShader()/CreatePixelShader() [preferred solution] 2) use code to detect any version of the DLL and
|
||||||
|
// grab a pointer to D3DCompile from the DLL.
|
||||||
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
|
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
|
||||||
|
|
||||||
// Create the vertex shader
|
// Create the vertex shader
|
||||||
{
|
{
|
||||||
static const char* vertexShader =
|
static const char* vertexShader = "cbuffer vertexBuffer : register(b0) \
|
||||||
"cbuffer vertexBuffer : register(b0) \
|
|
||||||
{\
|
{\
|
||||||
float4x4 ProjectionMatrix; \
|
float4x4 ProjectionMatrix; \
|
||||||
};\
|
};\
|
||||||
|
|
@ -326,20 +360,29 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
||||||
return output;\
|
return output;\
|
||||||
}";
|
}";
|
||||||
|
|
||||||
D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob, NULL);
|
D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob,
|
||||||
if (g_pVertexShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
NULL);
|
||||||
|
if (g_pVertexShaderBlob
|
||||||
|
== NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const
|
||||||
|
// char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||||
return false;
|
return false;
|
||||||
if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pVertexShader) != S_OK)
|
if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(),
|
||||||
|
g_pVertexShaderBlob->GetBufferSize(), &g_pVertexShader)
|
||||||
|
!= S_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the input layout
|
// Create the input layout
|
||||||
D3D10_INPUT_ELEMENT_DESC local_layout[] =
|
D3D10_INPUT_ELEMENT_DESC local_layout[] = {
|
||||||
{
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D10_INPUT_PER_VERTEX_DATA,
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D10_INPUT_PER_VERTEX_DATA,
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
0 },
|
||||||
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D10_INPUT_PER_VERTEX_DATA,
|
||||||
|
0 },
|
||||||
};
|
};
|
||||||
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(),
|
||||||
|
g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout)
|
||||||
|
!= S_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the constant buffer
|
// Create the constant buffer
|
||||||
|
|
@ -356,8 +399,7 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
||||||
|
|
||||||
// Create the pixel shader
|
// Create the pixel shader
|
||||||
{
|
{
|
||||||
static const char* pixelShader =
|
static const char* pixelShader = "struct PS_INPUT\
|
||||||
"struct PS_INPUT\
|
|
||||||
{\
|
{\
|
||||||
float4 pos : SV_POSITION;\
|
float4 pos : SV_POSITION;\
|
||||||
float4 col : COLOR0;\
|
float4 col : COLOR0;\
|
||||||
|
|
@ -372,10 +414,15 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
||||||
return out_col; \
|
return out_col; \
|
||||||
}";
|
}";
|
||||||
|
|
||||||
D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob, NULL);
|
D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob,
|
||||||
if (g_pPixelShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
NULL);
|
||||||
|
if (g_pPixelShaderBlob
|
||||||
|
== NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const
|
||||||
|
// char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||||
return false;
|
return false;
|
||||||
if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(), g_pPixelShaderBlob->GetBufferSize(), &g_pPixelShader) != S_OK)
|
if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(),
|
||||||
|
g_pPixelShaderBlob->GetBufferSize(), &g_pPixelShader)
|
||||||
|
!= S_OK)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -414,7 +461,8 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
||||||
desc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;
|
desc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL;
|
||||||
desc.DepthFunc = D3D10_COMPARISON_ALWAYS;
|
desc.DepthFunc = D3D10_COMPARISON_ALWAYS;
|
||||||
desc.StencilEnable = false;
|
desc.StencilEnable = false;
|
||||||
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D10_STENCIL_OP_KEEP;
|
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp =
|
||||||
|
D3D10_STENCIL_OP_KEEP;
|
||||||
desc.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS;
|
desc.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS;
|
||||||
desc.BackFace = desc.FrontFace;
|
desc.BackFace = desc.FrontFace;
|
||||||
g_pd3dDevice->CreateDepthStencilState(&desc, &g_pDepthStencilState);
|
g_pd3dDevice->CreateDepthStencilState(&desc, &g_pDepthStencilState);
|
||||||
|
|
@ -430,20 +478,73 @@ void ImGui_ImplDX10_InvalidateDeviceObjects()
|
||||||
if (!g_pd3dDevice)
|
if (!g_pd3dDevice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
if (g_pFontSampler)
|
||||||
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
g_pFontSampler->Release();
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
g_pFontSampler = NULL;
|
||||||
|
}
|
||||||
|
if (g_pFontTextureView)
|
||||||
|
{
|
||||||
|
g_pFontTextureView->Release();
|
||||||
|
g_pFontTextureView = NULL;
|
||||||
|
ImGui::GetIO().Fonts->TexID = NULL;
|
||||||
|
} // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
|
if (g_pIB)
|
||||||
|
{
|
||||||
|
g_pIB->Release();
|
||||||
|
g_pIB = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVB)
|
||||||
|
{
|
||||||
|
g_pVB->Release();
|
||||||
|
g_pVB = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_pBlendState) { g_pBlendState->Release(); g_pBlendState = NULL; }
|
if (g_pBlendState)
|
||||||
if (g_pDepthStencilState) { g_pDepthStencilState->Release(); g_pDepthStencilState = NULL; }
|
{
|
||||||
if (g_pRasterizerState) { g_pRasterizerState->Release(); g_pRasterizerState = NULL; }
|
g_pBlendState->Release();
|
||||||
if (g_pPixelShader) { g_pPixelShader->Release(); g_pPixelShader = NULL; }
|
g_pBlendState = NULL;
|
||||||
if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release(); g_pPixelShaderBlob = NULL; }
|
}
|
||||||
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release(); g_pVertexConstantBuffer = NULL; }
|
if (g_pDepthStencilState)
|
||||||
if (g_pInputLayout) { g_pInputLayout->Release(); g_pInputLayout = NULL; }
|
{
|
||||||
if (g_pVertexShader) { g_pVertexShader->Release(); g_pVertexShader = NULL; }
|
g_pDepthStencilState->Release();
|
||||||
if (g_pVertexShaderBlob) { g_pVertexShaderBlob->Release(); g_pVertexShaderBlob = NULL; }
|
g_pDepthStencilState = NULL;
|
||||||
|
}
|
||||||
|
if (g_pRasterizerState)
|
||||||
|
{
|
||||||
|
g_pRasterizerState->Release();
|
||||||
|
g_pRasterizerState = NULL;
|
||||||
|
}
|
||||||
|
if (g_pPixelShader)
|
||||||
|
{
|
||||||
|
g_pPixelShader->Release();
|
||||||
|
g_pPixelShader = NULL;
|
||||||
|
}
|
||||||
|
if (g_pPixelShaderBlob)
|
||||||
|
{
|
||||||
|
g_pPixelShaderBlob->Release();
|
||||||
|
g_pPixelShaderBlob = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVertexConstantBuffer)
|
||||||
|
{
|
||||||
|
g_pVertexConstantBuffer->Release();
|
||||||
|
g_pVertexConstantBuffer = NULL;
|
||||||
|
}
|
||||||
|
if (g_pInputLayout)
|
||||||
|
{
|
||||||
|
g_pInputLayout->Release();
|
||||||
|
g_pInputLayout = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVertexShader)
|
||||||
|
{
|
||||||
|
g_pVertexShader->Release();
|
||||||
|
g_pVertexShader = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVertexShaderBlob)
|
||||||
|
{
|
||||||
|
g_pVertexShaderBlob->Release();
|
||||||
|
g_pVertexShaderBlob = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
||||||
|
|
@ -463,8 +564,10 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
||||||
g_pd3dDevice = device;
|
g_pd3dDevice = device;
|
||||||
g_pFactory = pFactory;
|
g_pFactory = pFactory;
|
||||||
}
|
}
|
||||||
if (pDXGIDevice) pDXGIDevice->Release();
|
if (pDXGIDevice)
|
||||||
if (pDXGIAdapter) pDXGIAdapter->Release();
|
pDXGIDevice->Release();
|
||||||
|
if (pDXGIAdapter)
|
||||||
|
pDXGIAdapter->Release();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -472,7 +575,11 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
||||||
void ImGui_ImplDX10_Shutdown()
|
void ImGui_ImplDX10_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX10_InvalidateDeviceObjects();
|
ImGui_ImplDX10_InvalidateDeviceObjects();
|
||||||
if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; }
|
if (g_pFactory)
|
||||||
|
{
|
||||||
|
g_pFactory->Release();
|
||||||
|
g_pFactory = NULL;
|
||||||
|
}
|
||||||
g_pd3dDevice = NULL;
|
g_pd3dDevice = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include <kiwano-imgui/imgui_impl_dx11.h>
|
#include <kiwano-imgui/imgui_impl_dx11.h>
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
#include <stdio.h>
|
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
|
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
|
||||||
|
|
@ -36,7 +36,8 @@ struct VERTEX_CONSTANT_BUFFER
|
||||||
};
|
};
|
||||||
|
|
||||||
// Render Function
|
// Render Function
|
||||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from
|
||||||
|
// your main loop)
|
||||||
void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
ID3D11DeviceContext* ctx = g_pd3dDeviceContext;
|
ID3D11DeviceContext* ctx = g_pd3dDeviceContext;
|
||||||
|
|
@ -44,7 +45,11 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
// Create and grow vertex/index buffers if needed
|
// Create and grow vertex/index buffers if needed
|
||||||
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
{
|
{
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
if (g_pVB)
|
||||||
|
{
|
||||||
|
g_pVB->Release();
|
||||||
|
g_pVB = NULL;
|
||||||
|
}
|
||||||
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D11_BUFFER_DESC desc;
|
D3D11_BUFFER_DESC desc;
|
||||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||||
|
|
@ -58,7 +63,11 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
}
|
}
|
||||||
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
{
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (g_pIB)
|
||||||
|
{
|
||||||
|
g_pIB->Release();
|
||||||
|
g_pIB = NULL;
|
||||||
|
}
|
||||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D11_BUFFER_DESC desc;
|
D3D11_BUFFER_DESC desc;
|
||||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||||
|
|
@ -90,7 +99,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
ctx->Unmap(g_pIB, 0);
|
ctx->Unmap(g_pIB, 0);
|
||||||
|
|
||||||
// Setup orthographic projection matrix into our constant buffer
|
// Setup orthographic projection matrix into our constant buffer
|
||||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right).
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to
|
||||||
|
// draw_data->DisplayPos+data_data->DisplaySize (bottom right).
|
||||||
{
|
{
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
||||||
if (ctx->Map(g_pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
if (ctx->Map(g_pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
||||||
|
|
@ -100,8 +110,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||||
float T = draw_data->DisplayPos.y;
|
float T = draw_data->DisplayPos.y;
|
||||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||||
float mvp[4][4] =
|
float mvp[4][4] = {
|
||||||
{
|
|
||||||
{ 2.0f / (R - L), 0.0f, 0.0f, 0.0f },
|
{ 2.0f / (R - L), 0.0f, 0.0f, 0.0f },
|
||||||
{ 0.0f, 2.0f / (T - B), 0.0f, 0.0f },
|
{ 0.0f, 2.0f / (T - B), 0.0f, 0.0f },
|
||||||
{ 0.0f, 0.0f, 0.5f, 0.0f },
|
{ 0.0f, 0.0f, 0.5f, 0.0f },
|
||||||
|
|
@ -111,7 +120,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
ctx->Unmap(g_pVertexConstantBuffer, 0);
|
ctx->Unmap(g_pVertexConstantBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
|
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and
|
||||||
|
// verbose. Close your eyes!)
|
||||||
struct BACKUP_DX11_STATE
|
struct BACKUP_DX11_STATE
|
||||||
{
|
{
|
||||||
UINT ScissorRectsCount, ViewportsCount;
|
UINT ScissorRectsCount, ViewportsCount;
|
||||||
|
|
@ -199,7 +209,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
const D3D11_RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y), (LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y) };
|
const D3D11_RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y),
|
||||||
|
(LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y) };
|
||||||
ctx->RSSetScissorRects(1, &r);
|
ctx->RSSetScissorRects(1, &r);
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
|
|
@ -215,20 +226,46 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||||
// Restore modified DX state
|
// Restore modified DX state
|
||||||
ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
||||||
ctx->RSSetViewports(old.ViewportsCount, old.Viewports);
|
ctx->RSSetViewports(old.ViewportsCount, old.Viewports);
|
||||||
ctx->RSSetState(old.RS); if (old.RS) old.RS->Release();
|
ctx->RSSetState(old.RS);
|
||||||
ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release();
|
if (old.RS)
|
||||||
ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release();
|
old.RS->Release();
|
||||||
ctx->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release();
|
ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask);
|
||||||
ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
|
if (old.BlendState)
|
||||||
ctx->PSSetShader(old.PS, old.PSInstances, old.PSInstancesCount); if (old.PS) old.PS->Release();
|
old.BlendState->Release();
|
||||||
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
|
ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef);
|
||||||
ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
|
if (old.DepthStencilState)
|
||||||
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
old.DepthStencilState->Release();
|
||||||
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
|
ctx->PSSetShaderResources(0, 1, &old.PSShaderResource);
|
||||||
|
if (old.PSShaderResource)
|
||||||
|
old.PSShaderResource->Release();
|
||||||
|
ctx->PSSetSamplers(0, 1, &old.PSSampler);
|
||||||
|
if (old.PSSampler)
|
||||||
|
old.PSSampler->Release();
|
||||||
|
ctx->PSSetShader(old.PS, old.PSInstances, old.PSInstancesCount);
|
||||||
|
if (old.PS)
|
||||||
|
old.PS->Release();
|
||||||
|
for (UINT i = 0; i < old.PSInstancesCount; i++)
|
||||||
|
if (old.PSInstances[i])
|
||||||
|
old.PSInstances[i]->Release();
|
||||||
|
ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount);
|
||||||
|
if (old.VS)
|
||||||
|
old.VS->Release();
|
||||||
|
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
||||||
|
if (old.VSConstantBuffer)
|
||||||
|
old.VSConstantBuffer->Release();
|
||||||
|
for (UINT i = 0; i < old.VSInstancesCount; i++)
|
||||||
|
if (old.VSInstances[i])
|
||||||
|
old.VSInstances[i]->Release();
|
||||||
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
||||||
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset);
|
||||||
ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release();
|
if (old.IndexBuffer)
|
||||||
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
old.IndexBuffer->Release();
|
||||||
|
ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
||||||
|
if (old.VertexBuffer)
|
||||||
|
old.VertexBuffer->Release();
|
||||||
|
ctx->IASetInputLayout(old.InputLayout);
|
||||||
|
if (old.InputLayout)
|
||||||
|
old.InputLayout->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplDX11_CreateFontsTexture()
|
static void ImGui_ImplDX11_CreateFontsTexture()
|
||||||
|
|
@ -301,16 +338,17 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||||
if (g_pFontSampler)
|
if (g_pFontSampler)
|
||||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
|
|
||||||
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
|
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of
|
||||||
// If you would like to use this DX11 sample code but remove this dependency you can:
|
// d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A) If you would like to use this DX11 sample code but remove this
|
||||||
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
|
// dependency you can:
|
||||||
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
|
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to
|
||||||
|
// CreateVertexShader()/CreatePixelShader() [preferred solution] 2) use code to detect any version of the DLL and
|
||||||
|
// grab a pointer to D3DCompile from the DLL.
|
||||||
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
|
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
|
||||||
|
|
||||||
// Create the vertex shader
|
// Create the vertex shader
|
||||||
{
|
{
|
||||||
static const char* vertexShader =
|
static const char* vertexShader = "cbuffer vertexBuffer : register(b0) \
|
||||||
"cbuffer vertexBuffer : register(b0) \
|
|
||||||
{\
|
{\
|
||||||
float4x4 ProjectionMatrix; \
|
float4x4 ProjectionMatrix; \
|
||||||
};\
|
};\
|
||||||
|
|
@ -337,20 +375,29 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||||
return output;\
|
return output;\
|
||||||
}";
|
}";
|
||||||
|
|
||||||
D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob, NULL);
|
D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob,
|
||||||
if (g_pVertexShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
NULL);
|
||||||
|
if (g_pVertexShaderBlob
|
||||||
|
== NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const
|
||||||
|
// char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||||
return false;
|
return false;
|
||||||
if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader) != S_OK)
|
if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(),
|
||||||
|
g_pVertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader)
|
||||||
|
!= S_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the input layout
|
// Create the input layout
|
||||||
D3D11_INPUT_ELEMENT_DESC local_layout[] =
|
D3D11_INPUT_ELEMENT_DESC local_layout[] = {
|
||||||
{
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA,
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA,
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
0 },
|
||||||
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA,
|
||||||
|
0 },
|
||||||
};
|
};
|
||||||
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(),
|
||||||
|
g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout)
|
||||||
|
!= S_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the constant buffer
|
// Create the constant buffer
|
||||||
|
|
@ -367,8 +414,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||||
|
|
||||||
// Create the pixel shader
|
// Create the pixel shader
|
||||||
{
|
{
|
||||||
static const char* pixelShader =
|
static const char* pixelShader = "struct PS_INPUT\
|
||||||
"struct PS_INPUT\
|
|
||||||
{\
|
{\
|
||||||
float4 pos : SV_POSITION;\
|
float4 pos : SV_POSITION;\
|
||||||
float4 col : COLOR0;\
|
float4 col : COLOR0;\
|
||||||
|
|
@ -383,10 +429,15 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||||
return out_col; \
|
return out_col; \
|
||||||
}";
|
}";
|
||||||
|
|
||||||
D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob, NULL);
|
D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob,
|
||||||
if (g_pPixelShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
NULL);
|
||||||
|
if (g_pPixelShaderBlob
|
||||||
|
== NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const
|
||||||
|
// char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||||
return false;
|
return false;
|
||||||
if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(), g_pPixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader) != S_OK)
|
if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(),
|
||||||
|
g_pPixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader)
|
||||||
|
!= S_OK)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -425,7 +476,8 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||||
desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||||
desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
|
desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
desc.StencilEnable = false;
|
desc.StencilEnable = false;
|
||||||
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp =
|
||||||
|
D3D11_STENCIL_OP_KEEP;
|
||||||
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
desc.BackFace = desc.FrontFace;
|
desc.BackFace = desc.FrontFace;
|
||||||
g_pd3dDevice->CreateDepthStencilState(&desc, &g_pDepthStencilState);
|
g_pd3dDevice->CreateDepthStencilState(&desc, &g_pDepthStencilState);
|
||||||
|
|
@ -441,20 +493,73 @@ void ImGui_ImplDX11_InvalidateDeviceObjects()
|
||||||
if (!g_pd3dDevice)
|
if (!g_pd3dDevice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
if (g_pFontSampler)
|
||||||
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
g_pFontSampler->Release();
|
||||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
g_pFontSampler = NULL;
|
||||||
|
}
|
||||||
|
if (g_pFontTextureView)
|
||||||
|
{
|
||||||
|
g_pFontTextureView->Release();
|
||||||
|
g_pFontTextureView = NULL;
|
||||||
|
ImGui::GetIO().Fonts->TexID = NULL;
|
||||||
|
} // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
|
if (g_pIB)
|
||||||
|
{
|
||||||
|
g_pIB->Release();
|
||||||
|
g_pIB = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVB)
|
||||||
|
{
|
||||||
|
g_pVB->Release();
|
||||||
|
g_pVB = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_pBlendState) { g_pBlendState->Release(); g_pBlendState = NULL; }
|
if (g_pBlendState)
|
||||||
if (g_pDepthStencilState) { g_pDepthStencilState->Release(); g_pDepthStencilState = NULL; }
|
{
|
||||||
if (g_pRasterizerState) { g_pRasterizerState->Release(); g_pRasterizerState = NULL; }
|
g_pBlendState->Release();
|
||||||
if (g_pPixelShader) { g_pPixelShader->Release(); g_pPixelShader = NULL; }
|
g_pBlendState = NULL;
|
||||||
if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release(); g_pPixelShaderBlob = NULL; }
|
}
|
||||||
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release(); g_pVertexConstantBuffer = NULL; }
|
if (g_pDepthStencilState)
|
||||||
if (g_pInputLayout) { g_pInputLayout->Release(); g_pInputLayout = NULL; }
|
{
|
||||||
if (g_pVertexShader) { g_pVertexShader->Release(); g_pVertexShader = NULL; }
|
g_pDepthStencilState->Release();
|
||||||
if (g_pVertexShaderBlob) { g_pVertexShaderBlob->Release(); g_pVertexShaderBlob = NULL; }
|
g_pDepthStencilState = NULL;
|
||||||
|
}
|
||||||
|
if (g_pRasterizerState)
|
||||||
|
{
|
||||||
|
g_pRasterizerState->Release();
|
||||||
|
g_pRasterizerState = NULL;
|
||||||
|
}
|
||||||
|
if (g_pPixelShader)
|
||||||
|
{
|
||||||
|
g_pPixelShader->Release();
|
||||||
|
g_pPixelShader = NULL;
|
||||||
|
}
|
||||||
|
if (g_pPixelShaderBlob)
|
||||||
|
{
|
||||||
|
g_pPixelShaderBlob->Release();
|
||||||
|
g_pPixelShaderBlob = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVertexConstantBuffer)
|
||||||
|
{
|
||||||
|
g_pVertexConstantBuffer->Release();
|
||||||
|
g_pVertexConstantBuffer = NULL;
|
||||||
|
}
|
||||||
|
if (g_pInputLayout)
|
||||||
|
{
|
||||||
|
g_pInputLayout->Release();
|
||||||
|
g_pInputLayout = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVertexShader)
|
||||||
|
{
|
||||||
|
g_pVertexShader->Release();
|
||||||
|
g_pVertexShader = NULL;
|
||||||
|
}
|
||||||
|
if (g_pVertexShaderBlob)
|
||||||
|
{
|
||||||
|
g_pVertexShaderBlob->Release();
|
||||||
|
g_pVertexShaderBlob = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
|
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
|
||||||
|
|
@ -475,8 +580,10 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
||||||
g_pd3dDeviceContext = device_context;
|
g_pd3dDeviceContext = device_context;
|
||||||
g_pFactory = pFactory;
|
g_pFactory = pFactory;
|
||||||
}
|
}
|
||||||
if (pDXGIDevice) pDXGIDevice->Release();
|
if (pDXGIDevice)
|
||||||
if (pDXGIAdapter) pDXGIAdapter->Release();
|
pDXGIDevice->Release();
|
||||||
|
if (pDXGIAdapter)
|
||||||
|
pDXGIAdapter->Release();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -484,7 +591,11 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
||||||
void ImGui_ImplDX11_Shutdown()
|
void ImGui_ImplDX11_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; }
|
if (g_pFactory)
|
||||||
|
{
|
||||||
|
g_pFactory->Release();
|
||||||
|
g_pFactory = NULL;
|
||||||
|
}
|
||||||
g_pd3dDevice = NULL;
|
g_pd3dDevice = NULL;
|
||||||
g_pd3dDeviceContext = NULL;
|
g_pd3dDeviceContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,13 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
#include <thread>
|
||||||
|
#include <kiwano/core/Logger.h>
|
||||||
|
#include <kiwano/platform/Application.h>
|
||||||
#include <kiwano-network/HttpRequest.h>
|
#include <kiwano-network/HttpRequest.h>
|
||||||
#include <kiwano-network/HttpResponse.hpp>
|
#include <kiwano-network/HttpResponse.hpp>
|
||||||
#include <kiwano-network/HttpClient.h>
|
#include <kiwano-network/HttpClient.h>
|
||||||
|
|
||||||
#include <kiwano/core/Logger.h>
|
|
||||||
#include <kiwano/platform/Application.h>
|
|
||||||
#include <3rd-party/curl/curl.h> // CURL
|
#include <3rd-party/curl/curl.h> // CURL
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
@ -104,7 +102,8 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Init(HttpClient* client, Vector<ByteString> const& headers, ByteString const& url, ByteString* response_data, ByteString* response_header, char* error_buffer)
|
bool Init(HttpClient* client, Vector<ByteString> const& headers, ByteString const& url, ByteString* response_data,
|
||||||
|
ByteString* response_header, char* error_buffer)
|
||||||
{
|
{
|
||||||
if (!SetOption(CURLOPT_ERRORBUFFER, error_buffer))
|
if (!SetOption(CURLOPT_ERRORBUFFER, error_buffer))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -114,13 +113,15 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto ssl_ca_file = wide_to_string(client->GetSSLVerification());
|
const auto ssl_ca_file = wide_to_string(client->GetSSLVerification());
|
||||||
if (ssl_ca_file.empty()) {
|
if (ssl_ca_file.empty())
|
||||||
|
{
|
||||||
if (!SetOption(CURLOPT_SSL_VERIFYPEER, 0L))
|
if (!SetOption(CURLOPT_SSL_VERIFYPEER, 0L))
|
||||||
return false;
|
return false;
|
||||||
if (!SetOption(CURLOPT_SSL_VERIFYHOST, 0L))
|
if (!SetOption(CURLOPT_SSL_VERIFYHOST, 0L))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if (!SetOption(CURLOPT_SSL_VERIFYPEER, 1L))
|
if (!SetOption(CURLOPT_SSL_VERIFYPEER, 1L))
|
||||||
return false;
|
return false;
|
||||||
if (!SetOption(CURLOPT_SSL_VERIFYHOST, 2L))
|
if (!SetOption(CURLOPT_SSL_VERIFYHOST, 2L))
|
||||||
|
|
@ -145,10 +146,8 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SetOption(CURLOPT_URL, url.c_str())
|
return SetOption(CURLOPT_URL, url.c_str()) && SetOption(CURLOPT_WRITEFUNCTION, write_data)
|
||||||
&& SetOption(CURLOPT_WRITEFUNCTION, write_data)
|
&& SetOption(CURLOPT_WRITEDATA, response_data) && SetOption(CURLOPT_HEADERFUNCTION, write_data)
|
||||||
&& SetOption(CURLOPT_WRITEDATA, response_data)
|
|
||||||
&& SetOption(CURLOPT_HEADERFUNCTION, write_data)
|
|
||||||
&& SetOption(CURLOPT_HEADERDATA, response_header);
|
&& SetOption(CURLOPT_HEADERDATA, response_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,70 +167,43 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline bool GetRequest(
|
static inline bool GetRequest(HttpClient* client, Vector<ByteString> const& headers, ByteString const& url,
|
||||||
HttpClient* client,
|
long* response_code, ByteString* response_data, ByteString* response_header,
|
||||||
Vector<ByteString> const& headers,
|
|
||||||
ByteString const& url,
|
|
||||||
long* response_code,
|
|
||||||
ByteString* response_data,
|
|
||||||
ByteString* response_header,
|
|
||||||
char* error_buffer)
|
char* error_buffer)
|
||||||
{
|
{
|
||||||
Curl curl;
|
Curl curl;
|
||||||
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
||||||
&& curl.SetOption(CURLOPT_FOLLOWLOCATION, true)
|
&& curl.SetOption(CURLOPT_FOLLOWLOCATION, true) && curl.Perform(response_code);
|
||||||
&& curl.Perform(response_code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool PostRequest(
|
static inline bool PostRequest(HttpClient* client, Vector<ByteString> const& headers, ByteString const& url,
|
||||||
HttpClient* client,
|
ByteString const& request_data, long* response_code, ByteString* response_data,
|
||||||
Vector<ByteString> const& headers,
|
ByteString* response_header, char* error_buffer)
|
||||||
ByteString const& url,
|
|
||||||
ByteString const& request_data,
|
|
||||||
long* response_code,
|
|
||||||
ByteString* response_data,
|
|
||||||
ByteString* response_header,
|
|
||||||
char* error_buffer)
|
|
||||||
{
|
{
|
||||||
Curl curl;
|
Curl curl;
|
||||||
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
||||||
&& curl.SetOption(CURLOPT_POST, 1)
|
&& curl.SetOption(CURLOPT_POST, 1) && curl.SetOption(CURLOPT_POSTFIELDS, request_data.c_str())
|
||||||
&& curl.SetOption(CURLOPT_POSTFIELDS, request_data.c_str())
|
&& curl.SetOption(CURLOPT_POSTFIELDSIZE, request_data.size()) && curl.Perform(response_code);
|
||||||
&& curl.SetOption(CURLOPT_POSTFIELDSIZE, request_data.size())
|
|
||||||
&& curl.Perform(response_code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool PutRequest(
|
static inline bool PutRequest(HttpClient* client, Vector<ByteString> const& headers, ByteString const& url,
|
||||||
HttpClient* client,
|
ByteString const& request_data, long* response_code, ByteString* response_data,
|
||||||
Vector<ByteString> const& headers,
|
ByteString* response_header, char* error_buffer)
|
||||||
ByteString const& url,
|
|
||||||
ByteString const& request_data,
|
|
||||||
long* response_code,
|
|
||||||
ByteString* response_data,
|
|
||||||
ByteString* response_header,
|
|
||||||
char* error_buffer)
|
|
||||||
{
|
{
|
||||||
Curl curl;
|
Curl curl;
|
||||||
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
||||||
&& curl.SetOption(CURLOPT_CUSTOMREQUEST, "PUT")
|
&& curl.SetOption(CURLOPT_CUSTOMREQUEST, "PUT")
|
||||||
&& curl.SetOption(CURLOPT_POSTFIELDS, request_data.c_str())
|
&& curl.SetOption(CURLOPT_POSTFIELDS, request_data.c_str())
|
||||||
&& curl.SetOption(CURLOPT_POSTFIELDSIZE, request_data.size())
|
&& curl.SetOption(CURLOPT_POSTFIELDSIZE, request_data.size()) && curl.Perform(response_code);
|
||||||
&& curl.Perform(response_code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool DeleteRequest(
|
static inline bool DeleteRequest(HttpClient* client, Vector<ByteString> const& headers, ByteString const& url,
|
||||||
HttpClient* client,
|
long* response_code, ByteString* response_data, ByteString* response_header,
|
||||||
Vector<ByteString> const& headers,
|
|
||||||
ByteString const& url,
|
|
||||||
long* response_code,
|
|
||||||
ByteString* response_data,
|
|
||||||
ByteString* response_header,
|
|
||||||
char* error_buffer)
|
char* error_buffer)
|
||||||
{
|
{
|
||||||
Curl curl;
|
Curl curl;
|
||||||
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
return curl.Init(client, headers, url, response_data, response_header, error_buffer)
|
||||||
&& curl.SetOption(CURLOPT_CUSTOMREQUEST, "DELETE")
|
&& curl.SetOption(CURLOPT_CUSTOMREQUEST, "DELETE") && curl.SetOption(CURLOPT_FOLLOWLOCATION, true)
|
||||||
&& curl.SetOption(CURLOPT_FOLLOWLOCATION, true)
|
|
||||||
&& curl.Perform(response_code);
|
&& curl.Perform(response_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,7 +211,7 @@ namespace
|
||||||
CURL* curl_;
|
CURL* curl_;
|
||||||
curl_slist* curl_headers_;
|
curl_slist* curl_headers_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -326,10 +298,12 @@ namespace kiwano
|
||||||
ok = Curl::GetRequest(this, headers, url, &response_code, &response_data, &response_header, error_message);
|
ok = Curl::GetRequest(this, headers, url, &response_code, &response_data, &response_header, error_message);
|
||||||
break;
|
break;
|
||||||
case HttpRequest::Type::Post:
|
case HttpRequest::Type::Post:
|
||||||
ok = Curl::PostRequest(this, headers, url, data, &response_code, &response_data, &response_header, error_message);
|
ok = Curl::PostRequest(this, headers, url, data, &response_code, &response_data, &response_header,
|
||||||
|
error_message);
|
||||||
break;
|
break;
|
||||||
case HttpRequest::Type::Put:
|
case HttpRequest::Type::Put:
|
||||||
ok = Curl::PutRequest(this, headers, url, data, &response_code, &response_data, &response_header, error_message);
|
ok =
|
||||||
|
Curl::PutRequest(this, headers, url, data, &response_code, &response_data, &response_header, error_message);
|
||||||
break;
|
break;
|
||||||
case HttpRequest::Type::Delete:
|
case HttpRequest::Type::Delete:
|
||||||
ok = Curl::DeleteRequest(this, headers, url, &response_code, &response_data, &response_header, error_message);
|
ok = Curl::DeleteRequest(this, headers, url, &response_code, &response_data, &response_header, error_message);
|
||||||
|
|
@ -377,5 +351,5 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace network
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/common.h>
|
#include <condition_variable>
|
||||||
|
#include <kiwano/core/Common.h>
|
||||||
#include <kiwano/core/Component.h>
|
#include <kiwano/core/Component.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +110,6 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
inline void HttpClient::SetTimeoutForConnect(Duration timeout)
|
inline void HttpClient::SetTimeoutForConnect(Duration timeout)
|
||||||
{
|
{
|
||||||
timeout_for_connect_ = timeout;
|
timeout_for_connect_ = timeout;
|
||||||
|
|
@ -141,5 +140,5 @@ namespace kiwano
|
||||||
return ssl_verification_;
|
return ssl_verification_;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace network
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,5 @@ namespace kiwano
|
||||||
SetHeader(L"Content-Type", L"application/json;charset=UTF-8");
|
SetHeader(L"Content-Type", L"application/json;charset=UTF-8");
|
||||||
data_ = json.dump();
|
data_ = json.dump();
|
||||||
}
|
}
|
||||||
}
|
} // namespace network
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/common.h>
|
#include <kiwano/core/Common.h>
|
||||||
#include <kiwano/core/ObjectBase.h>
|
#include <kiwano/core/ObjectBase.h>
|
||||||
#include <kiwano/core/SmartPtr.hpp>
|
#include <kiwano/core/SmartPtr.hpp>
|
||||||
|
|
||||||
|
|
@ -40,8 +40,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief HTTPÇëÇó
|
* @brief HTTPÇëÇó
|
||||||
*/
|
*/
|
||||||
class KGE_API HttpRequest
|
class KGE_API HttpRequest : public virtual ObjectBase
|
||||||
: public ObjectBase
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -125,32 +124,74 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline HttpRequest::HttpRequest() : type_(Type::Unknown) {}
|
inline HttpRequest::HttpRequest()
|
||||||
|
: type_(Type::Unknown)
|
||||||
inline HttpRequest::HttpRequest(Type type) : type_(type) {}
|
{
|
||||||
|
|
||||||
inline void HttpRequest::SetUrl(String const& url) { url_ = url; }
|
|
||||||
|
|
||||||
inline String const& HttpRequest::GetUrl() const { return url_; }
|
|
||||||
|
|
||||||
inline void HttpRequest::SetType(Type type) { type_ = type; }
|
|
||||||
|
|
||||||
inline HttpRequest::Type HttpRequest::GetType() const { return type_; }
|
|
||||||
|
|
||||||
inline void HttpRequest::SetData(String const& data) { data_ = data; }
|
|
||||||
|
|
||||||
inline String const& HttpRequest::GetData() const { return data_; }
|
|
||||||
|
|
||||||
inline void HttpRequest::SetHeaders(Map<String, String> const& headers) { headers_ = headers; }
|
|
||||||
|
|
||||||
inline void HttpRequest::SetHeader(String const& field, String const& content) { headers_[field] = content; }
|
|
||||||
|
|
||||||
inline Map<String, String>& HttpRequest::GetHeaders() { return headers_; }
|
|
||||||
|
|
||||||
inline String const& HttpRequest::GetHeader(String const& header) const { return headers_.at(header); }
|
|
||||||
|
|
||||||
inline void HttpRequest::SetResponseCallback(ResponseCallback const& callback) { response_cb_ = callback; }
|
|
||||||
|
|
||||||
inline HttpRequest::ResponseCallback const& HttpRequest::GetResponseCallback() const { return response_cb_; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline HttpRequest::HttpRequest(Type type)
|
||||||
|
: type_(type)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void HttpRequest::SetUrl(String const& url)
|
||||||
|
{
|
||||||
|
url_ = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String const& HttpRequest::GetUrl() const
|
||||||
|
{
|
||||||
|
return url_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpRequest::SetType(Type type)
|
||||||
|
{
|
||||||
|
type_ = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline HttpRequest::Type HttpRequest::GetType() const
|
||||||
|
{
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpRequest::SetData(String const& data)
|
||||||
|
{
|
||||||
|
data_ = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String const& HttpRequest::GetData() const
|
||||||
|
{
|
||||||
|
return data_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpRequest::SetHeaders(Map<String, String> const& headers)
|
||||||
|
{
|
||||||
|
headers_ = headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpRequest::SetHeader(String const& field, String const& content)
|
||||||
|
{
|
||||||
|
headers_[field] = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Map<String, String>& HttpRequest::GetHeaders()
|
||||||
|
{
|
||||||
|
return headers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String const& HttpRequest::GetHeader(String const& header) const
|
||||||
|
{
|
||||||
|
return headers_.at(header);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpRequest::SetResponseCallback(ResponseCallback const& callback)
|
||||||
|
{
|
||||||
|
response_cb_ = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline HttpRequest::ResponseCallback const& HttpRequest::GetResponseCallback() const
|
||||||
|
{
|
||||||
|
return response_cb_;
|
||||||
|
}
|
||||||
|
} // namespace network
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief HTTPÏìÓ¦
|
* @brief HTTPÏìÓ¦
|
||||||
*/
|
*/
|
||||||
class KGE_API HttpResponse
|
class KGE_API HttpResponse : public virtual ObjectBase
|
||||||
: public ObjectBase
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HttpResponse(HttpRequestPtr request);
|
HttpResponse(HttpRequestPtr request);
|
||||||
|
|
@ -98,28 +97,66 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline HttpResponse::HttpResponse(HttpRequestPtr request) : request_(request), succeed_(false), response_code_(0) {}
|
inline HttpResponse::HttpResponse(HttpRequestPtr request)
|
||||||
|
: request_(request)
|
||||||
inline HttpRequestPtr HttpResponse::GetRequest() const { return request_; }
|
, succeed_(false)
|
||||||
|
, response_code_(0)
|
||||||
inline void HttpResponse::SetSucceed(bool succeed) { succeed_ = succeed; }
|
{
|
||||||
|
|
||||||
inline bool HttpResponse::IsSucceed() const { return succeed_; }
|
|
||||||
|
|
||||||
inline void HttpResponse::SetResponseCode(long response_code) { response_code_ = response_code; }
|
|
||||||
|
|
||||||
inline long HttpResponse::GetResponseCode() const { return response_code_; }
|
|
||||||
|
|
||||||
inline void HttpResponse::SetHeader(String const& response_header) { response_header_ = response_header; }
|
|
||||||
|
|
||||||
inline String HttpResponse::GetHeader() const { return response_header_; }
|
|
||||||
|
|
||||||
inline void HttpResponse::SetData(String const& response_data) { response_data_ = response_data; }
|
|
||||||
|
|
||||||
inline String const& HttpResponse::GetData() const { return response_data_; }
|
|
||||||
|
|
||||||
inline void HttpResponse::SetError(String const& error_buffer) { error_buffer_ = error_buffer; }
|
|
||||||
|
|
||||||
inline String const& HttpResponse::GetError() const { return error_buffer_; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline HttpRequestPtr HttpResponse::GetRequest() const
|
||||||
|
{
|
||||||
|
return request_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void HttpResponse::SetSucceed(bool succeed)
|
||||||
|
{
|
||||||
|
succeed_ = succeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool HttpResponse::IsSucceed() const
|
||||||
|
{
|
||||||
|
return succeed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpResponse::SetResponseCode(long response_code)
|
||||||
|
{
|
||||||
|
response_code_ = response_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline long HttpResponse::GetResponseCode() const
|
||||||
|
{
|
||||||
|
return response_code_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpResponse::SetHeader(String const& response_header)
|
||||||
|
{
|
||||||
|
response_header_ = response_header;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String HttpResponse::GetHeader() const
|
||||||
|
{
|
||||||
|
return response_header_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpResponse::SetData(String const& response_data)
|
||||||
|
{
|
||||||
|
response_data_ = response_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String const& HttpResponse::GetData() const
|
||||||
|
{
|
||||||
|
return response_data_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void HttpResponse::SetError(String const& error_buffer)
|
||||||
|
{
|
||||||
|
error_buffer_ = error_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String const& HttpResponse::GetError() const
|
||||||
|
{
|
||||||
|
return error_buffer_;
|
||||||
|
}
|
||||||
|
} // namespace network
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <kiwano-network/HttpClient.h>
|
||||||
#include <kiwano-network/HttpRequest.h>
|
#include <kiwano-network/HttpRequest.h>
|
||||||
#include <kiwano-network/HttpResponse.hpp>
|
#include <kiwano-network/HttpResponse.hpp>
|
||||||
#include <kiwano-network/HttpClient.h>
|
|
||||||
|
|
|
||||||
|
|
@ -36,25 +36,12 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Body::Body(b2Body* body, Actor* actor)
|
|
||||||
: Body()
|
|
||||||
{
|
|
||||||
SetB2Body(body);
|
|
||||||
SetActor(actor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Body::Body(World* world, Actor* actor)
|
|
||||||
: Body()
|
|
||||||
{
|
|
||||||
Init(world, actor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Body::~Body()
|
Body::~Body()
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Body::Init(World* world, Actor* actor)
|
bool Body::InitBody(World* world, Actor* actor)
|
||||||
{
|
{
|
||||||
KGE_ASSERT(world);
|
KGE_ASSERT(world);
|
||||||
|
|
||||||
|
|
@ -64,9 +51,14 @@ namespace kiwano
|
||||||
b2BodyDef def;
|
b2BodyDef def;
|
||||||
b2Body* b2body = world->GetB2World()->CreateBody(&def);
|
b2Body* b2body = world->GetB2World()->CreateBody(&def);
|
||||||
|
|
||||||
|
if (b2body)
|
||||||
|
{
|
||||||
SetB2Body(b2body);
|
SetB2Body(b2body);
|
||||||
SetActor(actor);
|
SetActor(actor);
|
||||||
UpdateFromActor();
|
UpdateFromActor();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fixture Body::AddFixture(Shape* shape, const Fixture::Param& param)
|
Fixture Body::AddFixture(Shape* shape, const Fixture::Param& param)
|
||||||
|
|
@ -166,9 +158,12 @@ namespace kiwano
|
||||||
b2MassData data;
|
b2MassData data;
|
||||||
body_->GetMassData(&data);
|
body_->GetMassData(&data);
|
||||||
|
|
||||||
if (mass) *mass = data.mass;
|
if (mass)
|
||||||
if (center) *center = world_->World2Stage(data.center);
|
*mass = data.mass;
|
||||||
if (inertia) *inertia = data.I;
|
if (center)
|
||||||
|
*center = world_->World2Stage(data.center);
|
||||||
|
if (inertia)
|
||||||
|
*inertia = data.I;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Body::SetMassData(float mass, Point const& center, float inertia)
|
void Body::SetMassData(float mass, Point const& center, float inertia)
|
||||||
|
|
@ -253,7 +248,7 @@ namespace kiwano
|
||||||
|
|
||||||
void Body::Destroy()
|
void Body::Destroy()
|
||||||
{
|
{
|
||||||
if (world_ && body_)
|
if (world_)
|
||||||
{
|
{
|
||||||
world_->RemoveBody(this);
|
world_->RemoveBody(this);
|
||||||
}
|
}
|
||||||
|
|
@ -285,17 +280,11 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
if (world_)
|
if (world_)
|
||||||
{
|
{
|
||||||
body_->SetTransform(
|
body_->SetTransform(world_->Stage2World(actor_->GetPosition()), math::Degree2Radian(actor_->GetRotation()));
|
||||||
world_->Stage2World(actor_->GetPosition()),
|
|
||||||
math::Degree2Radian(actor_->GetRotation())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body_->SetTransform(
|
body_->SetTransform(Stage2World(actor_->GetPosition()), math::Degree2Radian(actor_->GetRotation()));
|
||||||
Stage2World(actor_->GetPosition()),
|
|
||||||
math::Degree2Radian(actor_->GetRotation())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -309,5 +298,5 @@ namespace kiwano
|
||||||
fixture->SetFilterData(filter);
|
fixture->SetFilterData(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano-physics/helper.h>
|
|
||||||
#include <kiwano-physics/Shape.h>
|
|
||||||
#include <kiwano-physics/Fixture.h>
|
|
||||||
#include <kiwano-physics/ContactEdge.h>
|
#include <kiwano-physics/ContactEdge.h>
|
||||||
|
#include <kiwano-physics/Fixture.h>
|
||||||
|
#include <kiwano-physics/Shape.h>
|
||||||
|
#include <kiwano-physics/helper.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -39,8 +39,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 物体
|
/// @brief 物体
|
||||||
class KGE_API Body
|
class KGE_API Body : public virtual ObjectBase
|
||||||
: public virtual RefCounter
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -53,16 +52,20 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
Body();
|
Body();
|
||||||
Body(b2Body* body, Actor* actor);
|
|
||||||
Body(World* world, Actor* actor);
|
|
||||||
Body(World* world, ActorPtr actor);
|
|
||||||
virtual ~Body();
|
virtual ~Body();
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 初始化
|
/// @brief 初始化
|
||||||
/// @param[in] world 物理世界
|
/// @param[in] world 物理世界
|
||||||
/// @param[in] actor 绑定的角色
|
/// @param[in] actor 绑定的角色
|
||||||
void Init(World* world, Actor* actor);
|
bool InitBody(World* world, ActorPtr actor);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 初始化
|
||||||
|
/// @param[in] world 物理世界
|
||||||
|
/// @param[in] actor 绑定的角色
|
||||||
|
bool InitBody(World* world, Actor* actor);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 添加夹具
|
/// @brief 添加夹具
|
||||||
|
|
@ -319,62 +322,168 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline Body::Body(World* world, ActorPtr actor) : Body(world, actor.get()) {}
|
inline bool Body::InitBody(World* world, ActorPtr actor)
|
||||||
|
{
|
||||||
inline FixtureList Body::GetFixtureList() const { KGE_ASSERT(body_); return FixtureList(Fixture(body_->GetFixtureList())); }
|
return InitBody(world, actor.get());
|
||||||
|
|
||||||
inline ContactEdgeList Body::GetContactList() const { KGE_ASSERT(body_); return ContactEdgeList(ContactEdge(body_->GetContactList())); }
|
|
||||||
|
|
||||||
inline uint16_t Body::GetCategoryBits() const { return category_bits_; }
|
|
||||||
|
|
||||||
inline uint16_t Body::GetMaskBits() const { return mask_bits_; }
|
|
||||||
|
|
||||||
inline int16_t Body::GetGroupIndex() const { return group_index_; }
|
|
||||||
|
|
||||||
inline float Body::GetBodyRotation() const { KGE_ASSERT(body_); return math::Radian2Degree(body_->GetAngle()); }
|
|
||||||
|
|
||||||
inline void Body::SetBodyRotation(float angle) { SetBodyTransform(GetBodyPosition(), angle); }
|
|
||||||
|
|
||||||
inline void Body::SetBodyPosition(Point const& pos) { SetBodyTransform(pos, GetBodyRotation()); }
|
|
||||||
|
|
||||||
inline float Body::GetMass() const { KGE_ASSERT(body_); return body_->GetMass(); }
|
|
||||||
|
|
||||||
inline float Body::GetInertia() const { KGE_ASSERT(body_); return body_->GetInertia(); }
|
|
||||||
|
|
||||||
inline Body::Type Body::GetType() const { KGE_ASSERT(body_); return Type(body_->GetType()); }
|
|
||||||
|
|
||||||
inline void Body::SetType(Type type) { KGE_ASSERT(body_); body_->SetType(static_cast<b2BodyType>(type)); }
|
|
||||||
|
|
||||||
inline float Body::GetGravityScale() const { KGE_ASSERT(body_); return body_->GetGravityScale(); }
|
|
||||||
|
|
||||||
inline void Body::SetGravityScale(float scale) { KGE_ASSERT(body_); body_->SetGravityScale(scale); }
|
|
||||||
|
|
||||||
inline bool Body::IsIgnoreRotation() const { KGE_ASSERT(body_); return body_->IsFixedRotation(); }
|
|
||||||
|
|
||||||
inline void Body::SetIgnoreRotation(bool flag) { KGE_ASSERT(body_); body_->SetFixedRotation(flag); }
|
|
||||||
|
|
||||||
inline bool Body::IsBullet() const { KGE_ASSERT(body_); return body_->IsBullet(); }
|
|
||||||
|
|
||||||
inline void Body::SetBullet(bool flag) { KGE_ASSERT(body_); body_->SetBullet(flag); }
|
|
||||||
|
|
||||||
inline bool Body::IsAwake() const { KGE_ASSERT(body_); return body_->IsAwake(); }
|
|
||||||
|
|
||||||
inline void Body::SetAwake(bool flag) { KGE_ASSERT(body_); body_->SetAwake(flag); }
|
|
||||||
|
|
||||||
inline bool Body::IsSleepingAllowed() const { KGE_ASSERT(body_); return body_->IsSleepingAllowed(); }
|
|
||||||
|
|
||||||
inline void Body::SetSleepingAllowed(bool flag) { KGE_ASSERT(body_); body_->SetSleepingAllowed(flag); }
|
|
||||||
|
|
||||||
inline bool Body::IsActive() const { KGE_ASSERT(body_); return body_->IsActive(); }
|
|
||||||
|
|
||||||
inline void Body::SetActive(bool flag) { KGE_ASSERT(body_); body_->SetActive(flag); }
|
|
||||||
|
|
||||||
inline Actor* Body::GetActor() const { return actor_; }
|
|
||||||
|
|
||||||
inline void Body::SetActor(Actor* actor) { actor_ = actor; }
|
|
||||||
|
|
||||||
inline b2Body* Body::GetB2Body() const { return body_; }
|
|
||||||
|
|
||||||
inline World* Body::GetWorld() const { return world_; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline FixtureList Body::GetFixtureList() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return FixtureList(Fixture(body_->GetFixtureList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ContactEdgeList Body::GetContactList() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return ContactEdgeList(ContactEdge(body_->GetContactList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint16_t Body::GetCategoryBits() const
|
||||||
|
{
|
||||||
|
return category_bits_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint16_t Body::GetMaskBits() const
|
||||||
|
{
|
||||||
|
return mask_bits_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int16_t Body::GetGroupIndex() const
|
||||||
|
{
|
||||||
|
return group_index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float Body::GetBodyRotation() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return math::Radian2Degree(body_->GetAngle());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetBodyRotation(float angle)
|
||||||
|
{
|
||||||
|
SetBodyTransform(GetBodyPosition(), angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetBodyPosition(Point const& pos)
|
||||||
|
{
|
||||||
|
SetBodyTransform(pos, GetBodyRotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float Body::GetMass() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->GetMass();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float Body::GetInertia() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->GetInertia();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Body::Type Body::GetType() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return Type(body_->GetType());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetType(Type type)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
body_->SetType(static_cast<b2BodyType>(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float Body::GetGravityScale() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->GetGravityScale();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetGravityScale(float scale)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
body_->SetGravityScale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Body::IsIgnoreRotation() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->IsFixedRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetIgnoreRotation(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
body_->SetFixedRotation(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Body::IsBullet() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->IsBullet();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetBullet(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
body_->SetBullet(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Body::IsAwake() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->IsAwake();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetAwake(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
body_->SetAwake(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Body::IsSleepingAllowed() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->IsSleepingAllowed();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetSleepingAllowed(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
body_->SetSleepingAllowed(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Body::IsActive() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
return body_->IsActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetActive(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(body_);
|
||||||
|
body_->SetActive(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Actor* Body::GetActor() const
|
||||||
|
{
|
||||||
|
return actor_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Body::SetActor(Actor* actor)
|
||||||
|
{
|
||||||
|
actor_ = actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline b2Body* Body::GetB2Body() const
|
||||||
|
{
|
||||||
|
return body_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline World* Body::GetWorld() const
|
||||||
|
{
|
||||||
|
return world_;
|
||||||
|
}
|
||||||
|
} // namespace physics
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano-physics/Contact.h>
|
|
||||||
#include <kiwano-physics/Body.h>
|
#include <kiwano-physics/Body.h>
|
||||||
|
#include <kiwano-physics/Contact.h>
|
||||||
#include <kiwano-physics/World.h>
|
#include <kiwano-physics/World.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -86,5 +86,5 @@ namespace kiwano
|
||||||
return world->World2Stage(contact_->GetTangentSpeed());
|
return world->World2Stage(contact_->GetTangentSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano-physics/helper.h>
|
|
||||||
#include <kiwano-physics/Fixture.h>
|
#include <kiwano-physics/Fixture.h>
|
||||||
|
#include <kiwano-physics/helper.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -115,15 +115,12 @@ namespace kiwano
|
||||||
b2Contact* contact_;
|
b2Contact* contact_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 物理接触列表
|
/// @brief 物理接触列表
|
||||||
class ContactList
|
class ContactList : public List<Contact>
|
||||||
: public List<Contact>
|
|
||||||
{
|
{
|
||||||
template <typename _Ty>
|
template <typename _Ty>
|
||||||
class IteratorImpl
|
class IteratorImpl : public std::iterator<std::forward_iterator_tag, _Ty>
|
||||||
: public std::iterator<std::forward_iterator_tag, _Ty>
|
|
||||||
{
|
{
|
||||||
using herit = std::iterator<std::forward_iterator_tag, _Ty>;
|
using herit = std::iterator<std::forward_iterator_tag, _Ty>;
|
||||||
|
|
||||||
|
|
@ -175,9 +172,7 @@ namespace kiwano
|
||||||
using iterator = IteratorImpl<value_type>;
|
using iterator = IteratorImpl<value_type>;
|
||||||
using const_iterator = IteratorImpl<const value_type>;
|
using const_iterator = IteratorImpl<const value_type>;
|
||||||
|
|
||||||
inline ContactList()
|
inline ContactList() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ContactList(const value_type& first)
|
inline ContactList(const value_type& first)
|
||||||
: first_(first)
|
: first_(first)
|
||||||
|
|
@ -230,21 +225,71 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
inline bool Contact::IsValid() const
|
||||||
inline bool Contact::IsValid() const { return contact_ != nullptr;}
|
{
|
||||||
inline bool Contact::IsTouching() const { KGE_ASSERT(contact_); return contact_->IsTouching(); }
|
return contact_ != nullptr;
|
||||||
inline void Contact::SetEnabled(bool flag) { KGE_ASSERT(contact_); contact_->SetEnabled(flag); }
|
|
||||||
inline bool Contact::IsEnabled() const { KGE_ASSERT(contact_); return contact_->IsEnabled(); }
|
|
||||||
inline void Contact::SetFriction(float friction) { KGE_ASSERT(contact_); contact_->SetFriction(friction); }
|
|
||||||
inline float Contact::GetFriction() const { KGE_ASSERT(contact_); return contact_->GetFriction(); }
|
|
||||||
inline void Contact::ResetFriction() { KGE_ASSERT(contact_); contact_->ResetFriction(); }
|
|
||||||
inline void Contact::SetRestitution(float restitution) { KGE_ASSERT(contact_); contact_->SetRestitution(restitution); }
|
|
||||||
inline float Contact::GetRestitution() const { KGE_ASSERT(contact_); return contact_->GetRestitution(); }
|
|
||||||
inline void Contact::ResetRestitution() { KGE_ASSERT(contact_); contact_->ResetRestitution(); }
|
|
||||||
inline b2Contact* Contact::GetB2Contact() const { return contact_; }
|
|
||||||
inline void Contact::SetB2Contact(b2Contact* contact) { contact_ = contact; }
|
|
||||||
inline bool Contact::operator==(const Contact& rhs) const { return contact_ == rhs.contact_; }
|
|
||||||
inline bool Contact::operator!=(const Contact& rhs) const { return contact_ != rhs.contact_; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
inline bool Contact::IsTouching() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
return contact_->IsTouching();
|
||||||
}
|
}
|
||||||
|
inline void Contact::SetEnabled(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
contact_->SetEnabled(flag);
|
||||||
|
}
|
||||||
|
inline bool Contact::IsEnabled() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
return contact_->IsEnabled();
|
||||||
|
}
|
||||||
|
inline void Contact::SetFriction(float friction)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
contact_->SetFriction(friction);
|
||||||
|
}
|
||||||
|
inline float Contact::GetFriction() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
return contact_->GetFriction();
|
||||||
|
}
|
||||||
|
inline void Contact::ResetFriction()
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
contact_->ResetFriction();
|
||||||
|
}
|
||||||
|
inline void Contact::SetRestitution(float restitution)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
contact_->SetRestitution(restitution);
|
||||||
|
}
|
||||||
|
inline float Contact::GetRestitution() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
return contact_->GetRestitution();
|
||||||
|
}
|
||||||
|
inline void Contact::ResetRestitution()
|
||||||
|
{
|
||||||
|
KGE_ASSERT(contact_);
|
||||||
|
contact_->ResetRestitution();
|
||||||
|
}
|
||||||
|
inline b2Contact* Contact::GetB2Contact() const
|
||||||
|
{
|
||||||
|
return contact_;
|
||||||
|
}
|
||||||
|
inline void Contact::SetB2Contact(b2Contact* contact)
|
||||||
|
{
|
||||||
|
contact_ = contact;
|
||||||
|
}
|
||||||
|
inline bool Contact::operator==(const Contact& rhs) const
|
||||||
|
{
|
||||||
|
return contact_ == rhs.contact_;
|
||||||
|
}
|
||||||
|
inline bool Contact::operator!=(const Contact& rhs) const
|
||||||
|
{
|
||||||
|
return contact_ != rhs.contact_;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace physics
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -36,5 +36,5 @@ namespace kiwano
|
||||||
SetB2ContactEdge(edge);
|
SetB2ContactEdge(edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -60,14 +60,12 @@ namespace kiwano
|
||||||
b2ContactEdge* edge_;
|
b2ContactEdge* edge_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 物理接触边列表
|
/// @brief 物理接触边列表
|
||||||
class ContactEdgeList
|
class ContactEdgeList
|
||||||
{
|
{
|
||||||
template <typename _Ty>
|
template <typename _Ty>
|
||||||
class IteratorImpl
|
class IteratorImpl : public std::iterator<std::forward_iterator_tag, _Ty>
|
||||||
: public std::iterator<std::forward_iterator_tag, _Ty>
|
|
||||||
{
|
{
|
||||||
using herit = std::iterator<std::forward_iterator_tag, _Ty>;
|
using herit = std::iterator<std::forward_iterator_tag, _Ty>;
|
||||||
|
|
||||||
|
|
@ -119,9 +117,7 @@ namespace kiwano
|
||||||
using iterator = IteratorImpl<value_type>;
|
using iterator = IteratorImpl<value_type>;
|
||||||
using const_iterator = IteratorImpl<const value_type>;
|
using const_iterator = IteratorImpl<const value_type>;
|
||||||
|
|
||||||
inline ContactEdgeList()
|
inline ContactEdgeList() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ContactEdgeList(const value_type& first)
|
inline ContactEdgeList(const value_type& first)
|
||||||
: first_(first)
|
: first_(first)
|
||||||
|
|
@ -174,13 +170,36 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline bool ContactEdge::IsValid() const { return edge_ != nullptr; }
|
inline bool ContactEdge::IsValid() const
|
||||||
inline Body* ContactEdge::GetOtherBody() const { KGE_ASSERT(edge_); return static_cast<Body*>(edge_->other->GetUserData()); }
|
{
|
||||||
inline Contact ContactEdge::GetContact() const { KGE_ASSERT(edge_); return Contact(edge_->contact); }
|
return edge_ != nullptr;
|
||||||
inline b2ContactEdge* ContactEdge::GetB2ContactEdge() const { return edge_; }
|
}
|
||||||
inline void ContactEdge::SetB2ContactEdge(b2ContactEdge* edge) { edge_ = edge; }
|
inline Body* ContactEdge::GetOtherBody() const
|
||||||
inline bool ContactEdge::operator==(const ContactEdge& rhs) const { return edge_ == rhs.edge_; }
|
{
|
||||||
inline bool ContactEdge::operator!=(const ContactEdge& rhs) const { return edge_ != rhs.edge_; }
|
KGE_ASSERT(edge_);
|
||||||
|
return static_cast<Body*>(edge_->other->GetUserData());
|
||||||
|
}
|
||||||
|
inline Contact ContactEdge::GetContact() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(edge_);
|
||||||
|
return Contact(edge_->contact);
|
||||||
|
}
|
||||||
|
inline b2ContactEdge* ContactEdge::GetB2ContactEdge() const
|
||||||
|
{
|
||||||
|
return edge_;
|
||||||
|
}
|
||||||
|
inline void ContactEdge::SetB2ContactEdge(b2ContactEdge* edge)
|
||||||
|
{
|
||||||
|
edge_ = edge;
|
||||||
|
}
|
||||||
|
inline bool ContactEdge::operator==(const ContactEdge& rhs) const
|
||||||
|
{
|
||||||
|
return edge_ == rhs.edge_;
|
||||||
|
}
|
||||||
|
inline bool ContactEdge::operator!=(const ContactEdge& rhs) const
|
||||||
|
{
|
||||||
|
return edge_ != rhs.edge_;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,5 @@ namespace kiwano
|
||||||
this->contact = contact;
|
this->contact = contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,16 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano-physics/Contact.h>
|
|
||||||
#include <kiwano-physics/Body.h>
|
#include <kiwano-physics/Body.h>
|
||||||
|
#include <kiwano-physics/Contact.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
namespace physics
|
namespace physics
|
||||||
{
|
{
|
||||||
|
KGE_DECLARE_SMART_PTR(ContactBeginEvent);
|
||||||
|
KGE_DECLARE_SMART_PTR(ContactEndEvent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup Events
|
* \addtogroup Events
|
||||||
* @{
|
* @{
|
||||||
|
|
@ -33,8 +36,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 物理接触开始事件
|
/// @brief 物理接触开始事件
|
||||||
class KGE_API ContactBeginEvent
|
class KGE_API ContactBeginEvent : public Event
|
||||||
: public Event
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Contact contact; ///< 产生的接触
|
Contact contact; ///< 产生的接触
|
||||||
|
|
@ -46,8 +48,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 物理接触结束事件
|
/// @brief 物理接触结束事件
|
||||||
class KGE_API ContactEndEvent
|
class KGE_API ContactEndEvent : public Event
|
||||||
: public Event
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Contact contact; ///< 产生的接触
|
Contact contact; ///< 产生的接触
|
||||||
|
|
@ -58,5 +59,5 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano-physics/Fixture.h>
|
|
||||||
#include <kiwano-physics/Body.h>
|
#include <kiwano-physics/Body.h>
|
||||||
|
#include <kiwano-physics/Fixture.h>
|
||||||
#include <kiwano-physics/World.h>
|
#include <kiwano-physics/World.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -83,9 +83,12 @@ namespace kiwano
|
||||||
b2MassData data;
|
b2MassData data;
|
||||||
fixture_->GetMassData(&data);
|
fixture_->GetMassData(&data);
|
||||||
|
|
||||||
if (mass) *mass = data.mass;
|
if (mass)
|
||||||
if (center) *center = world->World2Stage(data.center);
|
*mass = data.mass;
|
||||||
if (inertia) *inertia = data.I;
|
if (center)
|
||||||
|
*center = world->World2Stage(data.center);
|
||||||
|
if (inertia)
|
||||||
|
*inertia = data.I;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Fixture::TestPoint(const Point& p) const
|
bool Fixture::TestPoint(const Point& p) const
|
||||||
|
|
@ -101,5 +104,5 @@ namespace kiwano
|
||||||
return fixture_->TestPoint(world->Stage2World(p));
|
return fixture_->TestPoint(world->Stage2World(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano-physics/helper.h>
|
|
||||||
#include <kiwano-physics/Shape.h>
|
#include <kiwano-physics/Shape.h>
|
||||||
|
#include <kiwano-physics/helper.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -54,7 +54,8 @@ namespace kiwano
|
||||||
, friction(friction)
|
, friction(friction)
|
||||||
, restitution(restitution)
|
, restitution(restitution)
|
||||||
, is_sensor(is_sensor)
|
, is_sensor(is_sensor)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Fixture();
|
Fixture();
|
||||||
|
|
@ -126,12 +127,10 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief ÎïÀí¼Ð¾ßÁбí
|
/// @brief ÎïÀí¼Ð¾ßÁбí
|
||||||
class FixtureList
|
class FixtureList : public List<Fixture>
|
||||||
: public List<Fixture>
|
|
||||||
{
|
{
|
||||||
template <typename _Ty>
|
template <typename _Ty>
|
||||||
class IteratorImpl
|
class IteratorImpl : public std::iterator<std::forward_iterator_tag, _Ty>
|
||||||
: public std::iterator<std::forward_iterator_tag, _Ty>
|
|
||||||
{
|
{
|
||||||
using herit = std::iterator<std::forward_iterator_tag, _Ty>;
|
using herit = std::iterator<std::forward_iterator_tag, _Ty>;
|
||||||
|
|
||||||
|
|
@ -183,9 +182,7 @@ namespace kiwano
|
||||||
using iterator = IteratorImpl<value_type>;
|
using iterator = IteratorImpl<value_type>;
|
||||||
using const_iterator = IteratorImpl<const value_type>;
|
using const_iterator = IteratorImpl<const value_type>;
|
||||||
|
|
||||||
inline FixtureList()
|
inline FixtureList() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline FixtureList(const value_type& first)
|
inline FixtureList(const value_type& first)
|
||||||
: first_(first)
|
: first_(first)
|
||||||
|
|
@ -238,18 +235,65 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline bool Fixture::IsSensor() const { KGE_ASSERT(fixture_); return fixture_->IsSensor(); }
|
inline bool Fixture::IsSensor() const
|
||||||
inline void Fixture::SetSensor(bool sensor) { KGE_ASSERT(fixture_); fixture_->SetSensor(sensor); }
|
{
|
||||||
inline float Fixture::GetDensity() const { KGE_ASSERT(fixture_); return fixture_->GetDensity(); }
|
KGE_ASSERT(fixture_);
|
||||||
inline void Fixture::SetDensity(float density) { KGE_ASSERT(fixture_); fixture_->SetDensity(density); }
|
return fixture_->IsSensor();
|
||||||
inline float Fixture::GetFriction() const { KGE_ASSERT(fixture_); return fixture_->GetFriction(); }
|
|
||||||
inline void Fixture::SetFriction(float friction) { KGE_ASSERT(fixture_); fixture_->SetFriction(friction); }
|
|
||||||
inline float Fixture::GetRestitution() const { KGE_ASSERT(fixture_); return fixture_->GetRestitution(); }
|
|
||||||
inline void Fixture::SetRestitution(float restitution) { KGE_ASSERT(fixture_); fixture_->SetRestitution(restitution); }
|
|
||||||
inline bool Fixture::IsValid() const { return fixture_ != nullptr; }
|
|
||||||
inline b2Fixture* Fixture::GetB2Fixture() const { return fixture_; }
|
|
||||||
inline void Fixture::SetB2Fixture(b2Fixture* fixture) { fixture_ = fixture; }
|
|
||||||
inline bool Fixture::operator==(const Fixture& rhs) const { return fixture_ == rhs.fixture_; }
|
|
||||||
inline bool Fixture::operator!=(const Fixture& rhs) const { return fixture_ != rhs.fixture_; }
|
|
||||||
}
|
}
|
||||||
|
inline void Fixture::SetSensor(bool sensor)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(fixture_);
|
||||||
|
fixture_->SetSensor(sensor);
|
||||||
}
|
}
|
||||||
|
inline float Fixture::GetDensity() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(fixture_);
|
||||||
|
return fixture_->GetDensity();
|
||||||
|
}
|
||||||
|
inline void Fixture::SetDensity(float density)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(fixture_);
|
||||||
|
fixture_->SetDensity(density);
|
||||||
|
}
|
||||||
|
inline float Fixture::GetFriction() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(fixture_);
|
||||||
|
return fixture_->GetFriction();
|
||||||
|
}
|
||||||
|
inline void Fixture::SetFriction(float friction)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(fixture_);
|
||||||
|
fixture_->SetFriction(friction);
|
||||||
|
}
|
||||||
|
inline float Fixture::GetRestitution() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(fixture_);
|
||||||
|
return fixture_->GetRestitution();
|
||||||
|
}
|
||||||
|
inline void Fixture::SetRestitution(float restitution)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(fixture_);
|
||||||
|
fixture_->SetRestitution(restitution);
|
||||||
|
}
|
||||||
|
inline bool Fixture::IsValid() const
|
||||||
|
{
|
||||||
|
return fixture_ != nullptr;
|
||||||
|
}
|
||||||
|
inline b2Fixture* Fixture::GetB2Fixture() const
|
||||||
|
{
|
||||||
|
return fixture_;
|
||||||
|
}
|
||||||
|
inline void Fixture::SetB2Fixture(b2Fixture* fixture)
|
||||||
|
{
|
||||||
|
fixture_ = fixture;
|
||||||
|
}
|
||||||
|
inline bool Fixture::operator==(const Fixture& rhs) const
|
||||||
|
{
|
||||||
|
return fixture_ == rhs.fixture_;
|
||||||
|
}
|
||||||
|
inline bool Fixture::operator!=(const Fixture& rhs) const
|
||||||
|
{
|
||||||
|
return fixture_ != rhs.fixture_;
|
||||||
|
}
|
||||||
|
} // namespace physics
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -36,28 +36,17 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Joint::Joint(b2Joint* joint)
|
|
||||||
: Joint()
|
|
||||||
{
|
|
||||||
SetB2Joint(joint);
|
|
||||||
}
|
|
||||||
|
|
||||||
Joint::Joint(World* world, b2JointDef* joint_def)
|
|
||||||
: Joint()
|
|
||||||
{
|
|
||||||
Init(world, joint_def);
|
|
||||||
}
|
|
||||||
|
|
||||||
Joint::~Joint()
|
Joint::~Joint()
|
||||||
{
|
{
|
||||||
if (world_)
|
Destroy();
|
||||||
{
|
|
||||||
world_->RemoveJoint(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Joint::Init(World* world, b2JointDef* joint_def)
|
bool Joint::InitJoint(World* world, b2JointDef* joint_def)
|
||||||
{
|
{
|
||||||
|
KGE_ASSERT(world);
|
||||||
|
|
||||||
|
Destroy();
|
||||||
|
|
||||||
world_ = world;
|
world_ = world;
|
||||||
if (world_)
|
if (world_)
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +54,10 @@ namespace kiwano
|
||||||
|
|
||||||
b2Joint* joint = world_->GetB2World()->CreateJoint(joint_def);
|
b2Joint* joint = world_->GetB2World()->CreateJoint(joint_def);
|
||||||
SetB2Joint(joint);
|
SetB2Joint(joint);
|
||||||
|
|
||||||
|
return joint != nullptr;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BodyPtr Joint::GetBodyA() const
|
BodyPtr Joint::GetBodyA() const
|
||||||
|
|
@ -93,6 +85,14 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Joint::Destroy()
|
||||||
|
{
|
||||||
|
if (world_)
|
||||||
|
{
|
||||||
|
world_->RemoveJoint(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// DistanceJoint
|
// DistanceJoint
|
||||||
//
|
//
|
||||||
|
|
@ -103,25 +103,19 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DistanceJoint::DistanceJoint(World* world, b2DistanceJointDef* def)
|
bool DistanceJoint::InitJoint(World* world, DistanceJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DistanceJoint::DistanceJoint(World* world, DistanceJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
b2DistanceJointDef def;
|
b2DistanceJointDef def;
|
||||||
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.anchor_a), world->Stage2World(param.anchor_b));
|
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.anchor_a),
|
||||||
|
world->Stage2World(param.anchor_b));
|
||||||
def.frequencyHz = param.frequency_hz;
|
def.frequencyHz = param.frequency_hz;
|
||||||
def.dampingRatio = param.damping_ratio;
|
def.dampingRatio = param.damping_ratio;
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2DistanceJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2DistanceJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DistanceJoint::SetLength(float length)
|
void DistanceJoint::SetLength(float length)
|
||||||
|
|
@ -146,15 +140,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FrictionJoint::FrictionJoint(World* world, b2FrictionJointDef* def)
|
bool FrictionJoint::InitJoint(World* world, FrictionJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FrictionJoint::FrictionJoint(World* world, FrictionJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
|
|
@ -163,8 +149,9 @@ namespace kiwano
|
||||||
def.maxForce = param.max_force;
|
def.maxForce = param.max_force;
|
||||||
def.maxTorque = world->Stage2World(param.max_torque);
|
def.maxTorque = world->Stage2World(param.max_torque);
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2FrictionJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2FrictionJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrictionJoint::SetMaxForce(float length)
|
void FrictionJoint::SetMaxForce(float length)
|
||||||
|
|
@ -201,15 +188,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GearJoint::GearJoint(World* world, b2GearJointDef* def)
|
bool GearJoint::InitJoint(World* world, GearJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GearJoint::GearJoint(World* world, GearJoint::Param param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.joint_a && param.joint_b);
|
KGE_ASSERT(param.joint_a && param.joint_b);
|
||||||
|
|
||||||
|
|
@ -218,8 +197,9 @@ namespace kiwano
|
||||||
def.joint2 = param.joint_b->GetB2Joint();
|
def.joint2 = param.joint_b->GetB2Joint();
|
||||||
def.ratio = param.ratio;
|
def.ratio = param.ratio;
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2GearJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2GearJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GearJoint::SetRatio(float ratio)
|
void GearJoint::SetRatio(float ratio)
|
||||||
|
|
@ -244,15 +224,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MotorJoint::MotorJoint(World* world, b2MotorJointDef* def)
|
bool MotorJoint::InitJoint(World* world, MotorJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MotorJoint::MotorJoint(World* world, MotorJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
|
|
@ -262,8 +234,9 @@ namespace kiwano
|
||||||
def.maxTorque = world->Stage2World(param.max_torque);
|
def.maxTorque = world->Stage2World(param.max_torque);
|
||||||
def.correctionFactor = param.correction_factor;
|
def.correctionFactor = param.correction_factor;
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2MotorJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2MotorJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotorJoint::SetMaxForce(float length)
|
void MotorJoint::SetMaxForce(float length)
|
||||||
|
|
@ -300,20 +273,13 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PrismaticJoint::PrismaticJoint(World* world, b2PrismaticJointDef* def)
|
bool PrismaticJoint::InitJoint(World* world, PrismaticJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PrismaticJoint::PrismaticJoint(World* world, PrismaticJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
b2PrismaticJointDef def;
|
b2PrismaticJointDef def;
|
||||||
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.anchor), Stage2World(param.axis));
|
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.anchor),
|
||||||
|
Stage2World(param.axis));
|
||||||
def.enableLimit = param.enable_limit;
|
def.enableLimit = param.enable_limit;
|
||||||
def.lowerTranslation = world->Stage2World(param.lower_translation);
|
def.lowerTranslation = world->Stage2World(param.lower_translation);
|
||||||
def.upperTranslation = world->Stage2World(param.upper_translation);
|
def.upperTranslation = world->Stage2World(param.upper_translation);
|
||||||
|
|
@ -321,8 +287,9 @@ namespace kiwano
|
||||||
def.maxMotorForce = param.max_motor_force;
|
def.maxMotorForce = param.max_motor_force;
|
||||||
def.motorSpeed = world->Stage2World(param.motor_speed);
|
def.motorSpeed = world->Stage2World(param.motor_speed);
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2PrismaticJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2PrismaticJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PrismaticJoint::GetJointTranslation() const
|
float PrismaticJoint::GetJointTranslation() const
|
||||||
|
|
@ -365,24 +332,18 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PulleyJoint::PulleyJoint(World* world, b2PulleyJointDef* def)
|
bool PulleyJoint::InitJoint(World* world, PulleyJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PulleyJoint::PulleyJoint(World* world, PulleyJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
b2PulleyJointDef def;
|
b2PulleyJointDef def;
|
||||||
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.ground_anchor_a), world->Stage2World(param.ground_anchor_b),
|
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.ground_anchor_a),
|
||||||
world->Stage2World(param.anchor_a), world->Stage2World(param.anchor_b), param.ratio);
|
world->Stage2World(param.ground_anchor_b), world->Stage2World(param.anchor_a),
|
||||||
|
world->Stage2World(param.anchor_b), param.ratio);
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2PulleyJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2PulleyJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point PulleyJoint::GetGroundAnchorA() const
|
Point PulleyJoint::GetGroundAnchorA() const
|
||||||
|
|
@ -437,15 +398,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RevoluteJoint::RevoluteJoint(World* world, b2RevoluteJointDef* def)
|
bool RevoluteJoint::InitJoint(World* world, RevoluteJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RevoluteJoint::RevoluteJoint(World* world, RevoluteJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
|
|
@ -458,8 +411,9 @@ namespace kiwano
|
||||||
def.maxMotorTorque = world->Stage2World(param.max_motor_torque);
|
def.maxMotorTorque = world->Stage2World(param.max_motor_torque);
|
||||||
def.motorSpeed = math::Degree2Radian(param.motor_speed);
|
def.motorSpeed = math::Degree2Radian(param.motor_speed);
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2RevoluteJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2RevoluteJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
float RevoluteJoint::GetJointAngle() const
|
float RevoluteJoint::GetJointAngle() const
|
||||||
|
|
@ -514,15 +468,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RopeJoint::RopeJoint(World* world, b2RopeJointDef* def)
|
bool RopeJoint::InitJoint(World* world, RopeJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RopeJoint::RopeJoint(World* world, RopeJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
|
|
@ -533,8 +479,9 @@ namespace kiwano
|
||||||
def.localAnchorB = world->Stage2World(param.local_anchor_b);
|
def.localAnchorB = world->Stage2World(param.local_anchor_b);
|
||||||
def.maxLength = world->Stage2World(param.max_length);
|
def.maxLength = world->Stage2World(param.max_length);
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2RopeJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2RopeJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RopeJoint::SetMaxLength(float length)
|
void RopeJoint::SetMaxLength(float length)
|
||||||
|
|
@ -559,15 +506,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WeldJoint::WeldJoint(World* world, b2WeldJointDef* def)
|
bool WeldJoint::InitJoint(World* world, WeldJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
WeldJoint::WeldJoint(World* world, WeldJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
|
|
@ -576,11 +515,11 @@ namespace kiwano
|
||||||
def.frequencyHz = param.frequency_hz;
|
def.frequencyHz = param.frequency_hz;
|
||||||
def.dampingRatio = param.damping_ratio;
|
def.dampingRatio = param.damping_ratio;
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2WeldJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2WeldJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// WheelJoint
|
// WheelJoint
|
||||||
//
|
//
|
||||||
|
|
@ -591,28 +530,22 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WheelJoint::WheelJoint(World* world, b2WheelJointDef* def)
|
bool WheelJoint::InitJoint(World* world, WheelJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
WheelJoint::WheelJoint(World* world, WheelJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
b2WheelJointDef def;
|
b2WheelJointDef def;
|
||||||
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.anchor), Stage2World(param.axis));
|
def.Initialize(param.body_a->GetB2Body(), param.body_b->GetB2Body(), world->Stage2World(param.anchor),
|
||||||
|
Stage2World(param.axis));
|
||||||
def.enableMotor = param.enable_motor;
|
def.enableMotor = param.enable_motor;
|
||||||
def.maxMotorTorque = world->Stage2World(param.max_motor_torque);
|
def.maxMotorTorque = world->Stage2World(param.max_motor_torque);
|
||||||
def.motorSpeed = world->Stage2World(param.motor_speed);
|
def.motorSpeed = world->Stage2World(param.motor_speed);
|
||||||
def.frequencyHz = param.frequency_hz;
|
def.frequencyHz = param.frequency_hz;
|
||||||
def.dampingRatio = param.damping_ratio;
|
def.dampingRatio = param.damping_ratio;
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2WheelJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2WheelJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
float WheelJoint::GetJointTranslation() const
|
float WheelJoint::GetJointTranslation() const
|
||||||
|
|
@ -649,15 +582,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseJoint::MouseJoint(World* world, b2MouseJointDef* def)
|
bool MouseJoint::InitJoint(World* world, MouseJoint::Param const& param)
|
||||||
: Joint(world, def)
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseJoint::MouseJoint(World* world, MouseJoint::Param const& param)
|
|
||||||
: Joint()
|
|
||||||
, raw_joint_(nullptr)
|
|
||||||
{
|
{
|
||||||
KGE_ASSERT(param.body_a && param.body_b);
|
KGE_ASSERT(param.body_a && param.body_b);
|
||||||
|
|
||||||
|
|
@ -669,8 +594,9 @@ namespace kiwano
|
||||||
def.frequencyHz = param.frequency_hz;
|
def.frequencyHz = param.frequency_hz;
|
||||||
def.dampingRatio = param.damping_ratio;
|
def.dampingRatio = param.damping_ratio;
|
||||||
|
|
||||||
Init(world, &def);
|
Joint::InitJoint(world, &def);
|
||||||
raw_joint_ = static_cast<b2MouseJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2MouseJoint*>(GetB2Joint());
|
||||||
|
return raw_joint_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseJoint::SetMaxForce(float length)
|
void MouseJoint::SetMaxForce(float length)
|
||||||
|
|
@ -685,5 +611,5 @@ namespace kiwano
|
||||||
return raw_joint_->GetMaxForce();
|
return raw_joint_->GetMaxForce();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano-physics/helper.h>
|
|
||||||
#include <kiwano-physics/Body.h>
|
#include <kiwano-physics/Body.h>
|
||||||
|
#include <kiwano-physics/helper.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -46,8 +46,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 关节
|
/// @brief 关节
|
||||||
class KGE_API Joint
|
class KGE_API Joint : public virtual ObjectBase
|
||||||
: public virtual RefCounter
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -76,24 +75,25 @@ namespace kiwano
|
||||||
Body* body_b; ///< 关节连接的物体B
|
Body* body_b; ///< 关节连接的物体B
|
||||||
|
|
||||||
ParamBase(Body* body_a, Body* body_b)
|
ParamBase(Body* body_a, Body* body_b)
|
||||||
: body_a(body_a), body_b(body_b)
|
: body_a(body_a)
|
||||||
|
, body_b(body_b)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ParamBase(BodyPtr body_a, BodyPtr body_b)
|
ParamBase(BodyPtr body_a, BodyPtr body_b)
|
||||||
: body_a(body_a.get()), body_b(body_b.get())
|
: body_a(body_a.get())
|
||||||
|
, body_b(body_b.get())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Joint();
|
Joint();
|
||||||
Joint(b2Joint* joint);
|
|
||||||
Joint(World* world, b2JointDef* joint_def);
|
|
||||||
virtual ~Joint();
|
virtual ~Joint();
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 初始化关节
|
/// @brief 初始化关节
|
||||||
void Init(World* world, b2JointDef* joint_def);
|
bool InitJoint(World* world, b2JointDef* joint_def);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取关节连接的物体A
|
/// @brief 获取关节连接的物体A
|
||||||
|
|
@ -107,6 +107,10 @@ namespace kiwano
|
||||||
/// @brief 获取物理世界
|
/// @brief 获取物理世界
|
||||||
World* GetWorld() const;
|
World* GetWorld() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 销毁关节
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
b2Joint* GetB2Joint() const;
|
b2Joint* GetB2Joint() const;
|
||||||
void SetB2Joint(b2Joint* joint);
|
void SetB2Joint(b2Joint* joint);
|
||||||
|
|
||||||
|
|
@ -116,11 +120,9 @@ namespace kiwano
|
||||||
Type type_;
|
Type type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 固定距离关节
|
/// @brief 固定距离关节
|
||||||
class KGE_API DistanceJoint
|
class KGE_API DistanceJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -132,36 +134,28 @@ namespace kiwano
|
||||||
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& anchor_a, Point const& anchor_b, float frequency_hz = 0.f,
|
||||||
Body* body_a,
|
float damping_ratio = 0.f)
|
||||||
Body* body_b,
|
|
||||||
Point const& anchor_a,
|
|
||||||
Point const& anchor_b,
|
|
||||||
float frequency_hz = 0.f,
|
|
||||||
float damping_ratio = 0.f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, anchor_a(anchor_a)
|
, anchor_a(anchor_a)
|
||||||
, anchor_b(anchor_b)
|
, anchor_b(anchor_b)
|
||||||
, frequency_hz(frequency_hz)
|
, frequency_hz(frequency_hz)
|
||||||
, damping_ratio(damping_ratio)
|
, damping_ratio(damping_ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& anchor_a, Point const& anchor_b, float frequency_hz = 0.f,
|
||||||
BodyPtr body_a,
|
float damping_ratio = 0.f)
|
||||||
BodyPtr body_b,
|
|
||||||
Point const& anchor_a,
|
|
||||||
Point const& anchor_b,
|
|
||||||
float frequency_hz = 0.f,
|
|
||||||
float damping_ratio = 0.f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), anchor_a, anchor_b, frequency_hz, damping_ratio)
|
: Param(body_a.get(), body_b.get(), anchor_a, anchor_b, frequency_hz, damping_ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DistanceJoint();
|
DistanceJoint();
|
||||||
DistanceJoint(World* world, b2DistanceJointDef* def);
|
|
||||||
DistanceJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置关节长度
|
/// @brief 设置关节长度
|
||||||
|
|
@ -191,11 +185,9 @@ namespace kiwano
|
||||||
b2DistanceJoint* raw_joint_;
|
b2DistanceJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 摩擦关节
|
/// @brief 摩擦关节
|
||||||
class KGE_API FrictionJoint
|
class KGE_API FrictionJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
|
|
@ -204,33 +196,25 @@ namespace kiwano
|
||||||
float max_force; ///< 最大摩擦力
|
float max_force; ///< 最大摩擦力
|
||||||
float max_torque; ///< 最大扭力
|
float max_torque; ///< 最大扭力
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& anchor, float max_force = 0.f, float max_torque = 0.f)
|
||||||
Body* body_a,
|
|
||||||
Body* body_b,
|
|
||||||
Point const& anchor,
|
|
||||||
float max_force = 0.f,
|
|
||||||
float max_torque = 0.f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, anchor(anchor)
|
, anchor(anchor)
|
||||||
, max_force(max_force)
|
, max_force(max_force)
|
||||||
, max_torque(max_torque)
|
, max_torque(max_torque)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& anchor, float max_force = 0.f, float max_torque = 0.f)
|
||||||
BodyPtr body_a,
|
|
||||||
BodyPtr body_b,
|
|
||||||
Point const& anchor,
|
|
||||||
float max_force = 0.f,
|
|
||||||
float max_torque = 0.f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), anchor, max_force, max_torque)
|
: Param(body_a.get(), body_b.get(), anchor, max_force, max_torque)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FrictionJoint();
|
FrictionJoint();
|
||||||
FrictionJoint(World* world, b2FrictionJointDef* def);
|
|
||||||
FrictionJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置最大摩擦力
|
/// @brief 设置最大摩擦力
|
||||||
|
|
@ -252,44 +236,38 @@ namespace kiwano
|
||||||
b2FrictionJoint* raw_joint_;
|
b2FrictionJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 齿轮关节
|
/// @brief 齿轮关节
|
||||||
class KGE_API GearJoint
|
class KGE_API GearJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 齿轮关节参数
|
/// @brief 齿轮关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
JointPtr joint_a; ///< 关节A(旋转关节/平移关节)
|
Joint* joint_a; ///< 关节A(旋转关节/平移关节)
|
||||||
JointPtr joint_b; ///< 关节B(旋转关节/平移关节)
|
Joint* joint_b; ///< 关节B(旋转关节/平移关节)
|
||||||
float ratio; ///< 齿轮传动比
|
float ratio; ///< 齿轮传动比
|
||||||
|
|
||||||
Param(
|
Param(Joint* joint_a, Joint* joint_b, float ratio = 1.f)
|
||||||
Joint* joint_a,
|
|
||||||
Joint* joint_b,
|
|
||||||
float ratio = 1.f
|
|
||||||
)
|
|
||||||
: ParamBase(nullptr, nullptr)
|
: ParamBase(nullptr, nullptr)
|
||||||
, joint_a(joint_a)
|
, joint_a(joint_a)
|
||||||
, joint_b(joint_b)
|
, joint_b(joint_b)
|
||||||
, ratio(ratio)
|
, ratio(ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(JointPtr joint_a, JointPtr joint_b, float ratio = 1.f)
|
||||||
JointPtr joint_a,
|
|
||||||
JointPtr joint_b,
|
|
||||||
float ratio = 1.f
|
|
||||||
)
|
|
||||||
: Param(joint_a.get(), joint_b.get(), ratio)
|
: Param(joint_a.get(), joint_b.get(), ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GearJoint();
|
GearJoint();
|
||||||
GearJoint(World* world, b2GearJointDef* def);
|
|
||||||
GearJoint(World* world, Param param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定齿轮传动比
|
/// @brief 设定齿轮传动比
|
||||||
|
|
@ -303,11 +281,9 @@ namespace kiwano
|
||||||
b2GearJoint* raw_joint_;
|
b2GearJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 马达关节
|
/// @brief 马达关节
|
||||||
class KGE_API MotorJoint
|
class KGE_API MotorJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -318,33 +294,27 @@ namespace kiwano
|
||||||
float max_torque; ///< 最大转矩
|
float max_torque; ///< 最大转矩
|
||||||
float correction_factor; ///< 位置矫正因子(范围 0-1)
|
float correction_factor; ///< 位置矫正因子(范围 0-1)
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, float max_force = 1.f, float max_torque = 100.f,
|
||||||
Body* body_a,
|
float correction_factor = 0.3f)
|
||||||
Body* body_b,
|
|
||||||
float max_force = 1.f,
|
|
||||||
float max_torque = 100.f,
|
|
||||||
float correction_factor = 0.3f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, max_force(max_force)
|
, max_force(max_force)
|
||||||
, max_torque(max_torque)
|
, max_torque(max_torque)
|
||||||
, correction_factor(correction_factor)
|
, correction_factor(correction_factor)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, float max_force = 0.f, float max_torque = 0.f,
|
||||||
BodyPtr body_a,
|
float correction_factor = 0.3f)
|
||||||
BodyPtr body_b,
|
|
||||||
float max_force = 0.f,
|
|
||||||
float max_torque = 0.f,
|
|
||||||
float correction_factor = 0.3f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), max_force, max_torque, correction_factor)
|
: Param(body_a.get(), body_b.get(), max_force, max_torque, correction_factor)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MotorJoint();
|
MotorJoint();
|
||||||
MotorJoint(World* world, b2MotorJointDef* def);
|
|
||||||
MotorJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置最大摩擦力
|
/// @brief 设置最大摩擦力
|
||||||
|
|
@ -366,11 +336,9 @@ namespace kiwano
|
||||||
b2MotorJoint* raw_joint_;
|
b2MotorJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 平移关节
|
/// @brief 平移关节
|
||||||
class KGE_API PrismaticJoint
|
class KGE_API PrismaticJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -386,18 +354,9 @@ namespace kiwano
|
||||||
float max_motor_force; ///< 最大马达力 [N]
|
float max_motor_force; ///< 最大马达力 [N]
|
||||||
float motor_speed; ///< 马达转速 [degree/s]
|
float motor_speed; ///< 马达转速 [degree/s]
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& anchor, Vec2 const& axis, bool enable_limit = false,
|
||||||
Body* body_a,
|
float lower_translation = 0.0f, float upper_translation = 0.0f, bool enable_motor = false,
|
||||||
Body* body_b,
|
float max_motor_force = 0.0f, float motor_speed = 0.0f)
|
||||||
Point const& anchor,
|
|
||||||
Vec2 const& axis,
|
|
||||||
bool enable_limit = false,
|
|
||||||
float lower_translation = 0.0f,
|
|
||||||
float upper_translation = 0.0f,
|
|
||||||
bool enable_motor = false,
|
|
||||||
float max_motor_force = 0.0f,
|
|
||||||
float motor_speed = 0.0f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, anchor(anchor)
|
, anchor(anchor)
|
||||||
, axis(axis)
|
, axis(axis)
|
||||||
|
|
@ -407,27 +366,23 @@ namespace kiwano
|
||||||
, enable_motor(enable_motor)
|
, enable_motor(enable_motor)
|
||||||
, max_motor_force(max_motor_force)
|
, max_motor_force(max_motor_force)
|
||||||
, motor_speed(motor_speed)
|
, motor_speed(motor_speed)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& anchor, Vec2 const& axis, bool enable_limit = false,
|
||||||
BodyPtr body_a,
|
float lower_translation = 0.0f, float upper_translation = 0.0f, bool enable_motor = false,
|
||||||
BodyPtr body_b,
|
float max_motor_force = 0.0f, float motor_speed = 0.0f)
|
||||||
Point const& anchor,
|
: Param(body_a.get(), body_b.get(), anchor, axis, enable_limit, lower_translation, upper_translation,
|
||||||
Vec2 const& axis,
|
enable_motor, max_motor_force, motor_speed)
|
||||||
bool enable_limit = false,
|
{
|
||||||
float lower_translation = 0.0f,
|
}
|
||||||
float upper_translation = 0.0f,
|
|
||||||
bool enable_motor = false,
|
|
||||||
float max_motor_force = 0.0f,
|
|
||||||
float motor_speed = 0.0f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), anchor, axis, enable_limit, lower_translation, upper_translation, enable_motor, max_motor_force, motor_speed)
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PrismaticJoint();
|
PrismaticJoint();
|
||||||
PrismaticJoint(World* world, b2PrismaticJointDef* def);
|
|
||||||
PrismaticJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取参考角
|
/// @brief 获取参考角
|
||||||
|
|
@ -489,11 +444,9 @@ namespace kiwano
|
||||||
b2PrismaticJoint* raw_joint_;
|
b2PrismaticJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 滑轮关节
|
/// @brief 滑轮关节
|
||||||
class KGE_API PulleyJoint
|
class KGE_API PulleyJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -506,39 +459,29 @@ namespace kiwano
|
||||||
Point ground_anchor_b; ///< 物体B对应的滑轮的位置
|
Point ground_anchor_b; ///< 物体B对应的滑轮的位置
|
||||||
float ratio; ///< 滑轮比,关节传动时,滑轮上升和下降的两头的位移比例
|
float ratio; ///< 滑轮比,关节传动时,滑轮上升和下降的两头的位移比例
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& anchor_a, Point const& anchor_b, Point const& ground_anchor_a,
|
||||||
Body* body_a,
|
Point const& ground_anchor_b, float ratio = 1.0f)
|
||||||
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
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, anchor_a(anchor_a)
|
, anchor_a(anchor_a)
|
||||||
, anchor_b(anchor_b)
|
, anchor_b(anchor_b)
|
||||||
, ground_anchor_a(ground_anchor_a)
|
, ground_anchor_a(ground_anchor_a)
|
||||||
, ground_anchor_b(ground_anchor_b)
|
, ground_anchor_b(ground_anchor_b)
|
||||||
, ratio(ratio)
|
, ratio(ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& anchor_a, Point const& anchor_b,
|
||||||
BodyPtr body_a,
|
Point const& ground_anchor_a, Point const& ground_anchor_b, float ratio = 1.0f)
|
||||||
BodyPtr body_b,
|
|
||||||
Point const& anchor_a,
|
|
||||||
Point const& anchor_b,
|
|
||||||
Point const& ground_anchor_a,
|
|
||||||
Point const& ground_anchor_b,
|
|
||||||
float ratio = 1.0f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), anchor_a, anchor_b, ground_anchor_a, ground_anchor_b, ratio)
|
: Param(body_a.get(), body_b.get(), anchor_a, anchor_b, ground_anchor_a, ground_anchor_b, ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PulleyJoint();
|
PulleyJoint();
|
||||||
PulleyJoint(World* world, b2PulleyJointDef* def);
|
|
||||||
PulleyJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 物体A对应的滑轮的位置
|
/// @brief 物体A对应的滑轮的位置
|
||||||
|
|
@ -572,11 +515,9 @@ namespace kiwano
|
||||||
b2PulleyJoint* raw_joint_;
|
b2PulleyJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 旋转关节
|
/// @brief 旋转关节
|
||||||
class KGE_API RevoluteJoint
|
class KGE_API RevoluteJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -591,17 +532,9 @@ namespace kiwano
|
||||||
float max_motor_torque; ///< 最大马达力 [N]
|
float max_motor_torque; ///< 最大马达力 [N]
|
||||||
float motor_speed; ///< 马达转速 [degree/s]
|
float motor_speed; ///< 马达转速 [degree/s]
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& anchor, bool enable_limit = false, float lower_angle = 0.0f,
|
||||||
Body* body_a,
|
float upper_angle = 0.0f, bool enable_motor = false, float max_motor_torque = 0.0f,
|
||||||
Body* body_b,
|
float motor_speed = 0.0f)
|
||||||
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,
|
|
||||||
float motor_speed = 0.0f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, anchor(anchor)
|
, anchor(anchor)
|
||||||
, enable_limit(enable_limit)
|
, enable_limit(enable_limit)
|
||||||
|
|
@ -610,26 +543,23 @@ namespace kiwano
|
||||||
, enable_motor(enable_motor)
|
, enable_motor(enable_motor)
|
||||||
, max_motor_torque(max_motor_torque)
|
, max_motor_torque(max_motor_torque)
|
||||||
, motor_speed(motor_speed)
|
, motor_speed(motor_speed)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& anchor, bool enable_limit = false, float lower_angle = 0.0f,
|
||||||
BodyPtr body_a,
|
float upper_angle = 0.0f, bool enable_motor = false, float max_motor_torque = 0.0f,
|
||||||
BodyPtr body_b,
|
float motor_speed = 0.0f)
|
||||||
Point const& anchor,
|
: Param(body_a.get(), body_b.get(), anchor, enable_limit, lower_angle, upper_angle, enable_motor,
|
||||||
bool enable_limit = false,
|
max_motor_torque, motor_speed)
|
||||||
float lower_angle = 0.0f,
|
{
|
||||||
float upper_angle = 0.0f,
|
}
|
||||||
bool enable_motor = false,
|
|
||||||
float max_motor_torque = 0.0f,
|
|
||||||
float motor_speed = 0.0f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), anchor, enable_limit, lower_angle, upper_angle, enable_motor, max_motor_torque, motor_speed)
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RevoluteJoint();
|
RevoluteJoint();
|
||||||
RevoluteJoint(World* world, b2RevoluteJointDef* def);
|
|
||||||
RevoluteJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取参考角
|
/// @brief 获取参考角
|
||||||
|
|
@ -691,11 +621,9 @@ namespace kiwano
|
||||||
b2RevoluteJoint* raw_joint_;
|
b2RevoluteJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 绳关节
|
/// @brief 绳关节
|
||||||
class KGE_API RopeJoint
|
class KGE_API RopeJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -706,33 +634,27 @@ namespace kiwano
|
||||||
Point local_anchor_b; ///< 关节在物体B上的连接点
|
Point local_anchor_b; ///< 关节在物体B上的连接点
|
||||||
float max_length; ///< 绳索最大长度
|
float max_length; ///< 绳索最大长度
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& local_anchor_a, Point const& local_anchor_b,
|
||||||
Body* body_a,
|
float max_length = 0.f)
|
||||||
Body* body_b,
|
|
||||||
Point const& local_anchor_a,
|
|
||||||
Point const& local_anchor_b,
|
|
||||||
float max_length = 0.f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, local_anchor_a(local_anchor_a)
|
, local_anchor_a(local_anchor_a)
|
||||||
, local_anchor_b(local_anchor_b)
|
, local_anchor_b(local_anchor_b)
|
||||||
, max_length(max_length)
|
, max_length(max_length)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& local_anchor_a, Point const& local_anchor_b,
|
||||||
BodyPtr body_a,
|
float max_length = 0.f)
|
||||||
BodyPtr body_b,
|
|
||||||
Point const& local_anchor_a,
|
|
||||||
Point const& local_anchor_b,
|
|
||||||
float max_length = 0.f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), local_anchor_a, local_anchor_b, max_length)
|
: Param(body_a.get(), body_b.get(), local_anchor_a, local_anchor_b, max_length)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RopeJoint();
|
RopeJoint();
|
||||||
RopeJoint(World* world, b2RopeJointDef* def);
|
|
||||||
RopeJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置关节最大长度
|
/// @brief 设置关节最大长度
|
||||||
|
|
@ -746,11 +668,9 @@ namespace kiwano
|
||||||
b2RopeJoint* raw_joint_;
|
b2RopeJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 焊接关节
|
/// @brief 焊接关节
|
||||||
class KGE_API WeldJoint
|
class KGE_API WeldJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -761,33 +681,25 @@ namespace kiwano
|
||||||
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& anchor, float frequency_hz = 0.f, float damping_ratio = 0.f)
|
||||||
Body* body_a,
|
|
||||||
Body* body_b,
|
|
||||||
Point const& anchor,
|
|
||||||
float frequency_hz = 0.f,
|
|
||||||
float damping_ratio = 0.f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, anchor(anchor)
|
, anchor(anchor)
|
||||||
, frequency_hz(frequency_hz)
|
, frequency_hz(frequency_hz)
|
||||||
, damping_ratio(damping_ratio)
|
, damping_ratio(damping_ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& anchor, float frequency_hz = 0.f, float damping_ratio = 0.f)
|
||||||
BodyPtr body_a,
|
|
||||||
BodyPtr body_b,
|
|
||||||
Point const& anchor,
|
|
||||||
float frequency_hz = 0.f,
|
|
||||||
float damping_ratio = 0.f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), anchor, frequency_hz, damping_ratio)
|
: Param(body_a.get(), body_b.get(), anchor, frequency_hz, damping_ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WeldJoint();
|
WeldJoint();
|
||||||
WeldJoint(World* world, b2WeldJointDef* def);
|
|
||||||
WeldJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取物体B相对于物体A的角度
|
/// @brief 获取物体B相对于物体A的角度
|
||||||
|
|
@ -813,11 +725,9 @@ namespace kiwano
|
||||||
b2WeldJoint* raw_joint_;
|
b2WeldJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 轮关节
|
/// @brief 轮关节
|
||||||
class KGE_API WheelJoint
|
class KGE_API WheelJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -832,17 +742,9 @@ namespace kiwano
|
||||||
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio; ///< 弹簧阻尼率,值越大关节运动阻尼越大
|
float damping_ratio; ///< 弹簧阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& anchor, Vec2 const& axis, float frequency_hz = 2.0f,
|
||||||
Body* body_a,
|
float damping_ratio = 0.7f, bool enable_motor = false, float max_motor_torque = 0.0f,
|
||||||
Body* body_b,
|
float motor_speed = 0.0f)
|
||||||
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,
|
|
||||||
float motor_speed = 0.0f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, anchor(anchor)
|
, anchor(anchor)
|
||||||
, axis(axis)
|
, axis(axis)
|
||||||
|
|
@ -851,26 +753,23 @@ namespace kiwano
|
||||||
, motor_speed(motor_speed)
|
, motor_speed(motor_speed)
|
||||||
, frequency_hz(frequency_hz)
|
, frequency_hz(frequency_hz)
|
||||||
, damping_ratio(damping_ratio)
|
, damping_ratio(damping_ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& anchor, Vec2 const& axis, float frequency_hz = 2.0f,
|
||||||
BodyPtr body_a,
|
float damping_ratio = 0.7f, bool enable_motor = false, float max_motor_torque = 0.0f,
|
||||||
BodyPtr body_b,
|
float motor_speed = 0.0f)
|
||||||
Point const& anchor,
|
: Param(body_a.get(), body_b.get(), anchor, axis, frequency_hz, damping_ratio, enable_motor,
|
||||||
Vec2 const& axis,
|
max_motor_torque, motor_speed)
|
||||||
float frequency_hz = 2.0f,
|
{
|
||||||
float damping_ratio = 0.7f,
|
}
|
||||||
bool enable_motor = false,
|
|
||||||
float max_motor_torque = 0.0f,
|
|
||||||
float motor_speed = 0.0f
|
|
||||||
)
|
|
||||||
: Param(body_a.get(), body_b.get(), anchor, axis, frequency_hz, damping_ratio, enable_motor, max_motor_torque, motor_speed)
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WheelJoint();
|
WheelJoint();
|
||||||
WheelJoint(World* world, b2WheelJointDef* def);
|
|
||||||
WheelJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取关节当前的平移距离
|
/// @brief 获取关节当前的平移距离
|
||||||
|
|
@ -932,12 +831,10 @@ namespace kiwano
|
||||||
b2WheelJoint* raw_joint_;
|
b2WheelJoint* raw_joint_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 鼠标关节
|
/// @brief 鼠标关节
|
||||||
/// @details 用于使身体的某个点追踪世界上的指定点,例如让物体追踪鼠标位置
|
/// @details 用于使身体的某个点追踪世界上的指定点,例如让物体追踪鼠标位置
|
||||||
class KGE_API MouseJoint
|
class KGE_API MouseJoint : public Joint
|
||||||
: public Joint
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -949,29 +846,28 @@ namespace kiwano
|
||||||
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(Body* body_a, Body* body_b, Point const& target, float max_force, float frequency_hz = 5.0f,
|
||||||
Body* body_a,
|
float damping_ratio = 0.7f)
|
||||||
Body* body_b,
|
|
||||||
Point const& target,
|
|
||||||
float max_force,
|
|
||||||
float frequency_hz = 5.0f,
|
|
||||||
float damping_ratio = 0.7f
|
|
||||||
)
|
|
||||||
: ParamBase(body_a, body_b)
|
: ParamBase(body_a, body_b)
|
||||||
, target(target)
|
, target(target)
|
||||||
, max_force(max_force)
|
, max_force(max_force)
|
||||||
, frequency_hz(frequency_hz)
|
, frequency_hz(frequency_hz)
|
||||||
, damping_ratio(damping_ratio)
|
, damping_ratio(damping_ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Param(BodyPtr body_a, BodyPtr body_b, Point const& target, float max_force, float frequency_hz = 5.0f, float damping_ratio = 0.7f)
|
Param(BodyPtr body_a, BodyPtr body_b, Point const& target, float max_force, float frequency_hz = 5.0f,
|
||||||
|
float damping_ratio = 0.7f)
|
||||||
: Param(body_a.get(), body_b.get(), target, max_force, frequency_hz, damping_ratio)
|
: Param(body_a.get(), body_b.get(), target, max_force, frequency_hz, damping_ratio)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MouseJoint();
|
MouseJoint();
|
||||||
MouseJoint(World* world, b2MouseJointDef* def);
|
|
||||||
MouseJoint(World* world, Param const& param);
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
|
bool InitJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大摩擦力 [N]
|
/// @brief 设定最大摩擦力 [N]
|
||||||
|
|
@ -1003,53 +899,214 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
inline b2Joint* Joint::GetB2Joint() const
|
||||||
inline b2Joint* Joint::GetB2Joint() const { return joint_; }
|
{
|
||||||
inline World* Joint::GetWorld() const { return world_; }
|
return joint_;
|
||||||
|
|
||||||
inline void DistanceJoint::SetFrequency(float hz) { KGE_ASSERT(raw_joint_); raw_joint_->SetFrequency(hz); }
|
|
||||||
inline float DistanceJoint::GetFrequency() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetFrequency(); }
|
|
||||||
inline void DistanceJoint::SetDampingRatio(float ratio) { KGE_ASSERT(raw_joint_); raw_joint_->SetDampingRatio(ratio); }
|
|
||||||
inline float DistanceJoint::GetDampingRatio() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetDampingRatio(); }
|
|
||||||
|
|
||||||
inline float PrismaticJoint::GetReferenceAngle() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetReferenceAngle()); }
|
|
||||||
inline bool PrismaticJoint::IsLimitEnabled() const { KGE_ASSERT(raw_joint_); return raw_joint_->IsLimitEnabled(); }
|
|
||||||
inline void PrismaticJoint::EnableLimit(bool flag) { KGE_ASSERT(raw_joint_); raw_joint_->EnableLimit(flag); }
|
|
||||||
inline bool PrismaticJoint::IsMotorEnabled() const { KGE_ASSERT(raw_joint_); return raw_joint_->IsMotorEnabled(); }
|
|
||||||
inline void PrismaticJoint::EnableMotor(bool flag) { KGE_ASSERT(raw_joint_); raw_joint_->EnableMotor(flag); }
|
|
||||||
inline void PrismaticJoint::SetMotorSpeed(float speed) { KGE_ASSERT(raw_joint_); raw_joint_->SetMotorSpeed(math::Degree2Radian(speed)); }
|
|
||||||
inline float PrismaticJoint::GetMotorSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetMotorSpeed()); }
|
|
||||||
inline void PrismaticJoint::SetMaxMotorForce(float force) { KGE_ASSERT(raw_joint_); raw_joint_->SetMaxMotorForce(force); }
|
|
||||||
inline float PrismaticJoint::GetMaxMotorForce() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetMaxMotorForce(); }
|
|
||||||
|
|
||||||
inline float RevoluteJoint::GetReferenceAngle() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetReferenceAngle()); }
|
|
||||||
inline bool RevoluteJoint::IsLimitEnabled() const { KGE_ASSERT(raw_joint_); return raw_joint_->IsLimitEnabled(); }
|
|
||||||
inline void RevoluteJoint::EnableLimit(bool flag) { KGE_ASSERT(raw_joint_); raw_joint_->EnableLimit(flag); }
|
|
||||||
inline bool RevoluteJoint::IsMotorEnabled() const { KGE_ASSERT(raw_joint_); return raw_joint_->IsMotorEnabled(); }
|
|
||||||
inline void RevoluteJoint::EnableMotor(bool flag) { KGE_ASSERT(raw_joint_); raw_joint_->EnableMotor(flag); }
|
|
||||||
inline void RevoluteJoint::SetMotorSpeed(float speed) { KGE_ASSERT(raw_joint_); raw_joint_->SetMotorSpeed(math::Degree2Radian(speed)); }
|
|
||||||
inline float RevoluteJoint::GetMotorSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetMotorSpeed()); }
|
|
||||||
|
|
||||||
inline float WeldJoint::GetReferenceAngle() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetReferenceAngle()); }
|
|
||||||
inline void WeldJoint::SetFrequency(float hz) { KGE_ASSERT(raw_joint_); raw_joint_->SetFrequency(hz); }
|
|
||||||
inline float WeldJoint::GetFrequency() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetFrequency(); }
|
|
||||||
inline void WeldJoint::SetDampingRatio(float ratio) { KGE_ASSERT(raw_joint_); raw_joint_->SetDampingRatio(ratio); }
|
|
||||||
inline float WeldJoint::GetDampingRatio() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetDampingRatio(); }
|
|
||||||
|
|
||||||
inline float WheelJoint::GetJointAngle() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetJointAngle()); }
|
|
||||||
inline float WheelJoint::GetJointAngularSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetJointAngularSpeed()); }
|
|
||||||
inline bool WheelJoint::IsMotorEnabled() const { KGE_ASSERT(raw_joint_); return raw_joint_->IsMotorEnabled(); }
|
|
||||||
inline void WheelJoint::EnableMotor(bool flag) { KGE_ASSERT(raw_joint_); raw_joint_->EnableMotor(flag); }
|
|
||||||
inline void WheelJoint::SetMotorSpeed(float speed) { KGE_ASSERT(raw_joint_); raw_joint_->SetMotorSpeed(math::Degree2Radian(speed)); }
|
|
||||||
inline float WheelJoint::GetMotorSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetMotorSpeed()); }
|
|
||||||
inline void WheelJoint::SetSpringFrequencyHz(float hz) { KGE_ASSERT(raw_joint_); raw_joint_->SetSpringFrequencyHz(hz); }
|
|
||||||
inline float WheelJoint::GetSpringFrequencyHz() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetSpringFrequencyHz(); }
|
|
||||||
inline void WheelJoint::SetSpringDampingRatio(float ratio) { KGE_ASSERT(raw_joint_); raw_joint_->SetSpringDampingRatio(ratio); }
|
|
||||||
inline float WheelJoint::GetSpringDampingRatio() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetSpringDampingRatio(); }
|
|
||||||
|
|
||||||
inline void MouseJoint::SetFrequency(float hz) { KGE_ASSERT(raw_joint_); raw_joint_->SetFrequency(hz); }
|
|
||||||
inline float MouseJoint::GetFrequency() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetFrequency(); }
|
|
||||||
inline void MouseJoint::SetDampingRatio(float ratio) { KGE_ASSERT(raw_joint_); raw_joint_->SetDampingRatio(ratio); }
|
|
||||||
inline float MouseJoint::GetDampingRatio() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetDampingRatio(); }
|
|
||||||
}
|
}
|
||||||
|
inline World* Joint::GetWorld() const
|
||||||
|
{
|
||||||
|
return world_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void DistanceJoint::SetFrequency(float hz)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetFrequency(hz);
|
||||||
|
}
|
||||||
|
inline float DistanceJoint::GetFrequency() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetFrequency();
|
||||||
|
}
|
||||||
|
inline void DistanceJoint::SetDampingRatio(float ratio)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetDampingRatio(ratio);
|
||||||
|
}
|
||||||
|
inline float DistanceJoint::GetDampingRatio() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetDampingRatio();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float PrismaticJoint::GetReferenceAngle() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetReferenceAngle());
|
||||||
|
}
|
||||||
|
inline bool PrismaticJoint::IsLimitEnabled() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->IsLimitEnabled();
|
||||||
|
}
|
||||||
|
inline void PrismaticJoint::EnableLimit(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->EnableLimit(flag);
|
||||||
|
}
|
||||||
|
inline bool PrismaticJoint::IsMotorEnabled() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->IsMotorEnabled();
|
||||||
|
}
|
||||||
|
inline void PrismaticJoint::EnableMotor(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->EnableMotor(flag);
|
||||||
|
}
|
||||||
|
inline void PrismaticJoint::SetMotorSpeed(float speed)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetMotorSpeed(math::Degree2Radian(speed));
|
||||||
|
}
|
||||||
|
inline float PrismaticJoint::GetMotorSpeed() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetMotorSpeed());
|
||||||
|
}
|
||||||
|
inline void PrismaticJoint::SetMaxMotorForce(float force)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetMaxMotorForce(force);
|
||||||
|
}
|
||||||
|
inline float PrismaticJoint::GetMaxMotorForce() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetMaxMotorForce();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float RevoluteJoint::GetReferenceAngle() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetReferenceAngle());
|
||||||
|
}
|
||||||
|
inline bool RevoluteJoint::IsLimitEnabled() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->IsLimitEnabled();
|
||||||
|
}
|
||||||
|
inline void RevoluteJoint::EnableLimit(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->EnableLimit(flag);
|
||||||
|
}
|
||||||
|
inline bool RevoluteJoint::IsMotorEnabled() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->IsMotorEnabled();
|
||||||
|
}
|
||||||
|
inline void RevoluteJoint::EnableMotor(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->EnableMotor(flag);
|
||||||
|
}
|
||||||
|
inline void RevoluteJoint::SetMotorSpeed(float speed)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetMotorSpeed(math::Degree2Radian(speed));
|
||||||
|
}
|
||||||
|
inline float RevoluteJoint::GetMotorSpeed() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetMotorSpeed());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float WeldJoint::GetReferenceAngle() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetReferenceAngle());
|
||||||
|
}
|
||||||
|
inline void WeldJoint::SetFrequency(float hz)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetFrequency(hz);
|
||||||
|
}
|
||||||
|
inline float WeldJoint::GetFrequency() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetFrequency();
|
||||||
|
}
|
||||||
|
inline void WeldJoint::SetDampingRatio(float ratio)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetDampingRatio(ratio);
|
||||||
|
}
|
||||||
|
inline float WeldJoint::GetDampingRatio() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetDampingRatio();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float WheelJoint::GetJointAngle() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetJointAngle());
|
||||||
|
}
|
||||||
|
inline float WheelJoint::GetJointAngularSpeed() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetJointAngularSpeed());
|
||||||
|
}
|
||||||
|
inline bool WheelJoint::IsMotorEnabled() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->IsMotorEnabled();
|
||||||
|
}
|
||||||
|
inline void WheelJoint::EnableMotor(bool flag)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->EnableMotor(flag);
|
||||||
|
}
|
||||||
|
inline void WheelJoint::SetMotorSpeed(float speed)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetMotorSpeed(math::Degree2Radian(speed));
|
||||||
|
}
|
||||||
|
inline float WheelJoint::GetMotorSpeed() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return math::Radian2Degree(raw_joint_->GetMotorSpeed());
|
||||||
|
}
|
||||||
|
inline void WheelJoint::SetSpringFrequencyHz(float hz)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetSpringFrequencyHz(hz);
|
||||||
|
}
|
||||||
|
inline float WheelJoint::GetSpringFrequencyHz() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetSpringFrequencyHz();
|
||||||
|
}
|
||||||
|
inline void WheelJoint::SetSpringDampingRatio(float ratio)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetSpringDampingRatio(ratio);
|
||||||
|
}
|
||||||
|
inline float WheelJoint::GetSpringDampingRatio() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetSpringDampingRatio();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MouseJoint::SetFrequency(float hz)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetFrequency(hz);
|
||||||
|
}
|
||||||
|
inline float MouseJoint::GetFrequency() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetFrequency();
|
||||||
|
}
|
||||||
|
inline void MouseJoint::SetDampingRatio(float ratio)
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
raw_joint_->SetDampingRatio(ratio);
|
||||||
|
}
|
||||||
|
inline float MouseJoint::GetDampingRatio() const
|
||||||
|
{
|
||||||
|
KGE_ASSERT(raw_joint_);
|
||||||
|
return raw_joint_->GetDampingRatio();
|
||||||
|
}
|
||||||
|
} // namespace physics
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -218,5 +218,5 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 圆形形状
|
/// @brief 圆形形状
|
||||||
class KGE_API CircleShape
|
class KGE_API CircleShape : public Shape
|
||||||
: public Shape
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CircleShape();
|
CircleShape();
|
||||||
|
|
@ -76,8 +75,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 盒子形状
|
/// @brief 盒子形状
|
||||||
class KGE_API BoxShape
|
class KGE_API BoxShape : public Shape
|
||||||
: public Shape
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoxShape();
|
BoxShape();
|
||||||
|
|
@ -98,8 +96,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 多边形形状
|
/// @brief 多边形形状
|
||||||
class KGE_API PolygonShape
|
class KGE_API PolygonShape : public Shape
|
||||||
: public Shape
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PolygonShape();
|
PolygonShape();
|
||||||
|
|
@ -118,8 +115,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 线段形状, 用于表示一条边
|
/// @brief 线段形状, 用于表示一条边
|
||||||
class KGE_API EdgeShape
|
class KGE_API EdgeShape : public Shape
|
||||||
: public Shape
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EdgeShape();
|
EdgeShape();
|
||||||
|
|
@ -138,8 +134,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 链式形状
|
/// @brief 链式形状
|
||||||
class KGE_API ChainShape
|
class KGE_API ChainShape : public Shape
|
||||||
: public Shape
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ChainShape();
|
ChainShape();
|
||||||
|
|
@ -158,5 +153,5 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
|
||||||
#include <kiwano-physics/ContactEvent.h>
|
#include <kiwano-physics/ContactEvent.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -48,14 +49,10 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SayGoodbye(b2Fixture* fixture) override
|
void SayGoodbye(b2Fixture* fixture) override {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class World::ContactListener
|
class World::ContactListener : public b2ContactListener
|
||||||
: public b2ContactListener
|
|
||||||
{
|
{
|
||||||
World* world_;
|
World* world_;
|
||||||
|
|
||||||
|
|
@ -67,18 +64,26 @@ namespace kiwano
|
||||||
|
|
||||||
void BeginContact(b2Contact* contact) override
|
void BeginContact(b2Contact* contact) override
|
||||||
{
|
{
|
||||||
ContactBeginEvent evt(contact);
|
ContactBeginEventPtr evt = new ContactBeginEvent(contact);
|
||||||
world_->Dispatch(evt);
|
world_->DispatchEvent(evt.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndContact(b2Contact* contact) override
|
void EndContact(b2Contact* contact) override
|
||||||
{
|
{
|
||||||
ContactEndEvent evt(contact);
|
ContactEndEventPtr evt = new ContactEndEvent(contact);
|
||||||
world_->Dispatch(evt);
|
world_->DispatchEvent(evt.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override { KGE_NOT_USED(contact); KGE_NOT_USED(oldManifold); }
|
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override
|
||||||
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) override { KGE_NOT_USED(contact); KGE_NOT_USED(impulse); }
|
{
|
||||||
|
KGE_NOT_USED(contact);
|
||||||
|
KGE_NOT_USED(oldManifold);
|
||||||
|
}
|
||||||
|
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) override
|
||||||
|
{
|
||||||
|
KGE_NOT_USED(contact);
|
||||||
|
KGE_NOT_USED(impulse);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
World::World()
|
World::World()
|
||||||
|
|
@ -191,11 +196,8 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
if (!removing_joint_ && joint)
|
if (!removing_joint_ && joint)
|
||||||
{
|
{
|
||||||
auto iter = std::find_if(
|
auto iter = std::find_if(joints_.begin(), joints_.end(),
|
||||||
joints_.begin(),
|
[joint](Joint* j) -> bool { return j->GetB2Joint() == joint; });
|
||||||
joints_.end(),
|
|
||||||
[joint](Joint* j) -> bool { return j->GetB2Joint() == joint; }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (iter != joints_.end())
|
if (iter != joints_.end())
|
||||||
{
|
{
|
||||||
|
|
@ -249,5 +251,5 @@ namespace kiwano
|
||||||
Stage::Update(dt);
|
Stage::Update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 物理世界
|
* @brief 物理世界
|
||||||
*/
|
*/
|
||||||
class KGE_API World
|
class KGE_API World : public Stage
|
||||||
: public Stage
|
|
||||||
{
|
{
|
||||||
friend class Body;
|
friend class Body;
|
||||||
friend class Joint;
|
friend class Joint;
|
||||||
|
|
@ -153,7 +152,6 @@ namespace kiwano
|
||||||
Vector<Joint*> joints_;
|
Vector<Joint*> joints_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline float World::GetGlobalScale() const
|
inline float World::GetGlobalScale() const
|
||||||
|
|
@ -195,5 +193,5 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
pos_iter_ = pos_iter;
|
pos_iter_ = pos_iter;
|
||||||
}
|
}
|
||||||
}
|
} // namespace physics
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,13 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
namespace physics
|
namespace physics
|
||||||
{
|
{
|
||||||
inline b2Vec2 Stage2World(const Vec2& pos) { return b2Vec2(pos.x, pos.y); }
|
inline b2Vec2 Stage2World(const Vec2& pos)
|
||||||
inline Vec2 World2Stage(const b2Vec2& pos) { return Vec2(pos.x, pos.y); }
|
{
|
||||||
|
return b2Vec2(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
inline Vec2 World2Stage(const b2Vec2& pos)
|
||||||
|
{
|
||||||
|
return Vec2(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
} // namespace physics
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <kiwano-physics/Shape.h>
|
#include <kiwano-physics/Body.h>
|
||||||
#include <kiwano-physics/Fixture.h>
|
|
||||||
#include <kiwano-physics/Contact.h>
|
#include <kiwano-physics/Contact.h>
|
||||||
#include <kiwano-physics/ContactEvent.h>
|
#include <kiwano-physics/ContactEvent.h>
|
||||||
#include <kiwano-physics/Body.h>
|
#include <kiwano-physics/Fixture.h>
|
||||||
#include <kiwano-physics/Joint.h>
|
#include <kiwano-physics/Joint.h>
|
||||||
|
#include <kiwano-physics/Shape.h>
|
||||||
#include <kiwano-physics/World.h>
|
#include <kiwano-physics/World.h>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/2d/Stage.h>
|
#include <kiwano/2d/Stage.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -29,7 +29,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
float default_anchor_x = 0.f;
|
float default_anchor_x = 0.f;
|
||||||
float default_anchor_y = 0.f;
|
float default_anchor_y = 0.f;
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
void Actor::SetDefaultAnchor(float anchor_x, float anchor_y)
|
void Actor::SetDefaultAnchor(float anchor_x, float anchor_y)
|
||||||
{
|
{
|
||||||
|
|
@ -60,6 +60,8 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Actor::~Actor() {}
|
||||||
|
|
||||||
void Actor::Update(Duration dt)
|
void Actor::Update(Duration dt)
|
||||||
{
|
{
|
||||||
UpdateActions(this, dt);
|
UpdateActions(this, dt);
|
||||||
|
|
@ -84,7 +86,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::Render(RenderTarget* rt)
|
void Actor::Render(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
if (!visible_)
|
if (!visible_)
|
||||||
return;
|
return;
|
||||||
|
|
@ -93,10 +95,10 @@ namespace kiwano
|
||||||
|
|
||||||
if (children_.empty())
|
if (children_.empty())
|
||||||
{
|
{
|
||||||
if (CheckVisibilty(rt))
|
if (CheckVisibility(ctx))
|
||||||
{
|
{
|
||||||
PrepareToRender(rt);
|
PrepareToRender(ctx);
|
||||||
OnRender(rt);
|
OnRender(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -108,52 +110,52 @@ namespace kiwano
|
||||||
if (child->GetZOrder() >= 0)
|
if (child->GetZOrder() >= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
child->Render(rt);
|
child->Render(ctx);
|
||||||
child = child->next_item().get();
|
child = child->next_item().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckVisibilty(rt))
|
if (CheckVisibility(ctx))
|
||||||
{
|
{
|
||||||
PrepareToRender(rt);
|
PrepareToRender(ctx);
|
||||||
OnRender(rt);
|
OnRender(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
child->Render(rt);
|
child->Render(ctx);
|
||||||
child = child->next_item().get();
|
child = child->next_item().get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::PrepareToRender(RenderTarget* rt)
|
void Actor::PrepareToRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
rt->SetTransform(transform_matrix_);
|
ctx.SetTransform(transform_matrix_);
|
||||||
rt->SetBrushOpacity(GetDisplayedOpacity());
|
ctx.SetBrushOpacity(GetDisplayedOpacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::RenderBorder(RenderTarget* rt)
|
void Actor::RenderBorder(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
if (show_border_ && !size_.IsOrigin())
|
if (show_border_ && !size_.IsOrigin())
|
||||||
{
|
{
|
||||||
Rect bounds = GetBounds();
|
Rect bounds = GetBounds();
|
||||||
|
|
||||||
rt->SetTransform(transform_matrix_);
|
ctx.SetTransform(transform_matrix_);
|
||||||
|
|
||||||
rt->SetCurrentBrush(GetStage()->GetBorderFillBrush());
|
ctx.SetCurrentBrush(GetStage()->GetBorderFillBrush());
|
||||||
rt->FillRectangle(bounds);
|
ctx.FillRectangle(bounds);
|
||||||
|
|
||||||
rt->SetCurrentBrush(GetStage()->GetBorderStrokeBrush());
|
ctx.SetCurrentBrush(GetStage()->GetBorderStrokeBrush());
|
||||||
rt->DrawRectangle(bounds, 2.f);
|
ctx.DrawRectangle(bounds, 2.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto child = children_.first_item(); child; child = child->next_item())
|
for (auto child = children_.first_item(); child; child = child->next_item())
|
||||||
{
|
{
|
||||||
child->RenderBorder(rt);
|
child->RenderBorder(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Actor::CheckVisibilty(RenderTarget* rt) const
|
bool Actor::CheckVisibility(RenderContext& ctx) const
|
||||||
{
|
{
|
||||||
if (dirty_visibility_)
|
if (dirty_visibility_)
|
||||||
{
|
{
|
||||||
|
|
@ -165,83 +167,89 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
visible_in_rt_ = rt->CheckVisibility(GetBounds(), GetTransformMatrix());
|
visible_in_rt_ = ctx.CheckVisibility(GetBounds(), GetTransformMatrix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return visible_in_rt_;
|
return visible_in_rt_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::Dispatch(Event& evt)
|
bool Actor::DispatchEvent(Event* evt)
|
||||||
{
|
{
|
||||||
if (!visible_)
|
if (!visible_)
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
ActorPtr prev;
|
// Dispatch to children those are greater than 0 in Z-Order
|
||||||
for (auto child = children_.last_item(); child; child = prev)
|
Actor* child = children_.last_item().get();
|
||||||
|
while (child)
|
||||||
{
|
{
|
||||||
prev = child->prev_item();
|
if (child->GetZOrder() < 0)
|
||||||
child->Dispatch(evt);
|
break;
|
||||||
|
|
||||||
|
if (!child->DispatchEvent(evt))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
child = child->prev_item().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!EventDispatcher::DispatchEvent(evt))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
HandleEvent(evt);
|
||||||
|
|
||||||
|
while (child)
|
||||||
|
{
|
||||||
|
if (!child->DispatchEvent(evt))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
child = child->prev_item().get();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Actor::HandleEvent(Event* evt)
|
||||||
|
{
|
||||||
if (responsible_)
|
if (responsible_)
|
||||||
{
|
{
|
||||||
if (evt.IsType<MouseMoveEvent>())
|
if (evt->IsType<MouseMoveEvent>())
|
||||||
{
|
{
|
||||||
auto& mouse_evt = evt.SafeCast<MouseMoveEvent>();
|
auto mouse_evt = dynamic_cast<MouseMoveEvent*>(evt);
|
||||||
if (!mouse_evt.target && ContainsPoint(mouse_evt.pos))
|
bool contains = ContainsPoint(mouse_evt->pos);
|
||||||
{
|
if (!hover_ && contains)
|
||||||
mouse_evt.target = this;
|
|
||||||
|
|
||||||
if (!hover_)
|
|
||||||
{
|
{
|
||||||
hover_ = true;
|
hover_ = true;
|
||||||
|
|
||||||
MouseHoverEvent hover;
|
MouseHoverEventPtr hover = new MouseHoverEvent;
|
||||||
hover.pos = mouse_evt.pos;
|
hover->pos = mouse_evt->pos;
|
||||||
hover.left_btn_down = mouse_evt.left_btn_down;
|
EventDispatcher::DispatchEvent(hover.get());
|
||||||
hover.right_btn_down = mouse_evt.right_btn_down;
|
|
||||||
hover.target = this;
|
|
||||||
EventDispatcher::Dispatch(hover);
|
|
||||||
}
|
}
|
||||||
}
|
else if (hover_ && !contains)
|
||||||
else if (hover_)
|
|
||||||
{
|
{
|
||||||
hover_ = false;
|
hover_ = false;
|
||||||
pressed_ = false;
|
pressed_ = false;
|
||||||
|
|
||||||
MouseOutEvent out;
|
MouseOutEventPtr out = new MouseOutEvent;
|
||||||
out.pos = mouse_evt.pos;
|
out->pos = mouse_evt->pos;
|
||||||
out.left_btn_down = mouse_evt.left_btn_down;
|
EventDispatcher::DispatchEvent(out.get());
|
||||||
out.right_btn_down = mouse_evt.right_btn_down;
|
|
||||||
out.target = this;
|
|
||||||
EventDispatcher::Dispatch(out);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.IsType<MouseDownEvent>() && hover_)
|
if (evt->IsType<MouseDownEvent>() && hover_)
|
||||||
{
|
{
|
||||||
pressed_ = true;
|
pressed_ = true;
|
||||||
evt.SafeCast<MouseDownEvent>().target = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.IsType<MouseUpEvent>() && pressed_)
|
if (evt->IsType<MouseUpEvent>() && pressed_)
|
||||||
{
|
{
|
||||||
pressed_ = false;
|
pressed_ = false;
|
||||||
|
|
||||||
auto mouse_up_evt = evt.SafeCast<MouseUpEvent>();
|
auto mouse_up_evt = dynamic_cast<MouseUpEvent*>(evt);
|
||||||
mouse_up_evt.target = this;
|
|
||||||
|
|
||||||
MouseClickEvent click;
|
MouseClickEventPtr click = new MouseClickEvent;
|
||||||
click.pos = mouse_up_evt.pos;
|
click->pos = mouse_up_evt->pos;
|
||||||
click.left_btn_down = mouse_up_evt.left_btn_down;
|
click->button = mouse_up_evt->button;
|
||||||
click.right_btn_down = mouse_up_evt.right_btn_down;
|
EventDispatcher::DispatchEvent(click.get());
|
||||||
click.target = this;
|
|
||||||
click.button = mouse_up_evt.button;
|
|
||||||
EventDispatcher::Dispatch(click);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher::Dispatch(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix3x2 const& Actor::GetTransformMatrix() const
|
Matrix3x2 const& Actor::GetTransformMatrix() const
|
||||||
|
|
@ -600,7 +608,8 @@ namespace kiwano
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
child->parent_ = nullptr;
|
child->parent_ = nullptr;
|
||||||
if (child->stage_) child->SetStage(nullptr);
|
if (child->stage_)
|
||||||
|
child->SetStage(nullptr);
|
||||||
children_.remove(ActorPtr(child));
|
children_.remove(ActorPtr(child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -645,4 +654,4 @@ namespace kiwano
|
||||||
return GetBounds().ContainsPoint(local);
|
return GetBounds().ContainsPoint(local);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,19 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/common.h>
|
|
||||||
#include <kiwano/core/time.h>
|
|
||||||
#include <kiwano/core/ObjectBase.h>
|
|
||||||
#include <kiwano/math/math.h>
|
|
||||||
#include <kiwano/2d/Transform.h>
|
#include <kiwano/2d/Transform.h>
|
||||||
#include <kiwano/2d/action/ActionManager.h>
|
#include <kiwano/2d/action/ActionManager.h>
|
||||||
#include <kiwano/core/TimerManager.h>
|
|
||||||
#include <kiwano/core/EventDispatcher.h>
|
#include <kiwano/core/EventDispatcher.h>
|
||||||
|
#include <kiwano/core/ObjectBase.h>
|
||||||
|
#include <kiwano/core/Time.h>
|
||||||
|
#include <kiwano/core/TimerManager.h>
|
||||||
|
#include <kiwano/math/math.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
class Stage;
|
class Stage;
|
||||||
class Director;
|
class Director;
|
||||||
class RenderTarget;
|
class RenderContext;
|
||||||
|
|
||||||
KGE_DECLARE_SMART_PTR(Actor);
|
KGE_DECLARE_SMART_PTR(Actor);
|
||||||
|
|
||||||
|
|
@ -49,14 +48,15 @@ namespace kiwano
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 角色
|
* @brief 角色
|
||||||
* @details 角色是舞台上最基本的元素,是完成渲染、更新、事件分发等功能的最小单位,也是动画、定时器、事件监听等功能的载体
|
* @details
|
||||||
|
* 角色是舞台上最基本的元素,是完成渲染、更新、事件分发等功能的最小单位,也是动画、定时器、事件监听等功能的载体
|
||||||
*/
|
*/
|
||||||
class KGE_API Actor
|
class KGE_API Actor
|
||||||
: public ObjectBase
|
: public virtual ObjectBase
|
||||||
, public TimerManager
|
, public TimerManager
|
||||||
, public ActionManager
|
, public ActionManager
|
||||||
, public EventDispatcher
|
, public EventDispatcher
|
||||||
, public IntrusiveListItem<ActorPtr>
|
, protected IntrusiveListItem<ActorPtr>
|
||||||
{
|
{
|
||||||
friend class Director;
|
friend class Director;
|
||||||
friend class Transition;
|
friend class Transition;
|
||||||
|
|
@ -73,6 +73,8 @@ namespace kiwano
|
||||||
|
|
||||||
Actor();
|
Actor();
|
||||||
|
|
||||||
|
virtual ~Actor();
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 更新角色
|
/// @brief 更新角色
|
||||||
/// @details 每帧画面刷新前调用该函数,重载该函数以实现角色的更新处理
|
/// @details 每帧画面刷新前调用该函数,重载该函数以实现角色的更新处理
|
||||||
|
|
@ -81,9 +83,10 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 渲染角色
|
/// @brief 渲染角色
|
||||||
/// @details 每帧画面刷新时调用该函数,默认不进行渲染,重载该函数以实现具体渲染过程
|
/// @details
|
||||||
/// @param rt 渲染目标
|
/// 每帧画面刷新时调用该函数,默认不进行渲染,重载该函数以实现具体渲染过程
|
||||||
virtual void OnRender(RenderTarget* rt);
|
/// @param ctx 渲染上下文
|
||||||
|
virtual void OnRender(RenderContext& ctx);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取显示状态
|
/// @brief 获取显示状态
|
||||||
|
|
@ -117,34 +120,6 @@ namespace kiwano
|
||||||
/// @brief 获取 y 坐标
|
/// @brief 获取 y 坐标
|
||||||
float GetPositionY() const;
|
float GetPositionY() const;
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取缩放比例
|
|
||||||
Point const& GetScale() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取横向缩放比例
|
|
||||||
float GetScaleX() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取纵向缩放比例
|
|
||||||
float GetScaleY() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取错切角度
|
|
||||||
Point const& GetSkew() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取横向错切角度
|
|
||||||
float GetSkewX() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取纵向错切角度
|
|
||||||
float GetSkewY() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取旋转角度
|
|
||||||
float GetRotation() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取宽度
|
/// @brief 获取宽度
|
||||||
float GetWidth() const;
|
float GetWidth() const;
|
||||||
|
|
@ -189,6 +164,34 @@ namespace kiwano
|
||||||
/// @brief 获取显示透明度
|
/// @brief 获取显示透明度
|
||||||
float GetDisplayedOpacity() const;
|
float GetDisplayedOpacity() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取旋转角度
|
||||||
|
float GetRotation() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取缩放比例
|
||||||
|
Point const& GetScale() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取横向缩放比例
|
||||||
|
float GetScaleX() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取纵向缩放比例
|
||||||
|
float GetScaleY() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取错切角度
|
||||||
|
Point const& GetSkew() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取横向错切角度
|
||||||
|
float GetSkewX() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取纵向错切角度
|
||||||
|
float GetSkewY() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取变换
|
/// @brief 获取变换
|
||||||
Transform GetTransform() const;
|
Transform GetTransform() const;
|
||||||
|
|
@ -362,10 +365,6 @@ namespace kiwano
|
||||||
/// @brief 从父角色移除
|
/// @brief 从父角色移除
|
||||||
void RemoveFromParent();
|
void RemoveFromParent();
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 判断点是否在角色内
|
|
||||||
virtual bool ContainsPoint(const Point& point) const;
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 暂停角色更新
|
/// @brief 暂停角色更新
|
||||||
void PauseUpdating();
|
void PauseUpdating();
|
||||||
|
|
@ -386,13 +385,19 @@ namespace kiwano
|
||||||
/// @brief 获取更新时的回调函数
|
/// @brief 获取更新时的回调函数
|
||||||
UpdateCallback GetCallbackOnUpdate() const;
|
UpdateCallback GetCallbackOnUpdate() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 判断点是否在角色内
|
||||||
|
virtual bool ContainsPoint(const Point& point) const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 渲染角色边界
|
/// @brief 渲染角色边界
|
||||||
void ShowBorder(bool show);
|
void ShowBorder(bool show);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 分发事件
|
/// @brief 分发事件
|
||||||
void Dispatch(Event& evt) override;
|
/// @param evt 事件
|
||||||
|
/// @return 是否继续分发该事件
|
||||||
|
virtual bool DispatchEvent(Event* evt);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置默认锚点
|
/// @brief 设置默认锚点
|
||||||
|
|
@ -405,19 +410,19 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 渲染自身和所有子角色
|
/// @brief 渲染自身和所有子角色
|
||||||
virtual void Render(RenderTarget* rt);
|
virtual void Render(RenderContext& ctx);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 绘制自身和所有子角色的边界
|
/// @brief 绘制自身和所有子角色的边界
|
||||||
virtual void RenderBorder(RenderTarget* rt);
|
virtual void RenderBorder(RenderContext& ctx);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 检查是否在渲染目标的视区内
|
/// @brief 检查是否在渲染上下文的视区内
|
||||||
virtual bool CheckVisibilty(RenderTarget* rt) const;
|
virtual bool CheckVisibility(RenderContext& ctx) const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 渲染前初始化渲染目标状态,仅当 CheckVisibilty 返回真时调用该函数
|
/// @brief 渲染前初始化渲染上下文状态,仅当 CheckVisibility 返回真时调用该函数
|
||||||
virtual void PrepareToRender(RenderTarget* rt);
|
virtual void PrepareToRender(RenderContext& ctx);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 更新自己的二维变换,并通知所有子角色
|
/// @brief 更新自己的二维变换,并通知所有子角色
|
||||||
|
|
@ -435,6 +440,10 @@ namespace kiwano
|
||||||
/// @brief 设置节点所在舞台
|
/// @brief 设置节点所在舞台
|
||||||
void SetStage(Stage* stage);
|
void SetStage(Stage* stage);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 处理事件
|
||||||
|
void HandleEvent(Event* evt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool visible_;
|
bool visible_;
|
||||||
bool update_pausing_;
|
bool update_pausing_;
|
||||||
|
|
@ -466,15 +475,14 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
inline void Actor::OnUpdate(Duration dt)
|
inline void Actor::OnUpdate(Duration dt)
|
||||||
{
|
{
|
||||||
KGE_NOT_USED(dt);
|
KGE_NOT_USED(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Actor::OnRender(RenderTarget* rt)
|
inline void Actor::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
KGE_NOT_USED(rt);
|
KGE_NOT_USED(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Actor::IsVisible() const
|
inline bool Actor::IsVisible() const
|
||||||
|
|
@ -681,5 +689,4 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
SetSkew(Vec2{ skewx, skewy });
|
SetSkew(Vec2{ skewx, skewy });
|
||||||
}
|
}
|
||||||
|
} // namespace kiwano
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,207 @@
|
||||||
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#include <kiwano/2d/Button.h>
|
||||||
|
#include <kiwano/2d/Stage.h>
|
||||||
|
#include <kiwano/platform/Window.h>
|
||||||
|
|
||||||
|
namespace kiwano
|
||||||
|
{
|
||||||
|
Button::Button()
|
||||||
|
: enabled_(true)
|
||||||
|
, status_(Status::Normal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::Button(const Callback& click)
|
||||||
|
: Button()
|
||||||
|
{
|
||||||
|
this->SetClickCallback(click);
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::Button(Callback const& click, Callback const& pressed, Callback const& mouse_over, Callback const& mouse_out)
|
||||||
|
: Button()
|
||||||
|
{
|
||||||
|
this->SetClickCallback(click);
|
||||||
|
this->SetPressedCallback(pressed);
|
||||||
|
this->SetMouseOverCallback(mouse_over);
|
||||||
|
this->SetMouseOutCallback(mouse_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::~Button() {}
|
||||||
|
|
||||||
|
bool Button::IsEnable() const
|
||||||
|
{
|
||||||
|
return enabled_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::SetEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled_ != enabled)
|
||||||
|
{
|
||||||
|
enabled_ = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::SetClickCallback(const Callback& func)
|
||||||
|
{
|
||||||
|
click_callback_ = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::SetPressedCallback(const Callback& func)
|
||||||
|
{
|
||||||
|
pressed_callback_ = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::SetReleasedCallback(const Callback& func)
|
||||||
|
{
|
||||||
|
released_callback_ = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::SetMouseOverCallback(const Callback& func)
|
||||||
|
{
|
||||||
|
mouse_over_callback_ = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::SetMouseOutCallback(const Callback& func)
|
||||||
|
{
|
||||||
|
mouse_out_callback_ = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::SetStatus(Status status)
|
||||||
|
{
|
||||||
|
if (status_ != status)
|
||||||
|
{
|
||||||
|
Status old_status = status_;
|
||||||
|
|
||||||
|
if (status == Status::Normal)
|
||||||
|
{
|
||||||
|
Window::Instance().SetCursor(CursorType::Arrow);
|
||||||
|
|
||||||
|
if (mouse_out_callback_)
|
||||||
|
mouse_out_callback_(this);
|
||||||
|
}
|
||||||
|
else if (status == Status::Hover)
|
||||||
|
{
|
||||||
|
Window::Instance().SetCursor(CursorType::Hand);
|
||||||
|
|
||||||
|
if (old_status == Status::Pressed)
|
||||||
|
{
|
||||||
|
if (released_callback_)
|
||||||
|
released_callback_(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mouse_over_callback_)
|
||||||
|
mouse_over_callback_(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (status == Status::Pressed)
|
||||||
|
{
|
||||||
|
if (pressed_callback_)
|
||||||
|
pressed_callback_(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_ = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button::Status Button::GetStatus() const
|
||||||
|
{
|
||||||
|
return status_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::UpdateStatus(Event* evt)
|
||||||
|
{
|
||||||
|
if (!enabled_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (evt->IsType<MouseHoverEvent>())
|
||||||
|
{
|
||||||
|
SetStatus(Status::Hover);
|
||||||
|
}
|
||||||
|
else if (evt->IsType<MouseOutEvent>())
|
||||||
|
{
|
||||||
|
SetStatus(Status::Normal);
|
||||||
|
}
|
||||||
|
else if (evt->IsType<MouseDownEvent>() && status_ == Status::Hover)
|
||||||
|
{
|
||||||
|
SetStatus(Status::Pressed);
|
||||||
|
}
|
||||||
|
else if (evt->IsType<MouseUpEvent>() && status_ == Status::Pressed)
|
||||||
|
{
|
||||||
|
SetStatus(Status::Hover);
|
||||||
|
}
|
||||||
|
else if (evt->IsType<MouseClickEvent>())
|
||||||
|
{
|
||||||
|
if (click_callback_)
|
||||||
|
click_callback_(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SpriteButton::SpriteButton()
|
||||||
|
: SpriteButton(nullptr, nullptr, nullptr, nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SpriteButton::SpriteButton(Callback const& click)
|
||||||
|
: SpriteButton(click, nullptr, nullptr, nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SpriteButton::SpriteButton(Callback const& click, Callback const& pressed, Callback const& mouse_over,
|
||||||
|
Callback const& mouse_out)
|
||||||
|
: Button(click, pressed, mouse_over, mouse_out)
|
||||||
|
{
|
||||||
|
SetResponsible(true);
|
||||||
|
|
||||||
|
EventListener::Callback handler = Closure(this, &SpriteButton::UpdateStatus);
|
||||||
|
AddListener<MouseHoverEvent>(handler);
|
||||||
|
AddListener<MouseOutEvent>(handler);
|
||||||
|
AddListener<MouseDownEvent>(handler);
|
||||||
|
AddListener<MouseUpEvent>(handler);
|
||||||
|
AddListener<MouseClickEvent>(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextButton::TextButton()
|
||||||
|
: TextButton(nullptr, nullptr, nullptr, nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TextButton::TextButton(Callback const& click)
|
||||||
|
: TextButton(click, nullptr, nullptr, nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TextButton::TextButton(Callback const& click, Callback const& pressed, Callback const& mouse_over,
|
||||||
|
Callback const& mouse_out)
|
||||||
|
: Button(click, pressed, mouse_over, mouse_out)
|
||||||
|
{
|
||||||
|
SetResponsible(true);
|
||||||
|
|
||||||
|
EventListener::Callback handler = Closure(this, &TextButton::UpdateStatus);
|
||||||
|
AddListener<MouseHoverEvent>(handler);
|
||||||
|
AddListener<MouseOutEvent>(handler);
|
||||||
|
AddListener<MouseDownEvent>(handler);
|
||||||
|
AddListener<MouseUpEvent>(handler);
|
||||||
|
AddListener<MouseClickEvent>(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace kiwano
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <kiwano/2d/Sprite.h>
|
||||||
|
#include <kiwano/2d/TextActor.h>
|
||||||
|
|
||||||
|
namespace kiwano
|
||||||
|
{
|
||||||
|
KGE_DECLARE_SMART_PTR(Button);
|
||||||
|
KGE_DECLARE_SMART_PTR(SpriteButton);
|
||||||
|
KGE_DECLARE_SMART_PTR(TextButton);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \~chinese
|
||||||
|
* @brief 按钮
|
||||||
|
*/
|
||||||
|
class KGE_API Button : public virtual ObjectBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 按钮回调函数
|
||||||
|
using Callback = Function<void(Button* /* self */)>;
|
||||||
|
|
||||||
|
Button();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 构造按钮
|
||||||
|
/// @param click 按钮点击回调函数
|
||||||
|
explicit Button(Callback const& click);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 构造按钮
|
||||||
|
/// @param click 按钮点击回调函数
|
||||||
|
/// @param pressed 按钮按下回调函数
|
||||||
|
/// @param mouse_over 按钮移入回调函数
|
||||||
|
/// @param mouse_out 按钮移出回调函数
|
||||||
|
Button(Callback const& click, Callback const& pressed, Callback const& mouse_over, Callback const& mouse_out);
|
||||||
|
|
||||||
|
virtual ~Button();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取按钮状态是启用还是禁用
|
||||||
|
bool IsEnable() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置按钮启用或禁用
|
||||||
|
void SetEnabled(bool enabled);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置按钮点击后的回调函数
|
||||||
|
void SetClickCallback(const Callback& func);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置按钮被按下时的回调函数
|
||||||
|
void SetPressedCallback(const Callback& func);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置按钮被抬起时的回调函数
|
||||||
|
void SetReleasedCallback(const Callback& func);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置鼠标移入按钮时的回调函数
|
||||||
|
void SetMouseOverCallback(const Callback& func);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置鼠标移出按钮时的回调函数
|
||||||
|
void SetMouseOutCallback(const Callback& func);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 按钮状态
|
||||||
|
enum class Status
|
||||||
|
{
|
||||||
|
Normal, ///< 普通
|
||||||
|
Hover, ///< 鼠标在按钮内
|
||||||
|
Pressed ///< 被按下
|
||||||
|
};
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置按钮状态
|
||||||
|
void SetStatus(Status status);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取按钮状态
|
||||||
|
Status GetStatus() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 更新按钮状态
|
||||||
|
void UpdateStatus(Event* evt);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool enabled_;
|
||||||
|
Status status_;
|
||||||
|
Callback click_callback_;
|
||||||
|
Callback pressed_callback_;
|
||||||
|
Callback released_callback_;
|
||||||
|
Callback mouse_over_callback_;
|
||||||
|
Callback mouse_out_callback_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 精灵按钮
|
||||||
|
class SpriteButton
|
||||||
|
: public Sprite
|
||||||
|
, public Button
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpriteButton();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 构造精灵按钮
|
||||||
|
/// @param click 按钮点击回调函数
|
||||||
|
explicit SpriteButton(Callback const& click);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 构造精灵按钮
|
||||||
|
/// @param click 按钮点击回调函数
|
||||||
|
/// @param pressed 按钮按下回调函数
|
||||||
|
/// @param mouse_over 按钮移入回调函数
|
||||||
|
/// @param mouse_out 按钮移出回调函数
|
||||||
|
SpriteButton(Callback const& click, Callback const& pressed, Callback const& mouse_over, Callback const& mouse_out);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 文字按钮
|
||||||
|
class TextButton
|
||||||
|
: public TextActor
|
||||||
|
, public Button
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextButton();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 构造文字按钮
|
||||||
|
/// @param click 按钮点击回调函数
|
||||||
|
explicit TextButton(Callback const& click);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 构造文字按钮
|
||||||
|
/// @param click 按钮点击回调函数
|
||||||
|
/// @param pressed 按钮按下回调函数
|
||||||
|
/// @param mouse_over 按钮移入回调函数
|
||||||
|
/// @param mouse_out 按钮移出回调函数
|
||||||
|
TextButton(Callback const& click, Callback const& pressed, Callback const& mouse_over, Callback const& mouse_out);
|
||||||
|
};
|
||||||
|
} // namespace kiwano
|
||||||
|
|
@ -20,51 +20,49 @@
|
||||||
|
|
||||||
#include <kiwano/2d/Canvas.h>
|
#include <kiwano/2d/Canvas.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
Canvas::Canvas()
|
Canvas::Canvas()
|
||||||
: cache_expired_(false)
|
: cache_expired_(false)
|
||||||
, stroke_width_(1.0f)
|
, stroke_width_(1.0f)
|
||||||
, stroke_style_(StrokeStyle::Miter)
|
, stroke_style_()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas::~Canvas()
|
Canvas::~Canvas() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Canvas::BeginDraw()
|
void Canvas::BeginDraw()
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->BeginDraw();
|
ctx_->BeginDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::EndDraw()
|
void Canvas::EndDraw()
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->EndDraw();
|
ctx_->EndDraw();
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::OnRender(RenderTarget* rt)
|
void Canvas::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
UpdateCache();
|
UpdateCache();
|
||||||
|
|
||||||
if (texture_cached_ && texture_cached_->IsValid())
|
if (texture_cached_ && texture_cached_->IsValid())
|
||||||
{
|
{
|
||||||
PrepareToRender(rt);
|
PrepareToRender(ctx);
|
||||||
|
|
||||||
Rect bitmap_rect(0.f, 0.f, texture_cached_->GetWidth(), texture_cached_->GetHeight());
|
Rect bitmap_rect(0.f, 0.f, texture_cached_->GetWidth(), texture_cached_->GetHeight());
|
||||||
rt->DrawTexture(*texture_cached_, bitmap_rect, bitmap_rect);
|
ctx.DrawTexture(*texture_cached_, bitmap_rect, bitmap_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::SetBrush(BrushPtr brush)
|
void Canvas::SetBrush(BrushPtr brush)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(brush);
|
ctx_->SetCurrentBrush(brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Canvas::GetStrokeWidth() const
|
float Canvas::GetStrokeWidth() const
|
||||||
|
|
@ -75,143 +73,108 @@ namespace kiwano
|
||||||
void Canvas::SetBrushTransform(Transform const& transform)
|
void Canvas::SetBrushTransform(Transform const& transform)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetTransform(transform.ToMatrix());
|
ctx_->SetTransform(transform.ToMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::SetBrushTransform(Matrix3x2 const& transform)
|
void Canvas::SetBrushTransform(Matrix3x2 const& transform)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetTransform(transform);
|
ctx_->SetTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::PushLayerArea(LayerArea& area)
|
void Canvas::PushLayerArea(LayerArea& area)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->PushLayer(area);
|
ctx_->PushLayer(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::PopLayerArea()
|
void Canvas::PopLayerArea()
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->PopLayer();
|
ctx_->PopLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::PushClipRect(Rect const& clip_rect)
|
void Canvas::PushClipRect(Rect const& clip_rect)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->PushClipRect(clip_rect);
|
ctx_->PushClipRect(clip_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::PopClipRect()
|
void Canvas::PopClipRect()
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->PopClipRect();
|
ctx_->PopClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::DrawLine(Point const& begin, Point const& end)
|
void Canvas::DrawLine(Point const& begin, Point const& end)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(stroke_brush_);
|
ctx_->SetCurrentBrush(stroke_brush_);
|
||||||
rt_->DrawLine(
|
ctx_->DrawLine(begin, end, stroke_width_, stroke_style_);
|
||||||
begin,
|
|
||||||
end,
|
|
||||||
stroke_width_,
|
|
||||||
stroke_style_
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::DrawCircle(Point const& center, float radius)
|
void Canvas::DrawCircle(Point const& center, float radius)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(stroke_brush_);
|
ctx_->SetCurrentBrush(stroke_brush_);
|
||||||
rt_->DrawEllipse(
|
ctx_->DrawEllipse(center, Vec2(radius, radius), stroke_width_, stroke_style_);
|
||||||
center,
|
|
||||||
Vec2(radius, radius),
|
|
||||||
stroke_width_,
|
|
||||||
stroke_style_
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::DrawEllipse(Point const& center, Vec2 const& radius)
|
void Canvas::DrawEllipse(Point const& center, Vec2 const& radius)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(stroke_brush_);
|
ctx_->SetCurrentBrush(stroke_brush_);
|
||||||
rt_->DrawEllipse(
|
ctx_->DrawEllipse(center, radius, stroke_width_, stroke_style_);
|
||||||
center,
|
|
||||||
radius,
|
|
||||||
stroke_width_,
|
|
||||||
stroke_style_
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::DrawRect(Rect const& rect)
|
void Canvas::DrawRect(Rect const& rect)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(stroke_brush_);
|
ctx_->SetCurrentBrush(stroke_brush_);
|
||||||
rt_->DrawRectangle(
|
ctx_->DrawRectangle(rect, stroke_width_, stroke_style_);
|
||||||
rect,
|
|
||||||
stroke_width_,
|
|
||||||
stroke_style_
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::DrawRoundedRect(Rect const& rect, Vec2 const& radius)
|
void Canvas::DrawRoundedRect(Rect const& rect, Vec2 const& radius)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(stroke_brush_);
|
ctx_->SetCurrentBrush(stroke_brush_);
|
||||||
rt_->DrawRoundedRectangle(
|
ctx_->DrawRoundedRectangle(rect, radius, stroke_width_, stroke_style_);
|
||||||
rect,
|
|
||||||
radius,
|
|
||||||
stroke_width_,
|
|
||||||
stroke_style_
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::FillCircle(Point const& center, float radius)
|
void Canvas::FillCircle(Point const& center, float radius)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(fill_brush_);
|
ctx_->SetCurrentBrush(fill_brush_);
|
||||||
rt_->FillEllipse(
|
ctx_->FillEllipse(center, Vec2(radius, radius));
|
||||||
center,
|
|
||||||
Vec2(radius, radius)
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::FillEllipse(Point const& center, Vec2 const& radius)
|
void Canvas::FillEllipse(Point const& center, Vec2 const& radius)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(fill_brush_);
|
ctx_->SetCurrentBrush(fill_brush_);
|
||||||
rt_->FillEllipse(
|
ctx_->FillEllipse(center, radius);
|
||||||
center,
|
|
||||||
radius
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::FillRect(Rect const& rect)
|
void Canvas::FillRect(Rect const& rect)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(fill_brush_);
|
ctx_->SetCurrentBrush(fill_brush_);
|
||||||
rt_->FillRectangle(
|
ctx_->FillRectangle(rect);
|
||||||
rect
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::FillRoundedRect(Rect const& rect, Vec2 const& radius)
|
void Canvas::FillRoundedRect(Rect const& rect, Vec2 const& radius)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(fill_brush_);
|
ctx_->SetCurrentBrush(fill_brush_);
|
||||||
rt_->FillRoundedRectangle(
|
ctx_->FillRoundedRectangle(rect, radius);
|
||||||
rect,
|
|
||||||
radius
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,7 +183,7 @@ namespace kiwano
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->DrawTexture(*texture, src_rect, dest_rect);
|
ctx_->DrawTexture(*texture, src_rect, dest_rect);
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +202,7 @@ namespace kiwano
|
||||||
void Canvas::DrawTextLayout(TextLayout const& layout, Point const& point)
|
void Canvas::DrawTextLayout(TextLayout const& layout, Point const& point)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->DrawTextLayout(layout, point);
|
ctx_->DrawTextLayout(layout, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::BeginPath(Point const& begin_pos)
|
void Canvas::BeginPath(Point const& begin_pos)
|
||||||
|
|
@ -275,36 +238,30 @@ namespace kiwano
|
||||||
void Canvas::StrokePath()
|
void Canvas::StrokePath()
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(stroke_brush_);
|
ctx_->SetCurrentBrush(stroke_brush_);
|
||||||
rt_->DrawGeometry(
|
ctx_->DrawGeometry(geo_sink_.GetGeometry(), stroke_width_, stroke_style_);
|
||||||
geo_sink_.GetGeometry(),
|
|
||||||
stroke_width_,
|
|
||||||
stroke_style_
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::FillPath()
|
void Canvas::FillPath()
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->SetCurrentBrush(fill_brush_);
|
ctx_->SetCurrentBrush(fill_brush_);
|
||||||
rt_->FillGeometry(
|
ctx_->FillGeometry(geo_sink_.GetGeometry());
|
||||||
geo_sink_.GetGeometry()
|
|
||||||
);
|
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::Clear()
|
void Canvas::Clear()
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->Clear();
|
ctx_->Clear();
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::Clear(Color const& clear_color)
|
void Canvas::Clear(Color const& clear_color)
|
||||||
{
|
{
|
||||||
InitRenderTargetAndBrushs();
|
InitRenderTargetAndBrushs();
|
||||||
rt_->Clear(clear_color);
|
ctx_->Clear(clear_color);
|
||||||
cache_expired_ = true;
|
cache_expired_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,9 +273,9 @@ namespace kiwano
|
||||||
|
|
||||||
void Canvas::InitRenderTargetAndBrushs()
|
void Canvas::InitRenderTargetAndBrushs()
|
||||||
{
|
{
|
||||||
if (!rt_)
|
if (!ctx_)
|
||||||
{
|
{
|
||||||
Renderer::instance().CreateTextureRenderTarget(rt_);
|
Renderer::Instance().CreateTextureRenderTarget(ctx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stroke_brush_)
|
if (!stroke_brush_)
|
||||||
|
|
@ -336,18 +293,18 @@ namespace kiwano
|
||||||
|
|
||||||
void Canvas::UpdateCache() const
|
void Canvas::UpdateCache() const
|
||||||
{
|
{
|
||||||
if (cache_expired_ && rt_)
|
if (cache_expired_ && ctx_)
|
||||||
{
|
{
|
||||||
if (!texture_cached_)
|
if (!texture_cached_)
|
||||||
{
|
{
|
||||||
texture_cached_ = new Texture;
|
texture_cached_ = new Texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rt_->GetOutput(*texture_cached_))
|
if (ctx_->GetOutput(*texture_cached_))
|
||||||
{
|
{
|
||||||
cache_expired_ = false;
|
cache_expired_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/renderer/RenderTarget.h>
|
#include <kiwano/render/GeometrySink.h>
|
||||||
#include <kiwano/renderer/GeometrySink.h>
|
#include <kiwano/render/RenderContext.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -36,8 +36,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 画布,用于绘制图元
|
* @brief 画布,用于绘制图元
|
||||||
*/
|
*/
|
||||||
class KGE_API Canvas
|
class KGE_API Canvas : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -206,7 +205,7 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置轮廓样式
|
/// @brief 设置轮廓样式
|
||||||
/// @param stroke_style 轮廓样式
|
/// @param stroke_style 轮廓样式
|
||||||
void SetStrokeStyle(StrokeStyle stroke_style);
|
void SetStrokeStyle(const StrokeStyle& stroke_style);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置文字画刷样式
|
/// @brief 设置文字画刷样式
|
||||||
|
|
@ -262,7 +261,7 @@ namespace kiwano
|
||||||
/// @brief 导出纹理
|
/// @brief 导出纹理
|
||||||
TexturePtr ExportToTexture() const;
|
TexturePtr ExportToTexture() const;
|
||||||
|
|
||||||
void OnRender(RenderTarget* rt) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitRenderTargetAndBrushs();
|
void InitRenderTargetAndBrushs();
|
||||||
|
|
@ -279,7 +278,7 @@ namespace kiwano
|
||||||
|
|
||||||
mutable bool cache_expired_;
|
mutable bool cache_expired_;
|
||||||
mutable TexturePtr texture_cached_;
|
mutable TexturePtr texture_cached_;
|
||||||
mutable TextureRenderTargetPtr rt_;
|
mutable TextureRenderContextPtr ctx_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
@ -289,7 +288,7 @@ namespace kiwano
|
||||||
stroke_width_ = std::max(width, 0.f);
|
stroke_width_ = std::max(width, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Canvas::SetStrokeStyle(StrokeStyle stroke_style)
|
inline void Canvas::SetStrokeStyle(const StrokeStyle& stroke_style)
|
||||||
{
|
{
|
||||||
stroke_style_ = stroke_style;
|
stroke_style_ = stroke_style;
|
||||||
}
|
}
|
||||||
|
|
@ -330,5 +329,4 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
return stroke_brush_;
|
return stroke_brush_;
|
||||||
}
|
}
|
||||||
|
} // namespace kiwano
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/DebugActor.h>
|
#include <kiwano/2d/DebugActor.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
|
#include <kiwano/render/Renderer.h>
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
|
|
||||||
#pragma comment(lib, "psapi.lib")
|
#pragma comment(lib, "psapi.lib")
|
||||||
|
|
@ -42,9 +42,7 @@ namespace kiwano
|
||||||
return "\03";
|
return "\03";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
std::locale comma_locale(std::locale(), new comma_numpunct);
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugActor::DebugActor()
|
DebugActor::DebugActor()
|
||||||
{
|
{
|
||||||
|
|
@ -53,33 +51,33 @@ namespace kiwano
|
||||||
SetResponsible(true);
|
SetResponsible(true);
|
||||||
SetCascadeOpacityEnabled(true);
|
SetCascadeOpacityEnabled(true);
|
||||||
|
|
||||||
|
comma_locale_ = std::locale(std::locale(), new comma_numpunct);
|
||||||
|
|
||||||
background_brush_ = new Brush;
|
background_brush_ = new Brush;
|
||||||
background_brush_->SetColor(Color(0.0f, 0.0f, 0.0f, 0.7f));
|
background_brush_->SetColor(Color(0.0f, 0.0f, 0.0f, 0.7f));
|
||||||
|
|
||||||
debug_text_ = new TextActor;
|
BrushPtr fill_brush = new Brush;
|
||||||
debug_text_->SetPosition(Point{ 10, 10 });
|
fill_brush->SetColor(Color::White);
|
||||||
this->AddChild(debug_text_);
|
|
||||||
|
|
||||||
TextStyle style;
|
TextStyle style;
|
||||||
style.font_family = L"Arial";
|
style.font_family = L"Arial";
|
||||||
style.font_size = 16.f;
|
style.font_size = 16.f;
|
||||||
style.font_weight = FontWeight::Normal;
|
style.font_weight = FontWeight::Normal;
|
||||||
style.line_spacing = 20.f;
|
style.line_spacing = 20.f;
|
||||||
debug_text_->SetStyle(style);
|
style.fill_brush = fill_brush;
|
||||||
debug_text_->SetFillColor(Color::White);
|
debug_text_.SetStyle(style);
|
||||||
|
|
||||||
AddListener<MouseHoverEvent>([=](Event&) { SetOpacity(0.4f); });
|
AddListener<MouseHoverEvent>([=](Event*) { SetOpacity(0.4f); });
|
||||||
AddListener<MouseOutEvent>([=](Event&) { SetOpacity(1.f); });
|
AddListener<MouseOutEvent>([=](Event*) { SetOpacity(1.f); });
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugActor::~DebugActor()
|
DebugActor::~DebugActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugActor::OnRender(RenderTarget* rt)
|
void DebugActor::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
rt->SetCurrentBrush(background_brush_);
|
ctx.SetCurrentBrush(background_brush_);
|
||||||
rt->FillRoundedRectangle(GetBounds(), Vec2{ 5.f, 5.f });
|
ctx.FillRoundedRectangle(GetBounds(), Vec2{ 5.f, 5.f });
|
||||||
|
ctx.DrawTextLayout(debug_text_, Point(10, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugActor::OnUpdate(Duration dt)
|
void DebugActor::OnUpdate(Duration dt)
|
||||||
|
|
@ -95,7 +93,7 @@ namespace kiwano
|
||||||
StringStream ss;
|
StringStream ss;
|
||||||
|
|
||||||
// For formatting integers with commas
|
// For formatting integers with commas
|
||||||
(void)ss.imbue(comma_locale);
|
(void)ss.imbue(comma_locale_);
|
||||||
|
|
||||||
ss << "Fps: " << frame_time_.size() << std::endl;
|
ss << "Fps: " << frame_time_.size() << std::endl;
|
||||||
|
|
||||||
|
|
@ -106,9 +104,10 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ss << "Render: " << Renderer::instance().GetStatus().duration.Milliseconds() << "ms" << std::endl;
|
ss << "Render: " << Renderer::Instance().GetStatus().duration.Milliseconds() << "ms" << std::endl;
|
||||||
|
|
||||||
ss << "Primitives / sec: " << std::fixed << Renderer::instance().GetStatus().primitives * frame_time_.size() << std::endl;
|
ss << "Primitives / sec: " << std::fixed << Renderer::Instance().GetStatus().primitives * frame_time_.size()
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
ss << "Memory: ";
|
ss << "Memory: ";
|
||||||
{
|
{
|
||||||
|
|
@ -124,22 +123,24 @@ namespace kiwano
|
||||||
ss << pmc.PrivateUsage / 1024 << "Kb";
|
ss << pmc.PrivateUsage / 1024 << "Kb";
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_text_->SetText(ss.str());
|
debug_text_.SetText(ss.str());
|
||||||
|
debug_text_.Update();
|
||||||
|
|
||||||
if (debug_text_->GetWidth() > GetWidth() - 20)
|
Size layout_size = debug_text_.GetLayoutSize();
|
||||||
|
if (layout_size.x > GetWidth() - 20)
|
||||||
{
|
{
|
||||||
SetWidth(20 + debug_text_->GetWidth());
|
SetWidth(20 + layout_size.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_text_->GetHeight() > GetHeight() - 20)
|
if (layout_size.y > GetHeight() - 20)
|
||||||
{
|
{
|
||||||
SetHeight(20 + debug_text_->GetHeight());
|
SetHeight(20 + layout_size.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebugActor::CheckVisibilty(RenderTarget* rt) const
|
bool DebugActor::CheckVisibility(RenderContext& ctx) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/2d/TextActor.h>
|
#include <kiwano/render/TextLayout.h>
|
||||||
#include <kiwano/renderer/Color.h>
|
|
||||||
#include <kiwano/renderer/Brush.h>
|
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -35,27 +33,26 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 调试节点
|
* @brief 调试节点
|
||||||
*/
|
*/
|
||||||
class KGE_API DebugActor
|
class KGE_API DebugActor : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DebugActor();
|
DebugActor();
|
||||||
|
|
||||||
virtual ~DebugActor();
|
virtual ~DebugActor();
|
||||||
|
|
||||||
void OnRender(RenderTarget* rt) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
||||||
void OnUpdate(Duration dt) override;
|
void OnUpdate(Duration dt) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CheckVisibilty(RenderTarget* rt) const override;
|
bool CheckVisibility(RenderContext& ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::locale comma_locale_;
|
||||||
BrushPtr background_brush_;
|
BrushPtr background_brush_;
|
||||||
TextActorPtr debug_text_;
|
TextLayout debug_text_;
|
||||||
Vector<Time> frame_time_;
|
Vector<Time> frame_time_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
} // namespace kiwano
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,15 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/Frame.h>
|
#include <kiwano/2d/Frame.h>
|
||||||
#include <kiwano/renderer/TextureCache.h>
|
#include <kiwano/render/TextureCache.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
Frame::Frame()
|
Frame::Frame() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Frame::Load(String const& file_path)
|
bool Frame::Load(String const& file_path)
|
||||||
{
|
{
|
||||||
TexturePtr texture = TextureCache::instance().AddOrGetTexture(file_path);
|
TexturePtr texture = TextureCache::Instance().AddOrGetTexture(file_path);
|
||||||
if (texture->IsValid())
|
if (texture->IsValid())
|
||||||
{
|
{
|
||||||
SetTexture(texture);
|
SetTexture(texture);
|
||||||
|
|
@ -40,7 +38,7 @@ namespace kiwano
|
||||||
|
|
||||||
bool Frame::Load(Resource const& res)
|
bool Frame::Load(Resource const& res)
|
||||||
{
|
{
|
||||||
TexturePtr texture = TextureCache::instance().AddOrGetTexture(res);
|
TexturePtr texture = TextureCache::Instance().AddOrGetTexture(res);
|
||||||
if (texture->IsValid())
|
if (texture->IsValid())
|
||||||
{
|
{
|
||||||
SetTexture(texture);
|
SetTexture(texture);
|
||||||
|
|
@ -71,4 +69,4 @@ namespace kiwano
|
||||||
crop_rect_.right_bottom.y = texture_->GetHeight();
|
crop_rect_.right_bottom.y = texture_->GetHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/ObjectBase.h>
|
#include <kiwano/core/ObjectBase.h>
|
||||||
#include <kiwano/renderer/Texture.h>
|
#include <kiwano/render/Texture.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -30,8 +30,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief ͼÏñÖ¡
|
* @brief ͼÏñÖ¡
|
||||||
*/
|
*/
|
||||||
class KGE_API Frame
|
class KGE_API Frame : public virtual ObjectBase
|
||||||
: public ObjectBase
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -91,11 +90,32 @@ namespace kiwano
|
||||||
Rect crop_rect_;
|
Rect crop_rect_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool Frame::IsValid() const { return texture_ && texture_->IsValid(); }
|
inline bool Frame::IsValid() const
|
||||||
inline float Frame::GetWidth() const { return crop_rect_.GetWidth(); }
|
{
|
||||||
inline float Frame::GetHeight() const { return crop_rect_.GetHeight(); }
|
return texture_ && texture_->IsValid();
|
||||||
inline Size Frame::GetSize() const { return crop_rect_.GetSize(); }
|
|
||||||
inline Point Frame::GetCropPoint() const { return crop_rect_.GetLeftTop(); }
|
|
||||||
inline Rect const& Frame::GetCropRect() const { return crop_rect_; }
|
|
||||||
inline TexturePtr Frame::GetTexture() const { return texture_; }
|
|
||||||
}
|
}
|
||||||
|
inline float Frame::GetWidth() const
|
||||||
|
{
|
||||||
|
return crop_rect_.GetWidth();
|
||||||
|
}
|
||||||
|
inline float Frame::GetHeight() const
|
||||||
|
{
|
||||||
|
return crop_rect_.GetHeight();
|
||||||
|
}
|
||||||
|
inline Size Frame::GetSize() const
|
||||||
|
{
|
||||||
|
return crop_rect_.GetSize();
|
||||||
|
}
|
||||||
|
inline Point Frame::GetCropPoint() const
|
||||||
|
{
|
||||||
|
return crop_rect_.GetLeftTop();
|
||||||
|
}
|
||||||
|
inline Rect const& Frame::GetCropRect() const
|
||||||
|
{
|
||||||
|
return crop_rect_;
|
||||||
|
}
|
||||||
|
inline TexturePtr Frame::GetTexture() const
|
||||||
|
{
|
||||||
|
return texture_;
|
||||||
|
}
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -23,18 +23,14 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
FrameSequence::FrameSequence()
|
FrameSequence::FrameSequence() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameSequence::FrameSequence(Vector<FramePtr> const& frames)
|
FrameSequence::FrameSequence(Vector<FramePtr> const& frames)
|
||||||
{
|
{
|
||||||
this->AddFrames(frames);
|
this->AddFrames(frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameSequence::~FrameSequence()
|
FrameSequence::~FrameSequence() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FrameSequence::AddFrame(FramePtr frame)
|
void FrameSequence::AddFrame(FramePtr frame)
|
||||||
{
|
{
|
||||||
|
|
@ -98,4 +94,4 @@ namespace kiwano
|
||||||
return frame_seq;
|
return frame_seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/common.h>
|
|
||||||
#include <kiwano/core/time.h>
|
|
||||||
#include <kiwano/2d/Frame.h>
|
#include <kiwano/2d/Frame.h>
|
||||||
|
#include <kiwano/core/Common.h>
|
||||||
|
#include <kiwano/core/Time.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -31,8 +31,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief ÐòÁÐÖ¡
|
* @brief ÐòÁÐÖ¡
|
||||||
*/
|
*/
|
||||||
class KGE_API FrameSequence
|
class KGE_API FrameSequence : public virtual ObjectBase
|
||||||
: public ObjectBase
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -80,4 +79,4 @@ namespace kiwano
|
||||||
private:
|
private:
|
||||||
Vector<FramePtr> frames_;
|
Vector<FramePtr> frames_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/GifSprite.h>
|
#include <kiwano/2d/GifSprite.h>
|
||||||
#include <kiwano/renderer/TextureCache.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/TextureCache.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -34,13 +34,13 @@ namespace kiwano
|
||||||
|
|
||||||
bool GifSprite::Load(String const& file_path)
|
bool GifSprite::Load(String const& file_path)
|
||||||
{
|
{
|
||||||
GifImagePtr image = TextureCache::instance().AddOrGetGifImage(file_path);
|
GifImagePtr image = TextureCache::Instance().AddOrGetGifImage(file_path);
|
||||||
return Load(image);
|
return Load(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GifSprite::Load(Resource const& res)
|
bool GifSprite::Load(Resource const& res)
|
||||||
{
|
{
|
||||||
GifImagePtr image = TextureCache::instance().AddOrGetGifImage(res);
|
GifImagePtr image = TextureCache::Instance().AddOrGetGifImage(res);
|
||||||
return Load(image);
|
return Load(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace kiwano
|
||||||
|
|
||||||
if (!frame_rt_)
|
if (!frame_rt_)
|
||||||
{
|
{
|
||||||
Renderer::instance().CreateTextureRenderTarget(frame_rt_);
|
Renderer::Instance().CreateTextureRenderTarget(frame_rt_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gif_->GetFramesCount() > 0)
|
if (gif_->GetFramesCount() > 0)
|
||||||
|
|
@ -70,13 +70,13 @@ namespace kiwano
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GifSprite::OnRender(RenderTarget* rt)
|
void GifSprite::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
if (frame_to_render_ && CheckVisibilty(rt))
|
if (frame_to_render_ && CheckVisibility(ctx))
|
||||||
{
|
{
|
||||||
PrepareToRender(rt);
|
PrepareToRender(ctx);
|
||||||
|
|
||||||
rt->DrawTexture(*frame_to_render_, &frame_.rect, nullptr);
|
ctx.DrawTexture(*frame_to_render_, &frame_.rect, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,7 +206,8 @@ namespace kiwano
|
||||||
if (!saved_frame_)
|
if (!saved_frame_)
|
||||||
{
|
{
|
||||||
saved_frame_ = new Texture;
|
saved_frame_ = new Texture;
|
||||||
frame_rt_->CreateTexture(*saved_frame_, frame_to_be_saved->GetSizeInPixels(), frame_to_be_saved->GetPixelFormat());
|
frame_rt_->CreateTexture(*saved_frame_, frame_to_be_saved->GetSizeInPixels(),
|
||||||
|
frame_to_be_saved->GetPixelFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
saved_frame_->CopyFrom(frame_to_be_saved);
|
saved_frame_->CopyFrom(frame_to_be_saved);
|
||||||
|
|
@ -240,4 +241,4 @@ namespace kiwano
|
||||||
return frame_rt_->EndDraw();
|
return frame_rt_->EndDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/core/Resource.h>
|
#include <kiwano/core/Resource.h>
|
||||||
#include <kiwano/renderer/RenderTarget.h>
|
#include <kiwano/render/GifImage.h>
|
||||||
#include <kiwano/renderer/GifImage.h>
|
#include <kiwano/render/RenderContext.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -37,8 +37,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief GIF ¾«Áé
|
* @brief GIF ¾«Áé
|
||||||
*/
|
*/
|
||||||
class KGE_API GifSprite
|
class KGE_API GifSprite : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -98,7 +97,7 @@ namespace kiwano
|
||||||
/// @brief »ñÈ¡ GIF ͼƬ
|
/// @brief »ñÈ¡ GIF ͼƬ
|
||||||
GifImagePtr GetGifImage() const;
|
GifImagePtr GetGifImage() const;
|
||||||
|
|
||||||
void OnRender(RenderTarget* rt) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Update(Duration dt) override;
|
void Update(Duration dt) override;
|
||||||
|
|
@ -147,24 +146,48 @@ namespace kiwano
|
||||||
GifImage::Frame frame_;
|
GifImage::Frame frame_;
|
||||||
TexturePtr saved_frame_;
|
TexturePtr saved_frame_;
|
||||||
TexturePtr frame_to_render_;
|
TexturePtr frame_to_render_;
|
||||||
TextureRenderTargetPtr frame_rt_;
|
TextureRenderContextPtr frame_rt_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline void GifSprite::SetLoopCount(int loops) { total_loop_count_ = loops; }
|
inline void GifSprite::SetLoopCount(int loops)
|
||||||
|
{
|
||||||
inline void GifSprite::SetLoopDoneCallback(LoopDoneCallback const& cb) { loop_cb_ = cb; }
|
total_loop_count_ = loops;
|
||||||
|
|
||||||
inline void GifSprite::SetDoneCallback(DoneCallback const& cb) { done_cb_ = cb; }
|
|
||||||
|
|
||||||
inline GifSprite::LoopDoneCallback GifSprite::GetLoopDoneCallback() const { return loop_cb_; }
|
|
||||||
|
|
||||||
inline GifSprite::DoneCallback GifSprite::GetDoneCallback() const { return done_cb_; }
|
|
||||||
|
|
||||||
inline GifImagePtr GifSprite::GetGifImage() const { return gif_; }
|
|
||||||
|
|
||||||
inline bool GifSprite::IsLastFrame() const { return (next_index_ == 0); }
|
|
||||||
|
|
||||||
inline bool GifSprite::EndOfAnimation() const { return IsLastFrame() && loop_count_ == total_loop_count_ + 1; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void GifSprite::SetLoopDoneCallback(LoopDoneCallback const& cb)
|
||||||
|
{
|
||||||
|
loop_cb_ = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GifSprite::SetDoneCallback(DoneCallback const& cb)
|
||||||
|
{
|
||||||
|
done_cb_ = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GifSprite::LoopDoneCallback GifSprite::GetLoopDoneCallback() const
|
||||||
|
{
|
||||||
|
return loop_cb_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GifSprite::DoneCallback GifSprite::GetDoneCallback() const
|
||||||
|
{
|
||||||
|
return done_cb_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GifImagePtr GifSprite::GetGifImage() const
|
||||||
|
{
|
||||||
|
return gif_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool GifSprite::IsLastFrame() const
|
||||||
|
{
|
||||||
|
return (next_index_ == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool GifSprite::EndOfAnimation() const
|
||||||
|
{
|
||||||
|
return IsLastFrame() && loop_count_ == total_loop_count_ + 1;
|
||||||
|
}
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Layer.h>
|
#include <kiwano/2d/Layer.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -29,9 +29,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer::~Layer()
|
Layer::~Layer() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::SetClipRect(Rect const& clip_rect)
|
void Layer::SetClipRect(Rect const& clip_rect)
|
||||||
{
|
{
|
||||||
|
|
@ -54,37 +52,31 @@ namespace kiwano
|
||||||
area_.SetMaskTransform(transform);
|
area_.SetMaskTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::Dispatch(Event& evt)
|
bool Layer::DispatchEvent(Event* evt)
|
||||||
{
|
{
|
||||||
if (!IsVisible())
|
if (!IsVisible())
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
if (!swallow_)
|
if (swallow_)
|
||||||
{
|
{
|
||||||
ActorPtr prev;
|
return EventDispatcher::DispatchEvent(evt);
|
||||||
for (auto child = GetAllChildren().last_item(); child; child = prev)
|
}
|
||||||
|
return Actor::DispatchEvent(evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::Render(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
prev = child->prev_item();
|
ctx.PushLayer(area_);
|
||||||
child->Dispatch(evt);
|
|
||||||
}
|
Actor::Render(ctx);
|
||||||
|
|
||||||
|
ctx.PopLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher::Dispatch(evt);
|
bool Layer::CheckVisibility(RenderContext& ctx) const
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::Render(RenderTarget* rt)
|
|
||||||
{
|
|
||||||
rt->PushLayer(area_);
|
|
||||||
|
|
||||||
Actor::Render(rt);
|
|
||||||
|
|
||||||
rt->PopLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Layer::CheckVisibilty(RenderTarget* rt) const
|
|
||||||
{
|
{
|
||||||
// Do not need to render Layer
|
// Do not need to render Layer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/renderer/LayerArea.h>
|
#include <kiwano/render/LayerArea.h>
|
||||||
#include <kiwano/renderer/RenderTarget.h>
|
#include <kiwano/render/RenderContext.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -36,8 +36,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 图层
|
* @brief 图层
|
||||||
*/
|
*/
|
||||||
class KGE_API Layer
|
class KGE_API Layer : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Layer();
|
Layer();
|
||||||
|
|
@ -82,12 +81,12 @@ namespace kiwano
|
||||||
/// @brief 获取图层区域
|
/// @brief 获取图层区域
|
||||||
LayerArea const& GetArea() const;
|
LayerArea const& GetArea() const;
|
||||||
|
|
||||||
void Dispatch(Event& evt) override;
|
bool DispatchEvent(Event* evt) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Render(RenderTarget* rt) override;
|
void Render(RenderContext& ctx) override;
|
||||||
|
|
||||||
bool CheckVisibilty(RenderTarget* rt) const override;
|
bool CheckVisibility(RenderContext& ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool swallow_;
|
bool swallow_;
|
||||||
|
|
@ -96,12 +95,23 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline bool Layer::IsSwallowEventsEnabled() const { return swallow_; }
|
inline bool Layer::IsSwallowEventsEnabled() const
|
||||||
|
{
|
||||||
inline void Layer::SetSwallowEvents(bool enabled) { swallow_ = enabled; }
|
return swallow_;
|
||||||
|
|
||||||
inline void Layer::SetArea(LayerArea const& area) { area_ = area; }
|
|
||||||
|
|
||||||
inline LayerArea const& Layer::GetArea() const { return area_; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Layer::SetSwallowEvents(bool enabled)
|
||||||
|
{
|
||||||
|
swallow_ = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Layer::SetArea(LayerArea const& area)
|
||||||
|
{
|
||||||
|
area_ = area;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LayerArea const& Layer::GetArea() const
|
||||||
|
{
|
||||||
|
return area_;
|
||||||
|
}
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,17 @@
|
||||||
|
|
||||||
#include <kiwano/2d/ShapeActor.h>
|
#include <kiwano/2d/ShapeActor.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
ShapeActor::ShapeActor()
|
ShapeActor::ShapeActor()
|
||||||
: stroke_width_(1.f)
|
: stroke_width_(1.f)
|
||||||
, stroke_style_(StrokeStyle::Miter)
|
, stroke_style_()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeActor::~ShapeActor()
|
ShapeActor::~ShapeActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Rect ShapeActor::GetBounds() const
|
Rect ShapeActor::GetBounds() const
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +55,7 @@ namespace kiwano
|
||||||
stroke_width_ = std::max(width, 0.f);
|
stroke_width_ = std::max(width, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeActor::SetStrokeStyle(StrokeStyle stroke_style)
|
void ShapeActor::SetStrokeStyle(const StrokeStyle& stroke_style)
|
||||||
{
|
{
|
||||||
stroke_style_ = stroke_style;
|
stroke_style_ = stroke_style;
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +75,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeActor::OnRender(RenderTarget* rt)
|
void ShapeActor::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
// Create default brush
|
// Create default brush
|
||||||
if (!fill_brush_)
|
if (!fill_brush_)
|
||||||
|
|
@ -92,29 +90,25 @@ namespace kiwano
|
||||||
stroke_brush_->SetColor(Color::Transparent);
|
stroke_brush_->SetColor(Color::Transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
rt->SetCurrentBrush(stroke_brush_);
|
ctx.SetCurrentBrush(stroke_brush_);
|
||||||
rt->DrawGeometry(geo_, stroke_width_ * 2 /* twice width for widening */, stroke_style_);
|
ctx.DrawGeometry(geo_, stroke_width_ * 2 /* twice width for widening */, stroke_style_);
|
||||||
|
|
||||||
rt->SetCurrentBrush(fill_brush_);
|
ctx.SetCurrentBrush(fill_brush_);
|
||||||
rt->FillGeometry(geo_);
|
ctx.FillGeometry(geo_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShapeActor::CheckVisibilty(RenderTarget* rt) const
|
bool ShapeActor::CheckVisibility(RenderContext& ctx) const
|
||||||
{
|
{
|
||||||
return geo_.IsValid() && Actor::CheckVisibilty(rt);
|
return geo_.IsValid() && Actor::CheckVisibility(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// LineActor
|
// LineActor
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
LineActor::LineActor()
|
LineActor::LineActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LineActor::~LineActor()
|
LineActor::~LineActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LineActor::SetLine(Point const& begin, Point const& end)
|
void LineActor::SetLine(Point const& begin, Point const& end)
|
||||||
{
|
{
|
||||||
|
|
@ -126,18 +120,13 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// RectActor
|
// RectActor
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
RectActor::RectActor()
|
RectActor::RectActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RectActor::~RectActor()
|
RectActor::~RectActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void RectActor::SetRectSize(Size const& size)
|
void RectActor::SetRectSize(Size const& size)
|
||||||
{
|
{
|
||||||
|
|
@ -148,18 +137,13 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// RoundRectActor
|
// RoundRectActor
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
RoundRectActor::RoundRectActor()
|
RoundRectActor::RoundRectActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RoundRectActor::~RoundRectActor()
|
RoundRectActor::~RoundRectActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void RoundRectActor::SetRadius(Vec2 const& radius)
|
void RoundRectActor::SetRadius(Vec2 const& radius)
|
||||||
{
|
{
|
||||||
|
|
@ -181,7 +165,6 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// CircleActor
|
// CircleActor
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -191,9 +174,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleActor::~CircleActor()
|
CircleActor::~CircleActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CircleActor::SetRadius(float radius)
|
void CircleActor::SetRadius(float radius)
|
||||||
{
|
{
|
||||||
|
|
@ -204,18 +185,13 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// EllipseActor
|
// EllipseActor
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
EllipseActor::EllipseActor()
|
EllipseActor::EllipseActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
EllipseActor::~EllipseActor()
|
EllipseActor::~EllipseActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void EllipseActor::SetRadius(Vec2 const& radius)
|
void EllipseActor::SetRadius(Vec2 const& radius)
|
||||||
{
|
{
|
||||||
|
|
@ -226,45 +202,30 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// PolygonActor
|
// PolygonActor
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
PolygonActor::PolygonActor()
|
PolygonActor::PolygonActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PolygonActor::~PolygonActor()
|
PolygonActor::~PolygonActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PolygonActor::SetVertices(Vector<Point> const& points)
|
void PolygonActor::SetVertices(Vector<Point> const& points)
|
||||||
{
|
{
|
||||||
if (points.size() > 1)
|
if (points.size() > 1)
|
||||||
{
|
{
|
||||||
SetGeometry(
|
SetGeometry(
|
||||||
GeometrySink()
|
GeometrySink().BeginPath(points[0]).AddLines(&points[1], points.size() - 1).EndPath(true).GetGeometry());
|
||||||
.BeginPath(points[0])
|
|
||||||
.AddLines(&points[1], points.size() - 1)
|
|
||||||
.EndPath(true)
|
|
||||||
.GetGeometry()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// PathShapeActor
|
// PathShapeActor
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
PathShapeActor::PathShapeActor()
|
PathShapeActor::PathShapeActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PathShapeActor::~PathShapeActor()
|
PathShapeActor::~PathShapeActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathShapeActor::BeginPath(Point const& begin_pos)
|
void PathShapeActor::BeginPath(Point const& begin_pos)
|
||||||
{
|
{
|
||||||
|
|
@ -307,4 +268,4 @@ namespace kiwano
|
||||||
SetGeometry(Geometry());
|
SetGeometry(Geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/renderer/Brush.h>
|
#include <kiwano/render/Brush.h>
|
||||||
#include <kiwano/renderer/Geometry.h>
|
#include <kiwano/render/Geometry.h>
|
||||||
#include <kiwano/renderer/GeometrySink.h>
|
#include <kiwano/render/GeometrySink.h>
|
||||||
#include <kiwano/renderer/StrokeStyle.h>
|
#include <kiwano/render/StrokeStyle.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -45,8 +45,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 二维形状角色
|
* @brief 二维形状角色
|
||||||
*/
|
*/
|
||||||
class KGE_API ShapeActor
|
class KGE_API ShapeActor : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -69,7 +68,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取线条样式
|
/// @brief 获取线条样式
|
||||||
StrokeStyle SetStrokeStyle() const;
|
const StrokeStyle& GetStrokeStyle() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取形状
|
/// @brief 获取形状
|
||||||
|
|
@ -113,16 +112,16 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置线条样式
|
/// @brief 设置线条样式
|
||||||
void SetStrokeStyle(StrokeStyle stroke_style);
|
void SetStrokeStyle(const StrokeStyle& stroke_style);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置几何形状
|
/// @brief 设置几何形状
|
||||||
void SetGeometry(Geometry const& geometry);
|
void SetGeometry(Geometry const& geometry);
|
||||||
|
|
||||||
void OnRender(RenderTarget* rt) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CheckVisibilty(RenderTarget* rt) const override;
|
bool CheckVisibility(RenderContext& ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BrushPtr fill_brush_;
|
BrushPtr fill_brush_;
|
||||||
|
|
@ -133,11 +132,9 @@ namespace kiwano
|
||||||
Geometry geo_;
|
Geometry geo_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 线段图形角色
|
/// @brief 线段图形角色
|
||||||
class KGE_API LineActor
|
class KGE_API LineActor : public ShapeActor
|
||||||
: public ShapeActor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LineActor();
|
LineActor();
|
||||||
|
|
@ -173,11 +170,9 @@ namespace kiwano
|
||||||
Point end_;
|
Point end_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 矩形角色
|
/// @brief 矩形角色
|
||||||
class KGE_API RectActor
|
class KGE_API RectActor : public ShapeActor
|
||||||
: public ShapeActor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RectActor();
|
RectActor();
|
||||||
|
|
@ -197,12 +192,9 @@ namespace kiwano
|
||||||
Size rect_size_;
|
Size rect_size_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 圆角矩形角色
|
/// @brief 圆角矩形角色
|
||||||
class KGE_API RoundRectActor
|
class KGE_API RoundRectActor : public ShapeActor
|
||||||
: public ShapeActor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RoundRectActor();
|
RoundRectActor();
|
||||||
|
|
@ -238,11 +230,9 @@ namespace kiwano
|
||||||
Vec2 radius_;
|
Vec2 radius_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 圆形角色
|
/// @brief 圆形角色
|
||||||
class KGE_API CircleActor
|
class KGE_API CircleActor : public ShapeActor
|
||||||
: public ShapeActor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CircleActor();
|
CircleActor();
|
||||||
|
|
@ -262,11 +252,9 @@ namespace kiwano
|
||||||
float radius_;
|
float radius_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 椭圆角色
|
/// @brief 椭圆角色
|
||||||
class KGE_API EllipseActor
|
class KGE_API EllipseActor : public ShapeActor
|
||||||
: public ShapeActor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EllipseActor();
|
EllipseActor();
|
||||||
|
|
@ -286,11 +274,9 @@ namespace kiwano
|
||||||
Vec2 radius_;
|
Vec2 radius_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 多边形角色
|
/// @brief 多边形角色
|
||||||
class KGE_API PolygonActor
|
class KGE_API PolygonActor : public ShapeActor
|
||||||
: public ShapeActor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PolygonActor();
|
PolygonActor();
|
||||||
|
|
@ -303,11 +289,9 @@ namespace kiwano
|
||||||
void SetVertices(Vector<Point> const& points);
|
void SetVertices(Vector<Point> const& points);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 路径图形角色
|
/// @brief 路径图形角色
|
||||||
class KGE_API PathShapeActor
|
class KGE_API PathShapeActor : public ShapeActor
|
||||||
: public ShapeActor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PathShapeActor();
|
PathShapeActor();
|
||||||
|
|
@ -378,25 +362,73 @@ namespace kiwano
|
||||||
fill_brush_->SetColor(color);
|
fill_brush_->SetColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ShapeActor::SetFillBrush(BrushPtr brush) { fill_brush_ = brush; }
|
inline void ShapeActor::SetFillBrush(BrushPtr brush)
|
||||||
inline void ShapeActor::SetStrokeBrush(BrushPtr brush) { stroke_brush_ = brush; }
|
{
|
||||||
inline BrushPtr ShapeActor::GetFillBrush() const { return fill_brush_; }
|
fill_brush_ = brush;
|
||||||
inline BrushPtr ShapeActor::GetStrokeBrush() const { return stroke_brush_; }
|
|
||||||
inline float ShapeActor::GetStrokeWidth() const { return stroke_width_; }
|
|
||||||
inline StrokeStyle ShapeActor::SetStrokeStyle() const { return stroke_style_; }
|
|
||||||
inline Geometry ShapeActor::GetGeometry() const { return geo_; }
|
|
||||||
|
|
||||||
inline Point const& LineActor::GetBeginPoint() const { return begin_; }
|
|
||||||
inline Point const& LineActor::GetEndPoint() const { return end_; }
|
|
||||||
inline void LineActor::SetBeginPoint(Point const& begin) { SetLine(begin, end_); }
|
|
||||||
inline void LineActor::SetEndPoint(Point const& end) { SetLine(begin_, end); }
|
|
||||||
|
|
||||||
inline Size const& RectActor::GetRectSize() const { return rect_size_; }
|
|
||||||
|
|
||||||
inline Vec2 RoundRectActor::GetRadius() const { return radius_; }
|
|
||||||
inline Size RoundRectActor::GetRectSize() const { return GetSize(); }
|
|
||||||
|
|
||||||
inline float CircleActor::GetRadius() const { return radius_; }
|
|
||||||
|
|
||||||
inline Vec2 EllipseActor::GetRadius() const { return radius_; }
|
|
||||||
}
|
}
|
||||||
|
inline void ShapeActor::SetStrokeBrush(BrushPtr brush)
|
||||||
|
{
|
||||||
|
stroke_brush_ = brush;
|
||||||
|
}
|
||||||
|
inline BrushPtr ShapeActor::GetFillBrush() const
|
||||||
|
{
|
||||||
|
return fill_brush_;
|
||||||
|
}
|
||||||
|
inline BrushPtr ShapeActor::GetStrokeBrush() const
|
||||||
|
{
|
||||||
|
return stroke_brush_;
|
||||||
|
}
|
||||||
|
inline float ShapeActor::GetStrokeWidth() const
|
||||||
|
{
|
||||||
|
return stroke_width_;
|
||||||
|
}
|
||||||
|
inline const StrokeStyle& ShapeActor::GetStrokeStyle() const
|
||||||
|
{
|
||||||
|
return stroke_style_;
|
||||||
|
}
|
||||||
|
inline Geometry ShapeActor::GetGeometry() const
|
||||||
|
{
|
||||||
|
return geo_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Point const& LineActor::GetBeginPoint() const
|
||||||
|
{
|
||||||
|
return begin_;
|
||||||
|
}
|
||||||
|
inline Point const& LineActor::GetEndPoint() const
|
||||||
|
{
|
||||||
|
return end_;
|
||||||
|
}
|
||||||
|
inline void LineActor::SetBeginPoint(Point const& begin)
|
||||||
|
{
|
||||||
|
SetLine(begin, end_);
|
||||||
|
}
|
||||||
|
inline void LineActor::SetEndPoint(Point const& end)
|
||||||
|
{
|
||||||
|
SetLine(begin_, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Size const& RectActor::GetRectSize() const
|
||||||
|
{
|
||||||
|
return rect_size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vec2 RoundRectActor::GetRadius() const
|
||||||
|
{
|
||||||
|
return radius_;
|
||||||
|
}
|
||||||
|
inline Size RoundRectActor::GetRectSize() const
|
||||||
|
{
|
||||||
|
return GetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float CircleActor::GetRadius() const
|
||||||
|
{
|
||||||
|
return radius_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vec2 EllipseActor::GetRadius() const
|
||||||
|
{
|
||||||
|
return radius_;
|
||||||
|
}
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,13 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/Sprite.h>
|
#include <kiwano/2d/Sprite.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
Sprite::Sprite()
|
Sprite::Sprite() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Sprite::~Sprite()
|
Sprite::~Sprite() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Sprite::Load(String const& file_path)
|
bool Sprite::Load(String const& file_path)
|
||||||
{
|
{
|
||||||
|
|
@ -74,13 +70,13 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::OnRender(RenderTarget* rt)
|
void Sprite::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
rt->DrawTexture(*frame_->GetTexture(), &frame_->GetCropRect(), &GetBounds());
|
ctx.DrawTexture(*frame_->GetTexture(), &frame_->GetCropRect(), &GetBounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sprite::CheckVisibilty(RenderTarget* rt) const
|
bool Sprite::CheckVisibility(RenderContext& ctx) const
|
||||||
{
|
{
|
||||||
return frame_ && frame_->IsValid() && Actor::CheckVisibilty(rt);
|
return frame_ && frame_->IsValid() && Actor::CheckVisibility(ctx);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief ¾«Áé
|
* @brief ¾«Áé
|
||||||
*/
|
*/
|
||||||
class KGE_API Sprite
|
class KGE_API Sprite : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Sprite();
|
Sprite();
|
||||||
|
|
@ -67,10 +66,10 @@ namespace kiwano
|
||||||
/// @param[in] frame ͼÏñÖ¡
|
/// @param[in] frame ͼÏñÖ¡
|
||||||
void SetFrame(FramePtr frame);
|
void SetFrame(FramePtr frame);
|
||||||
|
|
||||||
void OnRender(RenderTarget* rt) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CheckVisibilty(RenderTarget* rt) const override;
|
bool CheckVisibility(RenderContext& ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FramePtr frame_;
|
FramePtr frame_;
|
||||||
|
|
@ -78,6 +77,8 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline FramePtr Sprite::GetFrame() const { return frame_; }
|
inline FramePtr Sprite::GetFrame() const
|
||||||
|
{
|
||||||
|
return frame_;
|
||||||
}
|
}
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include <kiwano/2d/Stage.h>
|
#include <kiwano/2d/Stage.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -29,12 +29,10 @@ namespace kiwano
|
||||||
SetStage(this);
|
SetStage(this);
|
||||||
|
|
||||||
SetAnchor(Vec2{ 0, 0 });
|
SetAnchor(Vec2{ 0, 0 });
|
||||||
SetSize(Renderer::instance().GetOutputSize());
|
SetSize(Renderer::Instance().GetOutputSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
Stage::~Stage()
|
Stage::~Stage() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stage::OnEnter()
|
void Stage::OnEnter()
|
||||||
{
|
{
|
||||||
|
|
@ -46,9 +44,9 @@ namespace kiwano
|
||||||
KGE_SYS_LOG(L"Stage exited");
|
KGE_SYS_LOG(L"Stage exited");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stage::RenderBorder(RenderTarget* rt)
|
void Stage::RenderBorder(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
rt->SetBrushOpacity(1.0f);
|
ctx.SetBrushOpacity(GetDisplayedOpacity());
|
||||||
|
|
||||||
if (!border_fill_brush_)
|
if (!border_fill_brush_)
|
||||||
{
|
{
|
||||||
|
|
@ -62,7 +60,7 @@ namespace kiwano
|
||||||
border_stroke_brush_->SetColor(Color(Color::Red, .8f));
|
border_stroke_brush_->SetColor(Color(Color::Red, .8f));
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor::RenderBorder(rt);
|
Actor::RenderBorder(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/renderer/Brush.h>
|
#include <kiwano/render/Brush.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -37,8 +37,7 @@ namespace kiwano
|
||||||
* @details 舞台是所有角色的载体,是导演直接控制的对象
|
* @details 舞台是所有角色的载体,是导演直接控制的对象
|
||||||
* @see kiwano::Actor kiwano::Director
|
* @see kiwano::Actor kiwano::Director
|
||||||
*/
|
*/
|
||||||
class KGE_API Stage
|
class KGE_API Stage : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
friend class Transition;
|
friend class Transition;
|
||||||
friend class Director;
|
friend class Director;
|
||||||
|
|
@ -77,7 +76,7 @@ namespace kiwano
|
||||||
protected:
|
protected:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 绘制所有子角色的边界
|
/// @brief 绘制所有子角色的边界
|
||||||
void RenderBorder(RenderTarget* rt) override;
|
void RenderBorder(RenderContext& ctx) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BrushPtr border_fill_brush_;
|
BrushPtr border_fill_brush_;
|
||||||
|
|
@ -105,5 +104,4 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
border_stroke_brush_ = brush;
|
border_stroke_brush_ = brush;
|
||||||
}
|
}
|
||||||
|
} // namespace kiwano
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include <kiwano/2d/TextActor.h>
|
#include <kiwano/2d/TextActor.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +40,7 @@ namespace kiwano
|
||||||
text_default_style.fill_brush->SetColor(Color::White);
|
text_default_style.fill_brush->SetColor(Color::White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
void TextActor::SetDefaultStyle(TextStyle const& style)
|
void TextActor::SetDefaultStyle(TextStyle const& style)
|
||||||
{
|
{
|
||||||
|
|
@ -49,6 +49,7 @@ namespace kiwano
|
||||||
|
|
||||||
const TextStyle& TextActor::GetDefaultStyle()
|
const TextStyle& TextActor::GetDefaultStyle()
|
||||||
{
|
{
|
||||||
|
InitDefaultTextStyle();
|
||||||
return text_default_style;
|
return text_default_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
|
|
||||||
TextActor::TextActor(String const& text)
|
TextActor::TextActor(String const& text)
|
||||||
: TextActor(text, text_default_style)
|
: TextActor(text, GetDefaultStyle())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,19 +67,15 @@ namespace kiwano
|
||||||
: show_underline_(false)
|
: show_underline_(false)
|
||||||
, show_strikethrough_(false)
|
, show_strikethrough_(false)
|
||||||
{
|
{
|
||||||
InitDefaultTextStyle();
|
|
||||||
|
|
||||||
SetText(text);
|
SetText(text);
|
||||||
SetStyle(style);
|
SetStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextActor::~TextActor()
|
TextActor::~TextActor() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextActor::OnRender(RenderTarget* rt)
|
void TextActor::OnRender(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
rt->DrawTextLayout(text_layout_);
|
ctx.DrawTextLayout(text_layout_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextActor::OnUpdate(Duration dt)
|
void TextActor::OnUpdate(Duration dt)
|
||||||
|
|
@ -91,6 +88,11 @@ namespace kiwano
|
||||||
if (text_layout_.IsDirty())
|
if (text_layout_.IsDirty())
|
||||||
{
|
{
|
||||||
text_layout_.Update();
|
text_layout_.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text_layout_.GetDirtyFlag() & TextLayout::DirtyFlag::Updated)
|
||||||
|
{
|
||||||
|
text_layout_.SetDirtyFlag(TextLayout::DirtyFlag::Clean);
|
||||||
|
|
||||||
if (show_underline_)
|
if (show_underline_)
|
||||||
text_layout_.SetUnderline(true, 0, text_layout_.GetText().length());
|
text_layout_.SetUnderline(true, 0, text_layout_.GetText().length());
|
||||||
|
|
@ -102,14 +104,14 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextActor::CheckVisibilty(RenderTarget* rt) const
|
bool TextActor::CheckVisibility(RenderContext& ctx) const
|
||||||
{
|
{
|
||||||
return text_layout_.IsValid() && Actor::CheckVisibilty(rt);
|
return text_layout_.IsValid() && Actor::CheckVisibility(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextActor::SetFillColor(Color const& color)
|
void TextActor::SetFillColor(Color const& color)
|
||||||
{
|
{
|
||||||
if (!text_layout_.GetFillBrush())
|
if (!text_layout_.GetFillBrush() || text_layout_.GetFillBrush() == GetDefaultStyle().fill_brush)
|
||||||
{
|
{
|
||||||
BrushPtr brush = new Brush;
|
BrushPtr brush = new Brush;
|
||||||
text_layout_.SetFillBrush(brush);
|
text_layout_.SetFillBrush(brush);
|
||||||
|
|
@ -119,11 +121,12 @@ namespace kiwano
|
||||||
|
|
||||||
void TextActor::SetOutlineColor(Color const& outline_color)
|
void TextActor::SetOutlineColor(Color const& outline_color)
|
||||||
{
|
{
|
||||||
if (!text_layout_.GetOutlineBrush())
|
if (!text_layout_.GetOutlineBrush() || text_layout_.GetOutlineBrush() == GetDefaultStyle().outline_brush)
|
||||||
{
|
{
|
||||||
BrushPtr brush = new Brush;
|
BrushPtr brush = new Brush;
|
||||||
text_layout_.SetOutlineBrush(brush);
|
text_layout_.SetOutlineBrush(brush);
|
||||||
}
|
}
|
||||||
text_layout_.GetOutlineBrush()->SetColor(outline_color);
|
text_layout_.GetOutlineBrush()->SetColor(outline_color);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/renderer/Color.h>
|
#include <kiwano/render/Color.h>
|
||||||
#include <kiwano/renderer/TextLayout.h>
|
#include <kiwano/render/TextLayout.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -36,8 +36,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 文本角色
|
* @brief 文本角色
|
||||||
*/
|
*/
|
||||||
class KGE_API TextActor
|
class KGE_API TextActor : public Actor
|
||||||
: public Actor
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -69,6 +68,10 @@ namespace kiwano
|
||||||
/// @brief 获取文本布局
|
/// @brief 获取文本布局
|
||||||
const TextLayout& GetLayout() const;
|
const TextLayout& GetLayout() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief »ñÈ¡Îı¾²¼¾Ö´óС
|
||||||
|
Size GetLayoutSize() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取填充画刷
|
/// @brief 获取填充画刷
|
||||||
BrushPtr GetFillBrush() const;
|
BrushPtr GetFillBrush() const;
|
||||||
|
|
@ -143,7 +146,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置文字描边线相交样式
|
/// @brief 设置文字描边线相交样式
|
||||||
void SetOutlineStroke(StrokeStyle outline_stroke);
|
void SetOutlineStroke(const StrokeStyle& outline_stroke);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置是否显示下划线(默认值为 false)
|
/// @brief 设置是否显示下划线(默认值为 false)
|
||||||
|
|
@ -166,12 +169,12 @@ namespace kiwano
|
||||||
/// @brief 获取默认文字样式
|
/// @brief 获取默认文字样式
|
||||||
static const TextStyle& GetDefaultStyle();
|
static const TextStyle& GetDefaultStyle();
|
||||||
|
|
||||||
void OnRender(RenderTarget* rt) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
||||||
void OnUpdate(Duration dt) override;
|
void OnUpdate(Duration dt) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CheckVisibilty(RenderTarget* rt) const override;
|
bool CheckVisibility(RenderContext& ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool show_underline_;
|
bool show_underline_;
|
||||||
|
|
@ -201,6 +204,11 @@ namespace kiwano
|
||||||
return text_layout_;
|
return text_layout_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Size TextActor::GetLayoutSize() const
|
||||||
|
{
|
||||||
|
return text_layout_.GetLayoutSize();
|
||||||
|
}
|
||||||
|
|
||||||
inline BrushPtr TextActor::GetFillBrush() const
|
inline BrushPtr TextActor::GetFillBrush() const
|
||||||
{
|
{
|
||||||
return text_layout_.GetFillBrush();
|
return text_layout_.GetFillBrush();
|
||||||
|
|
@ -286,9 +294,8 @@ namespace kiwano
|
||||||
text_layout_.SetOutlineWidth(outline_width);
|
text_layout_.SetOutlineWidth(outline_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TextActor::SetOutlineStroke(StrokeStyle outline_stroke)
|
inline void TextActor::SetOutlineStroke(const StrokeStyle& outline_stroke)
|
||||||
{
|
{
|
||||||
text_layout_.SetOutlineStroke(outline_stroke);
|
text_layout_.SetOutlineStroke(outline_stroke);
|
||||||
}
|
}
|
||||||
|
} // namespace kiwano
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,6 @@ namespace kiwano
|
||||||
|
|
||||||
bool Transform::operator==(Transform const& rhs) const
|
bool Transform::operator==(Transform const& rhs) const
|
||||||
{
|
{
|
||||||
return position == rhs.position &&
|
return position == rhs.position && rotation == rhs.rotation && scale == rhs.scale && skew == rhs.skew;
|
||||||
rotation == rhs.rotation &&
|
|
||||||
scale == rhs.scale &&
|
|
||||||
skew == rhs.skew;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -44,4 +44,4 @@ namespace kiwano
|
||||||
|
|
||||||
bool operator==(const Transform& rhs) const;
|
bool operator==(const Transform& rhs) const;
|
||||||
};
|
};
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/Transition.h>
|
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
#include <kiwano/2d/Stage.h>
|
#include <kiwano/2d/Stage.h>
|
||||||
#include <kiwano/platform/Window.h>
|
#include <kiwano/2d/Transition.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
#include <kiwano/renderer/Renderer.h>
|
#include <kiwano/platform/Window.h>
|
||||||
|
#include <kiwano/render/Renderer.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -44,9 +44,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Transition::~Transition()
|
Transition::~Transition() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Transition::IsDone()
|
bool Transition::IsDone()
|
||||||
{
|
{
|
||||||
|
|
@ -60,7 +58,7 @@ namespace kiwano
|
||||||
|
|
||||||
out_stage_ = prev;
|
out_stage_ = prev;
|
||||||
in_stage_ = next;
|
in_stage_ = next;
|
||||||
window_size_ = Renderer::instance().GetOutputSize();
|
window_size_ = Renderer::Instance().GetOutputSize();
|
||||||
|
|
||||||
if (in_stage_)
|
if (in_stage_)
|
||||||
{
|
{
|
||||||
|
|
@ -91,30 +89,30 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transition::Render(RenderTarget* rt)
|
void Transition::Render(RenderContext& ctx)
|
||||||
{
|
{
|
||||||
if (out_stage_)
|
if (out_stage_)
|
||||||
{
|
{
|
||||||
out_stage_->PrepareToRender(rt);
|
out_stage_->PrepareToRender(ctx);
|
||||||
rt->PushClipRect(Rect{ Point{}, window_size_ });
|
ctx.PushClipRect(Rect{ Point{}, window_size_ });
|
||||||
rt->PushLayer(out_layer_);
|
ctx.PushLayer(out_layer_);
|
||||||
|
|
||||||
out_stage_->Render(rt);
|
out_stage_->Render(ctx);
|
||||||
|
|
||||||
rt->PopLayer();
|
ctx.PopLayer();
|
||||||
rt->PopClipRect();
|
ctx.PopClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_stage_)
|
if (in_stage_)
|
||||||
{
|
{
|
||||||
in_stage_->PrepareToRender(rt);
|
in_stage_->PrepareToRender(ctx);
|
||||||
rt->PushClipRect(Rect{ Point{}, window_size_ });
|
ctx.PushClipRect(Rect{ Point{}, window_size_ });
|
||||||
rt->PushLayer(in_layer_);
|
ctx.PushLayer(in_layer_);
|
||||||
|
|
||||||
in_stage_->Render(rt);
|
in_stage_->Render(ctx);
|
||||||
|
|
||||||
rt->PopLayer();
|
ctx.PopLayer();
|
||||||
rt->PopClipRect();
|
ctx.PopClipRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,27 +144,15 @@ namespace kiwano
|
||||||
|
|
||||||
if (process_ < .5f)
|
if (process_ < .5f)
|
||||||
{
|
{
|
||||||
out_layer_.SetAreaRect(
|
out_layer_.SetAreaRect(Rect(window_size_.x * process_, window_size_.y * process_,
|
||||||
Rect(
|
window_size_.x * (1 - process_), window_size_.y * (1 - process_)));
|
||||||
window_size_.x * process_,
|
|
||||||
window_size_.y * process_,
|
|
||||||
window_size_.x * (1 - process_),
|
|
||||||
window_size_.y * (1 - process_)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out_layer_.SetOpacity(0.f);
|
out_layer_.SetOpacity(0.f);
|
||||||
in_layer_.SetOpacity(1.f);
|
in_layer_.SetOpacity(1.f);
|
||||||
in_layer_.SetAreaRect(
|
in_layer_.SetAreaRect(Rect(window_size_.x * (1 - process_), window_size_.y * (1 - process_),
|
||||||
Rect(
|
window_size_.x * process_, window_size_.y * process_));
|
||||||
window_size_.x * (1 - process_),
|
|
||||||
window_size_.y * (1 - process_),
|
|
||||||
window_size_.x * process_,
|
|
||||||
window_size_.y * process_
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -383,4 +369,4 @@ namespace kiwano
|
||||||
in_stage_->SetAnchor(Vec2{ 0.f, 0.f });
|
in_stage_->SetAnchor(Vec2{ 0.f, 0.f });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/Stage.h>
|
#include <kiwano/2d/Stage.h>
|
||||||
#include <kiwano/renderer/LayerArea.h>
|
#include <kiwano/render/LayerArea.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
class Director;
|
class Director;
|
||||||
class RenderTarget;
|
class RenderContext;
|
||||||
|
|
||||||
KGE_DECLARE_SMART_PTR(Transition);
|
KGE_DECLARE_SMART_PTR(Transition);
|
||||||
KGE_DECLARE_SMART_PTR(FadeTransition);
|
KGE_DECLARE_SMART_PTR(FadeTransition);
|
||||||
|
|
@ -38,8 +38,7 @@ namespace kiwano
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 舞台过渡动画
|
* @brief 舞台过渡动画
|
||||||
*/
|
*/
|
||||||
class KGE_API Transition
|
class KGE_API Transition : public virtual ObjectBase
|
||||||
: public ObjectBase
|
|
||||||
{
|
{
|
||||||
friend class Director;
|
friend class Director;
|
||||||
|
|
||||||
|
|
@ -49,9 +48,7 @@ namespace kiwano
|
||||||
* @brief 构建空的场景过渡动画
|
* @brief 构建空的场景过渡动画
|
||||||
* @param duration 动画时长
|
* @param duration 动画时长
|
||||||
*/
|
*/
|
||||||
explicit Transition(
|
explicit Transition(Duration duration);
|
||||||
Duration duration
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual ~Transition();
|
virtual ~Transition();
|
||||||
|
|
||||||
|
|
@ -68,10 +65,7 @@ namespace kiwano
|
||||||
* @param[in] prev 转出场景
|
* @param[in] prev 转出场景
|
||||||
* @param[in] next 转入场景
|
* @param[in] next 转入场景
|
||||||
*/
|
*/
|
||||||
virtual void Init(
|
virtual void Init(StagePtr prev, StagePtr next);
|
||||||
StagePtr prev,
|
|
||||||
StagePtr next
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
|
|
@ -83,9 +77,9 @@ namespace kiwano
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 渲染过度动画
|
* @brief 渲染过度动画
|
||||||
* @param[in] rt äÖȾĿ±ê
|
* @param[in] ctx äÖȾÉÏÏÂÎÄ
|
||||||
*/
|
*/
|
||||||
virtual void Render(RenderTarget* rt);
|
virtual void Render(RenderContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
|
|
@ -111,14 +105,12 @@ namespace kiwano
|
||||||
LayerArea in_layer_;
|
LayerArea in_layer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 淡入淡出过渡动画
|
* @brief 淡入淡出过渡动画
|
||||||
* @details 前一场景淡出动画结束后,后一场景淡入
|
* @details 前一场景淡出动画结束后,后一场景淡入
|
||||||
*/
|
*/
|
||||||
class FadeTransition
|
class FadeTransition : public Transition
|
||||||
: public Transition
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -126,27 +118,20 @@ namespace kiwano
|
||||||
* @brief 构建淡入淡出过渡动画
|
* @brief 构建淡入淡出过渡动画
|
||||||
* @param duration 动画时长
|
* @param duration 动画时长
|
||||||
*/
|
*/
|
||||||
explicit FadeTransition(
|
explicit FadeTransition(Duration duration);
|
||||||
Duration duration
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Update(Duration dt) override;
|
void Update(Duration dt) override;
|
||||||
|
|
||||||
virtual void Init(
|
virtual void Init(StagePtr prev, StagePtr next) override;
|
||||||
StagePtr prev,
|
|
||||||
StagePtr next
|
|
||||||
) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 渐变过渡动画
|
* @brief 渐变过渡动画
|
||||||
* @details 前一场景淡出动画的同时,后一场景淡入
|
* @details 前一场景淡出动画的同时,后一场景淡入
|
||||||
*/
|
*/
|
||||||
class EmergeTransition
|
class EmergeTransition : public Transition
|
||||||
: public Transition
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -154,27 +139,20 @@ namespace kiwano
|
||||||
* @brief 构建渐变过渡动画
|
* @brief 构建渐变过渡动画
|
||||||
* @param duration 动画时长
|
* @param duration 动画时长
|
||||||
*/
|
*/
|
||||||
explicit EmergeTransition(
|
explicit EmergeTransition(Duration duration);
|
||||||
Duration duration
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Update(Duration dt) override;
|
void Update(Duration dt) override;
|
||||||
|
|
||||||
virtual void Init(
|
virtual void Init(StagePtr prev, StagePtr next) override;
|
||||||
StagePtr prev,
|
|
||||||
StagePtr next
|
|
||||||
) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 盒状过渡动画
|
* @brief 盒状过渡动画
|
||||||
* @details 前一场景以盒状收缩至消失,后一场景以盒状扩大
|
* @details 前一场景以盒状收缩至消失,后一场景以盒状扩大
|
||||||
*/
|
*/
|
||||||
class BoxTransition
|
class BoxTransition : public Transition
|
||||||
: public Transition
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -182,27 +160,20 @@ namespace kiwano
|
||||||
* @brief 构建盒状过渡动画
|
* @brief 构建盒状过渡动画
|
||||||
* @param duration 动画时长
|
* @param duration 动画时长
|
||||||
*/
|
*/
|
||||||
explicit BoxTransition(
|
explicit BoxTransition(Duration duration);
|
||||||
Duration duration
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Update(Duration dt) override;
|
void Update(Duration dt) override;
|
||||||
|
|
||||||
virtual void Init(
|
virtual void Init(StagePtr prev, StagePtr next) override;
|
||||||
StagePtr prev,
|
|
||||||
StagePtr next
|
|
||||||
) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 位移过渡动画
|
* @brief 位移过渡动画
|
||||||
* @details 两场景以位移的方式切换
|
* @details 两场景以位移的方式切换
|
||||||
*/
|
*/
|
||||||
class MoveTransition
|
class MoveTransition : public Transition
|
||||||
: public Transition
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -223,18 +194,12 @@ namespace kiwano
|
||||||
* @param duration 动画时长
|
* @param duration 动画时长
|
||||||
* @param type 位移方式
|
* @param type 位移方式
|
||||||
*/
|
*/
|
||||||
explicit MoveTransition(
|
explicit MoveTransition(Duration duration, Type type);
|
||||||
Duration duration,
|
|
||||||
Type type
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Update(Duration dt) override;
|
void Update(Duration dt) override;
|
||||||
|
|
||||||
virtual void Init(
|
virtual void Init(StagePtr prev, StagePtr next) override;
|
||||||
StagePtr prev,
|
|
||||||
StagePtr next
|
|
||||||
) override;
|
|
||||||
|
|
||||||
void Reset() override;
|
void Reset() override;
|
||||||
|
|
||||||
|
|
@ -244,14 +209,12 @@ namespace kiwano
|
||||||
Point start_pos_;
|
Point start_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 旋转过渡动画
|
* @brief 旋转过渡动画
|
||||||
* @details 前一场景以旋转方式收缩至消失,后一场景以旋转方式扩大
|
* @details 前一场景以旋转方式收缩至消失,后一场景以旋转方式扩大
|
||||||
*/
|
*/
|
||||||
class RotationTransition
|
class RotationTransition : public Transition
|
||||||
: public Transition
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -260,22 +223,16 @@ namespace kiwano
|
||||||
* @param duration 动画时长
|
* @param duration 动画时长
|
||||||
* @param rotation 旋转度数
|
* @param rotation 旋转度数
|
||||||
*/
|
*/
|
||||||
explicit RotationTransition(
|
explicit RotationTransition(Duration duration, float rotation = 360);
|
||||||
Duration duration,
|
|
||||||
float rotation = 360
|
|
||||||
);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Update(Duration dt) override;
|
void Update(Duration dt) override;
|
||||||
|
|
||||||
virtual void Init(
|
virtual void Init(StagePtr prev, StagePtr next) override;
|
||||||
StagePtr prev,
|
|
||||||
StagePtr next
|
|
||||||
) override;
|
|
||||||
|
|
||||||
void Reset() override;
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float rotation_;
|
float rotation_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/action/Action.h>
|
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
|
#include <kiwano/2d/action/Action.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -32,13 +32,9 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Action::~Action()
|
Action::~Action() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Action::Init(Actor* target)
|
void Action::Init(Actor* target) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Action::Update(Actor* target, Duration dt)
|
void Action::Update(Actor* target, Duration dt)
|
||||||
{
|
{
|
||||||
|
|
@ -88,8 +84,7 @@ namespace kiwano
|
||||||
if (cb_loop_done_)
|
if (cb_loop_done_)
|
||||||
cb_loop_done_(target);
|
cb_loop_done_(target);
|
||||||
|
|
||||||
if (loops_ >= 0
|
if (loops_ >= 0 && loops_done_ >= loops_)
|
||||||
&& loops_done_ >= loops_)
|
|
||||||
{
|
{
|
||||||
Done();
|
Done();
|
||||||
}
|
}
|
||||||
|
|
@ -110,4 +105,4 @@ namespace kiwano
|
||||||
Init(target);
|
Init(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/core/common.h>
|
#include <kiwano/core/Common.h>
|
||||||
#include <kiwano/core/time.h>
|
|
||||||
#include <kiwano/core/SmartPtr.hpp>
|
|
||||||
#include <kiwano/core/ObjectBase.h>
|
#include <kiwano/core/ObjectBase.h>
|
||||||
|
#include <kiwano/core/SmartPtr.hpp>
|
||||||
|
#include <kiwano/core/Time.h>
|
||||||
#include <kiwano/math/math.h>
|
#include <kiwano/math/math.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -45,7 +45,7 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief ¶¯»
|
/// @brief ¶¯»
|
||||||
class KGE_API Action
|
class KGE_API Action
|
||||||
: public ObjectBase
|
: public virtual ObjectBase
|
||||||
, protected IntrusiveListItem<ActionPtr>
|
, protected IntrusiveListItem<ActionPtr>
|
||||||
{
|
{
|
||||||
friend class ActionManager;
|
friend class ActionManager;
|
||||||
|
|
@ -192,7 +192,6 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
inline void Action::Resume()
|
inline void Action::Resume()
|
||||||
{
|
{
|
||||||
running_ = true;
|
running_ = true;
|
||||||
|
|
@ -287,4 +286,4 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
return cb_loop_done_;
|
return cb_loop_done_;
|
||||||
}
|
}
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,4 @@ namespace kiwano
|
||||||
return new ActionDelay(GetDelay());
|
return new ActionDelay(GetDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -30,16 +30,13 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 延时动画
|
/// @brief 延时动画
|
||||||
class KGE_API ActionDelay
|
class KGE_API ActionDelay : public Action
|
||||||
: public Action
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构建延时动画
|
/// @brief 构建延时动画
|
||||||
/// @param delay 延时时长
|
/// @param delay 延时时长
|
||||||
ActionDelay(
|
ActionDelay(Duration delay);
|
||||||
Duration delay
|
|
||||||
);
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -51,4 +48,4 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/action/ActionGroup.h>
|
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
|
#include <kiwano/2d/action/ActionGroup.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -39,9 +39,7 @@ namespace kiwano
|
||||||
this->Add(actions);
|
this->Add(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionGroup::~ActionGroup()
|
ActionGroup::~ActionGroup() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionGroup::Init(Actor* target)
|
void ActionGroup::Init(Actor* target)
|
||||||
{
|
{
|
||||||
|
|
@ -145,4 +143,4 @@ namespace kiwano
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 动画组合
|
/// @brief 动画组合
|
||||||
class KGE_API ActionGroup
|
class KGE_API ActionGroup : public Action
|
||||||
: public Action
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using ActionList = IntrusiveList<ActionPtr>;
|
using ActionList = IntrusiveList<ActionPtr>;
|
||||||
|
|
@ -83,6 +82,9 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline ActionGroup::ActionList const& ActionGroup::GetActions() const { return actions_; }
|
inline ActionGroup::ActionList const& ActionGroup::GetActions() const
|
||||||
|
{
|
||||||
|
return actions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <kiwano/2d/action/ActionTween.h>
|
|
||||||
#include <kiwano/2d/action/ActionWalk.h>
|
|
||||||
#include <kiwano/2d/action/ActionDelay.h>
|
#include <kiwano/2d/action/ActionDelay.h>
|
||||||
#include <kiwano/2d/action/ActionGroup.h>
|
#include <kiwano/2d/action/ActionGroup.h>
|
||||||
|
#include <kiwano/2d/action/ActionTween.h>
|
||||||
|
#include <kiwano/2d/action/ActionWalk.h>
|
||||||
#include <kiwano/2d/action/Animation.h>
|
#include <kiwano/2d/action/Animation.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -40,35 +40,68 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置循环次数
|
/// @brief 设置循环次数
|
||||||
inline ActionHelper& SetLoops(int loops) { core->SetLoops(loops); return (*this); }
|
inline ActionHelper& SetLoops(int loops)
|
||||||
|
{
|
||||||
|
core->SetLoops(loops);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置动画延迟
|
/// @brief 设置动画延迟
|
||||||
inline ActionHelper& SetDelay(Duration delay) { core->SetDelay(delay); return (*this); }
|
inline ActionHelper& SetDelay(Duration delay)
|
||||||
|
{
|
||||||
|
core->SetDelay(delay);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置动画结束回调函数
|
/// @brief 设置动画结束回调函数
|
||||||
inline ActionHelper& SetDoneCallback(DoneCallback const& cb) { core->SetDoneCallback(cb); return (*this); }
|
inline ActionHelper& SetDoneCallback(DoneCallback const& cb)
|
||||||
|
{
|
||||||
|
core->SetDoneCallback(cb);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置动画循环结束时的回调函数
|
/// @brief 设置动画循环结束时的回调函数
|
||||||
inline ActionHelper& SetLoopDoneCallback(DoneCallback const& cb) { core->SetLoopDoneCallback(cb); return (*this); }
|
inline ActionHelper& SetLoopDoneCallback(DoneCallback const& cb)
|
||||||
|
{
|
||||||
|
core->SetLoopDoneCallback(cb);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 动画结束时移除目标角色
|
/// @brief 动画结束时移除目标角色
|
||||||
inline ActionHelper& RemoveTargetWhenDone() { core->RemoveTargetWhenDone(); return (*this); }
|
inline ActionHelper& RemoveTargetWhenDone()
|
||||||
|
{
|
||||||
|
core->RemoveTargetWhenDone();
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置名称
|
/// @brief 设置名称
|
||||||
inline ActionHelper& SetName(String const& name) { core->SetName(name); return (*this); }
|
inline ActionHelper& SetName(String const& name)
|
||||||
|
{
|
||||||
|
core->SetName(name);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取指针
|
/// @brief 获取指针
|
||||||
inline ActionPtr Get() const { return core; }
|
inline ActionPtr Get() const
|
||||||
|
{
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
|
||||||
inline ActionHelper(ActionPtr core) : core(core) {}
|
inline ActionHelper(ActionPtr core)
|
||||||
|
: core(core)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
inline operator ActionPtr() const { return core; }
|
inline operator ActionPtr() const
|
||||||
|
{
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionPtr core;
|
ActionPtr core;
|
||||||
|
|
@ -82,45 +115,89 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置动画持续时长
|
/// @brief 设置动画持续时长
|
||||||
inline TweenHelper& SetDuration(Duration dur) { core->SetDuration(dur); return (*this); }
|
inline TweenHelper& SetDuration(Duration dur)
|
||||||
|
{
|
||||||
|
core->SetDuration(dur);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置循环次数
|
/// @brief 设置循环次数
|
||||||
inline TweenHelper& SetLoops(int loops) { core->SetLoops(loops); return (*this); }
|
inline TweenHelper& SetLoops(int loops)
|
||||||
|
{
|
||||||
|
core->SetLoops(loops);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置缓动函数
|
/// @brief 设置缓动函数
|
||||||
inline TweenHelper& SetEaseFunc(EaseFunc ease) { core->SetEaseFunc(ease); return (*this); }
|
inline TweenHelper& SetEaseFunc(EaseFunc ease)
|
||||||
|
{
|
||||||
|
core->SetEaseFunc(ease);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置动画延迟
|
/// @brief 设置动画延迟
|
||||||
inline TweenHelper& SetDelay(Duration delay) { core->SetDelay(delay); return (*this); }
|
inline TweenHelper& SetDelay(Duration delay)
|
||||||
|
{
|
||||||
|
core->SetDelay(delay);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置动画结束回调函数
|
/// @brief 设置动画结束回调函数
|
||||||
inline TweenHelper& SetDoneCallback(DoneCallback const& cb) { core->SetDoneCallback(cb); return (*this); }
|
inline TweenHelper& SetDoneCallback(DoneCallback const& cb)
|
||||||
|
{
|
||||||
|
core->SetDoneCallback(cb);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置动画循环结束时的回调函数
|
/// @brief 设置动画循环结束时的回调函数
|
||||||
inline TweenHelper& SetLoopDoneCallback(DoneCallback const& cb) { core->SetLoopDoneCallback(cb); return (*this); }
|
inline TweenHelper& SetLoopDoneCallback(DoneCallback const& cb)
|
||||||
|
{
|
||||||
|
core->SetLoopDoneCallback(cb);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 动画结束时移除目标角色
|
/// @brief 动画结束时移除目标角色
|
||||||
inline TweenHelper& RemoveTargetWhenDone() { core->RemoveTargetWhenDone(); return (*this); }
|
inline TweenHelper& RemoveTargetWhenDone()
|
||||||
|
{
|
||||||
|
core->RemoveTargetWhenDone();
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置名称
|
/// @brief 设置名称
|
||||||
inline TweenHelper& SetName(String const& name) { core->SetName(name); return (*this); }
|
inline TweenHelper& SetName(String const& name)
|
||||||
|
{
|
||||||
|
core->SetName(name);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取指针
|
/// @brief 获取指针
|
||||||
inline ActionTweenPtr Get() const { return core; }
|
inline ActionTweenPtr Get() const
|
||||||
|
{
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
|
||||||
inline TweenHelper(ActionTweenPtr core) : core(core) {}
|
inline TweenHelper(ActionTweenPtr core)
|
||||||
|
: core(core)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
inline operator ActionPtr() const { return core; }
|
inline operator ActionPtr() const
|
||||||
|
{
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
|
||||||
inline operator ActionTweenPtr() const { return core; }
|
inline operator ActionTweenPtr() const
|
||||||
|
{
|
||||||
|
return core;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionTweenPtr core;
|
ActionTweenPtr core;
|
||||||
|
|
@ -135,8 +212,7 @@ namespace kiwano
|
||||||
/// @brief 构造相对位移动画
|
/// @brief 构造相对位移动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param vector 移动向量
|
/// @param vector 移动向量
|
||||||
static inline TweenHelper
|
static inline TweenHelper MoveBy(Duration dur, Point const& vector)
|
||||||
MoveBy(Duration dur, Point const& vector)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionMoveBy(dur, vector));
|
return TweenHelper(new kiwano::ActionMoveBy(dur, vector));
|
||||||
}
|
}
|
||||||
|
|
@ -145,8 +221,7 @@ namespace kiwano
|
||||||
/// @brief 构造位移动画
|
/// @brief 构造位移动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param pos 目的坐标
|
/// @param pos 目的坐标
|
||||||
static inline TweenHelper
|
static inline TweenHelper MoveTo(Duration dur, Point const& pos)
|
||||||
MoveTo(Duration dur, Point const& pos)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionMoveTo(dur, pos));
|
return TweenHelper(new kiwano::ActionMoveTo(dur, pos));
|
||||||
}
|
}
|
||||||
|
|
@ -157,8 +232,7 @@ namespace kiwano
|
||||||
/// @param vec 跳跃位移向量
|
/// @param vec 跳跃位移向量
|
||||||
/// @param height 跳跃高度
|
/// @param height 跳跃高度
|
||||||
/// @param jumps 跳跃次数
|
/// @param jumps 跳跃次数
|
||||||
static inline TweenHelper
|
static inline TweenHelper JumpBy(Duration duration, Vec2 const& vec, float height, int jumps = 1)
|
||||||
JumpBy(Duration duration, Vec2 const& vec, float height, int jumps = 1)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionJumpBy(duration, vec, height, jumps));
|
return TweenHelper(new kiwano::ActionJumpBy(duration, vec, height, jumps));
|
||||||
}
|
}
|
||||||
|
|
@ -169,8 +243,7 @@ namespace kiwano
|
||||||
/// @param pos 目的坐标
|
/// @param pos 目的坐标
|
||||||
/// @param height 跳跃高度
|
/// @param height 跳跃高度
|
||||||
/// @param jumps 跳跃次数
|
/// @param jumps 跳跃次数
|
||||||
static inline TweenHelper
|
static inline TweenHelper JumpTo(Duration duration, Point const& pos, float height, int jumps = 1)
|
||||||
JumpTo(Duration duration, Point const& pos, float height, int jumps = 1)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionJumpTo(duration, pos, height, jumps));
|
return TweenHelper(new kiwano::ActionJumpTo(duration, pos, height, jumps));
|
||||||
}
|
}
|
||||||
|
|
@ -180,8 +253,7 @@ namespace kiwano
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param scale_x 横向缩放相对变化值
|
/// @param scale_x 横向缩放相对变化值
|
||||||
/// @param scale_y 纵向缩放相对变化值
|
/// @param scale_y 纵向缩放相对变化值
|
||||||
static inline TweenHelper
|
static inline TweenHelper ScaleBy(Duration dur, float scale_x, float scale_y)
|
||||||
ScaleBy(Duration dur, float scale_x, float scale_y)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionScaleBy(dur, scale_x, scale_y));
|
return TweenHelper(new kiwano::ActionScaleBy(dur, scale_x, scale_y));
|
||||||
}
|
}
|
||||||
|
|
@ -191,8 +263,7 @@ namespace kiwano
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param scale_x 横向缩放目标值
|
/// @param scale_x 横向缩放目标值
|
||||||
/// @param scale_y 纵向缩放目标值
|
/// @param scale_y 纵向缩放目标值
|
||||||
static inline TweenHelper
|
static inline TweenHelper ScaleTo(Duration dur, float scale_x, float scale_y)
|
||||||
ScaleTo(Duration dur, float scale_x, float scale_y)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionScaleTo(dur, scale_x, scale_y));
|
return TweenHelper(new kiwano::ActionScaleTo(dur, scale_x, scale_y));
|
||||||
}
|
}
|
||||||
|
|
@ -201,8 +272,7 @@ namespace kiwano
|
||||||
/// @brief 构造透明度渐变动画
|
/// @brief 构造透明度渐变动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param opacity 目标透明度
|
/// @param opacity 目标透明度
|
||||||
static inline TweenHelper
|
static inline TweenHelper FadeTo(Duration dur, float opacity)
|
||||||
FadeTo(Duration dur, float opacity)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionFadeTo(dur, opacity));
|
return TweenHelper(new kiwano::ActionFadeTo(dur, opacity));
|
||||||
}
|
}
|
||||||
|
|
@ -210,8 +280,7 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造淡入动画
|
/// @brief 构造淡入动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
static inline TweenHelper
|
static inline TweenHelper FadeIn(Duration dur)
|
||||||
FadeIn(Duration dur)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionFadeIn(dur));
|
return TweenHelper(new kiwano::ActionFadeIn(dur));
|
||||||
}
|
}
|
||||||
|
|
@ -219,8 +288,7 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造淡出动画
|
/// @brief 构造淡出动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
static inline TweenHelper
|
static inline TweenHelper FadeOut(Duration dur)
|
||||||
FadeOut(Duration dur)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionFadeOut(dur));
|
return TweenHelper(new kiwano::ActionFadeOut(dur));
|
||||||
}
|
}
|
||||||
|
|
@ -229,8 +297,7 @@ namespace kiwano
|
||||||
/// @brief 构造相对旋转动画
|
/// @brief 构造相对旋转动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param rotation 角度相对变化值
|
/// @param rotation 角度相对变化值
|
||||||
static inline TweenHelper
|
static inline TweenHelper RotateBy(Duration dur, float rotation)
|
||||||
RotateBy(Duration dur, float rotation)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionRotateBy(dur, rotation));
|
return TweenHelper(new kiwano::ActionRotateBy(dur, rotation));
|
||||||
}
|
}
|
||||||
|
|
@ -239,8 +306,7 @@ namespace kiwano
|
||||||
/// @brief 构造旋转动画
|
/// @brief 构造旋转动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param rotation 目标角度
|
/// @param rotation 目标角度
|
||||||
static inline TweenHelper
|
static inline TweenHelper RotateTo(Duration dur, float rotation)
|
||||||
RotateTo(Duration dur, float rotation)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionRotateTo(dur, rotation));
|
return TweenHelper(new kiwano::ActionRotateTo(dur, rotation));
|
||||||
}
|
}
|
||||||
|
|
@ -252,8 +318,8 @@ namespace kiwano
|
||||||
/// @param rotating 是否沿路径切线方向旋转
|
/// @param rotating 是否沿路径切线方向旋转
|
||||||
/// @param start 路径起点(百分比)
|
/// @param start 路径起点(百分比)
|
||||||
/// @param end 路径终点(百分比)
|
/// @param end 路径终点(百分比)
|
||||||
static inline TweenHelper
|
static inline TweenHelper Walk(Duration duration, Geometry const& path, bool rotating = false, float start = 0.f,
|
||||||
Walk(Duration duration, Geometry const& path, bool rotating = false, float start = 0.f, float end = 1.f)
|
float end = 1.f)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionWalk(duration, path, rotating, start, end));
|
return TweenHelper(new kiwano::ActionWalk(duration, path, rotating, start, end));
|
||||||
}
|
}
|
||||||
|
|
@ -262,8 +328,7 @@ namespace kiwano
|
||||||
/// @brief 构建帧动画
|
/// @brief 构建帧动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param[in] frame_seq 序列帧
|
/// @param[in] frame_seq 序列帧
|
||||||
static inline TweenHelper
|
static inline TweenHelper Animation(Duration dur, FrameSequencePtr frames)
|
||||||
Animation(Duration dur, FrameSequencePtr frames)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::Animation(dur, frames));
|
return TweenHelper(new kiwano::Animation(dur, frames));
|
||||||
}
|
}
|
||||||
|
|
@ -272,8 +337,7 @@ namespace kiwano
|
||||||
/// @brief 构造自定义动画
|
/// @brief 构造自定义动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param tween_func 动画回调函数
|
/// @param tween_func 动画回调函数
|
||||||
static inline TweenHelper
|
static inline TweenHelper Custom(Duration dur, ActionCustom::TweenFunc tween_func)
|
||||||
Custom(Duration dur, ActionCustom::TweenFunc tween_func)
|
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionCustom(dur, tween_func));
|
return TweenHelper(new kiwano::ActionCustom(dur, tween_func));
|
||||||
}
|
}
|
||||||
|
|
@ -281,8 +345,7 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构建延时动画
|
/// @brief 构建延时动画
|
||||||
/// @param delay 延时时长
|
/// @param delay 延时时长
|
||||||
static inline ActionHelper
|
static inline ActionHelper Delay(Duration delay)
|
||||||
Delay(Duration delay)
|
|
||||||
{
|
{
|
||||||
return ActionHelper(new kiwano::ActionDelay(delay));
|
return ActionHelper(new kiwano::ActionDelay(delay));
|
||||||
}
|
}
|
||||||
|
|
@ -291,8 +354,7 @@ namespace kiwano
|
||||||
/// @brief 动画组合
|
/// @brief 动画组合
|
||||||
/// @param actions 动画集合
|
/// @param actions 动画集合
|
||||||
/// @param sequence 动画按顺序依次执行或同时执行
|
/// @param sequence 动画按顺序依次执行或同时执行
|
||||||
static inline ActionHelper
|
static inline ActionHelper Group(Vector<ActionPtr> const& actions, bool sequence = true)
|
||||||
Group(Vector<ActionPtr> const& actions, bool sequence = true)
|
|
||||||
{
|
{
|
||||||
return ActionHelper(new kiwano::ActionGroup(actions, sequence));
|
return ActionHelper(new kiwano::ActionGroup(actions, sequence));
|
||||||
}
|
}
|
||||||
|
|
@ -300,12 +362,11 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 同步动画组合
|
/// @brief 同步动画组合
|
||||||
/// @param actions 动画集合
|
/// @param actions 动画集合
|
||||||
static inline ActionHelper
|
static inline ActionHelper Multiple(Vector<ActionPtr> const& actions)
|
||||||
Multiple(Vector<ActionPtr> const& actions)
|
|
||||||
{
|
{
|
||||||
return ActionHelper(new kiwano::ActionGroup(actions, false));
|
return ActionHelper(new kiwano::ActionGroup(actions, false));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <kiwano/2d/action/ActionManager.h>
|
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
|
#include <kiwano/2d/action/ActionManager.h>
|
||||||
#include <kiwano/core/Logger.h>
|
#include <kiwano/core/Logger.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
|
|
@ -58,18 +58,6 @@ namespace kiwano
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionManager::GetAction(String const & name)
|
|
||||||
{
|
|
||||||
if (actions_.empty())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
for (auto& action : actions_)
|
|
||||||
if (action->IsName(name))
|
|
||||||
return action;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionManager::ResumeAllActions()
|
void ActionManager::ResumeAllActions()
|
||||||
{
|
{
|
||||||
if (actions_.empty())
|
if (actions_.empty())
|
||||||
|
|
@ -77,7 +65,7 @@ namespace kiwano
|
||||||
|
|
||||||
for (auto& action : actions_)
|
for (auto& action : actions_)
|
||||||
{
|
{
|
||||||
action->Resume();
|
action.Resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +76,7 @@ namespace kiwano
|
||||||
|
|
||||||
for (auto& action : actions_)
|
for (auto& action : actions_)
|
||||||
{
|
{
|
||||||
action->Pause();
|
action.Pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,12 +87,24 @@ namespace kiwano
|
||||||
|
|
||||||
for (auto& action : actions_)
|
for (auto& action : actions_)
|
||||||
{
|
{
|
||||||
action->Stop();
|
action.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActionPtr ActionManager::GetAction(String const& name)
|
||||||
|
{
|
||||||
|
if (actions_.empty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
for (auto& action : actions_)
|
||||||
|
if (action.IsName(name))
|
||||||
|
return &action;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const ActionManager::Actions& ActionManager::GetAllActions() const
|
const ActionManager::Actions& ActionManager::GetAllActions() const
|
||||||
{
|
{
|
||||||
return actions_;
|
return actions_;
|
||||||
}
|
}
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,6 @@ namespace kiwano
|
||||||
/// @brief 添加动画
|
/// @brief 添加动画
|
||||||
Action* AddAction(Action* action);
|
Action* AddAction(Action* action);
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取指定名称的动画
|
|
||||||
/// @param name 动画名称
|
|
||||||
ActionPtr GetAction(String const& name);
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 继续所有暂停动画
|
/// @brief 继续所有暂停动画
|
||||||
void ResumeAllActions();
|
void ResumeAllActions();
|
||||||
|
|
@ -64,6 +59,11 @@ namespace kiwano
|
||||||
/// @brief 停止所有动画
|
/// @brief 停止所有动画
|
||||||
void StopAllActions();
|
void StopAllActions();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取指定名称的动画
|
||||||
|
/// @param name 动画名称
|
||||||
|
ActionPtr GetAction(String const& name);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取所有动画
|
/// @brief 获取所有动画
|
||||||
Actions const& GetAllActions() const;
|
Actions const& GetAllActions() const;
|
||||||
|
|
@ -78,4 +78,4 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <kiwano/2d/action/ActionTween.h>
|
|
||||||
#include <kiwano/2d/Actor.h>
|
#include <kiwano/2d/Actor.h>
|
||||||
|
#include <kiwano/2d/action/ActionTween.h>
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
@ -28,12 +28,30 @@ namespace kiwano
|
||||||
// Ease Functions
|
// Ease Functions
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
inline EaseFunc MakeEaseIn(float rate) { return std::bind(math::EaseIn, std::placeholders::_1, rate); }
|
inline EaseFunc MakeEaseIn(float rate)
|
||||||
inline EaseFunc MakeEaseOut(float rate) { return std::bind(math::EaseOut, std::placeholders::_1, rate); }
|
{
|
||||||
inline EaseFunc MakeEaseInOut(float rate) { return std::bind(math::EaseInOut, std::placeholders::_1, rate); }
|
return std::bind(math::EaseIn, std::placeholders::_1, rate);
|
||||||
inline EaseFunc MakeEaseElasticIn(float period) { return std::bind(math::EaseElasticIn, std::placeholders::_1, period); }
|
}
|
||||||
inline EaseFunc MakeEaseElasticOut(float period) { return std::bind(math::EaseElasticOut, std::placeholders::_1, period); }
|
inline EaseFunc MakeEaseOut(float rate)
|
||||||
inline EaseFunc MakeEaseElasticInOut(float period) { return std::bind(math::EaseElasticInOut, std::placeholders::_1, period); }
|
{
|
||||||
|
return std::bind(math::EaseOut, std::placeholders::_1, rate);
|
||||||
|
}
|
||||||
|
inline EaseFunc MakeEaseInOut(float rate)
|
||||||
|
{
|
||||||
|
return std::bind(math::EaseInOut, std::placeholders::_1, rate);
|
||||||
|
}
|
||||||
|
inline EaseFunc MakeEaseElasticIn(float period)
|
||||||
|
{
|
||||||
|
return std::bind(math::EaseElasticIn, std::placeholders::_1, period);
|
||||||
|
}
|
||||||
|
inline EaseFunc MakeEaseElasticOut(float period)
|
||||||
|
{
|
||||||
|
return std::bind(math::EaseElasticOut, std::placeholders::_1, period);
|
||||||
|
}
|
||||||
|
inline EaseFunc MakeEaseElasticInOut(float period)
|
||||||
|
{
|
||||||
|
return std::bind(math::EaseElasticInOut, std::placeholders::_1, period);
|
||||||
|
}
|
||||||
|
|
||||||
KGE_API EaseFunc Ease::Linear = math::Linear;
|
KGE_API EaseFunc Ease::Linear = math::Linear;
|
||||||
KGE_API EaseFunc Ease::EaseIn = MakeEaseIn(2.f);
|
KGE_API EaseFunc Ease::EaseIn = MakeEaseIn(2.f);
|
||||||
|
|
@ -131,7 +149,6 @@ namespace kiwano
|
||||||
dur_ = duration;
|
dur_ = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Move Action
|
// Move Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -188,7 +205,6 @@ namespace kiwano
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
delta_pos_ = end_pos_ - start_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Jump Action
|
// Jump Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -252,7 +268,6 @@ namespace kiwano
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
delta_pos_ = end_pos_ - start_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Scale Action
|
// Scale Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -309,7 +324,6 @@ namespace kiwano
|
||||||
delta_y_ = end_scale_y_ - start_scale_y_;
|
delta_y_ = end_scale_y_ - start_scale_y_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Opacity Action
|
// Opacity Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -351,7 +365,6 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Rotate Action
|
// Rotate Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -407,7 +420,6 @@ namespace kiwano
|
||||||
delta_val_ = end_val_ - start_val_;
|
delta_val_ = end_val_ - start_val_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// ActionCustom
|
// ActionCustom
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
@ -435,4 +447,4 @@ namespace kiwano
|
||||||
tween_func_(target, percent);
|
tween_func_(target, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ namespace kiwano
|
||||||
static KGE_API EaseFunc SineInOut;
|
static KGE_API EaseFunc SineInOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
KGE_DECLARE_SMART_PTR(ActionTween);
|
KGE_DECLARE_SMART_PTR(ActionTween);
|
||||||
KGE_DECLARE_SMART_PTR(ActionMoveBy);
|
KGE_DECLARE_SMART_PTR(ActionMoveBy);
|
||||||
KGE_DECLARE_SMART_PTR(ActionMoveTo);
|
KGE_DECLARE_SMART_PTR(ActionMoveTo);
|
||||||
|
|
@ -81,7 +80,6 @@ namespace kiwano
|
||||||
KGE_DECLARE_SMART_PTR(ActionRotateTo);
|
KGE_DECLARE_SMART_PTR(ActionRotateTo);
|
||||||
KGE_DECLARE_SMART_PTR(ActionCustom);
|
KGE_DECLARE_SMART_PTR(ActionCustom);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup Actions
|
* \addtogroup Actions
|
||||||
* @{
|
* @{
|
||||||
|
|
@ -89,8 +87,7 @@ namespace kiwano
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 补间动画
|
/// @brief 补间动画
|
||||||
class KGE_API ActionTween
|
class KGE_API ActionTween : public Action
|
||||||
: public Action
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActionTween();
|
ActionTween();
|
||||||
|
|
@ -127,11 +124,9 @@ namespace kiwano
|
||||||
EaseFunc ease_func_;
|
EaseFunc ease_func_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 相对位移动画
|
/// @brief 相对位移动画
|
||||||
class KGE_API ActionMoveBy
|
class KGE_API ActionMoveBy : public ActionTween
|
||||||
: public ActionTween
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -160,11 +155,9 @@ namespace kiwano
|
||||||
Vec2 delta_pos_;
|
Vec2 delta_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 位移动画
|
/// @brief 位移动画
|
||||||
class KGE_API ActionMoveTo
|
class KGE_API ActionMoveTo : public ActionMoveBy
|
||||||
: public ActionMoveBy
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -193,11 +186,9 @@ namespace kiwano
|
||||||
Point end_pos_;
|
Point end_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 相对跳跃动画
|
/// @brief 相对跳跃动画
|
||||||
class KGE_API ActionJumpBy
|
class KGE_API ActionJumpBy : public ActionTween
|
||||||
: public ActionTween
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -230,11 +221,9 @@ namespace kiwano
|
||||||
Point prev_pos_;
|
Point prev_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 跳跃动画
|
/// @brief 跳跃动画
|
||||||
class KGE_API ActionJumpTo
|
class KGE_API ActionJumpTo : public ActionJumpBy
|
||||||
: public ActionJumpBy
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -265,11 +254,9 @@ namespace kiwano
|
||||||
Point end_pos_;
|
Point end_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 相对缩放动画
|
/// @brief 相对缩放动画
|
||||||
class KGE_API ActionScaleBy
|
class KGE_API ActionScaleBy : public ActionTween
|
||||||
: public ActionTween
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -300,11 +287,9 @@ namespace kiwano
|
||||||
float delta_y_;
|
float delta_y_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 缩放动画
|
/// @brief 缩放动画
|
||||||
class KGE_API ActionScaleTo
|
class KGE_API ActionScaleTo : public ActionScaleBy
|
||||||
: public ActionScaleBy
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -335,11 +320,9 @@ namespace kiwano
|
||||||
float end_scale_y_;
|
float end_scale_y_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 透明度渐变动画
|
/// @brief 透明度渐变动画
|
||||||
class KGE_API ActionFadeTo
|
class KGE_API ActionFadeTo : public ActionTween
|
||||||
: public ActionTween
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -372,11 +355,9 @@ namespace kiwano
|
||||||
float end_val_;
|
float end_val_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 淡入动画
|
/// @brief 淡入动画
|
||||||
class KGE_API ActionFadeIn
|
class KGE_API ActionFadeIn : public ActionFadeTo
|
||||||
: public ActionFadeTo
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -386,11 +367,9 @@ namespace kiwano
|
||||||
explicit ActionFadeIn(Duration duration, EaseFunc func = nullptr);
|
explicit ActionFadeIn(Duration duration, EaseFunc func = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 淡出动画
|
/// @brief 淡出动画
|
||||||
class KGE_API ActionFadeOut
|
class KGE_API ActionFadeOut : public ActionFadeTo
|
||||||
: public ActionFadeTo
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -400,11 +379,9 @@ namespace kiwano
|
||||||
explicit ActionFadeOut(Duration duration, EaseFunc func = nullptr);
|
explicit ActionFadeOut(Duration duration, EaseFunc func = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 相对旋转动画
|
/// @brief 相对旋转动画
|
||||||
class KGE_API ActionRotateBy
|
class KGE_API ActionRotateBy : public ActionTween
|
||||||
: public ActionTween
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -432,11 +409,9 @@ namespace kiwano
|
||||||
float delta_val_;
|
float delta_val_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 旋转动画
|
/// @brief 旋转动画
|
||||||
class KGE_API ActionRotateTo
|
class KGE_API ActionRotateTo : public ActionRotateBy
|
||||||
: public ActionRotateBy
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -465,11 +440,9 @@ namespace kiwano
|
||||||
float end_val_;
|
float end_val_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 自定义动画
|
/// @brief 自定义动画
|
||||||
class KGE_API ActionCustom
|
class KGE_API ActionCustom : public ActionTween
|
||||||
: public ActionTween
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -507,4 +480,4 @@ namespace kiwano
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
}
|
} // namespace kiwano
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue