update class Text
new feature: Text alignment, underline, strikethrough, line spacing. Remove Text::setWrappingEnable.
This commit is contained in:
		
							parent
							
								
									8c9deb5dea
								
							
						
					
					
						commit
						9bef38091f
					
				|  | @ -58,7 +58,7 @@ e2d::String e2d::Action::getName() const | ||||||
| 	return m_sName; | 	return m_sName; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Action::setName(String& name) | void e2d::Action::setName(String name) | ||||||
| { | { | ||||||
| 	m_sName = name; | 	m_sName = name; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ static bool s_bInitialized = false; | ||||||
| static e2d::String s_sAppName; | static e2d::String s_sAppName; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| bool e2d::Game::init(String& sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID, String sAppname) | bool e2d::Game::init(String sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID, String sAppname) | ||||||
| { | { | ||||||
| 	if (s_bInitialized) | 	if (s_bInitialized) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -191,7 +191,7 @@ void e2d::Input::add(Function func, String name) | ||||||
| 	(new Listener(func, name))->start(); | 	(new Listener(func, name))->start(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Input::start(String& name) | void e2d::Input::start(String name) | ||||||
| { | { | ||||||
| 	for (const auto & pListener : s_vListeners) | 	for (const auto & pListener : s_vListeners) | ||||||
| 	{ | 	{ | ||||||
|  | @ -202,7 +202,7 @@ void e2d::Input::start(String& name) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Input::stop(String& name) | void e2d::Input::stop(String name) | ||||||
| { | { | ||||||
| 	for (const auto & pListener : s_vListeners) | 	for (const auto & pListener : s_vListeners) | ||||||
| 	{ | 	{ | ||||||
|  | @ -213,7 +213,7 @@ void e2d::Input::stop(String& name) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Input::clear(String& name) | void e2d::Input::clear(String name) | ||||||
| { | { | ||||||
| 	for (const auto & pListener : s_vListeners) | 	for (const auto & pListener : s_vListeners) | ||||||
| 	{ | 	{ | ||||||
|  | @ -248,7 +248,7 @@ void e2d::Input::clearAll() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<Listener*> e2d::Input::get(String& name) | std::vector<Listener*> e2d::Input::get(String name) | ||||||
| { | { | ||||||
| 	std::vector<Listener*> vListeners; | 	std::vector<Listener*> vListeners; | ||||||
| 	for (auto pListener : s_vListeners) | 	for (auto pListener : s_vListeners) | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ static HWND s_HWnd = nullptr; | ||||||
| static bool s_bShowConsole = false; | static bool s_bShowConsole = false; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| bool e2d::Window::__init(String& sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID /*= nullptr*/) | bool e2d::Window::__init(const String& sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID /*= nullptr*/) | ||||||
| { | { | ||||||
| 	if (!Window::__initMutex(sTitle)) | 	if (!Window::__initMutex(sTitle)) | ||||||
| 	{ | 	{ | ||||||
|  | @ -106,7 +106,7 @@ bool e2d::Window::__init(String& sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR | ||||||
| 	return SUCCEEDED(hr); | 	return SUCCEEDED(hr); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool e2d::Window::__initMutex(String& sTitle) | bool e2d::Window::__initMutex(const String& sTitle) | ||||||
| { | { | ||||||
| 	// ´´½¨½ø³Ì»¥³âÌå
 | 	// ´´½¨½ø³Ì»¥³âÌå
 | ||||||
| 	HANDLE m_hMutex = ::CreateMutex(NULL, TRUE, L"Easy2DApp-" + sTitle); | 	HANDLE m_hMutex = ::CreateMutex(NULL, TRUE, L"Easy2DApp-" + sTitle); | ||||||
|  | @ -204,7 +204,7 @@ void e2d::Window::setSize(UINT32 width, UINT32 height) | ||||||
| 	::MoveWindow(s_HWnd, (screenWidth - width) / 2, (screenHeight - height) / 2, width, height, TRUE); | 	::MoveWindow(s_HWnd, (screenWidth - width) / 2, (screenHeight - height) / 2, width, height, TRUE); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Window::setTitle(String&title) | void e2d::Window::setTitle(String title) | ||||||
| { | { | ||||||
| 	// ÉèÖô°¿Ú±êÌâ
 | 	// ÉèÖô°¿Ú±êÌâ
 | ||||||
| 	::SetWindowText(s_HWnd, title); | 	::SetWindowText(s_HWnd, title); | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ bool e2d::Font::isItalic() const | ||||||
| 	return m_bItalic; | 	return m_bItalic; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Font::setFamily(String& fontFamily) | void e2d::Font::setFamily(String fontFamily) | ||||||
| { | { | ||||||
| 	m_sFontFamily = fontFamily; | 	m_sFontFamily = fontFamily; | ||||||
| 	m_bRecreateNeeded = true; | 	m_bRecreateNeeded = true; | ||||||
|  | @ -90,14 +90,14 @@ void e2d::Font::_initTextFormat() | ||||||
| 		m_bItalic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, | 		m_bItalic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, | ||||||
| 		DWRITE_FONT_STRETCH_NORMAL, | 		DWRITE_FONT_STRETCH_NORMAL, | ||||||
| 		m_fFontSize, | 		m_fFontSize, | ||||||
| 		L"en-us", | 		L"zh-cn", | ||||||
| 		&m_pTextFormat | 		&m_pTextFormat | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	ASSERT(SUCCEEDED(hr), "Create IDWriteTextFormat Failed!"); | 	ASSERT(SUCCEEDED(hr), "Create IDWriteTextFormat Failed!"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| IDWriteTextFormat * e2d::Font::_getTextFormat() | IDWriteTextFormat * e2d::Font::getDWriteTextFormat() | ||||||
| { | { | ||||||
| 	if (m_bRecreateNeeded) | 	if (m_bRecreateNeeded) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -13,12 +13,12 @@ e2d::Image::Image() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Image::Image(String& strFileName) | e2d::Image::Image(String strFileName) | ||||||
| { | { | ||||||
| 	this->open(strFileName); | 	this->open(strFileName); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Image::Image(String& strFileName, double nClipX, double nClipY, double nClipWidth, double nClipHeight) | e2d::Image::Image(String strFileName, double nClipX, double nClipY, double nClipWidth, double nClipHeight) | ||||||
| { | { | ||||||
| 	this->open(strFileName); | 	this->open(strFileName); | ||||||
| 	this->clip(nClipX, nClipY, nClipWidth, nClipHeight); | 	this->clip(nClipX, nClipY, nClipWidth, nClipHeight); | ||||||
|  | @ -28,7 +28,7 @@ e2d::Image::~Image() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Image::open(String& strFilePath) | void e2d::Image::open(String strFilePath) | ||||||
| { | { | ||||||
| 	WARN_IF(strFilePath.isEmpty(), "Image cannot load bitmap from NULL file name."); | 	WARN_IF(strFilePath.isEmpty(), "Image cannot load bitmap from NULL file name."); | ||||||
| 
 | 
 | ||||||
|  | @ -124,7 +124,7 @@ e2d::Point e2d::Image::getClipPos() const | ||||||
| 	return Point(m_fSourceClipX, m_fSourceClipY); | 	return Point(m_fSourceClipX, m_fSourceClipY); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool e2d::Image::preload(String& fileName) | bool e2d::Image::preload(String fileName) | ||||||
| { | { | ||||||
| 	if (s_mBitmapsFromFile.find(fileName.getHashCode()) != s_mBitmapsFromFile.end()) | 	if (s_mBitmapsFromFile.find(fileName.getHashCode()) != s_mBitmapsFromFile.end()) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ e2d::Listener::Listener(Function func) | ||||||
| 	Input::__add(this); | 	Input::__add(this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Listener::Listener(Function func, String& name) | e2d::Listener::Listener(Function func, String name) | ||||||
| 	: m_bRunning(false) | 	: m_bRunning(false) | ||||||
| 	, m_sName(name) | 	, m_sName(name) | ||||||
| 	, m_callback(func) | 	, m_callback(func) | ||||||
|  | @ -52,7 +52,7 @@ e2d::String e2d::Listener::getName() | ||||||
| 	return m_sName; | 	return m_sName; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Listener::setName(String& name) | void e2d::Listener::setName(String name) | ||||||
| { | { | ||||||
| 	m_sName = name; | 	m_sName = name; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -114,7 +114,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionManager::resume(String& strActionName) | void e2d::ActionManager::resume(String strActionName) | ||||||
| { | { | ||||||
| 	for (auto action : s_vRunningActions) | 	for (auto action : s_vRunningActions) | ||||||
| 	{ | 	{ | ||||||
|  | @ -125,7 +125,7 @@ void e2d::ActionManager::resume(String& strActionName) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionManager::pause(String& strActionName) | void e2d::ActionManager::pause(String strActionName) | ||||||
| { | { | ||||||
| 	for (auto action : s_vRunningActions) | 	for (auto action : s_vRunningActions) | ||||||
| 	{ | 	{ | ||||||
|  | @ -136,7 +136,7 @@ void e2d::ActionManager::pause(String& strActionName) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionManager::stop(String& strActionName) | void e2d::ActionManager::stop(String strActionName) | ||||||
| { | { | ||||||
| 	for (auto action : s_vRunningActions) | 	for (auto action : s_vRunningActions) | ||||||
| 	{ | 	{ | ||||||
|  | @ -191,7 +191,7 @@ void e2d::ActionManager::stopAll() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<e2d::Action*> e2d::ActionManager::get(String& strActionName) | std::vector<e2d::Action*> e2d::ActionManager::get(String strActionName) | ||||||
| { | { | ||||||
| 	std::vector<Action*> vActions; | 	std::vector<Action*> vActions; | ||||||
| 	for (const auto action : s_vActions) | 	for (const auto action : s_vActions) | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ static MusicList& getMusicList() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| bool e2d::MusicManager::preload(String& strFilePath) | bool e2d::MusicManager::preload(String strFilePath) | ||||||
| { | { | ||||||
| 	UINT nRet = strFilePath.getHashCode(); | 	UINT nRet = strFilePath.getHashCode(); | ||||||
| 
 | 
 | ||||||
|  | @ -42,7 +42,7 @@ bool e2d::MusicManager::preload(String& strFilePath) | ||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool e2d::MusicManager::play(String& strFilePath, int nLoopCount) | bool e2d::MusicManager::play(String strFilePath, int nLoopCount) | ||||||
| { | { | ||||||
| 	if (MusicManager::preload(strFilePath)) | 	if (MusicManager::preload(strFilePath)) | ||||||
| 	{ | 	{ | ||||||
|  | @ -56,7 +56,7 @@ bool e2d::MusicManager::play(String& strFilePath, int nLoopCount) | ||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::MusicManager::pause(String& strFilePath) | void e2d::MusicManager::pause(String strFilePath) | ||||||
| { | { | ||||||
| 	auto music = MusicManager::get(strFilePath); | 	auto music = MusicManager::get(strFilePath); | ||||||
| 	if (music) | 	if (music) | ||||||
|  | @ -65,7 +65,7 @@ void e2d::MusicManager::pause(String& strFilePath) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::MusicManager::resume(String& strFilePath) | void e2d::MusicManager::resume(String strFilePath) | ||||||
| { | { | ||||||
| 	auto music = MusicManager::get(strFilePath); | 	auto music = MusicManager::get(strFilePath); | ||||||
| 	if (music) | 	if (music) | ||||||
|  | @ -74,7 +74,7 @@ void e2d::MusicManager::resume(String& strFilePath) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::MusicManager::stop(String& strFilePath) | void e2d::MusicManager::stop(String strFilePath) | ||||||
| { | { | ||||||
| 	auto music = MusicManager::get(strFilePath); | 	auto music = MusicManager::get(strFilePath); | ||||||
| 	if (music) | 	if (music) | ||||||
|  | @ -83,7 +83,7 @@ void e2d::MusicManager::stop(String& strFilePath) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Music * e2d::MusicManager::get(String& strFilePath) | e2d::Music * e2d::MusicManager::get(String strFilePath) | ||||||
| { | { | ||||||
| 	if (strFilePath.isEmpty()) | 	if (strFilePath.isEmpty()) | ||||||
| 		return nullptr; | 		return nullptr; | ||||||
|  |  | ||||||
|  | @ -62,7 +62,7 @@ void e2d::TimerManager::__add(Timer * pTimer) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::TimerManager::start(String& name) | void e2d::TimerManager::start(String name) | ||||||
| { | { | ||||||
| 	for (auto timer : s_vTimers) | 	for (auto timer : s_vTimers) | ||||||
| 	{ | 	{ | ||||||
|  | @ -73,7 +73,7 @@ void e2d::TimerManager::start(String& name) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::TimerManager::stop(String& name) | void e2d::TimerManager::stop(String name) | ||||||
| { | { | ||||||
| 	for (auto timer : s_vTimers) | 	for (auto timer : s_vTimers) | ||||||
| 	{ | 	{ | ||||||
|  | @ -84,7 +84,7 @@ void e2d::TimerManager::stop(String& name) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::TimerManager::clear(String& name) | void e2d::TimerManager::clear(String name) | ||||||
| { | { | ||||||
| 	for (auto timer : s_vTimers) | 	for (auto timer : s_vTimers) | ||||||
| 	{ | 	{ | ||||||
|  | @ -95,7 +95,7 @@ void e2d::TimerManager::clear(String& name) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<e2d::Timer*> e2d::TimerManager::get(String& name) | std::vector<e2d::Timer*> e2d::TimerManager::get(String name) | ||||||
| { | { | ||||||
| 	std::vector<Timer*> vTimers; | 	std::vector<Timer*> vTimers; | ||||||
| 	for (auto timer : s_vTimers) | 	for (auto timer : s_vTimers) | ||||||
|  |  | ||||||
|  | @ -211,10 +211,7 @@ void e2d::Node::_onExit() | ||||||
| void e2d::Node::_updateTransform() | void e2d::Node::_updateTransform() | ||||||
| { | { | ||||||
| 	// 计算中心点坐标
 | 	// 计算中心点坐标
 | ||||||
| 	D2D1_POINT_2F pivot = D2D1::Point2F( | 	D2D1_POINT_2F pivot = { m_fWidth * m_fPivotX, m_fHeight * m_fPivotY }; | ||||||
| 		m_fWidth * m_fPivotX, |  | ||||||
| 		m_fHeight * m_fPivotY |  | ||||||
| 	); |  | ||||||
| 	// 变换 Initial 矩阵,子节点将根据这个矩阵进行变换
 | 	// 变换 Initial 矩阵,子节点将根据这个矩阵进行变换
 | ||||||
| 	m_MatriInitial = D2D1::Matrix3x2F::Scale( | 	m_MatriInitial = D2D1::Matrix3x2F::Scale( | ||||||
| 		m_fScaleX, | 		m_fScaleX, | ||||||
|  | @ -614,7 +611,7 @@ e2d::Scene * e2d::Node::getParentScene() const | ||||||
| 	return m_pParentScene; | 	return m_pParentScene; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<e2d::Node*> e2d::Node::getChildren(String& name) | std::vector<e2d::Node*> e2d::Node::getChildren(String name) | ||||||
| { | { | ||||||
| 	std::vector<Node*> vChildren; | 	std::vector<Node*> vChildren; | ||||||
| 	unsigned int hash = name.getHashCode(); | 	unsigned int hash = name.getHashCode(); | ||||||
|  | @ -684,7 +681,7 @@ bool e2d::Node::removeChild(Node * child) | ||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::removeChildren(String& childName) | void e2d::Node::removeChildren(String childName) | ||||||
| { | { | ||||||
| 	WARN_IF(childName.isEmpty(), "Invalid Node name."); | 	WARN_IF(childName.isEmpty(), "Invalid Node name."); | ||||||
| 
 | 
 | ||||||
|  | @ -753,7 +750,7 @@ void e2d::Node::runAction(Action * action) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::resumeAction(String& strActionName) | void e2d::Node::resumeAction(String strActionName) | ||||||
| { | { | ||||||
| 	auto actions = ActionManager::get(strActionName); | 	auto actions = ActionManager::get(strActionName); | ||||||
| 	for (auto action : actions) | 	for (auto action : actions) | ||||||
|  | @ -765,7 +762,7 @@ void e2d::Node::resumeAction(String& strActionName) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::pauseAction(String& strActionName) | void e2d::Node::pauseAction(String strActionName) | ||||||
| { | { | ||||||
| 	auto actions = ActionManager::get(strActionName); | 	auto actions = ActionManager::get(strActionName); | ||||||
| 	for (auto action : actions) | 	for (auto action : actions) | ||||||
|  | @ -777,7 +774,7 @@ void e2d::Node::pauseAction(String& strActionName) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::stopAction(String& strActionName) | void e2d::Node::stopAction(String strActionName) | ||||||
| { | { | ||||||
| 	auto actions = ActionManager::get(strActionName); | 	auto actions = ActionManager::get(strActionName); | ||||||
| 	for (auto action : actions) | 	for (auto action : actions) | ||||||
|  | @ -789,7 +786,7 @@ void e2d::Node::stopAction(String& strActionName) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Action * e2d::Node::getAction(String& strActionName) | e2d::Action * e2d::Node::getAction(String strActionName) | ||||||
| { | { | ||||||
| 	auto actions = ActionManager::get(strActionName); | 	auto actions = ActionManager::get(strActionName); | ||||||
| 	for (auto action : actions) | 	for (auto action : actions) | ||||||
|  | @ -802,7 +799,7 @@ e2d::Action * e2d::Node::getAction(String& strActionName) | ||||||
| 	return nullptr; | 	return nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<e2d::Action*> e2d::Node::getActions(String& strActionName) | std::vector<e2d::Action*> e2d::Node::getActions(String strActionName) | ||||||
| { | { | ||||||
| 	std::vector<Action*>::iterator iter; | 	std::vector<Action*>::iterator iter; | ||||||
| 	auto actions = ActionManager::get(strActionName); | 	auto actions = ActionManager::get(strActionName); | ||||||
|  | @ -826,7 +823,7 @@ bool e2d::Node::isPointIn(Point point) const | ||||||
| 	// 如果存在形状,用形状判断
 | 	// 如果存在形状,用形状判断
 | ||||||
| 	if (m_pShape) | 	if (m_pShape) | ||||||
| 	{ | 	{ | ||||||
| 		m_pShape->_getD2dGeometry()->FillContainsPoint( | 		m_pShape->getD2dGeometry()->FillContainsPoint( | ||||||
| 			D2D1::Point2F( | 			D2D1::Point2F( | ||||||
| 				static_cast<float>(point.x), | 				static_cast<float>(point.x), | ||||||
| 				static_cast<float>(point.y)), | 				static_cast<float>(point.y)), | ||||||
|  | @ -970,7 +967,7 @@ void e2d::Node::setVisiable(bool value) | ||||||
| 	m_bVisiable = value; | 	m_bVisiable = value; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::setName(String& name) | void e2d::Node::setName(String name) | ||||||
| { | { | ||||||
| 	WARN_IF(name.isEmpty(), "Invalid Node name."); | 	WARN_IF(name.isEmpty(), "Invalid Node name."); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -12,13 +12,13 @@ e2d::Sprite::Sprite(Image * image) | ||||||
| 	open(image); | 	open(image); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Sprite::Sprite(String& imageFileName) | e2d::Sprite::Sprite(String imageFileName) | ||||||
| 	: m_pImage(nullptr) | 	: m_pImage(nullptr) | ||||||
| { | { | ||||||
| 	open(imageFileName); | 	open(imageFileName); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Sprite::Sprite(String& imageFileName, double x, double y, double width, double height) | e2d::Sprite::Sprite(String imageFileName, double x, double y, double width, double height) | ||||||
| 	: m_pImage(nullptr) | 	: m_pImage(nullptr) | ||||||
| { | { | ||||||
| 	open(imageFileName); | 	open(imageFileName); | ||||||
|  | @ -42,7 +42,7 @@ void e2d::Sprite::open(Image * image) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Sprite::open(String& imageFileName) | void e2d::Sprite::open(String imageFileName) | ||||||
| { | { | ||||||
| 	open(new Image(imageFileName)); | 	open(new Image(imageFileName)); | ||||||
| } | } | ||||||
|  | @ -65,6 +65,7 @@ void e2d::Sprite::onRender() | ||||||
| { | { | ||||||
| 	if (m_pImage && m_pImage->getBitmap()) | 	if (m_pImage && m_pImage->getBitmap()) | ||||||
| 	{ | 	{ | ||||||
|  | 		// »ñȡͼƬ²Ã¼ôλÖÃ
 | ||||||
| 		float fClipX = static_cast<float>(m_pImage->getClipX()); | 		float fClipX = static_cast<float>(m_pImage->getClipX()); | ||||||
| 		float fClipY = static_cast<float>(m_pImage->getClipY()); | 		float fClipY = static_cast<float>(m_pImage->getClipY()); | ||||||
| 		// äÖȾͼƬ
 | 		// äÖȾͼƬ
 | ||||||
|  |  | ||||||
|  | @ -1,43 +1,58 @@ | ||||||
| #include "..\enodes.h" | #include "..\enodes.h" | ||||||
| 
 | 
 | ||||||
| e2d::Text::Text() | e2d::Text::Text() | ||||||
| 	: m_bWordWrapping(false) | 	: m_bWrappingEnable(false) | ||||||
| 	, m_pFont(nullptr) | 	, m_pFont(nullptr) | ||||||
| 	, m_fWordWrappingWidth(0) | 	, m_fWrappingWidth(0) | ||||||
|  | 	, m_bHasUnderline(false) | ||||||
|  | 	, m_bHasStrikethrough(false) | ||||||
|  | 	, m_pDWriteTextLayout(nullptr) | ||||||
| { | { | ||||||
| 	this->setFont(new Font()); | 	this->setFont(new Font()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Text::Text(String& text) | e2d::Text::Text(String text) | ||||||
| 	: m_bWordWrapping(false) | 	: m_bWrappingEnable(false) | ||||||
| 	, m_pFont(nullptr) | 	, m_pFont(nullptr) | ||||||
| 	, m_fWordWrappingWidth(0) | 	, m_fWrappingWidth(0) | ||||||
|  | 	, m_bHasUnderline(false) | ||||||
|  | 	, m_bHasStrikethrough(false) | ||||||
|  | 	, m_pDWriteTextLayout(nullptr) | ||||||
| { | { | ||||||
| 	this->setText(text); | 	this->setText(text); | ||||||
| 	this->setFont(new Font()); | 	this->setFont(new Font()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Text::Text(Font * font) | e2d::Text::Text(Font * font) | ||||||
| 	: m_bWordWrapping(false) | 	: m_bWrappingEnable(false) | ||||||
| 	, m_pFont(nullptr) | 	, m_pFont(nullptr) | ||||||
| 	, m_fWordWrappingWidth(0) | 	, m_fWrappingWidth(0) | ||||||
|  | 	, m_bHasUnderline(false) | ||||||
|  | 	, m_bHasStrikethrough(false) | ||||||
|  | 	, m_pDWriteTextLayout(nullptr) | ||||||
| { | { | ||||||
| 	this->setFont(font); | 	this->setFont(font); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Text::Text(String& text, Font * font) | e2d::Text::Text(String text, Font * font) | ||||||
| 	: m_bWordWrapping(false) | 	: m_bWrappingEnable(false) | ||||||
| 	, m_pFont(nullptr) | 	, m_pFont(nullptr) | ||||||
| 	, m_fWordWrappingWidth(0) | 	, m_fWrappingWidth(0) | ||||||
|  | 	, m_bHasUnderline(false) | ||||||
|  | 	, m_bHasStrikethrough(false) | ||||||
|  | 	, m_pDWriteTextLayout(nullptr) | ||||||
| { | { | ||||||
| 	this->setText(text); | 	this->setText(text); | ||||||
| 	this->setFont(font); | 	this->setFont(font); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Text::Text(String& text, String fontFamily, double fontSize, UINT32 color, UINT32 fontWeight, bool italic) | e2d::Text::Text(String text, String fontFamily, double fontSize, UINT32 color, UINT32 fontWeight, bool italic) | ||||||
| 	: m_bWordWrapping(false) | 	: m_bWrappingEnable(false) | ||||||
| 	, m_pFont(nullptr) | 	, m_pFont(nullptr) | ||||||
| 	, m_fWordWrappingWidth(0) | 	, m_fWrappingWidth(0) | ||||||
|  | 	, m_bHasUnderline(false) | ||||||
|  | 	, m_bHasStrikethrough(false) | ||||||
|  | 	, m_pDWriteTextLayout(nullptr) | ||||||
| { | { | ||||||
| 	this->setText(text); | 	this->setText(text); | ||||||
| 	this->setFont(new Font(fontFamily, fontSize, color, fontWeight, italic)); | 	this->setFont(new Font(fontFamily, fontSize, color, fontWeight, italic)); | ||||||
|  | @ -53,22 +68,12 @@ e2d::String e2d::Text::getText() const | ||||||
| 	return m_sText; | 	return m_sText; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| double e2d::Text::getWidth() const |  | ||||||
| { |  | ||||||
| 	return m_fWordWrappingWidth * m_fScaleX; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| double e2d::Text::getRealWidth() const |  | ||||||
| { |  | ||||||
| 	return m_fWordWrappingWidth; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::Font * e2d::Text::getFont() const | e2d::Font * e2d::Text::getFont() const | ||||||
| { | { | ||||||
| 	return m_pFont; | 	return m_pFont; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Text::setText(String& text) | void e2d::Text::setText(String text) | ||||||
| { | { | ||||||
| 	m_sText = text; | 	m_sText = text; | ||||||
| 	_initTextLayout(); | 	_initTextLayout(); | ||||||
|  | @ -86,29 +91,76 @@ void e2d::Text::setFont(Font * font) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Text::setWordWrappingEnable(bool value) | void e2d::Text::setWrappingWidth(double wordWrapWidth) | ||||||
| { | { | ||||||
| 	m_bWordWrapping = value; | 	m_fWrappingWidth = max(static_cast<float>(wordWrapWidth), 0); | ||||||
|  | 	m_bWrappingEnable = (abs(m_fWrappingWidth) >= 1e-7); | ||||||
| 	_initTextLayout(); | 	_initTextLayout(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Text::setWordWrappingWidth(double wordWrapWidth) | void e2d::Text::setLineSpacing(double fLineSpacing) | ||||||
| { | { | ||||||
| 	m_fWordWrappingWidth = max(static_cast<float>(wordWrapWidth), 0); | 	if (m_pFont) | ||||||
| 	_initTextLayout(); | 	{ | ||||||
|  | 		if (fLineSpacing == 0.0f) | ||||||
|  | 		{ | ||||||
|  | 			m_pFont->getDWriteTextFormat()->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0); | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			m_pFont->getDWriteTextFormat()->SetLineSpacing( | ||||||
|  | 				DWRITE_LINE_SPACING_METHOD_UNIFORM, | ||||||
|  | 				static_cast<float>(fLineSpacing), | ||||||
|  | 				static_cast<float>(fLineSpacing) * 0.8f | ||||||
|  | 			); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		_initTextLayout(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Text::setAlignment(UINT32 nAlign) | ||||||
|  | { | ||||||
|  | 	if (m_pFont) | ||||||
|  | 	{ | ||||||
|  | 		m_pFont->getDWriteTextFormat()->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(nAlign)); | ||||||
|  | 		_initTextLayout(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Text::setUnderline(bool hasUnderline) | ||||||
|  | { | ||||||
|  | 	if (m_bHasUnderline != hasUnderline) | ||||||
|  | 	{ | ||||||
|  | 		m_bHasUnderline = hasUnderline; | ||||||
|  | 		_initTextLayout(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Text::setStrikethrough(bool hasStrikethrough) | ||||||
|  | { | ||||||
|  | 	if (m_bHasStrikethrough != hasStrikethrough) | ||||||
|  | 	{ | ||||||
|  | 		m_bHasStrikethrough = hasStrikethrough; | ||||||
|  | 		_initTextLayout(); | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Text::onRender() | void e2d::Text::onRender() | ||||||
| { | { | ||||||
| 	D2D1_RECT_F textLayoutRect = D2D1::RectF(0, 0, m_bWordWrapping ? m_fWordWrappingWidth : m_fWidth, m_fHeight); | 	// 创建文本区域
 | ||||||
|  | 	D2D1_RECT_F textLayoutRect = D2D1::RectF(0, 0, m_bWrappingEnable ? m_fWrappingWidth : m_fWidth, m_fHeight); | ||||||
|  | 	// 设置画刷颜色和透明度
 | ||||||
| 	Renderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_pFont->m_Color, m_fDisplayOpacity)); | 	Renderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_pFont->m_Color, m_fDisplayOpacity)); | ||||||
| 	Renderer::getRenderTarget()->DrawTextW( | 	// 渲染文字内容
 | ||||||
| 		m_sText, | 	if (m_pDWriteTextLayout) | ||||||
| 		static_cast<UINT32>(m_sText.getLength()), | 	{ | ||||||
| 		m_pFont->_getTextFormat(), | 		Renderer::getRenderTarget()->DrawTextLayout( | ||||||
| 		textLayoutRect, | 			{ 0, 0 }, | ||||||
| 		Renderer::getSolidColorBrush() | 			m_pDWriteTextLayout, | ||||||
| 	); | 			Renderer::getSolidColorBrush() | ||||||
|  | 		); | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Text::_initTextLayout() | void e2d::Text::_initTextLayout() | ||||||
|  | @ -117,41 +169,48 @@ void e2d::Text::_initTextLayout() | ||||||
| 	if (!m_pFont || m_sText.isEmpty()) | 	if (!m_pFont || m_sText.isEmpty()) | ||||||
| 	{ | 	{ | ||||||
| 		this->setSize(0, 0); | 		this->setSize(0, 0); | ||||||
| 		m_fWordWrappingWidth = 0; |  | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// 未打开文本自动换行时,设置 TextFormat 属性为不换行
 | 	// 未打开文本自动换行时,设置 TextFormat 属性为不换行
 | ||||||
| 	if (!m_bWordWrapping) | 	if (!m_bWrappingEnable) | ||||||
| 	{ | 	{ | ||||||
| 		m_pFont->_getTextFormat()->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); | 		m_pFont->getDWriteTextFormat()->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		m_pFont->_getTextFormat()->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); | 		m_pFont->getDWriteTextFormat()->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	// 获取 TextLayout
 | 	// 获取 TextLayout
 | ||||||
| 	IDWriteTextLayout * pDWriteTextLayout = nullptr; | 	SafeReleaseInterface(&m_pDWriteTextLayout); | ||||||
|  | 	UINT32 length = static_cast<UINT32>(m_sText.getLength()); | ||||||
| 
 | 
 | ||||||
| 	HRESULT hr = Renderer::getIDWriteFactory()->CreateTextLayout( | 	HRESULT hr = Renderer::getIDWriteFactory()->CreateTextLayout( | ||||||
| 		m_sText, | 		m_sText, | ||||||
| 		static_cast<UINT32>(m_sText.getLength()), | 		length, | ||||||
| 		m_pFont->_getTextFormat(), | 		m_pFont->getDWriteTextFormat(), | ||||||
| 		m_bWordWrapping ? m_fWordWrappingWidth : 0, | 		m_bWrappingEnable ? m_fWrappingWidth : 0, | ||||||
| 		0, | 		0, | ||||||
| 		&pDWriteTextLayout | 		&m_pDWriteTextLayout | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	ASSERT(SUCCEEDED(hr), "Create IDWriteTextFormat Failed!"); | 	ASSERT(SUCCEEDED(hr), "Create IDWriteTextFormat Failed!"); | ||||||
| 
 | 
 | ||||||
|  | 	// 添加下划线和删除线
 | ||||||
|  | 	if (m_bHasUnderline) | ||||||
|  | 	{ | ||||||
|  | 		m_pDWriteTextLayout->SetUnderline(true, { 0, length }); | ||||||
|  | 	} | ||||||
|  | 	if (m_bHasStrikethrough) | ||||||
|  | 	{ | ||||||
|  | 		m_pDWriteTextLayout->SetStrikethrough(true, { 0, length }); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	// 获取文本布局的宽度和高度
 | 	// 获取文本布局的宽度和高度
 | ||||||
| 	DWRITE_TEXT_METRICS metrics; | 	DWRITE_TEXT_METRICS metrics; | ||||||
| 	pDWriteTextLayout->GetMetrics(&metrics); | 	m_pDWriteTextLayout->GetMetrics(&metrics); | ||||||
| 
 | 
 | ||||||
| 	this->setSize(metrics.widthIncludingTrailingWhitespace, metrics.height); | 	this->setSize(metrics.widthIncludingTrailingWhitespace, metrics.height); | ||||||
| 	m_fWordWrappingWidth = metrics.widthIncludingTrailingWhitespace; | 	m_fWrappingWidth = metrics.widthIncludingTrailingWhitespace; | ||||||
| 
 |  | ||||||
| 	// ɾ³ýÏà¹Ø×ÊÔ´
 |  | ||||||
| 	SafeReleaseInterface(&pDWriteTextLayout); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -60,7 +60,7 @@ void e2d::Circle::_resize() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ID2D1EllipseGeometry * e2d::Circle::_getD2dGeometry() const | ID2D1EllipseGeometry * e2d::Circle::getD2dGeometry() const | ||||||
| { | { | ||||||
| 	return m_pD2dCircle; | 	return m_pD2dCircle; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -60,7 +60,7 @@ void e2d::Ellipse::_resize() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ID2D1EllipseGeometry * e2d::Ellipse::_getD2dGeometry() const | ID2D1EllipseGeometry * e2d::Ellipse::getD2dGeometry() const | ||||||
| { | { | ||||||
| 	return m_pD2dEllipse; | 	return m_pD2dEllipse; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ void e2d::Rect::_resize() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ID2D1RectangleGeometry * e2d::Rect::_getD2dGeometry() const | ID2D1RectangleGeometry * e2d::Rect::getD2dGeometry() const | ||||||
| { | { | ||||||
| 	return m_pD2dRectangle; | 	return m_pD2dRectangle; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -121,7 +121,7 @@ void e2d::Shape::_transform() | ||||||
| 
 | 
 | ||||||
| 		// 根据父节点转换几何图形
 | 		// 根据父节点转换几何图形
 | ||||||
| 		Renderer::getID2D1Factory()->CreateTransformedGeometry( | 		Renderer::getID2D1Factory()->CreateTransformedGeometry( | ||||||
| 			_getD2dGeometry(), | 			getD2dGeometry(), | ||||||
| 			m_pParentNode->m_MatriFinal, | 			m_pParentNode->m_MatriFinal, | ||||||
| 			&m_pTransformedShape | 			&m_pTransformedShape | ||||||
| 		); | 		); | ||||||
|  |  | ||||||
|  | @ -2,54 +2,54 @@ | ||||||
| 
 | 
 | ||||||
| static e2d::String s_sDefaultFileName = L"DefaultData.ini"; | static e2d::String s_sDefaultFileName = L"DefaultData.ini"; | ||||||
| 
 | 
 | ||||||
| void e2d::Data::saveInt(String& key, int value, String field) | void e2d::Data::saveInt(String key, int value, String field) | ||||||
| { | { | ||||||
| 	::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath()); | 	::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Data::saveDouble(String& key, double value, String field) | void e2d::Data::saveDouble(String key, double value, String field) | ||||||
| { | { | ||||||
| 	::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath()); | 	::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Data::saveBool(String& key, bool value, String field) | void e2d::Data::saveBool(String key, bool value, String field) | ||||||
| { | { | ||||||
| 	const wchar_t* sValue = value ? L"1" : L"0"; | 	const wchar_t* sValue = value ? L"1" : L"0"; | ||||||
| 	::WritePrivateProfileString(field, key, sValue, Data::getDataFilePath()); | 	::WritePrivateProfileString(field, key, sValue, Data::getDataFilePath()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Data::saveString(String& key, String& value, String field) | void e2d::Data::saveString(String key, String value, String field) | ||||||
| { | { | ||||||
| 	::WritePrivateProfileString(field, key, value, Data::getDataFilePath()); | 	::WritePrivateProfileString(field, key, value, Data::getDataFilePath()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int e2d::Data::getInt(String& key, int defaultValue, String field) | int e2d::Data::getInt(String key, int defaultValue, String field) | ||||||
| { | { | ||||||
| 	return ::GetPrivateProfileInt(field, key, defaultValue, Data::getDataFilePath()); | 	return ::GetPrivateProfileInt(field, key, defaultValue, Data::getDataFilePath()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| double e2d::Data::getDouble(String& key, double defaultValue, String field) | double e2d::Data::getDouble(String key, double defaultValue, String field) | ||||||
| { | { | ||||||
| 	wchar_t temp[32] = { 0 }; | 	wchar_t temp[32] = { 0 }; | ||||||
| 	::GetPrivateProfileString(field, key, String::toString(defaultValue), temp, 31, Data::getDataFilePath()); | 	::GetPrivateProfileString(field, key, String::toString(defaultValue), temp, 31, Data::getDataFilePath()); | ||||||
| 	return std::stof(temp); | 	return std::stof(temp); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool e2d::Data::getBool(String& key, bool defaultValue, String field) | bool e2d::Data::getBool(String key, bool defaultValue, String field) | ||||||
| { | { | ||||||
| 	int nDefaultValue = defaultValue ? 1 : 0; | 	int nDefaultValue = defaultValue ? 1 : 0; | ||||||
| 	int nValue = ::GetPrivateProfileInt(field, key, nDefaultValue, Data::getDataFilePath()); | 	int nValue = ::GetPrivateProfileInt(field, key, nDefaultValue, Data::getDataFilePath()); | ||||||
| 	return nValue != 0; | 	return nValue != 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String e2d::Data::getString(String& key, String& defaultValue, String field) | e2d::String e2d::Data::getString(String key, String defaultValue, String field) | ||||||
| { | { | ||||||
| 	wchar_t temp[256] = { 0 }; | 	wchar_t temp[256] = { 0 }; | ||||||
| 	::GetPrivateProfileString(field, key, defaultValue, temp, 255, Data::getDataFilePath()); | 	::GetPrivateProfileString(field, key, defaultValue, temp, 255, Data::getDataFilePath()); | ||||||
| 	return temp; | 	return temp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Data::setDataFileName(String& fileName) | void e2d::Data::setDataFileName(String fileName) | ||||||
| { | { | ||||||
| 	if (!fileName.isEmpty()) | 	if (!fileName.isEmpty()) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ Music::Music() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Music::Music(String& strFileName) | e2d::Music::Music(String strFileName) | ||||||
| 	: m_bOpened(false) | 	: m_bOpened(false) | ||||||
| 	, m_bPlaying(false) | 	, m_bPlaying(false) | ||||||
| 	, m_pwfx(nullptr) | 	, m_pwfx(nullptr) | ||||||
|  | @ -53,7 +53,7 @@ Music::~Music() | ||||||
| 	close(); | 	close(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool Music::open(String& strFileName) | bool Music::open(String strFileName) | ||||||
| { | { | ||||||
| 	if (m_bOpened) | 	if (m_bOpened) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -94,7 +94,7 @@ e2d::String e2d::Path::getDefaultSavePath() | ||||||
| 	return std::move(path); | 	return std::move(path); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String e2d::Path::getFileExtension(String& filePath) | e2d::String e2d::Path::getFileExtension(String filePath) | ||||||
| { | { | ||||||
| 	String fileExtension; | 	String fileExtension; | ||||||
| 	// 找到文件名中的最后一个 '.' 的位置
 | 	// 找到文件名中的最后一个 '.' 的位置
 | ||||||
|  | @ -111,7 +111,7 @@ e2d::String e2d::Path::getFileExtension(String& filePath) | ||||||
| 	return fileExtension; | 	return fileExtension; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::String e2d::Path::getSaveFilePath(const String& title, const String& defExt) | e2d::String e2d::Path::getSaveFilePath(const String title, const String defExt) | ||||||
| { | { | ||||||
| 	// 弹出保存对话框
 | 	// 弹出保存对话框
 | ||||||
| 	OPENFILENAME ofn = { 0 }; | 	OPENFILENAME ofn = { 0 }; | ||||||
|  | @ -134,7 +134,7 @@ e2d::String e2d::Path::getSaveFilePath(const String& title, const String& defExt | ||||||
| 	return L""; | 	return L""; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool e2d::Path::createFolder(String& strDirPath) | bool e2d::Path::createFolder(String strDirPath) | ||||||
| { | { | ||||||
| 	if (strDirPath.isEmpty()) | 	if (strDirPath.isEmpty()) | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ e2d::String e2d::Timer::getName() const | ||||||
| 	return m_sName; | 	return m_sName; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Timer::setName(String& name) | void e2d::Timer::setName(String name) | ||||||
| { | { | ||||||
| 	m_sName = name; | 	m_sName = name; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -48,7 +48,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 设置动作名称
 | 	// 设置动作名称
 | ||||||
| 	virtual void setName( | 	virtual void setName( | ||||||
| 		String&name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取一个新的逆向动作
 | 	// 获取一个新的逆向动作
 | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								core/ebase.h
								
								
								
								
							
							
						
						
									
										16
									
								
								core/ebase.h
								
								
								
								
							|  | @ -14,7 +14,7 @@ class Game | ||||||
| public: | public: | ||||||
| 	// 初始化游戏
 | 	// 初始化游戏
 | ||||||
| 	static bool init( | 	static bool init( | ||||||
| 		String& sTitle,				/* ´°¿Ú±êÌâ */ | 		String sTitle,				/* ´°¿Ú±êÌâ */ | ||||||
| 		UINT32 nWidth = 640U,		/* 窗口宽度 */ | 		UINT32 nWidth = 640U,		/* 窗口宽度 */ | ||||||
| 		UINT32 nHeight = 480U,		/* 窗口高度 */ | 		UINT32 nHeight = 480U,		/* 窗口高度 */ | ||||||
| 		LPCTSTR pIconID = nullptr,	/* 窗口图标 */ | 		LPCTSTR pIconID = nullptr,	/* 窗口图标 */ | ||||||
|  | @ -73,7 +73,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 设置窗口标题
 | 	// 设置窗口标题
 | ||||||
| 	static void setTitle( | 	static void setTitle( | ||||||
| 		String& sTitle | 		String sTitle | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 打开/隐藏控制台
 | 	// 打开/隐藏控制台
 | ||||||
|  | @ -89,7 +89,7 @@ public: | ||||||
| private: | private: | ||||||
| 	// 初始化窗口
 | 	// 初始化窗口
 | ||||||
| 	static bool __init( | 	static bool __init( | ||||||
| 		String& sTitle, | 		const String& sTitle, | ||||||
| 		UINT32 nWidth, | 		UINT32 nWidth, | ||||||
| 		UINT32 nHeight, | 		UINT32 nHeight, | ||||||
| 		LPCTSTR pIconID | 		LPCTSTR pIconID | ||||||
|  | @ -97,7 +97,7 @@ private: | ||||||
| 
 | 
 | ||||||
| 	// 创建进程互斥体
 | 	// 创建进程互斥体
 | ||||||
| 	static bool __initMutex( | 	static bool __initMutex( | ||||||
| 		String& sTitle | 		const String& sTitle | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 重置窗口属性
 | 	// 重置窗口属性
 | ||||||
|  | @ -159,17 +159,17 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 启动输入监听
 | 	// 启动输入监听
 | ||||||
| 	static void start( | 	static void start( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 停止输入监听
 | 	// 停止输入监听
 | ||||||
| 	static void stop( | 	static void stop( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 清除输入监听
 | 	// 清除输入监听
 | ||||||
| 	static void clear( | 	static void clear( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 启动所有监听器
 | 	// 启动所有监听器
 | ||||||
|  | @ -183,7 +183,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 获取监听器
 | 	// 获取监听器
 | ||||||
| 	static std::vector<Listener*> get( | 	static std::vector<Listener*> get( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取全部监听器
 | 	// 获取全部监听器
 | ||||||
|  |  | ||||||
|  | @ -297,6 +297,19 @@ public: | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // 文本对齐方式
 | ||||||
|  | class TextAlign | ||||||
|  | { | ||||||
|  | public: | ||||||
|  | 	enum COMMON_VALUE | ||||||
|  | 	{ | ||||||
|  | 		LEFT,		/* 左对齐 */ | ||||||
|  | 		RIGHT,		/* 右对齐 */ | ||||||
|  | 		CENTER		/* 居中对齐 */ | ||||||
|  | 	}; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| // 键值集合
 | // 键值集合
 | ||||||
| class KeyCode | class KeyCode | ||||||
| { | { | ||||||
|  | @ -358,17 +371,7 @@ public: | ||||||
| 		NUMPAD1 = 0x4F, | 		NUMPAD1 = 0x4F, | ||||||
| 		NUMPAD2 = 0x50, | 		NUMPAD2 = 0x50, | ||||||
| 		NUMPAD3 = 0x51, | 		NUMPAD3 = 0x51, | ||||||
| 		NUMPAD0 = 0x52, | 		NUMPAD0 = 0x52 | ||||||
| 		F1 = 0x3B, |  | ||||||
| 		F2 = 0x3C, |  | ||||||
| 		F3 = 0x3D, |  | ||||||
| 		F4 = 0x3E, |  | ||||||
| 		F5 = 0x3F, |  | ||||||
| 		F6 = 0x40, |  | ||||||
| 		F7 = 0x41, |  | ||||||
| 		F8 = 0x42, |  | ||||||
| 		F9 = 0x43, |  | ||||||
| 		F10 = 0x44 |  | ||||||
| 	}; | 	}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -449,7 +452,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 设置字体
 | 	// 设置字体
 | ||||||
| 	void setFamily( | 	void setFamily( | ||||||
| 		String& fontFamily | 		String fontFamily | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 设置字号
 | 	// 设置字号
 | ||||||
|  | @ -477,7 +480,7 @@ protected: | ||||||
| 	void _initTextFormat(); | 	void _initTextFormat(); | ||||||
| 
 | 
 | ||||||
| 	// 获取文字格式
 | 	// 获取文字格式
 | ||||||
| 	IDWriteTextFormat * _getTextFormat(); | 	IDWriteTextFormat * getDWriteTextFormat(); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	String		m_sFontFamily; | 	String		m_sFontFamily; | ||||||
|  | @ -500,12 +503,12 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 从本地文件中读取资源
 | 	// 从本地文件中读取资源
 | ||||||
| 	Image( | 	Image( | ||||||
| 		String& strFilePath	/* 图片文件路径 */ | 		String strFilePath	/* 图片文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 从本地文件中读取资源
 | 	// 从本地文件中读取资源
 | ||||||
| 	Image( | 	Image( | ||||||
| 		String& strFilePath,/* 图片文件路径 */ | 		String strFilePath,/* 图片文件路径 */ | ||||||
| 		double nClipX,		/* 裁剪位置 X 坐标 */ | 		double nClipX,		/* 裁剪位置 X 坐标 */ | ||||||
| 		double nClipY,		/* 裁剪位置 Y 坐标 */ | 		double nClipY,		/* 裁剪位置 Y 坐标 */ | ||||||
| 		double nClipWidth,	/* 裁剪宽度 */ | 		double nClipWidth,	/* 裁剪宽度 */ | ||||||
|  | @ -516,7 +519,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 从本地文件中读取图片
 | 	// 从本地文件中读取图片
 | ||||||
| 	void open( | 	void open( | ||||||
| 		String& strFilePath | 		String strFilePath | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 裁剪图片
 | 	// 裁剪图片
 | ||||||
|  | @ -559,7 +562,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 预加载资源
 | 	// 预加载资源
 | ||||||
| 	static bool preload( | 	static bool preload( | ||||||
| 		String& strFileName	/* 图片文件路径 */ | 		String strFileName	/* 图片文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 清空缓存
 | 	// 清空缓存
 | ||||||
|  | @ -664,7 +667,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	Listener( | 	Listener( | ||||||
| 		Function func,	/* 监听到消息时的执行函数 */ | 		Function func,	/* 监听到消息时的执行函数 */ | ||||||
| 		String& name	/* 监听器名称 */ | 		String name		/* 监听器名称 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 启动
 | 	// 启动
 | ||||||
|  | @ -684,7 +687,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 修改名称
 | 	// 修改名称
 | ||||||
| 	void setName( | 	void setName( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 设置监听到消息时的执行函数
 | 	// 设置监听到消息时的执行函数
 | ||||||
|  |  | ||||||
|  | @ -101,22 +101,22 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 启动具有相同名称的定时器
 | 	// 启动具有相同名称的定时器
 | ||||||
| 	static void start( | 	static void start( | ||||||
| 		String&name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 停止具有相同名称的定时器
 | 	// 停止具有相同名称的定时器
 | ||||||
| 	static void stop( | 	static void stop( | ||||||
| 		String&name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 删除具有相同名称的定时器
 | 	// 删除具有相同名称的定时器
 | ||||||
| 	static void clear( | 	static void clear( | ||||||
| 		String&name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取名称相同的定时器
 | 	// 获取名称相同的定时器
 | ||||||
| 	static std::vector<Timer*> get( | 	static std::vector<Timer*> get( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 启动所有定时器
 | 	// 启动所有定时器
 | ||||||
|  | @ -158,17 +158,17 @@ class ActionManager | ||||||
| public: | public: | ||||||
| 	// 继续名称相同的所有动作
 | 	// 继续名称相同的所有动作
 | ||||||
| 	static void resume( | 	static void resume( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 暂停名称相同的所有动作
 | 	// 暂停名称相同的所有动作
 | ||||||
| 	static void pause( | 	static void pause( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 停止名称相同的所有动作
 | 	// 停止名称相同的所有动作
 | ||||||
| 	static void stop( | 	static void stop( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 继续所有动作
 | 	// 继续所有动作
 | ||||||
|  | @ -182,7 +182,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 获取所有名称相同的动作
 | 	// 获取所有名称相同的动作
 | ||||||
| 	static std::vector<Action *> get( | 	static std::vector<Action *> get( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取所有动作
 | 	// 获取所有动作
 | ||||||
|  | @ -241,33 +241,33 @@ class MusicManager | ||||||
| public: | public: | ||||||
| 	// 预加载音乐资源
 | 	// 预加载音乐资源
 | ||||||
| 	static bool preload( | 	static bool preload( | ||||||
| 		String& strFilePath	/* 音乐文件路径 */ | 		String strFilePath	/* 音乐文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 播放音乐
 | 	// 播放音乐
 | ||||||
| 	static bool play( | 	static bool play( | ||||||
| 		String& strFilePath,	/* 音乐文件路径 */ | 		String strFilePath,	/* 音乐文件路径 */ | ||||||
| 		int nLoopCount = 0			/* 重复播放次数,设置 -1 为循环播放 */ | 		int nLoopCount = 0	/* 重复播放次数,设置 -1 为循环播放 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 暂停音乐
 | 	// 暂停音乐
 | ||||||
| 	static void pause( | 	static void pause( | ||||||
| 		String& strFilePath	/* 音乐文件路径 */ | 		String strFilePath	/* 音乐文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 继续播放音乐
 | 	// 继续播放音乐
 | ||||||
| 	static void resume( | 	static void resume( | ||||||
| 		String& strFilePath	/* 音乐文件路径 */ | 		String strFilePath	/* 音乐文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 停止音乐
 | 	// 停止音乐
 | ||||||
| 	static void stop( | 	static void stop( | ||||||
| 		String& strFilePath	/* 音乐文件路径 */ | 		String strFilePath	/* 音乐文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取指定音乐的 Music 对象
 | 	// 获取指定音乐的 Music 对象
 | ||||||
| 	static Music * get( | 	static Music * get( | ||||||
| 		String& strFilePath	/* 音乐文件路径 */ | 		String strFilePath	/* 音乐文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 暂停所有音乐
 | 	// 暂停所有音乐
 | ||||||
|  |  | ||||||
|  | @ -123,7 +123,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 获取所有名称相同的子节点
 | 	// 获取所有名称相同的子节点
 | ||||||
| 	virtual std::vector<Node*> getChildren( | 	virtual std::vector<Node*> getChildren( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取所有子节点
 | 	// 获取所有子节点
 | ||||||
|  | @ -139,7 +139,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 移除所有名称相同的子节点
 | 	// 移除所有名称相同的子节点
 | ||||||
| 	virtual void removeChildren( | 	virtual void removeChildren( | ||||||
| 		String& childName | 		String childName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 从父节点移除
 | 	// 从父节点移除
 | ||||||
|  | @ -160,7 +160,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 设置节点名称
 | 	// 设置节点名称
 | ||||||
| 	virtual void setName( | 	virtual void setName( | ||||||
| 		String& name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 设置节点横坐标
 | 	// 设置节点横坐标
 | ||||||
|  | @ -325,27 +325,27 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 继续动画
 | 	// 继续动画
 | ||||||
| 	virtual void resumeAction( | 	virtual void resumeAction( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 暂停动画
 | 	// 暂停动画
 | ||||||
| 	virtual void pauseAction( | 	virtual void pauseAction( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 停止动画
 | 	// 停止动画
 | ||||||
| 	virtual void stopAction( | 	virtual void stopAction( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取名称相同的动画
 | 	// 获取名称相同的动画
 | ||||||
| 	virtual Action * getAction( | 	virtual Action * getAction( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取所有名称相同的动画
 | 	// 获取所有名称相同的动画
 | ||||||
| 	virtual std::vector<Action*> getActions( | 	virtual std::vector<Action*> getActions( | ||||||
| 		String& strActionName | 		String strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 继续所有暂停动画
 | 	// 继续所有暂停动画
 | ||||||
|  | @ -449,12 +449,12 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 从文件图片创建精灵
 | 	// 从文件图片创建精灵
 | ||||||
| 	Sprite( | 	Sprite( | ||||||
| 		String& imageFileName | 		String imageFileName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 从文件图片创建精灵并裁剪
 | 	// 从文件图片创建精灵并裁剪
 | ||||||
| 	Sprite( | 	Sprite( | ||||||
| 		String& imageFileName, | 		String imageFileName, | ||||||
| 		double x, | 		double x, | ||||||
| 		double y, | 		double y, | ||||||
| 		double width, | 		double width, | ||||||
|  | @ -465,7 +465,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 从本地文件加载图片
 | 	// 从本地文件加载图片
 | ||||||
| 	virtual void open( | 	virtual void open( | ||||||
| 		String& imageFileName | 		String imageFileName | ||||||
| 	); | 	); | ||||||
| 	 | 	 | ||||||
| 	// 加载图片
 | 	// 加载图片
 | ||||||
|  | @ -499,24 +499,24 @@ public: | ||||||
| 	Text(); | 	Text(); | ||||||
| 
 | 
 | ||||||
| 	Text( | 	Text( | ||||||
| 		String& text	/* 文字内容 */ | 		String text		/* 文字内容 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	Text( | 	Text( | ||||||
| 		Font * font			/* 字体样式 */ | 		Font * font		/* 字体样式 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	Text( | 	Text( | ||||||
| 		String& text,/* 文字内容 */ | 		String text,	/* 文字内容 */ | ||||||
| 		Font * font			/* 字体样式 */ | 		Font * font		/* 字体样式 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	Text( | 	Text( | ||||||
| 		String& text,					/* 文字内容*/ | 		String text,							/* 文字内容*/ | ||||||
| 		String fontFamily,						/* 字体 */ | 		String fontFamily,						/* 字体 */ | ||||||
| 		double fontSize = 22,					/* 字号 */ | 		double fontSize = 22,					/* 字号 */ | ||||||
| 		UINT32 color = Color::WHITE,			/* 颜色 */ | 		UINT32 color = Color::WHITE,			/* 颜色 */ | ||||||
| 		UINT32 fontWeight = FontWeight::REGULAR,/* 粗细值 */ | 		UINT32 fontWeight = FontWeight::NORMAL,	/* 粗细值 */ | ||||||
| 		bool italic = false						/* 斜体 */ | 		bool italic = false						/* 斜体 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
|  | @ -525,18 +525,12 @@ public: | ||||||
| 	// 获取文本
 | 	// 获取文本
 | ||||||
| 	String getText() const; | 	String getText() const; | ||||||
| 
 | 
 | ||||||
| 	// 获取文本宽度
 |  | ||||||
| 	virtual double getWidth() const override; |  | ||||||
| 
 |  | ||||||
| 	// 获取文本宽度(不考虑缩放)
 |  | ||||||
| 	virtual double getRealWidth() const override; |  | ||||||
| 
 |  | ||||||
| 	// 获取字体
 | 	// 获取字体
 | ||||||
| 	Font * getFont() const; | 	Font * getFont() const; | ||||||
| 
 | 
 | ||||||
| 	// 设置文本
 | 	// 设置文本
 | ||||||
| 	void setText( | 	void setText( | ||||||
| 		String& text | 		String text | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 设置字体
 | 	// 设置字体
 | ||||||
|  | @ -544,14 +538,29 @@ public: | ||||||
| 		Font * pFont | 		Font * pFont | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 设置文字自动换行
 | 	// 设置文本自动换行宽度(默认为 0)
 | ||||||
| 	void setWordWrappingEnable( | 	void setWrappingWidth( | ||||||
| 		bool bEnable | 		double fWrappingWidth | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 设置文字换行宽度(WordWrapping 打开时生效)
 | 	// 设置行间距(默认为 0)
 | ||||||
| 	void setWordWrappingWidth( | 	void setLineSpacing( | ||||||
| 		double fWordWrapWidth | 		double fLineSpacing | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	// 设置对齐方式(默认为 TextAlign::LEFT)
 | ||||||
|  | 	void setAlignment( | ||||||
|  | 		UINT32 nAlign | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	// 设置下划线
 | ||||||
|  | 	void setUnderline( | ||||||
|  | 		bool hasUnderline | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	// 设置删除线
 | ||||||
|  | 	void setStrikethrough( | ||||||
|  | 		bool hasStrikethrough | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 渲染文字
 | 	// 渲染文字
 | ||||||
|  | @ -563,9 +572,12 @@ protected: | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	String	m_sText; | 	String	m_sText; | ||||||
| 	bool	m_bWordWrapping; | 	bool	m_bWrappingEnable; | ||||||
| 	float	m_fWordWrappingWidth; | 	bool	m_bHasUnderline; | ||||||
| 	Font * m_pFont; | 	bool	m_bHasStrikethrough; | ||||||
|  | 	float	m_fWrappingWidth; | ||||||
|  | 	Font *	m_pFont; | ||||||
|  | 	IDWriteTextLayout * m_pDWriteTextLayout; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -69,6 +69,9 @@ public: | ||||||
| 		bool bEnable | 		bool bEnable | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
|  | 	// 获取 ID2D1Geometry 对象
 | ||||||
|  | 	virtual ID2D1Geometry * getD2dGeometry() const = 0; | ||||||
|  | 
 | ||||||
| protected: | protected: | ||||||
| 	// 转换形状
 | 	// 转换形状
 | ||||||
| 	virtual void _transform(); | 	virtual void _transform(); | ||||||
|  | @ -79,9 +82,6 @@ protected: | ||||||
| 	// 渲染形状
 | 	// 渲染形状
 | ||||||
| 	virtual void _render(); | 	virtual void _render(); | ||||||
| 
 | 
 | ||||||
| 	// 获取 ID2D1Geometry 对象
 |  | ||||||
| 	virtual ID2D1Geometry * _getD2dGeometry() const = 0; |  | ||||||
| 
 |  | ||||||
| protected: | protected: | ||||||
| 	bool	m_bEnable; | 	bool	m_bEnable; | ||||||
| 	bool	m_bIsVisiable; | 	bool	m_bIsVisiable; | ||||||
|  | @ -117,6 +117,9 @@ public: | ||||||
| 
 | 
 | ||||||
| 	virtual ~Rect(); | 	virtual ~Rect(); | ||||||
| 
 | 
 | ||||||
|  | 	// 获取 ID2D1Geometry 对象
 | ||||||
|  | 	virtual ID2D1RectangleGeometry * getD2dGeometry() const override; | ||||||
|  | 
 | ||||||
| protected: | protected: | ||||||
| 	void _setRect( | 	void _setRect( | ||||||
| 		double left, | 		double left, | ||||||
|  | @ -128,8 +131,6 @@ protected: | ||||||
| 	// 重设大小
 | 	// 重设大小
 | ||||||
| 	virtual void _resize(); | 	virtual void _resize(); | ||||||
| 
 | 
 | ||||||
| 	virtual ID2D1RectangleGeometry * _getD2dGeometry() const override; |  | ||||||
| 
 |  | ||||||
| protected: | protected: | ||||||
| 	ID2D1RectangleGeometry * m_pD2dRectangle; | 	ID2D1RectangleGeometry * m_pD2dRectangle; | ||||||
| }; | }; | ||||||
|  | @ -155,6 +156,9 @@ public: | ||||||
| 
 | 
 | ||||||
| 	virtual ~Circle(); | 	virtual ~Circle(); | ||||||
| 
 | 
 | ||||||
|  | 	// 获取 ID2D1Geometry 对象
 | ||||||
|  | 	virtual ID2D1EllipseGeometry * getD2dGeometry() const override; | ||||||
|  | 
 | ||||||
| protected: | protected: | ||||||
| 	void _setCircle( | 	void _setCircle( | ||||||
| 		Point center, | 		Point center, | ||||||
|  | @ -164,8 +168,6 @@ protected: | ||||||
| 	// 重设大小
 | 	// 重设大小
 | ||||||
| 	virtual void _resize(); | 	virtual void _resize(); | ||||||
| 
 | 
 | ||||||
| 	virtual ID2D1EllipseGeometry * _getD2dGeometry() const override; |  | ||||||
| 
 |  | ||||||
| protected: | protected: | ||||||
| 	ID2D1EllipseGeometry * m_pD2dCircle; | 	ID2D1EllipseGeometry * m_pD2dCircle; | ||||||
| }; | }; | ||||||
|  | @ -192,6 +194,9 @@ public: | ||||||
| 
 | 
 | ||||||
| 	virtual ~Ellipse(); | 	virtual ~Ellipse(); | ||||||
| 
 | 
 | ||||||
|  | 	// 获取 ID2D1Geometry 对象
 | ||||||
|  | 	virtual ID2D1EllipseGeometry * getD2dGeometry() const override; | ||||||
|  | 
 | ||||||
| protected: | protected: | ||||||
| 	void _setEllipse( | 	void _setEllipse( | ||||||
| 		Point center, | 		Point center, | ||||||
|  | @ -202,8 +207,6 @@ protected: | ||||||
| 	// 重设大小
 | 	// 重设大小
 | ||||||
| 	virtual void _resize(); | 	virtual void _resize(); | ||||||
| 
 | 
 | ||||||
| 	virtual ID2D1EllipseGeometry * _getD2dGeometry() const override; |  | ||||||
| 
 |  | ||||||
| protected: | protected: | ||||||
| 	ID2D1EllipseGeometry * m_pD2dEllipse; | 	ID2D1EllipseGeometry * m_pD2dEllipse; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -79,7 +79,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 设置定时器名称
 | 	// 设置定时器名称
 | ||||||
| 	void setName( | 	void setName( | ||||||
| 		String&name | 		String name | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 设置定时器执行间隔
 | 	// 设置定时器执行间隔
 | ||||||
|  | @ -122,36 +122,36 @@ class Data | ||||||
| public: | public: | ||||||
| 	// 保存 int 类型的值
 | 	// 保存 int 类型的值
 | ||||||
| 	static void saveInt( | 	static void saveInt( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		int value,					/* 数据 */ | 		int value,					/* 数据 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 保存 double 类型的值
 | 	// 保存 double 类型的值
 | ||||||
| 	static void saveDouble( | 	static void saveDouble( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		double value,				/* 数据 */ | 		double value,				/* 数据 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 保存 bool 类型的值
 | 	// 保存 bool 类型的值
 | ||||||
| 	static void saveBool( | 	static void saveBool( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		bool value,					/* 数据 */ | 		bool value,					/* 数据 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 保存 字符串 类型的值
 | 	// 保存 字符串 类型的值
 | ||||||
| 	static void saveString( | 	static void saveString( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		String& value,				/* 数据 */ | 		String value,				/* 数据 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取 int 类型的值
 | 	// 获取 int 类型的值
 | ||||||
| 	// (若不存在则返回 defaultValue 参数的值)
 | 	// (若不存在则返回 defaultValue 参数的值)
 | ||||||
| 	static int getInt( | 	static int getInt( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		int defaultValue,			/* 默认值 */ | 		int defaultValue,			/* 默认值 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
|  | @ -159,7 +159,7 @@ public: | ||||||
| 	// 获取 double 类型的值
 | 	// 获取 double 类型的值
 | ||||||
| 	// (若不存在则返回 defaultValue 参数的值)
 | 	// (若不存在则返回 defaultValue 参数的值)
 | ||||||
| 	static double getDouble( | 	static double getDouble( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		double defaultValue,		/* 默认值 */ | 		double defaultValue,		/* 默认值 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
|  | @ -167,7 +167,7 @@ public: | ||||||
| 	// 获取 bool 类型的值
 | 	// 获取 bool 类型的值
 | ||||||
| 	// (若不存在则返回 defaultValue 参数的值)
 | 	// (若不存在则返回 defaultValue 参数的值)
 | ||||||
| 	static bool getBool( | 	static bool getBool( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		bool defaultValue,			/* 默认值 */ | 		bool defaultValue,			/* 默认值 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
|  | @ -175,14 +175,14 @@ public: | ||||||
| 	// 获取 字符串 类型的值
 | 	// 获取 字符串 类型的值
 | ||||||
| 	// (若不存在则返回 defaultValue 参数的值)
 | 	// (若不存在则返回 defaultValue 参数的值)
 | ||||||
| 	static String getString( | 	static String getString( | ||||||
| 		String& key,				/* 键值 */ | 		String key,					/* 键值 */ | ||||||
| 		String& defaultValue,		/* 默认值 */ | 		String defaultValue,		/* 默认值 */ | ||||||
| 		String field = L"Defalut"	/* 字段名称 */ | 		String field = L"Defalut"	/* 字段名称 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 修改数据文件的名称
 | 	// 修改数据文件的名称
 | ||||||
| 	static void setDataFileName( | 	static void setDataFileName( | ||||||
| 		String& strFileName			/* 文件名称 */ | 		String strFileName			/* 文件名称 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取数据文件的完整路径
 | 	// 获取数据文件的完整路径
 | ||||||
|  | @ -205,18 +205,18 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 获取文件扩展名
 | 	// 获取文件扩展名
 | ||||||
| 	static String getFileExtension( | 	static String getFileExtension( | ||||||
| 		String& filePath | 		String filePath | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 打开保存文件对话框
 | 	// 打开保存文件对话框
 | ||||||
| 	static String getSaveFilePath( | 	static String getSaveFilePath( | ||||||
| 		const String& title = L"保存到",		/* 对话框标题 */ | 		const String title = L"保存到",		/* 对话框标题 */ | ||||||
| 		const String& defExt = L""			/* 默认扩展名 */ | 		const String defExt = L""			/* 默认扩展名 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 创建文件夹
 | 	// 创建文件夹
 | ||||||
| 	static bool createFolder( | 	static bool createFolder( | ||||||
| 		String& strDirPath	/* 文件夹路径 */ | 		String strDirPath	/* 文件夹路径 */ | ||||||
| 	); | 	); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -231,14 +231,14 @@ public: | ||||||
| 	Music(); | 	Music(); | ||||||
| 
 | 
 | ||||||
| 	Music( | 	Music( | ||||||
| 		String& strFileName	/* 音乐文件路径 */ | 		String strFileName	/* 音乐文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	virtual ~Music(); | 	virtual ~Music(); | ||||||
| 
 | 
 | ||||||
| 	// 打开音乐文件
 | 	// 打开音乐文件
 | ||||||
| 	bool open( | 	bool open( | ||||||
| 		String& strFileName	/* 音乐文件路径 */ | 		String strFileName	/* 音乐文件路径 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 播放
 | 	// 播放
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue