The callback function is changed to a function object
This commit is contained in:
parent
213b174dac
commit
785dbf9b65
|
|
@ -58,7 +58,7 @@ e2d::String e2d::Action::getName() const
|
||||||
return m_sName;
|
return m_sName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Action::setName(const String & name)
|
void e2d::Action::setName(String& name)
|
||||||
{
|
{
|
||||||
m_sName = name;
|
m_sName = name;
|
||||||
}
|
}
|
||||||
|
|
@ -100,3 +100,119 @@ void e2d::Action::_resetTime()
|
||||||
{
|
{
|
||||||
m_fLast = Time::getTotalTime();
|
m_fLast = Time::getTotalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e2d::ActionMoveBy * e2d::action::MoveBy(double duration, Vector vector)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionMoveBy(duration, vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionMoveTo * e2d::action::MoveTo(double duration, Point pos)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionMoveTo(duration, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionScaleBy * e2d::action::ScaleBy(double duration, double scale)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionScaleBy(duration, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionScaleBy * e2d::action::ScaleBy(double duration, double scaleX, double scaleY)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionScaleBy(duration, scaleX, scaleY);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionScaleTo * e2d::action::ScaleTo(double duration, double scale)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionScaleTo(duration, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionScaleTo * e2d::action::ScaleTo(double duration, double scaleX, double scaleY)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionScaleTo(duration, scaleX, scaleY);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionOpacityBy * e2d::action::OpacityBy(double duration, double opacity)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionOpacityBy(duration, opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionOpacityTo * e2d::action::OpacityTo(double duration, double opacity)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionOpacityTo(duration, opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionFadeIn * e2d::action::FadeIn(double duration)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionFadeIn(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionFadeOut * e2d::action::FadeOut(double duration)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionFadeOut(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionRotateBy * e2d::action::RotateBy(double duration, double rotation)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionRotateBy(duration, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionRotateTo * e2d::action::RotateTo(double duration, double rotation)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionRotateTo(duration, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionTwo * e2d::action::Two(Action * pActionFirst, Action * pActionSecond, bool bAtSameTime)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionTwo(pActionFirst, pActionSecond, bAtSameTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionSequence * e2d::action::Sequence(int number, Action * action1, ...)
|
||||||
|
{
|
||||||
|
auto action = new (std::nothrow) ActionSequence();
|
||||||
|
if (action)
|
||||||
|
{
|
||||||
|
Action ** ppAction = &action1;
|
||||||
|
|
||||||
|
while (number > 0)
|
||||||
|
{
|
||||||
|
ASSERT((*ppAction) != nullptr, "ActionSequence NULL pointer exception!");
|
||||||
|
action->add(*ppAction);
|
||||||
|
ppAction++;
|
||||||
|
number--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionDelay * e2d::action::Delay(double duration)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionDelay(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionLoop * e2d::action::Loop(Action * action, int times)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionLoop(action, times);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation * e2d::action::Animate(double interval, int number, Image * frame, ...)
|
||||||
|
{
|
||||||
|
auto animation = new (std::nothrow) Animation(interval);
|
||||||
|
if (animation)
|
||||||
|
{
|
||||||
|
Image ** ppImage = &frame;
|
||||||
|
|
||||||
|
while (number > 0)
|
||||||
|
{
|
||||||
|
ASSERT((*ppImage) != nullptr, "Animation NULL pointer exception!");
|
||||||
|
animation->addKeyframe(*ppImage);
|
||||||
|
ppImage++;
|
||||||
|
number--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ActionFunc * e2d::action::Func(Function func)
|
||||||
|
{
|
||||||
|
return new (std::nothrow) ActionFunc(func);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
#include "..\eactions.h"
|
#include "..\eactions.h"
|
||||||
|
|
||||||
e2d::ActionCallback::ActionCallback(VoidFunction callback) :
|
e2d::ActionFunc::ActionFunc(Function func) :
|
||||||
m_Callback(callback)
|
m_Callback(func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ActionCallback * e2d::ActionCallback::clone() const
|
e2d::ActionFunc * e2d::ActionFunc::clone() const
|
||||||
{
|
{
|
||||||
return new ActionCallback(m_Callback);
|
return new ActionFunc(m_Callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ActionCallback::_init()
|
void e2d::ActionFunc::_init()
|
||||||
{
|
{
|
||||||
// 执行回调函数的动作不需要初始化
|
// 执行函数对象的动作不需要初始化
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ActionCallback::_update()
|
void e2d::ActionFunc::_update()
|
||||||
{
|
{
|
||||||
m_Callback();
|
m_Callback();
|
||||||
this->stop();
|
this->stop();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
e2d::Animation::Animation()
|
e2d::Animation::Animation()
|
||||||
: m_nFrameIndex(0)
|
: m_nFrameIndex(0)
|
||||||
|
, m_fInterval(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -11,9 +12,9 @@ e2d::Animation::Animation(double interval)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Animation::Animation(double interval, int number, Image * frame, ...)
|
e2d::Animation::Animation(int number, Image * frame, ...)
|
||||||
: m_nFrameIndex(0)
|
: m_nFrameIndex(0)
|
||||||
, m_fInterval(interval)
|
, m_fInterval(1)
|
||||||
{
|
{
|
||||||
Image ** ppImage = &frame;
|
Image ** ppImage = &frame;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ static bool s_bInitialized = false;
|
||||||
static e2d::String s_sAppName;
|
static e2d::String s_sAppName;
|
||||||
|
|
||||||
|
|
||||||
bool e2d::Game::init(const String & sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID, const String & sAppname)
|
bool e2d::Game::init(String& sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID, String sAppname)
|
||||||
{
|
{
|
||||||
if (s_bInitialized)
|
if (s_bInitialized)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -186,13 +186,12 @@ void e2d::Input::__add(Listener * pListener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Input::add(ListenerCallback callback, const String & name)
|
void e2d::Input::add(Function func, String name)
|
||||||
{
|
{
|
||||||
auto pListener = new Listener(callback, name);
|
(new Listener(func, name))->start();
|
||||||
pListener->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Input::start(const String & name)
|
void e2d::Input::start(String& name)
|
||||||
{
|
{
|
||||||
for (const auto & pListener : s_vListeners)
|
for (const auto & pListener : s_vListeners)
|
||||||
{
|
{
|
||||||
|
|
@ -203,7 +202,7 @@ void e2d::Input::start(const String & name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Input::stop(const String & name)
|
void e2d::Input::stop(String& name)
|
||||||
{
|
{
|
||||||
for (const auto & pListener : s_vListeners)
|
for (const auto & pListener : s_vListeners)
|
||||||
{
|
{
|
||||||
|
|
@ -214,7 +213,7 @@ void e2d::Input::stop(const String & name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Input::clear(const String & name)
|
void e2d::Input::clear(String& name)
|
||||||
{
|
{
|
||||||
for (const auto & pListener : s_vListeners)
|
for (const auto & pListener : s_vListeners)
|
||||||
{
|
{
|
||||||
|
|
@ -249,7 +248,7 @@ void e2d::Input::clearAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Listener*> e2d::Input::get(const 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(const String & sTitle, UINT32 nWidth, UINT32 nHeight, LPCTSTR pIconID /*= nullptr*/)
|
bool e2d::Window::__init(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(const String & sTitle, UINT32 nWidth, UINT32 nHeight, L
|
||||||
return SUCCEEDED(hr);
|
return SUCCEEDED(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Window::__initMutex(const String & sTitle)
|
bool e2d::Window::__initMutex(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(const 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(const String & fontFamily)
|
void e2d::Font::setFamily(String& fontFamily)
|
||||||
{
|
{
|
||||||
m_sFontFamily = fontFamily;
|
m_sFontFamily = fontFamily;
|
||||||
m_bRecreateNeeded = true;
|
m_bRecreateNeeded = true;
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ e2d::Image::Image()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image::Image(const String & strFileName)
|
e2d::Image::Image(String& strFileName)
|
||||||
{
|
{
|
||||||
this->open(strFileName);
|
this->open(strFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Image::Image(const 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(const 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(const 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())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,18 @@ e2d::Listener::Listener()
|
||||||
Input::__add(this);
|
Input::__add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Listener::Listener(ListenerCallback callback, const String & name)
|
e2d::Listener::Listener(Function func)
|
||||||
|
: m_bRunning(false)
|
||||||
|
, m_callback(func)
|
||||||
|
, m_bClear(false)
|
||||||
|
{
|
||||||
|
Input::__add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Listener::Listener(Function func, String& name)
|
||||||
: m_bRunning(false)
|
: m_bRunning(false)
|
||||||
, m_sName(name)
|
, m_sName(name)
|
||||||
, m_callback(callback)
|
, m_callback(func)
|
||||||
, m_bClear(false)
|
, m_bClear(false)
|
||||||
{
|
{
|
||||||
Input::__add(this);
|
Input::__add(this);
|
||||||
|
|
@ -44,14 +52,14 @@ e2d::String e2d::Listener::getName()
|
||||||
return m_sName;
|
return m_sName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Listener::setName(const String & name)
|
void e2d::Listener::setName(String& name)
|
||||||
{
|
{
|
||||||
m_sName = name;
|
m_sName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Listener::setCallback(ListenerCallback callback)
|
void e2d::Listener::setFunction(Function func)
|
||||||
{
|
{
|
||||||
m_callback = callback;
|
m_callback = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Listener::update()
|
void e2d::Listener::update()
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ActionManager::resume(const 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(const String & strActionName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ActionManager::pause(const 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(const String & strActionName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ActionManager::stop(const 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(const 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(const String & strFilePath)
|
bool e2d::MusicManager::preload(String& strFilePath)
|
||||||
{
|
{
|
||||||
UINT nRet = strFilePath.getHashCode();
|
UINT nRet = strFilePath.getHashCode();
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ bool e2d::MusicManager::preload(const String & strFilePath)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::MusicManager::play(const 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(const String & strFilePath, int nLoopCount)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MusicManager::pause(const 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(const String & strFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MusicManager::resume(const 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(const String & strFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::MusicManager::stop(const 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(const String & strFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Music * e2d::MusicManager::get(const String & strFilePath)
|
e2d::Music * e2d::MusicManager::get(String& strFilePath)
|
||||||
{
|
{
|
||||||
if (strFilePath.isEmpty())
|
if (strFilePath.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ void e2d::TimerManager::__update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::TimerManager::start(double timeOut, TimerCallback callback)
|
void e2d::TimerManager::start(double timeOut, Function func)
|
||||||
{
|
{
|
||||||
(new Timer(L"", callback, timeOut, 1, false, true))->start();
|
(new Timer(func, L"", timeOut, 1, false, true))->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::TimerManager::__add(Timer * pTimer)
|
void e2d::TimerManager::__add(Timer * pTimer)
|
||||||
|
|
@ -62,7 +62,7 @@ void e2d::TimerManager::__add(Timer * pTimer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::TimerManager::start(const 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(const String & name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::TimerManager::stop(const 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(const String & name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::TimerManager::clear(const 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(const String & name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<e2d::Timer*> e2d::TimerManager::get(const 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)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ e2d::Button::Button()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, ButtonCallback callback)
|
e2d::Button::Button(Node * normal, Function func)
|
||||||
: m_Callback(nullptr)
|
: m_Callback(nullptr)
|
||||||
, m_eBtnState(Button::NORMAL)
|
, m_eBtnState(Button::NORMAL)
|
||||||
, m_bEnable(true)
|
, m_bEnable(true)
|
||||||
|
|
@ -27,10 +27,10 @@ e2d::Button::Button(Node * normal, ButtonCallback callback)
|
||||||
, m_pDisabled(nullptr)
|
, m_pDisabled(nullptr)
|
||||||
{
|
{
|
||||||
this->setNormal(normal);
|
this->setNormal(normal);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, Node * selected, ButtonCallback callback)
|
e2d::Button::Button(Node * normal, Node * selected, Function func)
|
||||||
: m_Callback(nullptr)
|
: m_Callback(nullptr)
|
||||||
, m_eBtnState(Button::NORMAL)
|
, m_eBtnState(Button::NORMAL)
|
||||||
, m_bEnable(true)
|
, m_bEnable(true)
|
||||||
|
|
@ -42,10 +42,10 @@ e2d::Button::Button(Node * normal, Node * selected, ButtonCallback callback)
|
||||||
{
|
{
|
||||||
this->setNormal(normal);
|
this->setNormal(normal);
|
||||||
this->setSelected(selected);
|
this->setSelected(selected);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, ButtonCallback callback)
|
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function func)
|
||||||
: m_Callback(nullptr)
|
: m_Callback(nullptr)
|
||||||
, m_eBtnState(Button::NORMAL)
|
, m_eBtnState(Button::NORMAL)
|
||||||
, m_bEnable(true)
|
, m_bEnable(true)
|
||||||
|
|
@ -58,10 +58,10 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, ButtonCall
|
||||||
this->setNormal(normal);
|
this->setNormal(normal);
|
||||||
this->setMouseOver(mouseover);
|
this->setMouseOver(mouseover);
|
||||||
this->setSelected(selected);
|
this->setSelected(selected);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, ButtonCallback callback)
|
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, Function func)
|
||||||
: m_Callback(nullptr)
|
: m_Callback(nullptr)
|
||||||
, m_eBtnState(Button::NORMAL)
|
, m_eBtnState(Button::NORMAL)
|
||||||
, m_bEnable(true)
|
, m_bEnable(true)
|
||||||
|
|
@ -75,7 +75,7 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * dis
|
||||||
this->setMouseOver(mouseover);
|
this->setMouseOver(mouseover);
|
||||||
this->setSelected(selected);
|
this->setSelected(selected);
|
||||||
this->setDisabled(disabled);
|
this->setDisabled(disabled);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Button::isEnable() const
|
bool e2d::Button::isEnable() const
|
||||||
|
|
@ -170,11 +170,11 @@ void e2d::Button::setEnable(bool bEnable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::setCallback(ButtonCallback callback)
|
void e2d::Button::setFunction(Function func)
|
||||||
{
|
{
|
||||||
WARN_IF(m_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed.");
|
WARN_IF(m_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed.");
|
||||||
|
|
||||||
m_Callback = callback;
|
m_Callback = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::onFixedUpdate()
|
void e2d::Button::onFixedUpdate()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ e2d::ButtonToggle::ButtonToggle()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, ButtonCallback callback)
|
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Function func)
|
||||||
: Button()
|
: Button()
|
||||||
, m_bState(true)
|
, m_bState(true)
|
||||||
, m_pNormalOn(nullptr)
|
, m_pNormalOn(nullptr)
|
||||||
|
|
@ -28,10 +28,10 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, B
|
||||||
{
|
{
|
||||||
this->setNormal(toggleOnNormal);
|
this->setNormal(toggleOnNormal);
|
||||||
this->setNormalOff(toggleOffNormal);
|
this->setNormalOff(toggleOffNormal);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnSelected, Node * toggleOffSelected, ButtonCallback callback)
|
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnSelected, Node * toggleOffSelected, Function func)
|
||||||
: Button()
|
: Button()
|
||||||
, m_bState(true)
|
, m_bState(true)
|
||||||
, m_pNormalOn(nullptr)
|
, m_pNormalOn(nullptr)
|
||||||
|
|
@ -47,10 +47,10 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
|
||||||
this->setNormalOff(toggleOffNormal);
|
this->setNormalOff(toggleOffNormal);
|
||||||
this->setSelected(toggleOnSelected);
|
this->setSelected(toggleOnSelected);
|
||||||
this->setSelectedOff(toggleOffSelected);
|
this->setSelectedOff(toggleOffSelected);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, ButtonCallback callback)
|
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Function func)
|
||||||
: Button()
|
: Button()
|
||||||
, m_bState(true)
|
, m_bState(true)
|
||||||
, m_pNormalOn(nullptr)
|
, m_pNormalOn(nullptr)
|
||||||
|
|
@ -68,10 +68,10 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
|
||||||
this->setMouseOverOff(toggleOffMouseOver);
|
this->setMouseOverOff(toggleOffMouseOver);
|
||||||
this->setSelected(toggleOnSelected);
|
this->setSelected(toggleOnSelected);
|
||||||
this->setSelectedOff(toggleOffSelected);
|
this->setSelectedOff(toggleOffSelected);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Node * toggleOnDisabled, Node * toggleOffDisabled, ButtonCallback callback)
|
e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, Node * toggleOnMouseOver, Node * toggleOffMouseOver, Node * toggleOnSelected, Node * toggleOffSelected, Node * toggleOnDisabled, Node * toggleOffDisabled, Function func)
|
||||||
: Button()
|
: Button()
|
||||||
, m_bState(true)
|
, m_bState(true)
|
||||||
, m_pNormalOn(nullptr)
|
, m_pNormalOn(nullptr)
|
||||||
|
|
@ -91,7 +91,7 @@ e2d::ButtonToggle::ButtonToggle(Node * toggleOnNormal, Node * toggleOffNormal, N
|
||||||
this->setSelectedOff(toggleOffSelected);
|
this->setSelectedOff(toggleOffSelected);
|
||||||
this->setDisabled(toggleOnDisabled);
|
this->setDisabled(toggleOnDisabled);
|
||||||
this->setDisabledOff(toggleOffDisabled);
|
this->setDisabledOff(toggleOffDisabled);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::ButtonToggle::getState() const
|
bool e2d::ButtonToggle::getState() const
|
||||||
|
|
|
||||||
|
|
@ -614,7 +614,7 @@ e2d::Scene * e2d::Node::getParentScene() const
|
||||||
return m_pParentScene;
|
return m_pParentScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<e2d::Node*> e2d::Node::getChildren(const 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 +684,7 @@ bool e2d::Node::removeChild(Node * child)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::removeChildren(const String & childName)
|
void e2d::Node::removeChildren(String& childName)
|
||||||
{
|
{
|
||||||
WARN_IF(childName.isEmpty(), "Invalid Node name.");
|
WARN_IF(childName.isEmpty(), "Invalid Node name.");
|
||||||
|
|
||||||
|
|
@ -753,7 +753,7 @@ void e2d::Node::runAction(Action * action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::resumeAction(const 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 +765,7 @@ void e2d::Node::resumeAction(const String & strActionName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::pauseAction(const 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 +777,7 @@ void e2d::Node::pauseAction(const String & strActionName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::stopAction(const 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 +789,7 @@ void e2d::Node::stopAction(const String & strActionName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Action * e2d::Node::getAction(const 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 +802,7 @@ e2d::Action * e2d::Node::getAction(const String & strActionName)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<e2d::Action*> e2d::Node::getActions(const 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);
|
||||||
|
|
@ -970,7 +970,7 @@ void e2d::Node::setVisiable(bool value)
|
||||||
m_bVisiable = value;
|
m_bVisiable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::setName(const 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(const String & imageFileName)
|
e2d::Sprite::Sprite(String& imageFileName)
|
||||||
: m_pImage(nullptr)
|
: m_pImage(nullptr)
|
||||||
{
|
{
|
||||||
open(imageFileName);
|
open(imageFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Sprite::Sprite(const 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(const String & imageFileName)
|
void e2d::Sprite::open(String& imageFileName)
|
||||||
{
|
{
|
||||||
open(new Image(imageFileName));
|
open(new Image(imageFileName));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ e2d::Text::Text()
|
||||||
this->setFont(new Font());
|
this->setFont(new Font());
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Text::Text(const String & text)
|
e2d::Text::Text(String& text)
|
||||||
: m_bWordWrapping(false)
|
: m_bWordWrapping(false)
|
||||||
, m_pFont(nullptr)
|
, m_pFont(nullptr)
|
||||||
, m_fWordWrappingWidth(0)
|
, m_fWordWrappingWidth(0)
|
||||||
|
|
@ -25,7 +25,7 @@ e2d::Text::Text(Font * font)
|
||||||
this->setFont(font);
|
this->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Text::Text(const String & text, Font * font)
|
e2d::Text::Text(String& text, Font * font)
|
||||||
: m_bWordWrapping(false)
|
: m_bWordWrapping(false)
|
||||||
, m_pFont(nullptr)
|
, m_pFont(nullptr)
|
||||||
, m_fWordWrappingWidth(0)
|
, m_fWordWrappingWidth(0)
|
||||||
|
|
@ -34,7 +34,7 @@ e2d::Text::Text(const String & text, Font * font)
|
||||||
this->setFont(font);
|
this->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Text::Text(const 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_bWordWrapping(false)
|
||||||
, m_pFont(nullptr)
|
, m_pFont(nullptr)
|
||||||
, m_fWordWrappingWidth(0)
|
, m_fWordWrappingWidth(0)
|
||||||
|
|
@ -68,7 +68,7 @@ e2d::Font * e2d::Text::getFont() const
|
||||||
return m_pFont;
|
return m_pFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Text::setText(const String & text)
|
void e2d::Text::setText(String& text)
|
||||||
{
|
{
|
||||||
m_sText = text;
|
m_sText = text;
|
||||||
_initTextLayout();
|
_initTextLayout();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include "..\etools.h"
|
||||||
|
|
||||||
|
static e2d::String s_sDefaultFileName = L"DefaultData.ini";
|
||||||
|
|
||||||
|
void e2d::Data::saveInt(String& key, int value, String field)
|
||||||
|
{
|
||||||
|
::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Data::saveDouble(String& key, double value, String field)
|
||||||
|
{
|
||||||
|
::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Data::saveBool(String& key, bool value, String field)
|
||||||
|
{
|
||||||
|
const wchar_t* sValue = value ? L"1" : L"0";
|
||||||
|
::WritePrivateProfileString(field, key, sValue, Data::getDataFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Data::saveString(String& key, String& value, String field)
|
||||||
|
{
|
||||||
|
::WritePrivateProfileString(field, key, value, Data::getDataFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
int e2d::Data::getInt(String& key, int defaultValue, String field)
|
||||||
|
{
|
||||||
|
return ::GetPrivateProfileInt(field, key, defaultValue, Data::getDataFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
double e2d::Data::getDouble(String& key, double defaultValue, String field)
|
||||||
|
{
|
||||||
|
wchar_t temp[32] = { 0 };
|
||||||
|
::GetPrivateProfileString(field, key, String::toString(defaultValue), temp, 31, Data::getDataFilePath());
|
||||||
|
return std::stof(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool e2d::Data::getBool(String& key, bool defaultValue, String field)
|
||||||
|
{
|
||||||
|
int nDefaultValue = defaultValue ? 1 : 0;
|
||||||
|
int nValue = ::GetPrivateProfileInt(field, key, nDefaultValue, Data::getDataFilePath());
|
||||||
|
return nValue != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::String e2d::Data::getString(String& key, String& defaultValue, String field)
|
||||||
|
{
|
||||||
|
wchar_t temp[256] = { 0 };
|
||||||
|
::GetPrivateProfileString(field, key, defaultValue, temp, 255, Data::getDataFilePath());
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Data::setDataFileName(String& fileName)
|
||||||
|
{
|
||||||
|
if (!fileName.isEmpty())
|
||||||
|
{
|
||||||
|
s_sDefaultFileName.clear();
|
||||||
|
s_sDefaultFileName << fileName << L".ini";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::String e2d::Data::getDataFilePath()
|
||||||
|
{
|
||||||
|
return Path::getDefaultSavePath() + s_sDefaultFileName;
|
||||||
|
}
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
#include "..\etools.h"
|
|
||||||
#include <algorithm>
|
|
||||||
#include <commdlg.h>
|
|
||||||
|
|
||||||
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
|
||||||
EXTERN_C const GUID DECLSPEC_SELECTANY name \
|
|
||||||
= { l, w1, w2,{ b1, b2, b3, b4, b5, b6, b7, b8 } }
|
|
||||||
|
|
||||||
DEFINE_KNOWN_FOLDER(FOLDERID_LocalAppData, 0xF1B32785, 0x6FBA, 0x4FCF, 0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91);
|
|
||||||
|
|
||||||
|
|
||||||
e2d::String e2d::Path::getLocalAppDataPath()
|
|
||||||
{
|
|
||||||
typedef HRESULT(WINAPI* pFunSHGetKnownFolderPath)(const GUID& rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
|
|
||||||
|
|
||||||
// 获取 AppData\Local 文件夹的路径
|
|
||||||
PWSTR pszPath = NULL;
|
|
||||||
HMODULE hModule = LoadLibrary(L"shell32.dll");
|
|
||||||
pFunSHGetKnownFolderPath SHGetKnownFolderPath = (pFunSHGetKnownFolderPath)GetProcAddress(hModule, "SHGetKnownFolderPath");
|
|
||||||
HRESULT hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &pszPath);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
|
||||||
String path = pszPath;
|
|
||||||
CoTaskMemFree(pszPath);
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::String e2d::Path::getTempPath()
|
|
||||||
{
|
|
||||||
// 获取临时文件目录
|
|
||||||
wchar_t path[_MAX_PATH];
|
|
||||||
if (0 == ::GetTempPath(_MAX_PATH, path))
|
|
||||||
{
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建临时文件目录
|
|
||||||
e2d::String tempFilePath;
|
|
||||||
tempFilePath << path << L"Easy2DGameTemp\\";
|
|
||||||
// 创建文件夹
|
|
||||||
if (!Path::createFolder(tempFilePath))
|
|
||||||
{
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取 AppName
|
|
||||||
String sAppName = Game::getAppName();
|
|
||||||
if (!sAppName.isEmpty())
|
|
||||||
{
|
|
||||||
// 创建文件夹
|
|
||||||
if (!Path::createFolder(tempFilePath + sAppName + L"\\"))
|
|
||||||
{
|
|
||||||
return std::move(tempFilePath);
|
|
||||||
}
|
|
||||||
tempFilePath << sAppName << L"\\";
|
|
||||||
}
|
|
||||||
return std::move(tempFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::String e2d::Path::getDefaultSavePath()
|
|
||||||
{
|
|
||||||
// 获取 AppData 路径
|
|
||||||
String path = Path::getLocalAppDataPath();
|
|
||||||
|
|
||||||
if (path.isEmpty())
|
|
||||||
{
|
|
||||||
WARN_IF(true, "Cannot get local AppData path!");
|
|
||||||
return std::move(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建文件夹
|
|
||||||
if (!Path::createFolder(path + L"\\Easy2DGameData"))
|
|
||||||
{
|
|
||||||
return std::move(path);
|
|
||||||
}
|
|
||||||
path << L"\\Easy2DGameData";
|
|
||||||
|
|
||||||
// 获取 AppName
|
|
||||||
String sAppName = Game::getAppName();
|
|
||||||
if (!sAppName.isEmpty())
|
|
||||||
{
|
|
||||||
// 创建文件夹
|
|
||||||
if (!Path::createFolder(path + L"\\" + sAppName))
|
|
||||||
{
|
|
||||||
return std::move(path);
|
|
||||||
}
|
|
||||||
path << L"\\" << sAppName;
|
|
||||||
}
|
|
||||||
path << L"\\";
|
|
||||||
|
|
||||||
return std::move(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::String e2d::Path::getFileExtension(const String & filePath)
|
|
||||||
{
|
|
||||||
String fileExtension;
|
|
||||||
// 找到文件名中的最后一个 '.' 的位置
|
|
||||||
int pos = filePath.findLastOf(L'.');
|
|
||||||
// 判断 pos 是否是个有效位置
|
|
||||||
if (pos != -1)
|
|
||||||
{
|
|
||||||
// 截取扩展名
|
|
||||||
fileExtension = filePath.subtract(pos);
|
|
||||||
// 转换为小写字母
|
|
||||||
fileExtension = fileExtension.toLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
return fileExtension;
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::String e2d::Path::getSaveFilePath(const String & title, const String & defExt)
|
|
||||||
{
|
|
||||||
// 弹出保存对话框
|
|
||||||
OPENFILENAME ofn = { 0 };
|
|
||||||
wchar_t strFilename[MAX_PATH] = { 0 }; // 用于接收文件名
|
|
||||||
ofn.lStructSize = sizeof(OPENFILENAME); // 结构体大小
|
|
||||||
ofn.hwndOwner = Window::getHWnd(); // 窗口句柄
|
|
||||||
ofn.lpstrFilter = L"所有文件\0*.*\0\0"; // 设置过滤
|
|
||||||
ofn.nFilterIndex = 1; // 过滤器索引
|
|
||||||
ofn.lpstrFile = strFilename; // 接收返回的文件路径和文件名
|
|
||||||
ofn.nMaxFile = sizeof(strFilename); // 缓冲区长度
|
|
||||||
ofn.lpstrInitialDir = NULL; // 初始目录为默认
|
|
||||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
|
||||||
ofn.lpstrTitle = title; // 标题
|
|
||||||
ofn.lpstrDefExt = defExt; // 默认追加的扩展名
|
|
||||||
|
|
||||||
if (GetSaveFileName(&ofn))
|
|
||||||
{
|
|
||||||
return strFilename;
|
|
||||||
}
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool e2d::Path::createFolder(const String & strDirPath)
|
|
||||||
{
|
|
||||||
if (strDirPath.isEmpty())
|
|
||||||
{
|
|
||||||
WARN_IF(true, "Path::createFolder Failed: Invalid directory path!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-1 == ::_waccess(strDirPath, 0))
|
|
||||||
{
|
|
||||||
if (0 != ::_wmkdir(strDirPath))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
@ -35,7 +35,7 @@ Music::Music()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Music::Music(const 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(const String & strFileName)
|
bool Music::open(String& strFileName)
|
||||||
{
|
{
|
||||||
if (m_bOpened)
|
if (m_bOpened)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,64 +1,153 @@
|
||||||
#include "..\etools.h"
|
#include "..\etools.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <commdlg.h>
|
||||||
|
|
||||||
static e2d::String s_sDefaultFileName = L"DefaultData.ini";
|
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||||
|
EXTERN_C const GUID DECLSPEC_SELECTANY name \
|
||||||
|
= { l, w1, w2,{ b1, b2, b3, b4, b5, b6, b7, b8 } }
|
||||||
|
|
||||||
void e2d::Data::saveInt(const String & key, int value, const String & field)
|
DEFINE_KNOWN_FOLDER(FOLDERID_LocalAppData, 0xF1B32785, 0x6FBA, 0x4FCF, 0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91);
|
||||||
|
|
||||||
|
|
||||||
|
e2d::String e2d::Path::getLocalAppDataPath()
|
||||||
{
|
{
|
||||||
::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath());
|
typedef HRESULT(WINAPI* pFunSHGetKnownFolderPath)(const GUID& rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Data::saveDouble(const String & key, double value, const String & field)
|
// 获取 AppData\Local 文件夹的路径
|
||||||
{
|
PWSTR pszPath = NULL;
|
||||||
::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath());
|
HMODULE hModule = LoadLibrary(L"shell32.dll");
|
||||||
}
|
pFunSHGetKnownFolderPath SHGetKnownFolderPath = (pFunSHGetKnownFolderPath)GetProcAddress(hModule, "SHGetKnownFolderPath");
|
||||||
|
HRESULT hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &pszPath);
|
||||||
|
|
||||||
void e2d::Data::saveBool(const String & key, bool value, const String & field)
|
if (SUCCEEDED(hr))
|
||||||
{
|
|
||||||
const wchar_t* sValue = value ? L"1" : L"0";
|
|
||||||
::WritePrivateProfileString(field, key, sValue, Data::getDataFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Data::saveString(const String & key, const String & value, const String & field)
|
|
||||||
{
|
|
||||||
::WritePrivateProfileString(field, key, value, Data::getDataFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
int e2d::Data::getInt(const String & key, int defaultValue, const String & field)
|
|
||||||
{
|
|
||||||
return ::GetPrivateProfileInt(field, key, defaultValue, Data::getDataFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
double e2d::Data::getDouble(const String & key, double defaultValue, const String & field)
|
|
||||||
{
|
|
||||||
wchar_t temp[32] = { 0 };
|
|
||||||
::GetPrivateProfileString(field, key, String::toString(defaultValue), temp, 31, Data::getDataFilePath());
|
|
||||||
return std::stof(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool e2d::Data::getBool(const String & key, bool defaultValue, const String & field)
|
|
||||||
{
|
|
||||||
int nDefaultValue = defaultValue ? 1 : 0;
|
|
||||||
int nValue = ::GetPrivateProfileInt(field, key, nDefaultValue, Data::getDataFilePath());
|
|
||||||
return nValue != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::String e2d::Data::getString(const String & key, const String & defaultValue, const String & field)
|
|
||||||
{
|
|
||||||
wchar_t temp[256] = { 0 };
|
|
||||||
::GetPrivateProfileString(field, key, defaultValue, temp, 255, Data::getDataFilePath());
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Data::setDataFileName(const String & fileName)
|
|
||||||
{
|
|
||||||
if (!fileName.isEmpty())
|
|
||||||
{
|
{
|
||||||
s_sDefaultFileName.clear();
|
String path = pszPath;
|
||||||
s_sDefaultFileName << fileName << L".ini";
|
CoTaskMemFree(pszPath);
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
return L"";
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::Data::getDataFilePath()
|
e2d::String e2d::Path::getTempPath()
|
||||||
{
|
{
|
||||||
return Path::getDefaultSavePath() + s_sDefaultFileName;
|
// 获取临时文件目录
|
||||||
|
wchar_t path[_MAX_PATH];
|
||||||
|
if (0 == ::GetTempPath(_MAX_PATH, path))
|
||||||
|
{
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建临时文件目录
|
||||||
|
e2d::String tempFilePath;
|
||||||
|
tempFilePath << path << L"Easy2DGameTemp\\";
|
||||||
|
// 创建文件夹
|
||||||
|
if (!Path::createFolder(tempFilePath))
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取 AppName
|
||||||
|
String sAppName = Game::getAppName();
|
||||||
|
if (!sAppName.isEmpty())
|
||||||
|
{
|
||||||
|
// 创建文件夹
|
||||||
|
if (!Path::createFolder(tempFilePath + sAppName + L"\\"))
|
||||||
|
{
|
||||||
|
return std::move(tempFilePath);
|
||||||
|
}
|
||||||
|
tempFilePath << sAppName << L"\\";
|
||||||
|
}
|
||||||
|
return std::move(tempFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::String e2d::Path::getDefaultSavePath()
|
||||||
|
{
|
||||||
|
// 获取 AppData 路径
|
||||||
|
String path = Path::getLocalAppDataPath();
|
||||||
|
|
||||||
|
if (path.isEmpty())
|
||||||
|
{
|
||||||
|
WARN_IF(true, "Cannot get local AppData path!");
|
||||||
|
return std::move(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建文件夹
|
||||||
|
if (!Path::createFolder(path + L"\\Easy2DGameData"))
|
||||||
|
{
|
||||||
|
return std::move(path);
|
||||||
|
}
|
||||||
|
path << L"\\Easy2DGameData";
|
||||||
|
|
||||||
|
// 获取 AppName
|
||||||
|
String sAppName = Game::getAppName();
|
||||||
|
if (!sAppName.isEmpty())
|
||||||
|
{
|
||||||
|
// 创建文件夹
|
||||||
|
if (!Path::createFolder(path + L"\\" + sAppName))
|
||||||
|
{
|
||||||
|
return std::move(path);
|
||||||
|
}
|
||||||
|
path << L"\\" << sAppName;
|
||||||
|
}
|
||||||
|
path << L"\\";
|
||||||
|
|
||||||
|
return std::move(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::String e2d::Path::getFileExtension(String& filePath)
|
||||||
|
{
|
||||||
|
String fileExtension;
|
||||||
|
// 找到文件名中的最后一个 '.' 的位置
|
||||||
|
int pos = filePath.findLastOf(L'.');
|
||||||
|
// 判断 pos 是否是个有效位置
|
||||||
|
if (pos != -1)
|
||||||
|
{
|
||||||
|
// 截取扩展名
|
||||||
|
fileExtension = filePath.subtract(pos);
|
||||||
|
// 转换为小写字母
|
||||||
|
fileExtension = fileExtension.toLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::String e2d::Path::getSaveFilePath(const String& title, const String& defExt)
|
||||||
|
{
|
||||||
|
// 弹出保存对话框
|
||||||
|
OPENFILENAME ofn = { 0 };
|
||||||
|
wchar_t strFilename[MAX_PATH] = { 0 }; // 用于接收文件名
|
||||||
|
ofn.lStructSize = sizeof(OPENFILENAME); // 结构体大小
|
||||||
|
ofn.hwndOwner = Window::getHWnd(); // 窗口句柄
|
||||||
|
ofn.lpstrFilter = L"所有文件\0*.*\0\0"; // 设置过滤
|
||||||
|
ofn.nFilterIndex = 1; // 过滤器索引
|
||||||
|
ofn.lpstrFile = strFilename; // 接收返回的文件路径和文件名
|
||||||
|
ofn.nMaxFile = sizeof(strFilename); // 缓冲区长度
|
||||||
|
ofn.lpstrInitialDir = NULL; // 初始目录为默认
|
||||||
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
||||||
|
ofn.lpstrTitle = title; // 标题
|
||||||
|
ofn.lpstrDefExt = defExt; // 默认追加的扩展名
|
||||||
|
|
||||||
|
if (GetSaveFileName(&ofn))
|
||||||
|
{
|
||||||
|
return strFilename;
|
||||||
|
}
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool e2d::Path::createFolder(String& strDirPath)
|
||||||
|
{
|
||||||
|
if (strDirPath.isEmpty())
|
||||||
|
{
|
||||||
|
WARN_IF(true, "Path::createFolder Failed: Invalid directory path!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-1 == ::_waccess(strDirPath, 0))
|
||||||
|
{
|
||||||
|
if (0 != ::_wmkdir(strDirPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include "..\enodes.h"
|
#include "..\enodes.h"
|
||||||
#include "..\emanagers.h"
|
#include "..\emanagers.h"
|
||||||
|
|
||||||
e2d::Timer::Timer(const String & name, TimerCallback callback, double interval /* = 0 */, int updateTimes /* = -1 */, bool atOnce /* = false */, bool autoRelease /* = false */)
|
e2d::Timer::Timer(Function func, String name, double interval /* = 0 */, int updateTimes /* = -1 */, bool atOnce /* = false */, bool autoRelease /* = false */)
|
||||||
: m_bRunning(false)
|
: m_bRunning(false)
|
||||||
, m_nRunTimes(0)
|
, m_nRunTimes(0)
|
||||||
, m_Callback(nullptr)
|
, m_Callback(nullptr)
|
||||||
|
|
@ -14,7 +14,7 @@ e2d::Timer::Timer(const String & name, TimerCallback callback, double interval /
|
||||||
, m_bClear(true)
|
, m_bClear(true)
|
||||||
{
|
{
|
||||||
this->setName(name);
|
this->setName(name);
|
||||||
this->setCallback(callback);
|
this->setFunction(func);
|
||||||
this->setUpdateTimes(updateTimes);
|
this->setUpdateTimes(updateTimes);
|
||||||
this->setInterval(interval);
|
this->setInterval(interval);
|
||||||
m_bAutoRelease = autoRelease;
|
m_bAutoRelease = autoRelease;
|
||||||
|
|
@ -49,7 +49,7 @@ e2d::String e2d::Timer::getName() const
|
||||||
return m_sName;
|
return m_sName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::setName(const String & name)
|
void e2d::Timer::setName(String& name)
|
||||||
{
|
{
|
||||||
m_sName = name;
|
m_sName = name;
|
||||||
}
|
}
|
||||||
|
|
@ -59,9 +59,9 @@ void e2d::Timer::setInterval(double interval)
|
||||||
m_fInterval = max(interval, 0);
|
m_fInterval = max(interval, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::setCallback(TimerCallback callback)
|
void e2d::Timer::setFunction(Function func)
|
||||||
{
|
{
|
||||||
m_Callback = callback;
|
m_Callback = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::setUpdateTimes(int updateTimes)
|
void e2d::Timer::setUpdateTimes(int updateTimes)
|
||||||
|
|
|
||||||
|
|
@ -48,15 +48,15 @@ public:
|
||||||
|
|
||||||
// 设置动作名称
|
// 设置动作名称
|
||||||
virtual void setName(
|
virtual void setName(
|
||||||
const String &name
|
String&name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取一个新的拷贝动作
|
|
||||||
virtual Action * clone() const = 0;
|
|
||||||
|
|
||||||
// 获取一个新的逆向动作
|
// 获取一个新的逆向动作
|
||||||
virtual Action * reverse() const;
|
virtual Action * reverse() const;
|
||||||
|
|
||||||
|
// 获取一个新的拷贝动作
|
||||||
|
virtual Action * clone() const = 0;
|
||||||
|
|
||||||
// 重置动作
|
// 重置动作
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
|
|
@ -514,7 +514,6 @@ public:
|
||||||
|
|
||||||
// 创建帧动画
|
// 创建帧动画
|
||||||
Animation(
|
Animation(
|
||||||
double interval, /* 帧间隔(秒) */
|
|
||||||
int number, /* 帧数量 */
|
int number, /* 帧数量 */
|
||||||
Image * frame, /* 第一帧 */
|
Image * frame, /* 第一帧 */
|
||||||
...
|
...
|
||||||
|
|
@ -555,17 +554,17 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ActionCallback :
|
class ActionFunc :
|
||||||
public Action
|
public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建执行回调函数的动作
|
// 创建执行函数对象的动作
|
||||||
ActionCallback(
|
ActionFunc(
|
||||||
VoidFunction callback /* 回调函数 */
|
Function func /* 函数对象 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual ActionCallback * clone() const override;
|
virtual ActionFunc * clone() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动作
|
// 初始化动作
|
||||||
|
|
@ -575,7 +574,7 @@ protected:
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
VoidFunction m_Callback;
|
Function m_Callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -689,9 +688,9 @@ namespace e2d
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建执行回调函数的动作
|
// 创建执行函数对象的动作
|
||||||
ActionCallback* Callback(
|
ActionFunc* Func(
|
||||||
VoidFunction callback /* 回调函数 */
|
Function func /* 函数对象 */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -36,3 +36,4 @@
|
||||||
|
|
||||||
|
|
||||||
using namespace e2d;
|
using namespace e2d;
|
||||||
|
using namespace e2d::action;
|
||||||
26
core/ebase.h
26
core/ebase.h
|
|
@ -14,11 +14,11 @@ class Game
|
||||||
public:
|
public:
|
||||||
// 初始化游戏
|
// 初始化游戏
|
||||||
static bool init(
|
static bool init(
|
||||||
const String & sTitle, /* 窗口标题 */
|
String& sTitle, /* 窗口标题 */
|
||||||
UINT32 nWidth, /* 窗口宽度 */
|
UINT32 nWidth = 640U, /* 窗口宽度 */
|
||||||
UINT32 nHeight, /* 窗口高度 */
|
UINT32 nHeight = 480U, /* 窗口高度 */
|
||||||
LPCTSTR pIconID = nullptr, /* 窗口图标 */
|
LPCTSTR pIconID = nullptr, /* 窗口图标 */
|
||||||
const String & sAppname = L"" /* AppName */
|
String sAppname = L"" /* AppName */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动游戏
|
// 启动游戏
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
|
|
||||||
// 设置窗口标题
|
// 设置窗口标题
|
||||||
static void setTitle(
|
static void setTitle(
|
||||||
const String & sTitle
|
String& sTitle
|
||||||
);
|
);
|
||||||
|
|
||||||
// 打开/隐藏控制台
|
// 打开/隐藏控制台
|
||||||
|
|
@ -89,7 +89,7 @@ public:
|
||||||
private:
|
private:
|
||||||
// 初始化窗口
|
// 初始化窗口
|
||||||
static bool __init(
|
static bool __init(
|
||||||
const String & sTitle,
|
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(
|
||||||
const String & sTitle
|
String& sTitle
|
||||||
);
|
);
|
||||||
|
|
||||||
// 重置窗口属性
|
// 重置窗口属性
|
||||||
|
|
@ -153,23 +153,23 @@ class Input
|
||||||
public:
|
public:
|
||||||
// 添加输入监听
|
// 添加输入监听
|
||||||
static void add(
|
static void add(
|
||||||
ListenerCallback callback, /* 回调函数 */
|
Function func, /* 监听到消息时的执行函数 */
|
||||||
const String & name = L"" /* 监听器名称 */
|
String name = L"" /* 监听器名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动输入监听
|
// 启动输入监听
|
||||||
static void start(
|
static void start(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 停止输入监听
|
// 停止输入监听
|
||||||
static void stop(
|
static void stop(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 清除输入监听
|
// 清除输入监听
|
||||||
static void clear(
|
static void clear(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动所有监听器
|
// 启动所有监听器
|
||||||
|
|
@ -183,7 +183,7 @@ public:
|
||||||
|
|
||||||
// 获取监听器
|
// 获取监听器
|
||||||
static std::vector<Listener*> get(
|
static std::vector<Listener*> get(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取全部监听器
|
// 获取全部监听器
|
||||||
|
|
|
||||||
|
|
@ -9,26 +9,19 @@ namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// 返回值和参数列表都为空的函数
|
// 函数对象
|
||||||
typedef std::function<void(void)> VoidFunction;
|
typedef std::function<void()> Function;
|
||||||
|
|
||||||
// 监听器回调函数
|
|
||||||
typedef VoidFunction ListenerCallback;
|
|
||||||
|
|
||||||
// 定时器回调函数
|
|
||||||
typedef VoidFunction TimerCallback;
|
|
||||||
|
|
||||||
// 按钮点击回调函数
|
|
||||||
typedef VoidFunction ButtonCallback;
|
|
||||||
|
|
||||||
|
// 创建函数对象
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
inline VoidFunction CreateCallback(Func&& func)
|
inline Function CreateFunc(Func&& func)
|
||||||
{
|
{
|
||||||
return std::bind(func);
|
return std::bind(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建函数对象
|
||||||
template<typename Object, typename Func>
|
template<typename Object, typename Func>
|
||||||
inline VoidFunction CreateCallback(Object&& obj, Func&& func)
|
inline Function CreateFunc(Object&& obj, Func&& func)
|
||||||
{
|
{
|
||||||
return std::bind(func, obj);
|
return std::bind(func, obj);
|
||||||
}
|
}
|
||||||
|
|
@ -463,7 +456,7 @@ public:
|
||||||
|
|
||||||
// 设置字体
|
// 设置字体
|
||||||
void setFamily(
|
void setFamily(
|
||||||
const String & fontFamily
|
String& fontFamily
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置字号
|
// 设置字号
|
||||||
|
|
@ -514,12 +507,12 @@ public:
|
||||||
|
|
||||||
// 从本地文件中读取资源
|
// 从本地文件中读取资源
|
||||||
Image(
|
Image(
|
||||||
const String & strFilePath /* 图片文件路径 */
|
String& strFilePath /* 图片文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 从本地文件中读取资源
|
// 从本地文件中读取资源
|
||||||
Image(
|
Image(
|
||||||
const String & strFilePath,/* 图片文件路径 */
|
String& strFilePath,/* 图片文件路径 */
|
||||||
double nClipX, /* 裁剪位置 X 坐标 */
|
double nClipX, /* 裁剪位置 X 坐标 */
|
||||||
double nClipY, /* 裁剪位置 Y 坐标 */
|
double nClipY, /* 裁剪位置 Y 坐标 */
|
||||||
double nClipWidth, /* 裁剪宽度 */
|
double nClipWidth, /* 裁剪宽度 */
|
||||||
|
|
@ -530,7 +523,7 @@ public:
|
||||||
|
|
||||||
// 从本地文件中读取图片
|
// 从本地文件中读取图片
|
||||||
void open(
|
void open(
|
||||||
const String & strFilePath
|
String& strFilePath
|
||||||
);
|
);
|
||||||
|
|
||||||
// 裁剪图片
|
// 裁剪图片
|
||||||
|
|
@ -573,7 +566,7 @@ public:
|
||||||
|
|
||||||
// 预加载资源
|
// 预加载资源
|
||||||
static bool preload(
|
static bool preload(
|
||||||
const String & strFileName /* 图片文件路径 */
|
String& strFileName /* 图片文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 清空缓存
|
// 清空缓存
|
||||||
|
|
@ -673,8 +666,12 @@ public:
|
||||||
Listener();
|
Listener();
|
||||||
|
|
||||||
Listener(
|
Listener(
|
||||||
ListenerCallback callback, /* 回调函数 */
|
Function func /* 监听到消息时的执行函数 */
|
||||||
const String & name = L"" /* 监听器名称 */
|
);
|
||||||
|
|
||||||
|
Listener(
|
||||||
|
Function func, /* 监听到消息时的执行函数 */
|
||||||
|
String& name /* 监听器名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动
|
// 启动
|
||||||
|
|
@ -694,12 +691,12 @@ public:
|
||||||
|
|
||||||
// 修改名称
|
// 修改名称
|
||||||
void setName(
|
void setName(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 修改回调函数
|
// 设置监听到消息时的执行函数
|
||||||
void setCallback(
|
void setFunction(
|
||||||
ListenerCallback callback
|
Function func
|
||||||
);
|
);
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
|
|
@ -709,7 +706,7 @@ protected:
|
||||||
String m_sName;
|
String m_sName;
|
||||||
bool m_bRunning;
|
bool m_bRunning;
|
||||||
bool m_bClear;
|
bool m_bClear;
|
||||||
ListenerCallback m_callback;
|
Function m_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
// String 类模板函数定义
|
// String 类模板函数定义
|
||||||
|
|
|
||||||
|
|
@ -96,27 +96,27 @@ public:
|
||||||
// 等待一段时间后执行指定函数
|
// 等待一段时间后执行指定函数
|
||||||
static void start(
|
static void start(
|
||||||
double timeOut, /* 等待的时长(秒) */
|
double timeOut, /* 等待的时长(秒) */
|
||||||
TimerCallback callback /* 执行的函数 */
|
Function func /* 执行的函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动具有相同名称的定时器
|
// 启动具有相同名称的定时器
|
||||||
static void start(
|
static void start(
|
||||||
const String &name
|
String&name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 停止具有相同名称的定时器
|
// 停止具有相同名称的定时器
|
||||||
static void stop(
|
static void stop(
|
||||||
const String &name
|
String&name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 删除具有相同名称的定时器
|
// 删除具有相同名称的定时器
|
||||||
static void clear(
|
static void clear(
|
||||||
const String &name
|
String&name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取名称相同的定时器
|
// 获取名称相同的定时器
|
||||||
static std::vector<Timer*> get(
|
static std::vector<Timer*> get(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动所有定时器
|
// 启动所有定时器
|
||||||
|
|
@ -158,17 +158,17 @@ class ActionManager
|
||||||
public:
|
public:
|
||||||
// 继续名称相同的所有动作
|
// 继续名称相同的所有动作
|
||||||
static void resume(
|
static void resume(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停名称相同的所有动作
|
// 暂停名称相同的所有动作
|
||||||
static void pause(
|
static void pause(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 停止名称相同的所有动作
|
// 停止名称相同的所有动作
|
||||||
static void stop(
|
static void stop(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 继续所有动作
|
// 继续所有动作
|
||||||
|
|
@ -182,7 +182,7 @@ public:
|
||||||
|
|
||||||
// 获取所有名称相同的动作
|
// 获取所有名称相同的动作
|
||||||
static std::vector<Action *> get(
|
static std::vector<Action *> get(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取所有动作
|
// 获取所有动作
|
||||||
|
|
@ -241,33 +241,33 @@ class MusicManager
|
||||||
public:
|
public:
|
||||||
// 预加载音乐资源
|
// 预加载音乐资源
|
||||||
static bool preload(
|
static bool preload(
|
||||||
const String & strFilePath /* 音乐文件路径 */
|
String& strFilePath /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 播放音乐
|
// 播放音乐
|
||||||
static bool play(
|
static bool play(
|
||||||
const String & strFilePath, /* 音乐文件路径 */
|
String& strFilePath, /* 音乐文件路径 */
|
||||||
int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停音乐
|
// 暂停音乐
|
||||||
static void pause(
|
static void pause(
|
||||||
const String & strFilePath /* 音乐文件路径 */
|
String& strFilePath /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 继续播放音乐
|
// 继续播放音乐
|
||||||
static void resume(
|
static void resume(
|
||||||
const String & strFilePath /* 音乐文件路径 */
|
String& strFilePath /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 停止音乐
|
// 停止音乐
|
||||||
static void stop(
|
static void stop(
|
||||||
const String & strFilePath /* 音乐文件路径 */
|
String& strFilePath /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取指定音乐的 Music 对象
|
// 获取指定音乐的 Music 对象
|
||||||
static Music * get(
|
static Music * get(
|
||||||
const String & strFilePath /* 音乐文件路径 */
|
String& strFilePath /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停所有音乐
|
// 暂停所有音乐
|
||||||
|
|
|
||||||
104
core/enodes.h
104
core/enodes.h
|
|
@ -123,7 +123,7 @@ public:
|
||||||
|
|
||||||
// 获取所有名称相同的子节点
|
// 获取所有名称相同的子节点
|
||||||
virtual std::vector<Node*> getChildren(
|
virtual std::vector<Node*> getChildren(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取所有子节点
|
// 获取所有子节点
|
||||||
|
|
@ -139,7 +139,7 @@ public:
|
||||||
|
|
||||||
// 移除所有名称相同的子节点
|
// 移除所有名称相同的子节点
|
||||||
virtual void removeChildren(
|
virtual void removeChildren(
|
||||||
const String & childName
|
String& childName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 从父节点移除
|
// 从父节点移除
|
||||||
|
|
@ -160,7 +160,7 @@ public:
|
||||||
|
|
||||||
// 设置节点名称
|
// 设置节点名称
|
||||||
virtual void setName(
|
virtual void setName(
|
||||||
const String & name
|
String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置节点横坐标
|
// 设置节点横坐标
|
||||||
|
|
@ -325,27 +325,27 @@ public:
|
||||||
|
|
||||||
// 继续动画
|
// 继续动画
|
||||||
virtual void resumeAction(
|
virtual void resumeAction(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停动画
|
// 暂停动画
|
||||||
virtual void pauseAction(
|
virtual void pauseAction(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 停止动画
|
// 停止动画
|
||||||
virtual void stopAction(
|
virtual void stopAction(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取名称相同的动画
|
// 获取名称相同的动画
|
||||||
virtual Action * getAction(
|
virtual Action * getAction(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取所有名称相同的动画
|
// 获取所有名称相同的动画
|
||||||
virtual std::vector<Action*> getActions(
|
virtual std::vector<Action*> getActions(
|
||||||
const String & strActionName
|
String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 继续所有暂停动画
|
// 继续所有暂停动画
|
||||||
|
|
@ -449,12 +449,12 @@ public:
|
||||||
|
|
||||||
// 从文件图片创建精灵
|
// 从文件图片创建精灵
|
||||||
Sprite(
|
Sprite(
|
||||||
const String & imageFileName
|
String& imageFileName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 从文件图片创建精灵并裁剪
|
// 从文件图片创建精灵并裁剪
|
||||||
Sprite(
|
Sprite(
|
||||||
const 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(
|
||||||
const String & imageFileName
|
String& imageFileName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 加载图片
|
// 加载图片
|
||||||
|
|
@ -499,7 +499,7 @@ public:
|
||||||
Text();
|
Text();
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
const String & text /* 文字内容 */
|
String& text /* 文字内容 */
|
||||||
);
|
);
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
|
|
@ -507,12 +507,12 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
const String & text,/* 文字内容 */
|
String& text,/* 文字内容 */
|
||||||
Font * font /* 字体样式 */
|
Font * font /* 字体样式 */
|
||||||
);
|
);
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
const String & text, /* 文字内容*/
|
String& text, /* 文字内容*/
|
||||||
String fontFamily, /* 字体 */
|
String fontFamily, /* 字体 */
|
||||||
double fontSize = 22, /* 字号 */
|
double fontSize = 22, /* 字号 */
|
||||||
UINT32 color = Color::WHITE, /* 颜色 */
|
UINT32 color = Color::WHITE, /* 颜色 */
|
||||||
|
|
@ -536,7 +536,7 @@ public:
|
||||||
|
|
||||||
// 设置文本
|
// 设置文本
|
||||||
void setText(
|
void setText(
|
||||||
const String & text
|
String& text
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置字体
|
// 设置字体
|
||||||
|
|
@ -579,14 +579,14 @@ public:
|
||||||
// 创建按钮
|
// 创建按钮
|
||||||
Button(
|
Button(
|
||||||
Node * normal, /* 普通状态 */
|
Node * normal, /* 普通状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建按钮
|
// 创建按钮
|
||||||
Button(
|
Button(
|
||||||
Node * normal, /* 普通状态 */
|
Node * normal, /* 普通状态 */
|
||||||
Node * selected, /* 鼠标按下状态 */
|
Node * selected, /* 鼠标按下状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建按钮
|
// 创建按钮
|
||||||
|
|
@ -594,7 +594,7 @@ public:
|
||||||
Node * normal, /* 普通状态 */
|
Node * normal, /* 普通状态 */
|
||||||
Node * mouseover, /* 鼠标移入状态 */
|
Node * mouseover, /* 鼠标移入状态 */
|
||||||
Node * selected, /* 鼠标按下状态 */
|
Node * selected, /* 鼠标按下状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建按钮
|
// 创建按钮
|
||||||
|
|
@ -603,7 +603,7 @@ public:
|
||||||
Node * mouseover, /* 鼠标移入状态 */
|
Node * mouseover, /* 鼠标移入状态 */
|
||||||
Node * selected, /* 鼠标移入状态 */
|
Node * selected, /* 鼠标移入状态 */
|
||||||
Node * disabled, /* 按钮禁用状态 */
|
Node * disabled, /* 按钮禁用状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取按钮状态是启用还是禁用
|
// 获取按钮状态是启用还是禁用
|
||||||
|
|
@ -624,7 +624,7 @@ public:
|
||||||
Node * mouseover
|
Node * mouseover
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置鼠标选中按钮时显示的按钮
|
// 设置鼠标按下按钮时显示的按钮
|
||||||
virtual void setSelected(
|
virtual void setSelected(
|
||||||
Node * selected
|
Node * selected
|
||||||
);
|
);
|
||||||
|
|
@ -634,9 +634,9 @@ public:
|
||||||
Node * disabled
|
Node * disabled
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置回调函数
|
// 设置按钮点击后的执行函数
|
||||||
void setCallback(
|
void setFunction(
|
||||||
ButtonCallback callback
|
Function func
|
||||||
);
|
);
|
||||||
|
|
||||||
// 更新按钮状态
|
// 更新按钮状态
|
||||||
|
|
@ -651,7 +651,7 @@ protected:
|
||||||
// 刷新按钮显示
|
// 刷新按钮显示
|
||||||
virtual void _updateVisiable();
|
virtual void _updateVisiable();
|
||||||
|
|
||||||
// 执行按钮回调函数
|
// 执行按钮函数对象
|
||||||
virtual void _runCallback();
|
virtual void _runCallback();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -662,7 +662,7 @@ protected:
|
||||||
bool m_bEnable;
|
bool m_bEnable;
|
||||||
bool m_bIsSelected;
|
bool m_bIsSelected;
|
||||||
BTN_STATE m_eBtnState;
|
BTN_STATE m_eBtnState;
|
||||||
ButtonCallback m_Callback;
|
Function m_Callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -675,42 +675,42 @@ public:
|
||||||
|
|
||||||
// 创建开关按钮
|
// 创建开关按钮
|
||||||
ButtonToggle(
|
ButtonToggle(
|
||||||
Node * onNormal,
|
Node * onNormal, /* 按钮打开时,普通状态 */
|
||||||
Node * offNormal,
|
Node * offNormal, /* 按钮关闭时,普通状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建开关按钮
|
// 创建开关按钮
|
||||||
ButtonToggle(
|
ButtonToggle(
|
||||||
Node * onNormal,
|
Node * onNormal, /* 按钮打开时,普通状态 */
|
||||||
Node * offNormal,
|
Node * offNormal, /* 按钮关闭时,普通状态 */
|
||||||
Node * onSelected,
|
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
|
||||||
Node * offSelected,
|
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建开关按钮
|
// 创建开关按钮
|
||||||
ButtonToggle(
|
ButtonToggle(
|
||||||
Node * onNormal,
|
Node * onNormal, /* 按钮打开时,普通状态 */
|
||||||
Node * offNormal,
|
Node * offNormal, /* 按钮关闭时,普通状态 */
|
||||||
Node * onMouseOver,
|
Node * onMouseOver, /* 按钮打开时,鼠标移入状态 */
|
||||||
Node * offMouseOver,
|
Node * offMouseOver, /* 按钮关闭时,鼠标移入状态 */
|
||||||
Node * onSelected,
|
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
|
||||||
Node * offSelected,
|
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建开关按钮
|
// 创建开关按钮
|
||||||
ButtonToggle(
|
ButtonToggle(
|
||||||
Node * onNormal,
|
Node * onNormal, /* 按钮打开时,普通状态 */
|
||||||
Node * offNormal,
|
Node * offNormal, /* 按钮关闭时,普通状态 */
|
||||||
Node * onMouseOver,
|
Node * onMouseOver, /* 按钮打开时,鼠标移入状态 */
|
||||||
Node * offMouseOver,
|
Node * offMouseOver, /* 按钮关闭时,鼠标移入状态 */
|
||||||
Node * onSelected,
|
Node * onSelected, /* 按钮打开时,鼠标按下状态 */
|
||||||
Node * offSelected,
|
Node * offSelected, /* 按钮关闭时,鼠标按下状态 */
|
||||||
Node * onDisabled,
|
Node * onDisabled, /* 按钮打开时,禁用状态 */
|
||||||
Node * offDisabled,
|
Node * offDisabled, /* 按钮关闭时,禁用状态 */
|
||||||
ButtonCallback callback = nullptr
|
Function func = nullptr /* 按钮点击后的执行函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取开关状态(打开或关闭)
|
// 获取开关状态(打开或关闭)
|
||||||
|
|
@ -731,7 +731,7 @@ public:
|
||||||
Node * mouseover
|
Node * mouseover
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
// 设置按钮打开状态下,鼠标选中按钮时显示的按钮
|
// 设置按钮打开状态下,鼠标按下按钮时显示的按钮
|
||||||
virtual void setSelected(
|
virtual void setSelected(
|
||||||
Node * selected
|
Node * selected
|
||||||
) override;
|
) override;
|
||||||
|
|
@ -751,7 +751,7 @@ public:
|
||||||
Node * mouseover
|
Node * mouseover
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置按钮关闭状态下,鼠标选中按钮时显示的按钮
|
// 设置按钮关闭状态下,鼠标按下按钮时显示的按钮
|
||||||
void setSelectedOff(
|
void setSelectedOff(
|
||||||
Node * selected
|
Node * selected
|
||||||
);
|
);
|
||||||
|
|
@ -765,7 +765,7 @@ protected:
|
||||||
// 刷新按钮开关
|
// 刷新按钮开关
|
||||||
virtual void _updateState();
|
virtual void _updateState();
|
||||||
|
|
||||||
// 执行按钮回调函数
|
// 执行按钮函数对象
|
||||||
virtual void _runCallback() override;
|
virtual void _runCallback() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ class Timer :
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Timer(
|
Timer(
|
||||||
const String &name = L"", /* 定时器名称 */
|
Function func = nullptr, /* 定时器执行函数 */
|
||||||
TimerCallback callback = nullptr, /* 定时器回调函数 */
|
String name = L"", /* 定时器名称 */
|
||||||
double interval = 0, /* 时间间隔(秒) */
|
double interval = 0, /* 时间间隔(秒) */
|
||||||
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
||||||
bool atOnce = false, /* 是否立即执行 */
|
bool atOnce = false, /* 是否立即执行 */
|
||||||
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
// 设置定时器名称
|
// 设置定时器名称
|
||||||
void setName(
|
void setName(
|
||||||
const String &name
|
String&name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置定时器执行间隔
|
// 设置定时器执行间隔
|
||||||
|
|
@ -87,9 +87,9 @@ public:
|
||||||
double fInterval /* 时间间隔(秒) */
|
double fInterval /* 时间间隔(秒) */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置定时器回调函数
|
// 设置定时器的执行函数
|
||||||
void setCallback(
|
void setFunction(
|
||||||
TimerCallback callback
|
Function func
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置定时器执行次数
|
// 设置定时器执行次数
|
||||||
|
|
@ -112,7 +112,7 @@ protected:
|
||||||
int m_nUpdateTimes;
|
int m_nUpdateTimes;
|
||||||
double m_fInterval;
|
double m_fInterval;
|
||||||
double m_fLast;
|
double m_fLast;
|
||||||
TimerCallback m_Callback;
|
Function m_Callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -122,67 +122,67 @@ class Data
|
||||||
public:
|
public:
|
||||||
// 保存 int 类型的值
|
// 保存 int 类型的值
|
||||||
static void saveInt(
|
static void saveInt(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
int value, /* 数据 */
|
int value, /* 数据 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 保存 double 类型的值
|
// 保存 double 类型的值
|
||||||
static void saveDouble(
|
static void saveDouble(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
double value, /* 数据 */
|
double value, /* 数据 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 保存 bool 类型的值
|
// 保存 bool 类型的值
|
||||||
static void saveBool(
|
static void saveBool(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
bool value, /* 数据 */
|
bool value, /* 数据 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 保存 字符串 类型的值
|
// 保存 字符串 类型的值
|
||||||
static void saveString(
|
static void saveString(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
const String & value, /* 数据 */
|
String& value, /* 数据 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取 int 类型的值
|
// 获取 int 类型的值
|
||||||
// (若不存在则返回 defaultValue 参数的值)
|
// (若不存在则返回 defaultValue 参数的值)
|
||||||
static int getInt(
|
static int getInt(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
int defaultValue, /* 默认值 */
|
int defaultValue, /* 默认值 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取 double 类型的值
|
// 获取 double 类型的值
|
||||||
// (若不存在则返回 defaultValue 参数的值)
|
// (若不存在则返回 defaultValue 参数的值)
|
||||||
static double getDouble(
|
static double getDouble(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
double defaultValue, /* 默认值 */
|
double defaultValue, /* 默认值 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取 bool 类型的值
|
// 获取 bool 类型的值
|
||||||
// (若不存在则返回 defaultValue 参数的值)
|
// (若不存在则返回 defaultValue 参数的值)
|
||||||
static bool getBool(
|
static bool getBool(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
bool defaultValue, /* 默认值 */
|
bool defaultValue, /* 默认值 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取 字符串 类型的值
|
// 获取 字符串 类型的值
|
||||||
// (若不存在则返回 defaultValue 参数的值)
|
// (若不存在则返回 defaultValue 参数的值)
|
||||||
static String getString(
|
static String getString(
|
||||||
const String & key, /* 键值 */
|
String& key, /* 键值 */
|
||||||
const String & defaultValue, /* 默认值 */
|
String& defaultValue, /* 默认值 */
|
||||||
const String & field = L"Defalut" /* 字段名称 */
|
String field = L"Defalut" /* 字段名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 修改数据文件的名称
|
// 修改数据文件的名称
|
||||||
static void setDataFileName(
|
static void setDataFileName(
|
||||||
const String & strFileName /* 文件名称 */
|
String& strFileName /* 文件名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取数据文件的完整路径
|
// 获取数据文件的完整路径
|
||||||
|
|
@ -205,18 +205,18 @@ public:
|
||||||
|
|
||||||
// 获取文件扩展名
|
// 获取文件扩展名
|
||||||
static String getFileExtension(
|
static String getFileExtension(
|
||||||
const 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(
|
||||||
const String & strDirPath /* 文件夹路径 */
|
String& strDirPath /* 文件夹路径 */
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -231,14 +231,14 @@ public:
|
||||||
Music();
|
Music();
|
||||||
|
|
||||||
Music(
|
Music(
|
||||||
const String & strFileName /* 音乐文件路径 */
|
String& strFileName /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~Music();
|
virtual ~Music();
|
||||||
|
|
||||||
// 打开音乐文件
|
// 打开音乐文件
|
||||||
bool open(
|
bool open(
|
||||||
const String & strFileName /* 音乐文件路径 */
|
String& strFileName /* 音乐文件路径 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 播放
|
// 播放
|
||||||
|
|
|
||||||
|
|
@ -76,15 +76,15 @@
|
||||||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
|
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
|
||||||
<ClCompile Include="..\..\core\Shape\Rect.cpp" />
|
<ClCompile Include="..\..\core\Shape\Rect.cpp" />
|
||||||
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
|
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Path.cpp" />
|
<ClCompile Include="..\..\core\Tool\Path.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Random.cpp" />
|
<ClCompile Include="..\..\core\Tool\Random.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Timer.cpp" />
|
<ClCompile Include="..\..\core\Tool\Timer.cpp" />
|
||||||
<ClCompile Include="..\..\core\Transition\ETransition.cpp" />
|
<ClCompile Include="..\..\core\Transition\Transition.cpp" />
|
||||||
<ClCompile Include="..\..\core\Transition\ETransitionEmerge.cpp" />
|
<ClCompile Include="..\..\core\Transition\TransitionEmerge.cpp" />
|
||||||
<ClCompile Include="..\..\core\Transition\ETransitionFade.cpp" />
|
<ClCompile Include="..\..\core\Transition\TransitionFade.cpp" />
|
||||||
<ClCompile Include="..\..\core\Transition\ETransitionMove.cpp" />
|
<ClCompile Include="..\..\core\Transition\TransitionMove.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{722EA245-ADD5-4296-8C85-8FF42C0335D3}</ProjectGuid>
|
<ProjectGuid>{722EA245-ADD5-4296-8C85-8FF42C0335D3}</ProjectGuid>
|
||||||
|
|
|
||||||
|
|
@ -138,18 +138,6 @@
|
||||||
<ClCompile Include="..\..\core\Tool\Timer.cpp">
|
<ClCompile Include="..\..\core\Tool\Timer.cpp">
|
||||||
<Filter>Tool</Filter>
|
<Filter>Tool</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Transition\ETransition.cpp">
|
|
||||||
<Filter>Transition</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Transition\ETransitionEmerge.cpp">
|
|
||||||
<Filter>Transition</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Transition\ETransitionFade.cpp">
|
|
||||||
<Filter>Transition</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Transition\ETransitionMove.cpp">
|
|
||||||
<Filter>Transition</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Node\Button.cpp">
|
<ClCompile Include="..\..\core\Node\Button.cpp">
|
||||||
<Filter>Node</Filter>
|
<Filter>Node</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -183,9 +171,6 @@
|
||||||
<ClCompile Include="..\..\core\Manager\ShapeManager.cpp">
|
<ClCompile Include="..\..\core\Manager\ShapeManager.cpp">
|
||||||
<Filter>Manager</Filter>
|
<Filter>Manager</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Tool\File.cpp">
|
|
||||||
<Filter>Tool</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Shape\Rect.cpp">
|
<ClCompile Include="..\..\core\Shape\Rect.cpp">
|
||||||
<Filter>Shape</Filter>
|
<Filter>Shape</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -201,5 +186,20 @@
|
||||||
<ClCompile Include="..\..\core\Tool\Path.cpp">
|
<ClCompile Include="..\..\core\Tool\Path.cpp">
|
||||||
<Filter>Tool</Filter>
|
<Filter>Tool</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Transition\Transition.cpp">
|
||||||
|
<Filter>Transition</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Transition\TransitionEmerge.cpp">
|
||||||
|
<Filter>Transition</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Transition\TransitionFade.cpp">
|
||||||
|
<Filter>Transition</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Transition\TransitionMove.cpp">
|
||||||
|
<Filter>Transition</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Tool\Data.cpp">
|
||||||
|
<Filter>Tool</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -235,8 +235,8 @@
|
||||||
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
|
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
|
||||||
<ClCompile Include="..\..\core\Shape\Rect.cpp" />
|
<ClCompile Include="..\..\core\Shape\Rect.cpp" />
|
||||||
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
|
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Path.cpp" />
|
<ClCompile Include="..\..\core\Tool\Path.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\File.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
<ClCompile Include="..\..\core\Tool\Music.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Random.cpp" />
|
<ClCompile Include="..\..\core\Tool\Random.cpp" />
|
||||||
<ClCompile Include="..\..\core\Tool\Timer.cpp" />
|
<ClCompile Include="..\..\core\Tool\Timer.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -144,9 +144,6 @@
|
||||||
<ClCompile Include="..\..\core\Tool\Music.cpp">
|
<ClCompile Include="..\..\core\Tool\Music.cpp">
|
||||||
<Filter>Tool</Filter>
|
<Filter>Tool</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Tool\File.cpp">
|
|
||||||
<Filter>Tool</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Manager\MusicManager.cpp">
|
<ClCompile Include="..\..\core\Manager\MusicManager.cpp">
|
||||||
<Filter>Manager</Filter>
|
<Filter>Manager</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -174,9 +171,6 @@
|
||||||
<ClCompile Include="..\..\core\Common\Listener.cpp">
|
<ClCompile Include="..\..\core\Common\Listener.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Tool\Path.cpp">
|
|
||||||
<Filter>Tool</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Transition\Transition.cpp">
|
<ClCompile Include="..\..\core\Transition\Transition.cpp">
|
||||||
<Filter>Transition</Filter>
|
<Filter>Transition</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -189,6 +183,12 @@
|
||||||
<ClCompile Include="..\..\core\Transition\TransitionMove.cpp">
|
<ClCompile Include="..\..\core\Transition\TransitionMove.cpp">
|
||||||
<Filter>Transition</Filter>
|
<Filter>Transition</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Tool\Data.cpp">
|
||||||
|
<Filter>Tool</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Tool\Path.cpp">
|
||||||
|
<Filter>Tool</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\etools.h" />
|
<ClInclude Include="..\..\core\etools.h" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue