some optimizations for Array<>
refactoring project minor refactoring project refactoring Logger refactoring DataUtil
This commit is contained in:
parent
ed65cf767b
commit
4e3a32ec15
|
|
@ -4,17 +4,17 @@ VisualStudioVersion = 15.0.28307.271
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "samples\HelloWorld\HelloWorld.vcxproj", "{3561A359-F9FD-48AB-A977-34E7E568BC8E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D", "src\easy2d\Easy2D.vcxproj", "{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D", "easy2d\Easy2D.vcxproj", "{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D-ImGui", "src\easy2d-imgui\Easy2D-ImGui.vcxproj", "{23AFF03B-A670-4C33-B790-18EEC82C61AE}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D-ImGui", "easy2d-imgui\Easy2D-ImGui.vcxproj", "{23AFF03B-A670-4C33-B790-18EEC82C61AE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D-Audio", "src\easy2d-audio\Easy2D-Audio.vcxproj", "{5D45F66B-BECD-4909-BCFC-C0F3CED9D0A2}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D-Audio", "easy2d-audio\Easy2D-Audio.vcxproj", "{5D45F66B-BECD-4909-BCFC-C0F3CED9D0A2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Samples", "samples\Samples\Samples.vcxproj", "{45F5738D-CDF2-4024-974D-25B64F9043DE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImGuiSample", "samples\ImGuiSample\ImGuiSample.vcxproj", "{6152D36C-EA40-4968-A696-244B6CA58395}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2D", "3rd-party\box2d\Box2D.vcxproj", "{A434E80C-1049-10BE-D9CA-B31D459E0CEF}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2D", "samples\libs\box2d\Box2D.vcxproj", "{A434E80C-1049-10BE-D9CA-B31D459E0CEF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2DSample", "samples\Box2DSample\Box2DSample.vcxproj", "{324CFF47-4EB2-499A-BE5F-53A82E3BA14B}"
|
||||
EndProject
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{5D45F66B-BECD-4909-BCFC-C0F3CED9D0A2}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<Keyword>Easy2D-Audio</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
|
@ -96,6 +96,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../easy2d</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
@ -111,6 +112,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../easy2d</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
@ -128,6 +130,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../easy2d</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
@ -145,9 +148,9 @@
|
|||
<ClCompile Include="Voice.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="easy2d-audio.h" />
|
||||
<ClInclude Include="audio-modules.h" />
|
||||
<ClInclude Include="audio.h" />
|
||||
<ClInclude Include="easy2d-audio.h" />
|
||||
<ClInclude Include="Music.h" />
|
||||
<ClInclude Include="Player.h" />
|
||||
<ClInclude Include="Transcoder.h" />
|
||||
|
|
@ -11,10 +11,10 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="audio.h" />
|
||||
<ClInclude Include="audio-modules.h" />
|
||||
<ClInclude Include="easy2d-audio.h" />
|
||||
<ClInclude Include="Music.h" />
|
||||
<ClInclude Include="Player.h" />
|
||||
<ClInclude Include="Transcoder.h" />
|
||||
<ClInclude Include="Voice.h" />
|
||||
<ClInclude Include="easy2d-audio.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -70,7 +70,7 @@ namespace easy2d
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
E2D_ERROR_HR_LOG(hr, L"Load media file failed");
|
||||
E2D_ERROR_LOG(L"Load media file failed with HRESULT of %08X", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ namespace easy2d
|
|||
delete[] wave_data_;
|
||||
wave_data_ = nullptr;
|
||||
}
|
||||
E2D_ERROR_HR_LOG(hr, L"Create source voice error");
|
||||
E2D_ERROR_LOG(L"Create source voice failed with HRESULT of %08X", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ namespace easy2d
|
|||
HRESULT hr = voice_.Play(wave_data_, size_, static_cast<UINT32>(loop_count));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
E2D_ERROR_HR_LOG(hr, L"Submitting source buffer error");
|
||||
E2D_ERROR_LOG(L"Submitting source buffer failed with HRESULT of %08X", hr);
|
||||
}
|
||||
|
||||
playing_ = SUCCEEDED(hr);
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{23AFF03B-A670-4C33-B790-18EEC82C61AE}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<Keyword>Easy2D-ImGui</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../easy2d;../../3rd-party/ImGui;</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>../easy2d</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
@ -96,6 +96,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../easy2d</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
@ -111,6 +112,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../easy2d</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
@ -128,6 +130,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../easy2d</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
@ -137,22 +140,22 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imconfig.h" />
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imgui.h" />
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imgui_internal.h" />
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imstb_rectpack.h" />
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imstb_textedit.h" />
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imstb_truetype.h" />
|
||||
<ClInclude Include="easy2d-imgui.h" />
|
||||
<ClInclude Include="libs\ImGui\imconfig.h" />
|
||||
<ClInclude Include="libs\ImGui\imgui.h" />
|
||||
<ClInclude Include="libs\ImGui\imgui_internal.h" />
|
||||
<ClInclude Include="libs\ImGui\imstb_rectpack.h" />
|
||||
<ClInclude Include="libs\ImGui\imstb_textedit.h" />
|
||||
<ClInclude Include="libs\ImGui\imstb_truetype.h" />
|
||||
<ClInclude Include="ImGuiLayer.h" />
|
||||
<ClInclude Include="ImGuiView.h" />
|
||||
<ClInclude Include="imgui_impl_dx11.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui.cpp" />
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui_demo.cpp" />
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui_draw.cpp" />
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="libs\ImGui\imgui.cpp" />
|
||||
<ClCompile Include="libs\ImGui\imgui_demo.cpp" />
|
||||
<ClCompile Include="libs\ImGui\imgui_draw.cpp" />
|
||||
<ClCompile Include="libs\ImGui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="ImGuiLayer.cpp" />
|
||||
<ClCompile Include="ImGuiView.cpp" />
|
||||
<ClCompile Include="imgui_impl_dx11.cpp" />
|
||||
|
|
@ -1,43 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="easy2d-imgui.h" />
|
||||
<ClInclude Include="imgui_impl_dx11.h" />
|
||||
<ClInclude Include="ImGuiLayer.h" />
|
||||
<ClInclude Include="ImGuiView.h" />
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imconfig.h">
|
||||
<ClInclude Include="libs\ImGui\imconfig.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imgui.h">
|
||||
<ClInclude Include="libs\ImGui\imgui.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imgui_internal.h">
|
||||
<ClInclude Include="libs\ImGui\imgui_internal.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imstb_rectpack.h">
|
||||
<ClInclude Include="libs\ImGui\imstb_rectpack.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imstb_textedit.h">
|
||||
<ClInclude Include="libs\ImGui\imstb_textedit.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\3rd-party\ImGui\imstb_truetype.h">
|
||||
<ClInclude Include="libs\ImGui\imstb_truetype.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="easy2d-imgui.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="imgui_impl_dx11.cpp" />
|
||||
<ClCompile Include="ImGuiLayer.cpp" />
|
||||
<ClCompile Include="ImGuiView.cpp" />
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui.cpp">
|
||||
<ClCompile Include="libs\ImGui\imgui.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui_demo.cpp">
|
||||
<ClCompile Include="libs\ImGui\imgui_demo.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui_draw.cpp">
|
||||
<ClCompile Include="libs\ImGui\imgui_draw.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\3rd-party\ImGui\imgui_widgets.cpp">
|
||||
<ClCompile Include="libs\ImGui\imgui_widgets.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
|
@ -6,4 +6,4 @@
|
|||
#include "ImGuiLayer.h"
|
||||
|
||||
// ImGui
|
||||
#include "imgui.h"
|
||||
#include "libs/ImGui/imgui.h"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// dear imgui: Renderer for Easy2D (DirectX11)
|
||||
|
||||
#include "imgui.h"
|
||||
#include "libs/ImGui/imgui.h"
|
||||
#include "imgui_impl_dx11.h"
|
||||
|
||||
// DirectX
|
||||
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "time.h"
|
||||
#include "../common/IntrusiveList.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "ActionGroup.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "ActionManager.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -20,9 +20,8 @@
|
|||
|
||||
#pragma once
|
||||
#include "Action.h"
|
||||
#include "logs.h"
|
||||
#include "Geometry.h" // ActionPath
|
||||
#include "../math/ease.hpp"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,11 +19,10 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "Canvas.h"
|
||||
#include "render.h"
|
||||
#include "logs.h"
|
||||
#include "Image.h"
|
||||
#include "Geometry.h"
|
||||
#include "render.h"
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
#include "Node.h"
|
||||
#include "Font.hpp"
|
||||
#include "TextStyle.hpp"
|
||||
#include "../DX/TextRenderer.h"
|
||||
#include "../renderer/TextRenderer.h"
|
||||
|
||||
#undef DrawText
|
||||
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "DebugNode.h"
|
||||
#include "Text.h"
|
||||
#include "render.h"
|
||||
#include "../renderer/render.h"
|
||||
#include <sstream>
|
||||
#include <psapi.h>
|
||||
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "Node.h"
|
||||
#include "time.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "Frames.h"
|
||||
#include "Image.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "time.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "Geometry.h"
|
||||
#include "render.h"
|
||||
#include "logs.h"
|
||||
#include "../renderer/render.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "GeometryNode.h"
|
||||
#include "render.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "Image.h"
|
||||
#include "logs.h"
|
||||
#include "render.h"
|
||||
#include "modules.h"
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h"
|
||||
#include "../platform/modules.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ namespace easy2d
|
|||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
E2D_ERROR_HR_LOG(hr, L"Load image file failed!");
|
||||
E2D_ERROR_LOG(L"Load image file failed with HRESULT of %08X", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "Resource.h"
|
||||
#include "../base/Resource.h"
|
||||
#include <d2d1.h>
|
||||
|
||||
namespace easy2d
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Layer.h"
|
||||
#include "render.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -21,9 +21,8 @@
|
|||
#include "Node.h"
|
||||
#include "Action.h"
|
||||
#include "Scene.h"
|
||||
#include "Task.h"
|
||||
#include "render.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -20,11 +20,10 @@
|
|||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "time.h"
|
||||
#include "Transform.hpp"
|
||||
#include "TaskManager.h"
|
||||
#include "ActionManager.h"
|
||||
#include "EventDispatcher.h"
|
||||
#include "../base/TaskManager.h"
|
||||
#include "../base/EventDispatcher.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "Scene.h"
|
||||
#include "logs.h"
|
||||
#include "render.h"
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "Sprite.h"
|
||||
#include "render.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "Text.h"
|
||||
#include "render.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -21,9 +21,9 @@
|
|||
#include "Transition.h"
|
||||
#include "Node.h"
|
||||
#include "Scene.h"
|
||||
#include "window.h"
|
||||
#include "render.h"
|
||||
#include "logs.h"
|
||||
#include "../base/window.h"
|
||||
#include "../base/logs.h"
|
||||
#include "../renderer/render.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "time.h"
|
||||
#include <d2d1.h>
|
||||
|
||||
namespace easy2d
|
||||
|
|
@ -19,69 +19,22 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "RefCounter.hpp"
|
||||
#include "../common/Array.h"
|
||||
#include "../common/String.h"
|
||||
#include "../common/IntrusivePtr.hpp"
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
|
||||
#ifndef E2D_DECLARE_SMART_PTR
|
||||
#define E2D_DECLARE_SMART_PTR(CLASS)\
|
||||
class CLASS;\
|
||||
using CLASS##Ptr = ::easy2d::SmartPtr< CLASS >
|
||||
#endif
|
||||
#include "Color.h"
|
||||
#include "../common/helper.h"
|
||||
#include "../common/ComPtr.hpp"
|
||||
#include "../common/Closure.hpp"
|
||||
#include "../common/Singleton.hpp"
|
||||
#include "../common/IntrusiveList.hpp"
|
||||
#include "../base/time.h"
|
||||
#include "../base/RefCounter.hpp"
|
||||
#include "../base/SmartPtr.hpp"
|
||||
#include "../base/Object.h"
|
||||
#include "../math/helper.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
using StringStream = std::wstringstream;
|
||||
|
||||
template<typename Type1, typename Type2>
|
||||
using Pair = std::pair<Type1, Type2>;
|
||||
|
||||
template<typename Type>
|
||||
using List = std::list<Type>;
|
||||
|
||||
template<typename Type>
|
||||
using Set = std::set<Type>;
|
||||
|
||||
template<typename Type>
|
||||
using UnorderedSet = std::unordered_set<Type>;
|
||||
|
||||
template<typename KeyType, typename MappedType>
|
||||
using Map = std::map<KeyType, MappedType>;
|
||||
|
||||
template<typename KeyType, typename MappedType>
|
||||
using UnorderedMap = std::unordered_map<KeyType, MappedType>;
|
||||
}
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
struct DefaultIntrusivePtrManager
|
||||
{
|
||||
static inline void AddRef(RefCounter* ptr)
|
||||
{
|
||||
if (ptr) ptr->Retain();
|
||||
}
|
||||
|
||||
static inline void Release(RefCounter* ptr)
|
||||
{
|
||||
if (ptr) ptr->Release();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename _Ty>
|
||||
using SmartPtr = IntrusivePtr<_Ty, DefaultIntrusivePtrManager, true>;
|
||||
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Object);
|
||||
E2D_DECLARE_SMART_PTR(Image);
|
||||
E2D_DECLARE_SMART_PTR(Task);
|
||||
E2D_DECLARE_SMART_PTR(Frames);
|
||||
E2D_DECLARE_SMART_PTR(EventListener);
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Geometry);
|
||||
E2D_DECLARE_SMART_PTR(LineGeometry);
|
||||
|
|
@ -128,3 +81,52 @@ namespace easy2d
|
|||
E2D_DECLARE_SMART_PTR(Button);
|
||||
E2D_DECLARE_SMART_PTR(Menu);
|
||||
}
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
// 画笔样式
|
||||
enum class StrokeStyle : int
|
||||
{
|
||||
Miter = 0, /* 斜切 */
|
||||
Bevel = 1, /* 斜角 */
|
||||
Round = 2 /* 圆角 */
|
||||
};
|
||||
|
||||
// 方向
|
||||
enum class Direction : int
|
||||
{
|
||||
Up, /* 上 */
|
||||
Down, /* 下 */
|
||||
Left, /* 左 */
|
||||
Right /* 右 */
|
||||
};
|
||||
|
||||
// 鼠标指针
|
||||
enum class MouseCursor : int
|
||||
{
|
||||
Arrow, /* 指针 */
|
||||
TextInput, /* 输入文本 */
|
||||
Hand, /* 手指 */
|
||||
SizeAll,
|
||||
SizeNESW,
|
||||
SizeNS,
|
||||
SizeNWSE,
|
||||
SizeWE,
|
||||
};
|
||||
|
||||
// 文字抗锯齿属性
|
||||
enum class TextAntialias
|
||||
{
|
||||
Default, // 系统默认
|
||||
ClearType, // ClearType 抗锯齿
|
||||
GrayScale, // 灰度抗锯齿
|
||||
None // 不启用抗锯齿
|
||||
};
|
||||
|
||||
// 图层属性
|
||||
struct LayerProperties
|
||||
{
|
||||
math::Rect area;
|
||||
float opacity;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,118 +1,119 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="easy2d.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="macros.h" />
|
||||
<ClInclude Include="2d\include-forwards.h" />
|
||||
<ClInclude Include="2d\Action.h" />
|
||||
<ClInclude Include="2d\ActionGroup.h" />
|
||||
<ClInclude Include="2d\ActionHelper.h" />
|
||||
<ClInclude Include="2d\ActionManager.h" />
|
||||
<ClInclude Include="2d\ActionTween.h" />
|
||||
<ClInclude Include="2d\Animation.h" />
|
||||
<ClInclude Include="2d\Canvas.h" />
|
||||
<ClInclude Include="2d\Color.h" />
|
||||
<ClInclude Include="2d\DebugNode.h" />
|
||||
<ClInclude Include="2d\Font.hpp" />
|
||||
<ClInclude Include="2d\Frames.h" />
|
||||
<ClInclude Include="2d\Geometry.h" />
|
||||
<ClInclude Include="2d\GeometryNode.h" />
|
||||
<ClInclude Include="2d\Image.h" />
|
||||
<ClInclude Include="2d\Layer.h" />
|
||||
<ClInclude Include="2d\Node.h" />
|
||||
<ClInclude Include="2d\Scene.h" />
|
||||
<ClInclude Include="2d\Sprite.h" />
|
||||
<ClInclude Include="2d\Text.h" />
|
||||
<ClInclude Include="2d\TextStyle.hpp" />
|
||||
<ClInclude Include="2d\Transform.hpp" />
|
||||
<ClInclude Include="2d\Transition.h" />
|
||||
<ClInclude Include="base\Component.h" />
|
||||
<ClInclude Include="base\Event.hpp" />
|
||||
<ClInclude Include="base\EventDispatcher.h" />
|
||||
<ClInclude Include="base\EventListener.h" />
|
||||
<ClInclude Include="base\Input.h" />
|
||||
<ClInclude Include="base\keys.hpp" />
|
||||
<ClInclude Include="base\logs.h" />
|
||||
<ClInclude Include="base\Object.h" />
|
||||
<ClInclude Include="base\RefCounter.hpp" />
|
||||
<ClInclude Include="base\Resource.h" />
|
||||
<ClInclude Include="base\SmartPtr.hpp" />
|
||||
<ClInclude Include="base\Task.h" />
|
||||
<ClInclude Include="base\TaskManager.h" />
|
||||
<ClInclude Include="base\time.h" />
|
||||
<ClInclude Include="base\window.h" />
|
||||
<ClInclude Include="common\Array.h" />
|
||||
<ClInclude Include="common\closure.hpp" />
|
||||
<ClInclude Include="common\ComPtr.hpp" />
|
||||
<ClInclude Include="common\helper.h" />
|
||||
<ClInclude Include="common\IntrusiveList.hpp" />
|
||||
<ClInclude Include="common\IntrusivePtr.hpp" />
|
||||
<ClInclude Include="common\noncopyable.hpp" />
|
||||
<ClInclude Include="common\Singleton.hpp" />
|
||||
<ClInclude Include="common\String.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="core\Action.h" />
|
||||
<ClInclude Include="core\ActionGroup.h" />
|
||||
<ClInclude Include="core\ActionHelper.h" />
|
||||
<ClInclude Include="core\ActionTween.h" />
|
||||
<ClInclude Include="core\ActionManager.h" />
|
||||
<ClInclude Include="core\Animation.h" />
|
||||
<ClInclude Include="core\Canvas.h" />
|
||||
<ClInclude Include="core\Color.h" />
|
||||
<ClInclude Include="core\Component.h" />
|
||||
<ClInclude Include="core\DebugNode.h" />
|
||||
<ClInclude Include="core\Event.hpp" />
|
||||
<ClInclude Include="core\EventDispatcher.h" />
|
||||
<ClInclude Include="core\EventListener.h" />
|
||||
<ClInclude Include="core\Font.hpp" />
|
||||
<ClInclude Include="core\Frames.h" />
|
||||
<ClInclude Include="core\Application.h" />
|
||||
<ClInclude Include="core\Geometry.h" />
|
||||
<ClInclude Include="core\GeometryNode.h" />
|
||||
<ClInclude Include="core\helper.h" />
|
||||
<ClInclude Include="core\Image.h" />
|
||||
<ClInclude Include="core\include-forwards.h" />
|
||||
<ClInclude Include="core\Input.h" />
|
||||
<ClInclude Include="core\keys.hpp" />
|
||||
<ClInclude Include="core\Layer.h" />
|
||||
<ClInclude Include="core\logs.h" />
|
||||
<ClInclude Include="core\modules.h" />
|
||||
<ClInclude Include="core\Node.h" />
|
||||
<ClInclude Include="core\Object.h" />
|
||||
<ClInclude Include="core\RefCounter.hpp" />
|
||||
<ClInclude Include="core\render.h" />
|
||||
<ClInclude Include="core\Resource.h" />
|
||||
<ClInclude Include="core\Scene.h" />
|
||||
<ClInclude Include="core\Sprite.h" />
|
||||
<ClInclude Include="core\Task.h" />
|
||||
<ClInclude Include="core\TaskManager.h" />
|
||||
<ClInclude Include="core\Text.h" />
|
||||
<ClInclude Include="core\TextStyle.hpp" />
|
||||
<ClInclude Include="core\time.h" />
|
||||
<ClInclude Include="core\Transform.hpp" />
|
||||
<ClInclude Include="core\Transition.h" />
|
||||
<ClInclude Include="core\window.h" />
|
||||
<ClInclude Include="dx\D2DDeviceResources.h" />
|
||||
<ClInclude Include="dx\D3D10DeviceResources.h" />
|
||||
<ClInclude Include="dx\D3D11DeviceResources.h" />
|
||||
<ClInclude Include="dx\DeviceResources.h" />
|
||||
<ClInclude Include="dx\helper.hpp" />
|
||||
<ClInclude Include="dx\TextRenderer.h" />
|
||||
<ClInclude Include="easy2d.h" />
|
||||
<ClInclude Include="macros.h" />
|
||||
<ClInclude Include="math\constants.hpp" />
|
||||
<ClInclude Include="math\ease.hpp" />
|
||||
<ClInclude Include="math\helper.h" />
|
||||
<ClInclude Include="math\Matrix.hpp" />
|
||||
<ClInclude Include="math\rand.h" />
|
||||
<ClInclude Include="math\Rect.hpp" />
|
||||
<ClInclude Include="math\scalar.hpp" />
|
||||
<ClInclude Include="math\vector.hpp" />
|
||||
<ClInclude Include="math\Vec2.hpp" />
|
||||
<ClInclude Include="platform\Application.h" />
|
||||
<ClInclude Include="platform\modules.h" />
|
||||
<ClInclude Include="renderer\D2DDeviceResources.h" />
|
||||
<ClInclude Include="renderer\D3D10DeviceResources.h" />
|
||||
<ClInclude Include="renderer\D3D11DeviceResources.h" />
|
||||
<ClInclude Include="renderer\DeviceResources.h" />
|
||||
<ClInclude Include="renderer\helper.hpp" />
|
||||
<ClInclude Include="renderer\render.h" />
|
||||
<ClInclude Include="renderer\TextRenderer.h" />
|
||||
<ClInclude Include="ui\Button.h" />
|
||||
<ClInclude Include="ui\Menu.h" />
|
||||
<ClInclude Include="utils\Data.h" />
|
||||
<ClInclude Include="utils\DataUtil.h" />
|
||||
<ClInclude Include="utils\File.h" />
|
||||
<ClInclude Include="utils\Path.h" />
|
||||
<ClInclude Include="utils\ResLoader.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="common\String.cpp" />
|
||||
<ClCompile Include="core\Action.cpp" />
|
||||
<ClCompile Include="core\ActionGroup.cpp" />
|
||||
<ClCompile Include="core\ActionTween.cpp" />
|
||||
<ClCompile Include="core\ActionManager.cpp" />
|
||||
<ClCompile Include="core\Animation.cpp" />
|
||||
<ClCompile Include="core\Canvas.cpp" />
|
||||
<ClCompile Include="core\Color.cpp" />
|
||||
<ClCompile Include="core\DebugNode.cpp" />
|
||||
<ClCompile Include="core\EventDispatcher.cpp" />
|
||||
<ClCompile Include="core\EventListener.cpp" />
|
||||
<ClCompile Include="core\Frames.cpp" />
|
||||
<ClCompile Include="core\Application.cpp" />
|
||||
<ClCompile Include="core\Geometry.cpp" />
|
||||
<ClCompile Include="core\GeometryNode.cpp" />
|
||||
<ClCompile Include="core\Image.cpp" />
|
||||
<ClCompile Include="core\Input.cpp" />
|
||||
<ClCompile Include="core\Layer.cpp" />
|
||||
<ClCompile Include="core\logs.cpp" />
|
||||
<ClCompile Include="core\modules.cpp" />
|
||||
<ClCompile Include="core\Node.cpp" />
|
||||
<ClCompile Include="core\Object.cpp" />
|
||||
<ClCompile Include="core\render.cpp" />
|
||||
<ClCompile Include="core\Resource.cpp" />
|
||||
<ClCompile Include="core\Scene.cpp" />
|
||||
<ClCompile Include="core\Sprite.cpp" />
|
||||
<ClCompile Include="core\Task.cpp" />
|
||||
<ClCompile Include="core\TaskManager.cpp" />
|
||||
<ClCompile Include="core\Text.cpp" />
|
||||
<ClCompile Include="core\time.cpp" />
|
||||
<ClCompile Include="core\Transition.cpp" />
|
||||
<ClCompile Include="core\window.cpp" />
|
||||
<ClCompile Include="dx\D2DDeviceResources.cpp" />
|
||||
<ClCompile Include="dx\D3D10DeviceResources.cpp" />
|
||||
<ClCompile Include="dx\D3D11DeviceResources.cpp" />
|
||||
<ClCompile Include="dx\TextRenderer.cpp" />
|
||||
<ClCompile Include="2d\Action.cpp" />
|
||||
<ClCompile Include="2d\ActionGroup.cpp" />
|
||||
<ClCompile Include="2d\ActionManager.cpp" />
|
||||
<ClCompile Include="2d\ActionTween.cpp" />
|
||||
<ClCompile Include="2d\Animation.cpp" />
|
||||
<ClCompile Include="2d\Canvas.cpp" />
|
||||
<ClCompile Include="2d\Color.cpp" />
|
||||
<ClCompile Include="2d\DebugNode.cpp" />
|
||||
<ClCompile Include="2d\Frames.cpp" />
|
||||
<ClCompile Include="2d\Geometry.cpp" />
|
||||
<ClCompile Include="2d\GeometryNode.cpp" />
|
||||
<ClCompile Include="2d\Image.cpp" />
|
||||
<ClCompile Include="2d\Layer.cpp" />
|
||||
<ClCompile Include="2d\Node.cpp" />
|
||||
<ClCompile Include="2d\Scene.cpp" />
|
||||
<ClCompile Include="2d\Sprite.cpp" />
|
||||
<ClCompile Include="2d\Text.cpp" />
|
||||
<ClCompile Include="2d\Transition.cpp" />
|
||||
<ClCompile Include="base\EventDispatcher.cpp" />
|
||||
<ClCompile Include="base\EventListener.cpp" />
|
||||
<ClCompile Include="base\Input.cpp" />
|
||||
<ClCompile Include="base\logs.cpp" />
|
||||
<ClCompile Include="base\Object.cpp" />
|
||||
<ClCompile Include="base\Resource.cpp" />
|
||||
<ClCompile Include="base\Task.cpp" />
|
||||
<ClCompile Include="base\TaskManager.cpp" />
|
||||
<ClCompile Include="base\time.cpp" />
|
||||
<ClCompile Include="base\window.cpp" />
|
||||
<ClCompile Include="platform\Application.cpp" />
|
||||
<ClCompile Include="platform\modules.cpp" />
|
||||
<ClCompile Include="renderer\D2DDeviceResources.cpp" />
|
||||
<ClCompile Include="renderer\D3D10DeviceResources.cpp" />
|
||||
<ClCompile Include="renderer\D3D11DeviceResources.cpp" />
|
||||
<ClCompile Include="renderer\render.cpp" />
|
||||
<ClCompile Include="renderer\TextRenderer.cpp" />
|
||||
<ClCompile Include="ui\Button.cpp" />
|
||||
<ClCompile Include="ui\Menu.cpp" />
|
||||
<ClCompile Include="utils\Data.cpp" />
|
||||
<ClCompile Include="utils\DataUtil.cpp" />
|
||||
<ClCompile Include="utils\File.cpp" />
|
||||
<ClCompile Include="utils\Path.cpp" />
|
||||
<ClCompile Include="utils\ResLoader.cpp" />
|
||||
|
|
@ -201,7 +202,7 @@
|
|||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
@ -212,7 +213,7 @@
|
|||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
@ -226,7 +227,7 @@
|
|||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
|
|
@ -242,7 +243,7 @@
|
|||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
|
|
@ -0,0 +1,369 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="math">
|
||||
<UniqueIdentifier>{80bc6386-2b70-4bae-993c-649a55163a1b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="utils">
|
||||
<UniqueIdentifier>{68eac919-ee87-4030-a033-c251731928f5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ui">
|
||||
<UniqueIdentifier>{07b6d541-4a1b-472a-aae0-daf9d082fe84}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="common">
|
||||
<UniqueIdentifier>{86e2d0f2-a9d0-4456-b6a5-d480228bbf82}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="platform">
|
||||
<UniqueIdentifier>{c2654ccc-59f6-4c17-bb6b-99b07fc78702}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="2d">
|
||||
<UniqueIdentifier>{896bdedf-6e82-449b-9b6e-0bc69f3699b1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="base">
|
||||
<UniqueIdentifier>{2e18d99a-e906-499a-9e29-4e0783202644}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="renderer">
|
||||
<UniqueIdentifier>{7897afce-24cb-42b4-9443-56508e4ec89c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ui\Button.h">
|
||||
<Filter>ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ui\Menu.h">
|
||||
<Filter>ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Action.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\ActionGroup.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\ActionHelper.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\ActionManager.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\ActionTween.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Animation.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Canvas.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Color.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\DebugNode.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Font.hpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Frames.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Geometry.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\GeometryNode.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Image.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\include-forwards.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Layer.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Node.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Scene.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Sprite.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Text.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\TextStyle.hpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Transform.hpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="2d\Transition.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Array.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\closure.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\ComPtr.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\helper.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\IntrusiveList.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\IntrusivePtr.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\noncopyable.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Singleton.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\String.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Component.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Event.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\EventDispatcher.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\EventListener.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\keys.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\logs.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\RefCounter.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Resource.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Task.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\TaskManager.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\time.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer\D2DDeviceResources.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer\D3D10DeviceResources.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer\D3D11DeviceResources.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer\DeviceResources.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer\helper.hpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer\render.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="renderer\TextRenderer.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="math\constants.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="math\ease.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="math\Matrix.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="math\rand.h">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="math\Rect.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="math\scalar.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\Application.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\modules.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="utils\File.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="utils\Path.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="utils\ResLoader.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="macros.h" />
|
||||
<ClInclude Include="math\helper.h">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="math\Vec2.hpp">
|
||||
<Filter>math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Input.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\window.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\SmartPtr.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Object.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="easy2d.h" />
|
||||
<ClInclude Include="utils\DataUtil.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ui\Button.cpp">
|
||||
<Filter>ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ui\Menu.cpp">
|
||||
<Filter>ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Action.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\ActionGroup.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\ActionManager.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\ActionTween.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Animation.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Canvas.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Color.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\DebugNode.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Frames.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Geometry.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\GeometryNode.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Image.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Layer.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Node.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Scene.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Sprite.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Text.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="2d\Transition.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\EventDispatcher.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\EventListener.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\logs.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\Resource.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\Task.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\TaskManager.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\time.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer\D2DDeviceResources.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer\D3D10DeviceResources.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer\D3D11DeviceResources.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer\render.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer\TextRenderer.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\Application.cpp">
|
||||
<Filter>platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\modules.cpp">
|
||||
<Filter>platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils\File.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils\Path.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils\ResLoader.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\Input.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\window.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base\Object.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="utils\DataUtil.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -105,6 +105,8 @@ namespace easy2d
|
|||
void* data;
|
||||
};
|
||||
|
||||
class Node;
|
||||
|
||||
// 事件
|
||||
struct E2D_API Event
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "EventDispatcher.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,16 +19,22 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "../base/SmartPtr.hpp"
|
||||
#include "../common/helper.h"
|
||||
#include "../common/IntrusiveList.hpp"
|
||||
#include "Object.h"
|
||||
#include "Event.hpp"
|
||||
#include <functional>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
using EventCallback = std::function<void(Event const&)>;
|
||||
typedef std::function<void(Event const&)> EventCallback;
|
||||
|
||||
class EventDispatcher;
|
||||
|
||||
E2D_DECLARE_SMART_PTR(EventListener);
|
||||
|
||||
// 事件监听器
|
||||
class E2D_API EventListener
|
||||
: public virtual Object
|
||||
, protected IntrusiveListItem<EventListenerPtr>
|
||||
|
|
@ -19,10 +19,11 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "../macros.h"
|
||||
#include "../common/Singleton.hpp"
|
||||
#include "../math/helper.h"
|
||||
#include "keys.hpp"
|
||||
#include "Component.h"
|
||||
#include "../common/Singleton.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -19,10 +19,15 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "helper.h"
|
||||
#include "../macros.h"
|
||||
#include "../common/helper.h"
|
||||
#include "RefCounter.hpp"
|
||||
#include "SmartPtr.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
E2D_DECLARE_SMART_PTR(Object);
|
||||
|
||||
class E2D_API Object
|
||||
: public RefCounter
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "Resource.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -51,11 +51,6 @@ namespace easy2d
|
|||
operator=(rhs);
|
||||
}
|
||||
|
||||
Resource::Resource(Resource && rhs)
|
||||
{
|
||||
operator=(std::forward<Resource&&>(rhs));
|
||||
}
|
||||
|
||||
Resource::~Resource()
|
||||
{
|
||||
if (IsFileType() && file_name_)
|
||||
|
|
@ -96,28 +91,6 @@ namespace easy2d
|
|||
return *this;
|
||||
}
|
||||
|
||||
Resource & Resource::operator=(Resource && rhs)
|
||||
{
|
||||
if (IsFileType() && file_name_)
|
||||
{
|
||||
delete file_name_;
|
||||
file_name_ = nullptr;
|
||||
}
|
||||
|
||||
type_ = rhs.type_;
|
||||
if (IsFileType())
|
||||
{
|
||||
file_name_ = rhs.file_name_;
|
||||
rhs.file_name_ = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
bin_name_ = rhs.bin_name_;
|
||||
bin_type_ = rhs.bin_type_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Resource::Load(LPVOID& buffer, DWORD& buffer_size) const
|
||||
{
|
||||
if (type_ != Type::Binary)
|
||||
|
|
@ -19,7 +19,8 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "helper.h"
|
||||
#include "../macros.h"
|
||||
#include "../common/helper.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -53,10 +54,6 @@ namespace easy2d
|
|||
Resource const& rhs
|
||||
);
|
||||
|
||||
Resource(
|
||||
Resource && rhs
|
||||
);
|
||||
|
||||
virtual ~Resource();
|
||||
|
||||
inline bool IsFileType() const { return type_ == Type::File; }
|
||||
|
|
@ -72,8 +69,6 @@ namespace easy2d
|
|||
|
||||
Resource& operator= (Resource const& rhs);
|
||||
|
||||
Resource& operator= (Resource && rhs);
|
||||
|
||||
private:
|
||||
Type type_;
|
||||
union
|
||||
|
|
@ -19,65 +19,31 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "../core/helper.h"
|
||||
#include "../base/RefCounter.hpp"
|
||||
#include "../common/IntrusivePtr.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
// 数据管理工具
|
||||
class E2D_API Data
|
||||
struct DefaultIntrusivePtrManager
|
||||
{
|
||||
public:
|
||||
Data(
|
||||
String const& key, /* 键值 */
|
||||
String const& field = L"Defalut" /* 字段名称 */
|
||||
);
|
||||
static inline void AddRef(RefCounter* ptr)
|
||||
{
|
||||
if (ptr) ptr->Retain();
|
||||
}
|
||||
|
||||
// 该数据是否存在
|
||||
bool Exists() const;
|
||||
|
||||
// 保存 int 类型的值
|
||||
bool SaveInt(
|
||||
int val
|
||||
);
|
||||
|
||||
// 保存 float 类型的值
|
||||
bool SaveFloat(
|
||||
float val
|
||||
);
|
||||
|
||||
// 保存 double 类型的值
|
||||
bool SaveDouble(
|
||||
double val
|
||||
);
|
||||
|
||||
// 保存 bool 类型的值
|
||||
bool SaveBool(
|
||||
bool val
|
||||
);
|
||||
|
||||
// 保存 String 类型的值
|
||||
bool SaveString(
|
||||
String const& val
|
||||
);
|
||||
|
||||
// 获取 int 类型的值
|
||||
int GetInt() const;
|
||||
|
||||
// 获取 float 类型的值
|
||||
float GetFloat() const;
|
||||
|
||||
// 获取 double 类型的值
|
||||
double GetDouble() const;
|
||||
|
||||
// 获取 bool 类型的值
|
||||
bool GetBool() const;
|
||||
|
||||
// 获取 字符串 类型的值
|
||||
String GetString();
|
||||
|
||||
protected:
|
||||
String key_;
|
||||
String field_;
|
||||
String const& data_path_;
|
||||
static inline void Release(RefCounter* ptr)
|
||||
{
|
||||
if (ptr) ptr->Release();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename _Ty>
|
||||
using SmartPtr = IntrusivePtr<_Ty, DefaultIntrusivePtrManager, true>;
|
||||
|
||||
}
|
||||
|
||||
#ifndef E2D_DECLARE_SMART_PTR
|
||||
#define E2D_DECLARE_SMART_PTR(CLASS)\
|
||||
class CLASS;\
|
||||
using CLASS##Ptr = ::easy2d::SmartPtr< CLASS >
|
||||
#endif
|
||||
|
|
@ -19,15 +19,18 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "include-forwards.h"
|
||||
#include "time.h"
|
||||
#include "../common/helper.h"
|
||||
#include "../common/IntrusiveList.hpp"
|
||||
#include "Object.h"
|
||||
#include "time.h"
|
||||
#include <functional>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
class TaskManager;
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Task);
|
||||
|
||||
// 定时任务
|
||||
class E2D_API Task
|
||||
: public virtual Object
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#include "TaskManager.h"
|
||||
#include "logs.h"
|
||||
#include "../base/logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -28,7 +28,7 @@ namespace easy2d
|
|||
{
|
||||
typedef int Value;
|
||||
|
||||
enum : int
|
||||
enum : Value
|
||||
{
|
||||
Left = VK_LBUTTON, // 報炎恣囚
|
||||
Right = VK_RBUTTON, // 報炎嘔囚
|
||||
|
|
@ -42,7 +42,7 @@ namespace easy2d
|
|||
{
|
||||
typedef int Value;
|
||||
|
||||
enum : int
|
||||
enum : Value
|
||||
{
|
||||
Unknown = 0,
|
||||
Up = VK_UP,
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
// Copyright (c) 2016-2018 Easy2D - 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 "logs.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
namespace __console_colors
|
||||
{
|
||||
const WORD _blue = FOREGROUND_BLUE | FOREGROUND_INTENSITY;
|
||||
const WORD _green = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
||||
const WORD _red = FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
const WORD _yellow = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
const WORD _white = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
|
||||
const WORD _blue_bg = _white | BACKGROUND_BLUE | BACKGROUND_INTENSITY;
|
||||
const WORD _green_bg = _white | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
||||
const WORD _red_bg = _white | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||
const WORD _yellow_bg = BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||
const WORD _white_bg = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||
|
||||
const WORD _reset = _white;
|
||||
|
||||
#define DECLARE_HANDLE_COLOR(NAME, HANDLE_NAME, COLOR)\
|
||||
inline std::wostream& (NAME)(std::wostream& _out)\
|
||||
{ ::SetConsoleTextAttribute(::GetStdHandle(HANDLE_NAME), _##COLOR); return _out; }
|
||||
|
||||
#define DECLARE_COLOR(COLOR) \
|
||||
DECLARE_HANDLE_COLOR(stdout_##COLOR, STD_OUTPUT_HANDLE, COLOR)\
|
||||
DECLARE_HANDLE_COLOR(stderr_##COLOR, STD_ERROR_HANDLE, COLOR)
|
||||
|
||||
#define DECLARE_BG_COLOR(COLOR) \
|
||||
DECLARE_HANDLE_COLOR(stdout_##COLOR##_bg, STD_OUTPUT_HANDLE, COLOR##_bg)\
|
||||
DECLARE_HANDLE_COLOR(stderr_##COLOR##_bg, STD_ERROR_HANDLE, COLOR##_bg)
|
||||
|
||||
DECLARE_COLOR(red);
|
||||
DECLARE_COLOR(green);
|
||||
DECLARE_COLOR(yellow);
|
||||
DECLARE_COLOR(blue);
|
||||
DECLARE_COLOR(white);
|
||||
DECLARE_COLOR(reset);
|
||||
|
||||
DECLARE_BG_COLOR(red);
|
||||
DECLARE_BG_COLOR(green);
|
||||
DECLARE_BG_COLOR(yellow);
|
||||
DECLARE_BG_COLOR(blue);
|
||||
DECLARE_BG_COLOR(white);
|
||||
|
||||
#undef DECLARE_COLOR
|
||||
#undef DECLARE_BG_COLOR
|
||||
}
|
||||
|
||||
Logger::Logger()
|
||||
{
|
||||
enabled_ = ::GetConsoleWindow() != nullptr;
|
||||
default_stdout_color_ = default_stderr_color_ = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
|
||||
CONSOLE_SCREEN_BUFFER_INFO stdout_info;
|
||||
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE), &stdout_info))
|
||||
{
|
||||
default_stdout_color_ = stdout_info.wAttributes;
|
||||
}
|
||||
|
||||
CONSOLE_SCREEN_BUFFER_INFO stderr_info;
|
||||
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_ERROR_HANDLE), &stderr_info))
|
||||
{
|
||||
default_stderr_color_ = stderr_info.wAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
// Copyright (c) 2016-2018 Easy2D - 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 "../macros.h"
|
||||
#include "../common/Singleton.hpp"
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#ifndef E2D_LOG
|
||||
# ifdef E2D_DEBUG
|
||||
# define E2D_LOG(FORMAT, ...) easy2d::Logger::Instance().Messageln((FORMAT), __VA_ARGS__)
|
||||
# else
|
||||
# define E2D_LOG __noop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef E2D_WARNING_LOG
|
||||
# define E2D_WARNING_LOG(FORMAT, ...) easy2d::Logger::Instance().Warningln((FORMAT), __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifndef E2D_ERROR_LOG
|
||||
# define E2D_ERROR_LOG(FORMAT, ...) easy2d::Logger::Instance().Errorln((FORMAT), __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
namespace __console_colors
|
||||
{
|
||||
using ConsoleColor = std::wostream&(*)(std::wostream&);
|
||||
|
||||
#define DECLARE_COLOR(COLOR)\
|
||||
extern std::wostream&(stdout_##COLOR)(std::wostream&);\
|
||||
extern std::wostream&(stderr_##COLOR)(std::wostream&);
|
||||
|
||||
#define DECLARE_BG_COLOR(COLOR)\
|
||||
extern std::wostream&(stdout_##COLOR##_bg)(std::wostream&);\
|
||||
extern std::wostream&(stderr_##COLOR##_bg)(std::wostream&);
|
||||
|
||||
DECLARE_COLOR(red);
|
||||
DECLARE_COLOR(green);
|
||||
DECLARE_COLOR(yellow);
|
||||
DECLARE_COLOR(blue);
|
||||
DECLARE_COLOR(white);
|
||||
DECLARE_COLOR(reset);
|
||||
|
||||
DECLARE_BG_COLOR(red);
|
||||
DECLARE_BG_COLOR(green);
|
||||
DECLARE_BG_COLOR(yellow);
|
||||
DECLARE_BG_COLOR(blue);
|
||||
DECLARE_BG_COLOR(white);
|
||||
|
||||
#undef DECLARE_COLOR
|
||||
#undef DECLARE_BG_COLOR
|
||||
}
|
||||
|
||||
class E2D_API Logger
|
||||
: public Singleton<Logger>
|
||||
{
|
||||
E2D_DECLARE_SINGLETON(Logger);
|
||||
|
||||
public:
|
||||
inline void Enable()
|
||||
{
|
||||
enabled_ = true;
|
||||
}
|
||||
|
||||
inline void Disable()
|
||||
{
|
||||
enabled_ = false;
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Print(const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
Output(std::wcout, stdout_white, nullptr, format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Println(const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
OutputLine(std::wcout, stdout_white, nullptr, format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Message(const wchar_t * format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
Output(std::wcout, stdout_blue, nullptr, format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Messageln(const wchar_t * format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
OutputLine(std::wcout, stdout_blue, nullptr, format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Warning(const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
Output(std::wcerr, stdout_yellow_bg, L"Warning: ", format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Warningln(const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
OutputLine(std::wcerr, stdout_yellow_bg, L"Warning: ", format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Error(const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
Output(std::wcerr, stderr_red_bg, L"Error: ", format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Errorln(const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
using namespace __console_colors;
|
||||
OutputLine(std::wcerr, stderr_red_bg, L"Error: ", format, std::forward<_Args&&>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
Logger();
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void OutputLine(std::wostream& os, __console_colors::ConsoleColor color, const wchar_t* prompt, const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
if (!enabled_)
|
||||
return;
|
||||
|
||||
Output(os, color, prompt, format, std::forward<_Args&&>(args)...);
|
||||
|
||||
os << std::endl;
|
||||
::OutputDebugStringW(L"\r\n");
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline void Output(std::wostream& os, __console_colors::ConsoleColor color, const wchar_t* prompt, const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
if (!enabled_)
|
||||
return;
|
||||
|
||||
std::wstring output = MakeOutputString(prompt, format, std::forward<_Args&&>(args)...);
|
||||
|
||||
os << color << output;
|
||||
::OutputDebugStringW(output.c_str());
|
||||
|
||||
ResetColor();
|
||||
}
|
||||
|
||||
template <typename ..._Args>
|
||||
inline std::wstring MakeOutputString(const wchar_t* prompt, const wchar_t* format, _Args&&... args) const
|
||||
{
|
||||
static wchar_t temp_buffer[1024 * 3 + 1];
|
||||
|
||||
const auto len = ::_scwprintf(format, std::forward<_Args&&>(args)...);
|
||||
::swprintf_s(temp_buffer, len + 1, format, std::forward<_Args&&>(args)...);
|
||||
|
||||
std::wstringstream ss;
|
||||
ss << Logger::OutPrefix;
|
||||
|
||||
if (prompt)
|
||||
ss << prompt;
|
||||
|
||||
ss << temp_buffer;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
inline void ResetColor() const
|
||||
{
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_OUTPUT_HANDLE), default_stdout_color_);
|
||||
::SetConsoleTextAttribute(::GetStdHandle(STD_ERROR_HANDLE), default_stderr_color_);
|
||||
}
|
||||
|
||||
static inline std::wostream& OutPrefix(std::wostream& out)
|
||||
{
|
||||
std::time_t unix = std::time(nullptr);
|
||||
std::tm tmbuf;
|
||||
localtime_s(&tmbuf, &unix);
|
||||
out << std::put_time(&tmbuf, L"[easy2d] %H:%M:%S ");
|
||||
return out;
|
||||
}
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
WORD default_stdout_color_;
|
||||
WORD default_stderr_color_;
|
||||
};
|
||||
}
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
inline void ThrowIfFailed(HRESULT hr)
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
E2D_ERROR_LOG(L"Fatal error with HRESULT of %08X", hr);
|
||||
|
||||
static char buffer[1024 + 1];
|
||||
sprintf_s(buffer, "Fatal error with HRESULT of %08X", hr);
|
||||
throw std::runtime_error(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue