fix: vs2013 & vs2012 support

This commit is contained in:
Haibo 2018-09-11 17:54:21 +08:00
parent fc2d409fd3
commit 909a72b189
7 changed files with 33 additions and 30 deletions

View File

@ -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_;
}
};
}

View File

@ -48,7 +48,7 @@ e2d::Window::Window()
::CoInitialize(nullptr);
// 获取系统 DPI
dpi_ = static_cast<float>(::GetDpiForSystem());
Renderer::GetFactory()->GetDesktopDpi(&dpi_, &dpi_);
}
e2d::Window::~Window()

View File

@ -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<int>(pos));
file_ext = file_path_.Subtract(static_cast<int>(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<LPCWSTR>(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<LPCWSTR>(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;
}

View File

@ -1,4 +1,5 @@
#include "..\e2dtransition.h"
#include "..\e2dobject.h"
e2d::BoxTransition::BoxTransition(float duration)
: Transition(duration)

View File

@ -1,4 +1,5 @@
#include "..\e2dtransition.h"
#include "..\e2dobject.h"
e2d::MoveTransition::MoveTransition(float duration, Direction direction)
: Transition(duration)

View File

@ -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
)
);
}

View File

@ -1,6 +1,6 @@
#include "..\e2dmodule.h"
#include "..\e2dtransition.h"
#include "..\e2dobject.h"
#include "..\e2dmodule.h"
e2d::Transition::Transition(float duration)
: done_(false)