From 909a72b1896a1c61cffe84cb82fc002c3963402d Mon Sep 17 00:00:00 2001 From: Haibo Date: Tue, 11 Sep 2018 17:54:21 +0800 Subject: [PATCH] fix: vs2013 & vs2012 support --- core/e2dtransition.h | 6 ++-- core/modules/Window.cpp | 2 +- core/tools/File.cpp | 42 ++++++++++++------------- core/transitions/BoxTransition.cpp | 1 + core/transitions/MoveTransition.cpp | 1 + core/transitions/RotationTransition.cpp | 9 +++--- core/transitions/Transition.cpp | 2 +- 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/core/e2dtransition.h b/core/e2dtransition.h index e14c856a..9bf74b93 100644 --- a/core/e2dtransition.h +++ b/core/e2dtransition.h @@ -46,7 +46,7 @@ namespace e2d protected: bool done_; float duration_; - float delta_; + float process_; Time started_; Size window_size_; Scene* out_scene_; @@ -148,7 +148,7 @@ namespace e2d : public Transition { public: - explicit MoveTransition( + explicit RotationTransition( float moveDuration, /* 动画持续时长 */ float rotation = 360 /* 旋转度数 */ ); @@ -165,6 +165,6 @@ namespace e2d protected: float rotation_; - } + }; } \ No newline at end of file diff --git a/core/modules/Window.cpp b/core/modules/Window.cpp index 2a1f8eed..c4a15db2 100644 --- a/core/modules/Window.cpp +++ b/core/modules/Window.cpp @@ -48,7 +48,7 @@ e2d::Window::Window() ::CoInitialize(nullptr); // 获取系统 DPI - dpi_ = static_cast(::GetDpiForSystem()); + Renderer::GetFactory()->GetDesktopDpi(&dpi_, &dpi_); } e2d::Window::~Window() diff --git a/core/tools/File.cpp b/core/tools/File.cpp index 910e4d18..4931ffc6 100644 --- a/core/tools/File.cpp +++ b/core/tools/File.cpp @@ -72,18 +72,18 @@ const e2d::String& e2d::File::GetPath() const e2d::String e2d::File::GetExtension() const { - String fileExtension; + String file_ext; // 找到文件名中的最后一个 '.' 的位置 - size_t pos = std::wstring(file_path_).find_last_of(L'.'); + size_t pos = file_path_.operator std::wstring().find_last_of(L'.'); // 判断 pos 是否是有效位置 if (pos != std::wstring::npos) { // 截取扩展名 - fileExtension = file_path_.Subtract(static_cast(pos)); + file_ext = file_path_.Subtract(static_cast(pos)); // 转换为小写字母 - fileExtension = fileExtension.ToLower(); + file_ext = file_ext.ToLower(); } - return std::move(fileExtension); + return std::move(file_ext); } bool e2d::File::Delete() @@ -96,7 +96,7 @@ bool e2d::File::Delete() e2d::File e2d::File::Extract(int resource_name, const String & resource_type, const String& dest_file_name) { // 创建文件 - HANDLE hFile = ::CreateFile( + HANDLE file = ::CreateFile( static_cast(dest_file_name), GENERIC_WRITE, NULL, @@ -106,25 +106,25 @@ e2d::File e2d::File::Extract(int resource_name, const String & resource_type, co NULL ); - if (hFile == INVALID_HANDLE_VALUE) + if (file == INVALID_HANDLE_VALUE) return std::move(File()); // 查找资源文件中、加载资源到内存、得到资源大小 - HRSRC hRes = ::FindResource(NULL, MAKEINTRESOURCE(resource_name), (LPCWSTR)resource_type); - HGLOBAL hMem = ::LoadResource(NULL, hRes); - DWORD dwSize = ::SizeofResource(NULL, hRes); + HRSRC res = ::FindResource(NULL, MAKEINTRESOURCE(resource_name), (LPCWSTR)resource_type); + HGLOBAL res_data = ::LoadResource(NULL, res); + DWORD res_size = ::SizeofResource(NULL, res); - if (hRes && hMem && dwSize) + if (res && res_data && res_size) { // 写入文件 - DWORD dwWrite = 0; - ::WriteFile(hFile, hMem, dwSize, &dwWrite, NULL); - ::CloseHandle(hFile); + DWORD written_bytes = 0; + ::WriteFile(file, res_data, res_size, &written_bytes, NULL); + ::CloseHandle(file); return File(dest_file_name); } else { - ::CloseHandle(hFile); + ::CloseHandle(file); ::DeleteFile(static_cast(dest_file_name)); return std::move(File()); } @@ -134,7 +134,7 @@ void e2d::File::AddSearchPath(const String & path) { String tmp = path; tmp.Replace(L"/", L"\\"); - if (tmp[tmp.GetLength() - 1] != L'\\') + if (tmp.At(tmp.GetLength() - 1) != L'\\') { tmp << L"\\"; } @@ -150,17 +150,17 @@ bool e2d::File::CreateFolder(const String & dir_path) if (dir_path.IsEmpty() || dir_path.GetLength() >= MAX_PATH) return false; - wchar_t tmpDirPath[_MAX_PATH] = { 0 }; + wchar_t tmp_dir_path[MAX_PATH] = { 0 }; int length = dir_path.GetLength(); for (int i = 0; i < length; ++i) { - tmpDirPath[i] = dir_path.At(i); - if (tmpDirPath[i] == L'\\' || tmpDirPath[i] == L'/' || i == (length - 1)) + tmp_dir_path[i] = dir_path.At(i); + if (tmp_dir_path[i] == L'\\' || tmp_dir_path[i] == L'/' || i == (length - 1)) { - if (::_waccess(tmpDirPath, 0) != 0) + if (::_waccess(tmp_dir_path, 0) != 0) { - if (::_wmkdir(tmpDirPath) != 0) + if (::_wmkdir(tmp_dir_path) != 0) { return false; } diff --git a/core/transitions/BoxTransition.cpp b/core/transitions/BoxTransition.cpp index 29878aab..483d38fd 100644 --- a/core/transitions/BoxTransition.cpp +++ b/core/transitions/BoxTransition.cpp @@ -1,4 +1,5 @@ #include "..\e2dtransition.h" +#include "..\e2dobject.h" e2d::BoxTransition::BoxTransition(float duration) : Transition(duration) diff --git a/core/transitions/MoveTransition.cpp b/core/transitions/MoveTransition.cpp index c50422b1..9f91925a 100644 --- a/core/transitions/MoveTransition.cpp +++ b/core/transitions/MoveTransition.cpp @@ -1,4 +1,5 @@ #include "..\e2dtransition.h" +#include "..\e2dobject.h" e2d::MoveTransition::MoveTransition(float duration, Direction direction) : Transition(duration) diff --git a/core/transitions/RotationTransition.cpp b/core/transitions/RotationTransition.cpp index 57c1c9f5..d343a320 100644 --- a/core/transitions/RotationTransition.cpp +++ b/core/transitions/RotationTransition.cpp @@ -1,4 +1,5 @@ #include "..\e2dtransition.h" +#include "..\e2dobject.h" e2d::RotationTransition::RotationTransition(float duration, float rotation) : Transition(duration) @@ -42,8 +43,8 @@ void e2d::RotationTransition::Update() (.5f - process_) * 2, center_pos ) * D2D1::Matrix3x2F::Rotation( - rotation * (.5f - process_) * 2, - center_pos, + rotation_ * (.5f - process_) * 2, + center_pos ) ); } @@ -61,8 +62,8 @@ void e2d::RotationTransition::Update() (process_ - .5f) * 2, center_pos ) * D2D1::Matrix3x2F::Rotation( - rotation * (process_ - .5f) * 2, - center_pos, + rotation_ * (process_ - .5f) * 2, + center_pos ) ); } diff --git a/core/transitions/Transition.cpp b/core/transitions/Transition.cpp index 68d1531b..fd04c6e0 100644 --- a/core/transitions/Transition.cpp +++ b/core/transitions/Transition.cpp @@ -1,6 +1,6 @@ -#include "..\e2dmodule.h" #include "..\e2dtransition.h" #include "..\e2dobject.h" +#include "..\e2dmodule.h" e2d::Transition::Transition(float duration) : done_(false)