diff --git a/core/Action/ActionBase.cpp b/core/Action/ActionBase.cpp index 2a0f4bca..f4130116 100644 --- a/core/Action/ActionBase.cpp +++ b/core/Action/ActionBase.cpp @@ -57,7 +57,7 @@ e2d::String e2d::ActionBase::getName() const return m_sName; } -void e2d::ActionBase::setName(String name) +void e2d::ActionBase::setName(const String& name) { m_sName = name; } diff --git a/core/Base/Game.cpp b/core/Base/Game.cpp index cae159b2..440112d0 100644 --- a/core/Base/Game.cpp +++ b/core/Base/Game.cpp @@ -13,7 +13,7 @@ static bool s_bInitialized = false; static e2d::String s_sGameName; -bool e2d::Game::init(String sGameName) +bool e2d::Game::init(const String& name) { if (s_bInitialized) { @@ -60,7 +60,7 @@ bool e2d::Game::init(String sGameName) } // 保存游戏名称 - s_sGameName = sGameName; + s_sGameName = name; // 初始化路径 if (!Path::__init()) @@ -88,7 +88,7 @@ succeeded: return s_bInitialized; } -int e2d::Game::start(bool bAutoRelease/* true */) +int e2d::Game::start(bool autoRelease/* true */) { if (!s_bInitialized) { @@ -134,7 +134,7 @@ int e2d::Game::start(bool bAutoRelease/* true */) } } - if (bAutoRelease) + if (autoRelease) { Game::destroy(); } @@ -201,7 +201,7 @@ void e2d::Game::destroy() s_bInitialized = false; } -bool e2d::Game::createMutex(String sMutexName, String sWindowTitle) +bool e2d::Game::createMutex(const String& sMutexName, const String& sWindowTitle) { // 创建进程互斥体 HANDLE m_hMutex = ::CreateMutex(NULL, TRUE, L"Easy2DApp-" + sMutexName); diff --git a/core/Base/Window.cpp b/core/Base/Window.cpp index de0559d9..813d1d40 100644 --- a/core/Base/Window.cpp +++ b/core/Base/Window.cpp @@ -174,16 +174,16 @@ void e2d::Window::setSize(int width, int height) ::MoveWindow(s_HWnd, (screenWidth - width) / 2, (screenHeight - height) / 2, width, height, TRUE); } -void e2d::Window::setTitle(String title) +void e2d::Window::setTitle(const String& title) { // 设置窗口标题 ::SetWindowText(s_HWnd, title); } -void e2d::Window::setIcon(int pIconID) +void e2d::Window::setIcon(int iconID) { HINSTANCE hInstance = ::GetModuleHandle(NULL); - HICON hIcon = (HICON)::LoadImage(hInstance, MAKEINTRESOURCE(pIconID), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); + HICON hIcon = (HICON)::LoadImage(hInstance, MAKEINTRESOURCE(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); // 设置窗口的图标 ::SendMessage(s_HWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon); ::SendMessage(s_HWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); @@ -237,11 +237,11 @@ void e2d::Window::showConsole(bool show) } } -void e2d::Window::setTypewritingEnable(bool bEnable) +void e2d::Window::setTypewritingEnable(bool enable) { static HIMC hImc = nullptr; - if (bEnable) + if (enable) { if (hImc != nullptr) { diff --git a/core/Collider/Collider.cpp b/core/Collider/Collider.cpp index d1be4b5c..ecf2d717 100644 --- a/core/Collider/Collider.cpp +++ b/core/Collider/Collider.cpp @@ -27,9 +27,9 @@ e2d::Color e2d::Collider::getColor() const return m_nColor; } -void e2d::Collider::setEnable(bool bEnable) +void e2d::Collider::setEnable(bool enable) { - m_bEnable = bEnable; + m_bEnable = enable; } void e2d::Collider::setVisiable(bool bVisiable) @@ -42,9 +42,9 @@ void e2d::Collider::setColor(Color color) m_nColor = color; } -void e2d::Collider::setAutoResize(bool bEnable) +void e2d::Collider::setAutoResize(bool enable) { - m_bAutoResize = bEnable; + m_bAutoResize = enable; } void e2d::Collider::_render() diff --git a/core/Common/Image.cpp b/core/Common/Image.cpp index 03f5beb6..1a38211c 100644 --- a/core/Common/Image.cpp +++ b/core/Common/Image.cpp @@ -14,57 +14,57 @@ e2d::Image::Image() { } -e2d::Image::Image(String strFileName) +e2d::Image::Image(const String& filePath) : m_pBitmap(nullptr) { - this->open(strFileName); + this->open(filePath); } -e2d::Image::Image(int resNameId, String resType) +e2d::Image::Image(int resNameId, const String& resType) : m_pBitmap(nullptr) { this->open(resNameId, resType); } -e2d::Image::Image(String strFileName, double nCropX, double nCropY, double nCropWidth, double nCropHeight) +e2d::Image::Image(const String& filePath, double cropX, double cropY, double cropWidth, double cropHeight) : m_pBitmap(nullptr) { - this->open(strFileName); - this->crop(nCropX, nCropY, nCropWidth, nCropHeight); + this->open(filePath); + this->crop(cropX, cropY, cropWidth, cropHeight); } -e2d::Image::Image(int resNameId, String resType, double nCropX, double nCropY, double nCropWidth, double nCropHeight) +e2d::Image::Image(int resNameId, const String& resType, double cropX, double cropY, double cropWidth, double cropHeight) : m_pBitmap(nullptr) { this->open(resNameId, resType); - this->crop(nCropX, nCropY, nCropWidth, nCropHeight); + this->crop(cropX, cropY, cropWidth, cropHeight); } e2d::Image::~Image() { } -bool e2d::Image::open(String strFilePath) +bool e2d::Image::open(const String& filePath) { - WARN_IF(strFilePath.isEmpty(), "Image cannot load bitmap from NULL file name."); + WARN_IF(filePath.isEmpty(), "Image cannot load bitmap from NULL file name."); - if (strFilePath.isEmpty()) + if (filePath.isEmpty()) return false; - if (!Image::preload(strFilePath)) + if (!Image::preload(filePath)) { WARN_IF(true, "Load Image from file failed!"); return false; } - m_pBitmap = s_mBitmapsFromFile.at(strFilePath.getHashCode()); + m_pBitmap = s_mBitmapsFromFile.at(filePath.getHashCode()); m_fSourceCropX = m_fSourceCropY = 0; m_fSourceCropWidth = m_pBitmap->GetSize().width; m_fSourceCropHeight = m_pBitmap->GetSize().height; return true; } -bool e2d::Image::open(int resNameId, String resType) +bool e2d::Image::open(int resNameId, const String& resType) { if (!Image::preload(resNameId, resType)) { @@ -156,7 +156,7 @@ e2d::Point e2d::Image::getCropPos() const return Point(m_fSourceCropX, m_fSourceCropY); } -bool e2d::Image::preload(String fileName) +bool e2d::Image::preload(const String& fileName) { if (s_mBitmapsFromFile.find(fileName.getHashCode()) != s_mBitmapsFromFile.end()) { @@ -232,7 +232,7 @@ bool e2d::Image::preload(String fileName) return SUCCEEDED(hr); } -bool e2d::Image::preload(int resNameId, String resType) +bool e2d::Image::preload(int resNameId, const String& resType) { if (s_mBitmapsFromResource.find(resNameId) != s_mBitmapsFromResource.end()) { diff --git a/core/Common/Scene.cpp b/core/Common/Scene.cpp index f943e87e..87dc580b 100644 --- a/core/Common/Scene.cpp +++ b/core/Common/Scene.cpp @@ -67,12 +67,12 @@ bool e2d::Scene::remove(Node * child) return m_pRoot->removeChild(child); } -std::vector e2d::Scene::get(String name) const +std::vector e2d::Scene::get(const String& name) const { return m_pRoot->getChildren(name); } -e2d::Node * e2d::Scene::getOne(String name) const +e2d::Node * e2d::Scene::getOne(const String& name) const { return m_pRoot->getChild(name); } diff --git a/core/Common/TextStyle.cpp b/core/Common/TextStyle.cpp index a6a30a6f..47e3ce5c 100644 --- a/core/Common/TextStyle.cpp +++ b/core/Common/TextStyle.cpp @@ -19,7 +19,7 @@ e2d::TextStyle::TextStyle() {} e2d::TextStyle::TextStyle( - String fontFamily, + const String& fontFamily, double fontSize, Color color, UINT32 fontWeight, diff --git a/core/Manager/ActionManager.cpp b/core/Manager/ActionManager.cpp index 377b5dde..1741343d 100644 --- a/core/Manager/ActionManager.cpp +++ b/core/Manager/ActionManager.cpp @@ -114,7 +114,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode) } } -void e2d::ActionManager::resume(String strActionName) +void e2d::ActionManager::resume(const String& strActionName) { 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(const String& strActionName) { 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(const String& strActionName) { for (auto action : s_vRunningActions) { @@ -201,7 +201,7 @@ void e2d::ActionManager::stopAll() } } -std::vector e2d::ActionManager::get(String strActionName) +std::vector e2d::ActionManager::get(const String& strActionName) { std::vector vActions; for (auto action : s_vActions) diff --git a/core/Manager/ColliderManager.cpp b/core/Manager/ColliderManager.cpp index 197246bb..2fef31e3 100644 --- a/core/Manager/ColliderManager.cpp +++ b/core/Manager/ColliderManager.cpp @@ -9,7 +9,7 @@ class Listener public: Listener( e2d::Function func, - e2d::String name, + const e2d::String& name, bool paused ) : name(name) @@ -47,9 +47,9 @@ static e2d::Node * s_pActiveNode = nullptr; static e2d::Node * s_pPassiveNode = nullptr; -void e2d::ColliderManager::setEnable(bool bEnable) +void e2d::ColliderManager::setEnable(bool enable) { - s_bCollisionEnable = bEnable; + s_bCollisionEnable = enable; } void e2d::ColliderManager::__update() @@ -133,13 +133,13 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider) s_pPassiveNode = nullptr; } -void e2d::ColliderManager::add(Function func, String name, bool paused) +void e2d::ColliderManager::add(Function func, const String& name, bool paused) { auto listener = new Listener(func, name, paused); s_vListeners.push_back(listener); } -void e2d::ColliderManager::pause(String name) +void e2d::ColliderManager::pause(const String& name) { for (auto pListener : s_vListeners) { @@ -150,7 +150,7 @@ void e2d::ColliderManager::pause(String name) } } -void e2d::ColliderManager::resume(String name) +void e2d::ColliderManager::resume(const String& name) { for (auto pListener : s_vListeners) { @@ -161,7 +161,7 @@ void e2d::ColliderManager::resume(String name) } } -void e2d::ColliderManager::stop(String name) +void e2d::ColliderManager::stop(const String& name) { for (auto pListener : s_vListeners) { @@ -215,7 +215,7 @@ e2d::Node* e2d::ColliderManager::isCausedBy(Node * pNode) return nullptr; } -e2d::Node* e2d::ColliderManager::isCausedBy(String name) +e2d::Node* e2d::ColliderManager::isCausedBy(const String& name) { if (s_pActiveNode->getName() == name) return s_pActiveNode; diff --git a/core/Manager/InputManager.cpp b/core/Manager/InputManager.cpp index 05d9840c..460d3299 100644 --- a/core/Manager/InputManager.cpp +++ b/core/Manager/InputManager.cpp @@ -7,7 +7,7 @@ class Listener public: Listener( e2d::Function func, - e2d::String name, + const e2d::String& name, bool paused ) : name(name) @@ -37,13 +37,13 @@ public: static std::vector s_vListeners; -void e2d::InputManager::add(Function func, String name, bool paused) +void e2d::InputManager::add(Function func, const String& name, bool paused) { auto listener = new Listener(func, name, paused); s_vListeners.push_back(listener); } -void e2d::InputManager::pause(String name) +void e2d::InputManager::pause(const String& name) { for (auto pListener : s_vListeners) { @@ -54,7 +54,7 @@ void e2d::InputManager::pause(String name) } } -void e2d::InputManager::resume(String name) +void e2d::InputManager::resume(const String& name) { for (auto pListener : s_vListeners) { @@ -65,7 +65,7 @@ void e2d::InputManager::resume(String name) } } -void e2d::InputManager::stop(String name) +void e2d::InputManager::stop(const String& name) { for (auto pListener : s_vListeners) { diff --git a/core/Node/Button.cpp b/core/Node/Button.cpp index 7e336c98..abc2afb4 100644 --- a/core/Node/Button.cpp +++ b/core/Node/Button.cpp @@ -161,11 +161,11 @@ void e2d::Button::setDisabled(Node * disabled) } } -void e2d::Button::setEnable(bool bEnable) +void e2d::Button::setEnable(bool enable) { - if (m_bEnable != bEnable) + if (m_bEnable != enable) { - m_bEnable = bEnable; + m_bEnable = enable; _updateVisiable(); } } diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index 24be12bf..1ab7232a 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -610,7 +610,7 @@ void e2d::Node::setCollider(Collider * pCollider) } } -void e2d::Node::addColliableName(String collliderName) +void e2d::Node::addColliableName(const String& collliderName) { unsigned int hash = collliderName.getHashCode(); m_vColliders.insert(hash); @@ -626,7 +626,7 @@ void e2d::Node::addColliableName(const InitList& vCollliderName) } #endif -void e2d::Node::removeColliableName(String collliderName) +void e2d::Node::removeColliableName(const String& collliderName) { unsigned int hash = collliderName.getHashCode(); m_vColliders.erase(hash); @@ -692,7 +692,7 @@ e2d::Scene * e2d::Node::getParentScene() const return m_pParentScene; } -std::vector e2d::Node::getChildren(String name) const +std::vector e2d::Node::getChildren(const String& name) const { std::vector vChildren; unsigned int hash = name.getHashCode(); @@ -708,7 +708,7 @@ std::vector e2d::Node::getChildren(String name) const return std::move(vChildren); } -e2d::Node * e2d::Node::getChild(String name) const +e2d::Node * e2d::Node::getChild(const String& name) const { unsigned int hash = name.getHashCode(); @@ -777,7 +777,7 @@ bool e2d::Node::removeChild(Node * child) return false; } -void e2d::Node::removeChildren(String childName) +void e2d::Node::removeChildren(const String& childName) { WARN_IF(childName.isEmpty(), "Invalid Node name."); @@ -846,7 +846,7 @@ void e2d::Node::runAction(ActionBase * action) } } -void e2d::Node::resumeAction(String strActionName) +void e2d::Node::resumeAction(const String& strActionName) { auto actions = ActionManager::get(strActionName); for (auto action : actions) @@ -858,7 +858,7 @@ void e2d::Node::resumeAction(String strActionName) } } -void e2d::Node::pauseAction(String strActionName) +void e2d::Node::pauseAction(const String& strActionName) { auto actions = ActionManager::get(strActionName); for (auto action : actions) @@ -870,7 +870,7 @@ void e2d::Node::pauseAction(String strActionName) } } -void e2d::Node::stopAction(String strActionName) +void e2d::Node::stopAction(const String& strActionName) { auto actions = ActionManager::get(strActionName); for (auto action : actions) @@ -882,7 +882,7 @@ void e2d::Node::stopAction(String strActionName) } } -e2d::ActionBase * e2d::Node::getAction(String strActionName) +e2d::ActionBase * e2d::Node::getAction(const String& strActionName) { auto actions = ActionManager::get(strActionName); for (auto action : actions) @@ -895,7 +895,7 @@ e2d::ActionBase * e2d::Node::getAction(String strActionName) return nullptr; } -std::vector e2d::Node::getActions(String strActionName) +std::vector e2d::Node::getActions(const String& strActionName) { std::vector::iterator iter; auto actions = ActionManager::get(strActionName); @@ -1022,9 +1022,9 @@ void e2d::Node::setDefaultPiovt(double defaultPiovtX, double defaultPiovtY) s_fDefaultPiovtY = min(max(static_cast(defaultPiovtY), 0), 1); } -void e2d::Node::setDefaultColliderEnable(bool bEnable) +void e2d::Node::setDefaultColliderEnable(bool enable) { - s_fDefaultColliderEnabled = bEnable; + s_fDefaultColliderEnabled = enable; } void e2d::Node::destroy() @@ -1057,7 +1057,7 @@ void e2d::Node::setVisiable(bool value) m_bVisiable = value; } -void e2d::Node::setName(String name) +void e2d::Node::setName(const String& name) { WARN_IF(name.isEmpty(), "Invalid Node name."); diff --git a/core/Node/Sprite.cpp b/core/Node/Sprite.cpp index 3e540769..75fc22a7 100644 --- a/core/Node/Sprite.cpp +++ b/core/Node/Sprite.cpp @@ -12,26 +12,26 @@ e2d::Sprite::Sprite(Image * image) open(image); } -e2d::Sprite::Sprite(String strFilePath) +e2d::Sprite::Sprite(const String& filePath) : m_pImage(nullptr) { - open(strFilePath); + open(filePath); } -e2d::Sprite::Sprite(int resNameId, String resType) +e2d::Sprite::Sprite(int resNameId, const String& resType) : m_pImage(nullptr) { open(resNameId, resType); } -e2d::Sprite::Sprite(String strFilePath, double x, double y, double width, double height) +e2d::Sprite::Sprite(const String& filePath, double x, double y, double width, double height) : m_pImage(nullptr) { - open(strFilePath); + open(filePath); crop(x, y, width, height); } -e2d::Sprite::Sprite(int resNameId, String resType, double x, double y, double width, double height) +e2d::Sprite::Sprite(int resNameId, const String& resType, double x, double y, double width, double height) : m_pImage(nullptr) { open(resNameId, resType); @@ -56,7 +56,7 @@ bool e2d::Sprite::open(Image * image) return false; } -bool e2d::Sprite::open(String strFilePath) +bool e2d::Sprite::open(const String& filePath) { if (!m_pImage) { @@ -64,7 +64,7 @@ bool e2d::Sprite::open(String strFilePath) m_pImage->retain(); } - if (m_pImage->open(strFilePath)) + if (m_pImage->open(filePath)) { Node::setSize(m_pImage->getWidth(), m_pImage->getHeight()); return true; @@ -72,7 +72,7 @@ bool e2d::Sprite::open(String strFilePath) return false; } -bool e2d::Sprite::open(int resNameId, String resType) +bool e2d::Sprite::open(int resNameId, const String& resType) { if (!m_pImage) { diff --git a/core/Node/Text.cpp b/core/Node/Text.cpp index 0d0b6c41..a79e97e0 100644 --- a/core/Node/Text.cpp +++ b/core/Node/Text.cpp @@ -8,7 +8,7 @@ e2d::Text::Text() { } -e2d::Text::Text(String text) +e2d::Text::Text(const String& text) : m_TextStyle() , m_pDWriteTextLayout(nullptr) , m_pDWriteTextFormat(nullptr) @@ -25,7 +25,7 @@ e2d::Text::Text(TextStyle textStyle) _reset(); } -e2d::Text::Text(String text, TextStyle textStyle) +e2d::Text::Text(const String& text, TextStyle textStyle) : m_TextStyle(textStyle) , m_pDWriteTextLayout(nullptr) , m_pDWriteTextFormat(nullptr) @@ -35,8 +35,8 @@ e2d::Text::Text(String text, TextStyle textStyle) } e2d::Text::Text( - String text, - String fontFamily, + const String& text, + const String& fontFamily, double fontSize, UINT32 color, UINT32 fontWeight, @@ -159,7 +159,7 @@ bool e2d::Text::hasOutline() const return m_TextStyle.hasOutline; } -void e2d::Text::setText(String text) +void e2d::Text::setText(const String& text) { m_sText = text; _reset(); @@ -171,7 +171,7 @@ void e2d::Text::setTextStyle(TextStyle textStyle) _reset(); } -void e2d::Text::setFontFamily(String fontFamily) +void e2d::Text::setFontFamily(const String& fontFamily) { m_TextStyle.fontFamily = fontFamily; _reset(); diff --git a/core/Tool/Data.cpp b/core/Tool/Data.cpp index ec5617ed..6faddef2 100644 --- a/core/Tool/Data.cpp +++ b/core/Tool/Data.cpp @@ -2,54 +2,54 @@ static e2d::String s_sDataFileName = L"DefaultData.ini"; -void e2d::Data::saveInt(String key, int value, String field) +void e2d::Data::saveInt(const String& key, int value, const String& field) { ::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath()); } -void e2d::Data::saveDouble(String key, double value, String field) +void e2d::Data::saveDouble(const String& key, double value, const String& field) { ::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath()); } -void e2d::Data::saveBool(String key, bool value, String field) +void e2d::Data::saveBool(const String& key, bool value, const 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) +void e2d::Data::saveString(const String& key, const String& value, const String& field) { ::WritePrivateProfileString(field, key, value, Data::getDataFilePath()); } -int e2d::Data::getInt(String key, int defaultValue, String field) +int e2d::Data::getInt(const String& key, int defaultValue, const String& field) { return ::GetPrivateProfileInt(field, key, defaultValue, Data::getDataFilePath()); } -double e2d::Data::getDouble(String key, double defaultValue, String field) +double e2d::Data::getDouble(const String& key, double defaultValue, const String& field) { wchar_t temp[32] = { 0 }; ::GetPrivateProfileString(field, key, String::parse(defaultValue), temp, 31, Data::getDataFilePath()); return std::stof(temp); } -bool e2d::Data::getBool(String key, bool defaultValue, String field) +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(String key, String defaultValue, String field) +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(String fileName) +void e2d::Data::setDataFileName(const String& fileName) { if (!fileName.isEmpty()) { diff --git a/core/Tool/Music.cpp b/core/Tool/Music.cpp index 55c3864c..ae122983 100644 --- a/core/Tool/Music.cpp +++ b/core/Tool/Music.cpp @@ -36,7 +36,7 @@ public: virtual ~MusicPlayer(); bool open( - const e2d::String& strFileName + const e2d::String& filePath ); bool MusicPlayer::open( @@ -122,7 +122,7 @@ MusicPlayer::~MusicPlayer() close(); } -bool MusicPlayer::open(const e2d::String& strFileName) +bool MusicPlayer::open(const e2d::String& filePath) { if (m_bOpened) { @@ -130,7 +130,7 @@ bool MusicPlayer::open(const e2d::String& strFileName) return false; } - if (strFileName.isEmpty()) + if (filePath.isEmpty()) { WARN_IF(true, "MusicInfo::open Invalid file name."); return false; @@ -143,14 +143,14 @@ bool MusicPlayer::open(const e2d::String& strFileName) } // 定位 wave 文件 - wchar_t strFilePath[MAX_PATH]; - if (!_findMediaFileCch(strFilePath, MAX_PATH, strFileName)) + wchar_t pFilePath[MAX_PATH]; + if (!_findMediaFileCch(pFilePath, MAX_PATH, filePath)) { - WARN_IF(true, "Failed to find media file: %s", (const wchar_t*)strFileName); + WARN_IF(true, "Failed to find media file: %s", pFilePath); return false; } - m_hmmio = mmioOpen(strFilePath, nullptr, MMIO_ALLOCBUF | MMIO_READ); + m_hmmio = mmioOpen(pFilePath, nullptr, MMIO_ALLOCBUF | MMIO_READ); if (nullptr == m_hmmio) { @@ -605,9 +605,9 @@ bool MusicPlayer::_findMediaFileCch(wchar_t* strDestPath, int cchDest, const wch } -bool e2d::Music::preload(String strFilePath) +bool e2d::Music::preload(const String& filePath) { - UINT nRet = strFilePath.getHashCode(); + UINT nRet = filePath.getHashCode(); if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) { @@ -617,7 +617,7 @@ bool e2d::Music::preload(String strFilePath) { MusicPlayer * pPlayer = new (std::nothrow) MusicPlayer(); - if (pPlayer->open(strFilePath)) + if (pPlayer->open(filePath)) { pPlayer->setVolume(s_fMusicVolume); GetMusicFileList().insert(std::pair(nRet, pPlayer)); @@ -632,7 +632,7 @@ bool e2d::Music::preload(String strFilePath) return false; } -bool e2d::Music::preload(int resNameId, String resType) +bool e2d::Music::preload(int resNameId, const String& resType) { if (GetMusicResList().end() != GetMusicResList().find(resNameId)) { @@ -657,11 +657,11 @@ bool e2d::Music::preload(int resNameId, String resType) return false; } -bool e2d::Music::play(String strFilePath, int nLoopCount) +bool e2d::Music::play(const String& filePath, int nLoopCount) { - if (Music::preload(strFilePath)) + if (Music::preload(filePath)) { - UINT nRet = strFilePath.getHashCode(); + UINT nRet = filePath.getHashCode(); auto pMusic = GetMusicFileList()[nRet]; if (pMusic->play(nLoopCount)) { @@ -671,7 +671,7 @@ bool e2d::Music::play(String strFilePath, int nLoopCount) return false; } -bool e2d::Music::play(int resNameId, String resType, int nLoopCount) +bool e2d::Music::play(int resNameId, const String& resType, int nLoopCount) { if (Music::preload(resNameId, resType)) { @@ -684,63 +684,63 @@ bool e2d::Music::play(int resNameId, String resType, int nLoopCount) return false; } -void e2d::Music::pause(String strFilePath) +void e2d::Music::pause(const String& filePath) { - if (strFilePath.isEmpty()) + if (filePath.isEmpty()) return; - UINT nRet = strFilePath.getHashCode(); + UINT nRet = filePath.getHashCode(); if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) GetMusicFileList()[nRet]->pause(); } -void e2d::Music::pause(int resNameId, String resType) +void e2d::Music::pause(int resNameId, const String& resType) { if (GetMusicResList().end() != GetMusicResList().find(resNameId)) GetMusicResList()[resNameId]->pause(); } -void e2d::Music::resume(String strFilePath) +void e2d::Music::resume(const String& filePath) { - if (strFilePath.isEmpty()) + if (filePath.isEmpty()) return; - UINT nRet = strFilePath.getHashCode(); + UINT nRet = filePath.getHashCode(); if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) GetMusicFileList()[nRet]->resume(); } -void e2d::Music::resume(int resNameId, String resType) +void e2d::Music::resume(int resNameId, const String& resType) { if (GetMusicResList().end() != GetMusicResList().find(resNameId)) GetMusicResList()[resNameId]->pause(); } -void e2d::Music::stop(String strFilePath) +void e2d::Music::stop(const String& filePath) { - if (strFilePath.isEmpty()) + if (filePath.isEmpty()) return; - UINT nRet = strFilePath.getHashCode(); + UINT nRet = filePath.getHashCode(); if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) GetMusicFileList()[nRet]->stop(); } -void e2d::Music::stop(int resNameId, String resType) +void e2d::Music::stop(int resNameId, const String& resType) { if (GetMusicResList().end() != GetMusicResList().find(resNameId)) GetMusicResList()[resNameId]->stop(); } -bool e2d::Music::isPlaying(String strFilePath) +bool e2d::Music::isPlaying(const String& filePath) { - if (strFilePath.isEmpty()) + if (filePath.isEmpty()) return false; - UINT nRet = strFilePath.getHashCode(); + UINT nRet = filePath.getHashCode(); if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) return GetMusicFileList()[nRet]->isPlaying(); @@ -748,7 +748,7 @@ bool e2d::Music::isPlaying(String strFilePath) return false; } -bool e2d::Music::isPlaying(int resNameId, String resType) +bool e2d::Music::isPlaying(int resNameId, const String& resType) { if (GetMusicResList().end() != GetMusicResList().find(resNameId)) return GetMusicResList()[resNameId]->isPlaying(); diff --git a/core/Tool/Path.cpp b/core/Tool/Path.cpp index d977d472..e8c1f8c9 100644 --- a/core/Tool/Path.cpp +++ b/core/Tool/Path.cpp @@ -129,7 +129,7 @@ e2d::String e2d::Path::getDefaultSavePath() return s_sDefaultSavePath; } -e2d::String e2d::Path::getFileExtension(String filePath) +e2d::String e2d::Path::getFileExtension(const String& filePath) { String fileExtension; // 找到文件名中的最后一个 '.' 的位置 @@ -146,7 +146,7 @@ e2d::String e2d::Path::getFileExtension(String filePath) 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 }; @@ -169,17 +169,17 @@ e2d::String e2d::Path::getSaveFilePath(const String title, const String defExt) return L""; } -bool e2d::Path::createFolder(String strDirPath) +bool e2d::Path::createFolder(const String& dirPath) { - if (strDirPath.isEmpty()) + if (dirPath.isEmpty()) { WARN_IF(true, "Path::createFolder Failed: Invalid directory path!"); return false; } - if (-1 == ::_waccess(strDirPath, 0)) + if (-1 == ::_waccess(dirPath, 0)) { - if (0 != ::_wmkdir(strDirPath)) + if (0 != ::_wmkdir(dirPath)) { return false; } diff --git a/core/Tool/Timer.cpp b/core/Tool/Timer.cpp index 3e40e4f8..59e3bf54 100644 --- a/core/Tool/Timer.cpp +++ b/core/Tool/Timer.cpp @@ -6,7 +6,7 @@ class TimerInfo public: TimerInfo( e2d::Function func, - e2d::String name, + const e2d::String& name, double delay, int updateTimes, bool paused @@ -65,13 +65,13 @@ public: static std::vector s_vTimers; -void e2d::Timer::start(Function func, double delay, int updateTimes, bool paused, String name) +void e2d::Timer::start(Function func, double delay, int updateTimes, bool paused, const String& name) { auto timer = new TimerInfo(func, name, delay, updateTimes, paused); s_vTimers.push_back(timer); } -void e2d::Timer::start(Function func, String name) +void e2d::Timer::start(Function func, const String& name) { Timer::start(func, 0, -1, false, name); } @@ -82,7 +82,7 @@ void e2d::Timer::startOnce(Function func, double timeOut) s_vTimers.push_back(timer); } -void e2d::Timer::pause(String name) +void e2d::Timer::pause(const String& name) { for (auto timer : s_vTimers) { @@ -93,7 +93,7 @@ void e2d::Timer::pause(String name) } } -void e2d::Timer::resume(String name) +void e2d::Timer::resume(const String& name) { for (auto timer : s_vTimers) { @@ -104,7 +104,7 @@ void e2d::Timer::resume(String name) } } -void e2d::Timer::stop(String name) +void e2d::Timer::stop(const String& name) { for (auto timer : s_vTimers) { diff --git a/core/e2daction.h b/core/e2daction.h index 438334b7..34f7f61e 100644 --- a/core/e2daction.h +++ b/core/e2daction.h @@ -189,7 +189,7 @@ public: // 设置动作名称 virtual void setName( - String name + const String& name ); // 获取一个新的逆向动作 diff --git a/core/e2dbase.h b/core/e2dbase.h index 57487a77..465144f4 100644 --- a/core/e2dbase.h +++ b/core/e2dbase.h @@ -14,12 +14,12 @@ class Game public: // 初始化游戏 static bool init( - String sGameName = L"" /* 游戏英文名称 */ + const String& name = L"" /* 游戏英文名称 */ ); // 启动游戏 static int start( - bool bAutoRelease = true + bool autoRelease = true /* 游戏结束时自动回收资源 */ ); // 暂停游戏 @@ -39,8 +39,8 @@ public: // 创建进程互斥体 static bool createMutex( - String sMutexName, /* 互斥体名称 */ - String sWindowTitle = L"" /* 窗口标题 */ + const String& sMutexName, /* 互斥体名称 */ + const String& sWindowTitle = L"" /* 窗口标题 */ ); // 获取游戏名称 @@ -56,18 +56,18 @@ class Window public: // 修改窗口大小 static void setSize( - int nWidth, /* 窗口宽度 */ - int nHeight /* 窗口高度 */ + int width, /* 窗口宽度 */ + int height /* 窗口高度 */ ); // 设置窗口标题 static void setTitle( - String sTitle /* 窗口标题 */ + const String& title /* 窗口标题 */ ); // 设置窗口图标 static void setIcon( - int pIconID + int iconID ); // 获取窗口标题 @@ -92,7 +92,7 @@ public: // 是否允许响应输入法 static void setTypewritingEnable( - bool bEnable + bool enable ); private: diff --git a/core/e2dcollider.h b/core/e2dcollider.h index 868c1202..a98871fc 100644 --- a/core/e2dcollider.h +++ b/core/e2dcollider.h @@ -33,7 +33,7 @@ public: // 启用或关闭该碰撞体 virtual void setEnable( - bool bEnable + bool enable ); // 设置碰撞体的可见性 @@ -48,7 +48,7 @@ public: // 设置大小跟随 void setAutoResize( - bool bEnable + bool enable ); // 获取 ID2D1Geometry 对象 diff --git a/core/e2dcommon.h b/core/e2dcommon.h index afd38134..8940e0c9 100644 --- a/core/e2dcommon.h +++ b/core/e2dcommon.h @@ -497,7 +497,7 @@ struct TextStyle TextStyle(); TextStyle( - String fontFamily, + const String& fontFamily, double fontSize = 22, Color color = Color::WHITE, UINT32 fontWeight = FontWeight::NORMAL, @@ -610,53 +610,53 @@ public: // 加载图片文件 Image( - String strFilePath /* 图片文件路径 */ + const String& filePath /* 图片文件路径 */ ); // 加载图片资源 Image( - int resNameId, /* 图片资源名称 */ - String resType /* 图片资源类型 */ + int resNameId, /* 图片资源名称 */ + const String& resType /* 图片资源类型 */ ); // 加载图片文件并裁剪 Image( - String strFilePath, /* 图片文件路径 */ - double nCropX, /* 裁剪位置 X 坐标 */ - double nCropY, /* 裁剪位置 Y 坐标 */ - double nCropWidth, /* 裁剪宽度 */ - double nCropHeight /* 裁剪高度 */ + const String& filePath, /* 图片文件路径 */ + double cropX, /* 裁剪位置 X 坐标 */ + double cropY, /* 裁剪位置 Y 坐标 */ + double cropWidth, /* 裁剪宽度 */ + double cropHeight /* 裁剪高度 */ ); // 加载图片资源并裁剪 Image( - int resNameId, /* 图片资源名称 */ - String resType, /* 图片资源类型 */ - double nCropX, /* 裁剪位置 X 坐标 */ - double nCropY, /* 裁剪位置 Y 坐标 */ - double nCropWidth, /* 裁剪宽度 */ - double nCropHeight /* 裁剪高度 */ + int resNameId, /* 图片资源名称 */ + const String& resType, /* 图片资源类型 */ + double cropX, /* 裁剪位置 X 坐标 */ + double cropY, /* 裁剪位置 Y 坐标 */ + double cropWidth, /* 裁剪宽度 */ + double cropHeight /* 裁剪高度 */ ); virtual ~Image(); // 加载图片文件 bool open( - String strFilePath + const String& filePath ); // 加载图片资源 bool open( - int resNameId, /* 图片资源名称 */ - String resType /* 图片资源类型 */ + int resNameId, /* 图片资源名称 */ + const String& resType /* 图片资源类型 */ ); // 将图片裁剪为矩形 void crop( - double nCropX, /* 裁剪位置 X 坐标 */ - double nCropY, /* 裁剪位置 Y 坐标 */ - double nCropWidth, /* 裁剪宽度 */ - double nCropHeight /* 裁剪高度 */ + double cropX, /* 裁剪位置 X 坐标 */ + double cropY, /* 裁剪位置 Y 坐标 */ + double cropWidth, /* 裁剪宽度 */ + double cropHeight /* 裁剪高度 */ ); // 获取宽度 @@ -691,13 +691,13 @@ public: // 预加载图片文件 static bool preload( - String strFileName /* 图片文件路径 */ + const String& filePath /* 图片文件路径 */ ); // 预加载图片资源 static bool preload( - int resNameId, /* 图片资源名称 */ - String resType /* 图片资源类型 */ + int resNameId, /* 图片资源名称 */ + const String& resType /* 图片资源类型 */ ); // 清空缓存 @@ -772,12 +772,12 @@ public: // 获取所有名称相同的子节点 std::vector get( - String name + const String& name ) const; // 获取名称相同的子节点 Node* getOne( - String name + const String& name ) const; // 获取所有子节点 diff --git a/core/e2dmanager.h b/core/e2dmanager.h index dc8df647..8904a9c9 100644 --- a/core/e2dmanager.h +++ b/core/e2dmanager.h @@ -95,17 +95,17 @@ class ActionManager public: // 继续名称相同的所有动作 static void resume( - String strActionName + const String& strActionName ); // 暂停名称相同的所有动作 static void pause( - String strActionName + const String& strActionName ); // 停止名称相同的所有动作 static void stop( - String strActionName + const String& strActionName ); // 继续所有动作 @@ -119,7 +119,7 @@ public: // 获取所有名称相同的动作 static std::vector get( - String strActionName + const String& strActionName ); // 获取所有动作 @@ -182,24 +182,24 @@ class InputManager public: // 添加输入监听 static void add( - Function func, /* 监听到用户输入时的执行函数 */ - String name = L"", /* 监听器名称 */ - bool paused = false /* 是否暂停 */ + Function func, /* 监听到用户输入时的执行函数 */ + const String& name = L"", /* 监听器名称 */ + bool paused = false /* 是否暂停 */ ); // 暂停输入监听 static void pause( - String name + const String& name ); // 暂停输入监听 static void resume( - String name + const String& name ); // 停止输入监听 static void stop( - String name + const String& name ); // 暂停所有监听器 @@ -230,29 +230,29 @@ class ColliderManager public: // 开启或关闭碰撞监听功能(默认关闭) static void setEnable( - bool bEnable + bool enable ); // 添加碰撞监听 static void add( - Function func, /* 监听到碰撞时的执行函数 */ - String name = L"", /* 监听器名称 */ - bool paused = false /* 是否暂停 */ + Function func, /* 监听到碰撞时的执行函数 */ + const String& name = L"", /* 监听器名称 */ + bool paused = false /* 是否暂停 */ ); // 暂停碰撞监听 static void pause( - String name + const String& name ); // 暂停碰撞监听 static void resume( - String name + const String& name ); // 停止碰撞监听 static void stop( - String name + const String& name ); // 暂停所有监听器 @@ -270,14 +270,16 @@ public: // 获取碰撞发生时的被动体 static Node * getPassiveNode(); - // 判断碰撞是否由该节点引发(如果是,返回与其相撞的节点指针,否则返回空) + // 判断碰撞是否由该节点引发 + // 如果是,返回与其相撞的节点指针,否则返回空 static Node * isCausedBy( Node * pNode ); - // 判断发生碰撞的节点名称是否相同(若相同返回其指针,否则返回空) + // 判断发生碰撞的节点名称是否相同 + // 若相同,返回其指针,否则返回空 static Node * isCausedBy( - String name + const String& name ); private: diff --git a/core/e2dnode.h b/core/e2dnode.h index 7a9de2ba..4f3a8379 100644 --- a/core/e2dnode.h +++ b/core/e2dnode.h @@ -130,12 +130,12 @@ public: // 获取所有名称相同的子节点 virtual std::vector getChildren( - String name + const String& name ) const; // 获取名称相同的子节点 virtual Node* getChild( - String name + const String& name ) const; // 获取所有子节点 @@ -151,7 +151,7 @@ public: // 移除所有名称相同的子节点 virtual void removeChildren( - String childName + const String& childName ); // 从父节点移除 @@ -172,7 +172,7 @@ public: // 设置节点名称 virtual void setName( - String name + const String& name ); // 设置节点横坐标 @@ -336,7 +336,7 @@ public: // 添加可碰撞节点的名称 virtual void addColliableName( - String collliderName + const String& collliderName ); #ifdef HIGHER_THAN_VS2012 @@ -348,7 +348,7 @@ public: // 移除可碰撞节点的名称 virtual void removeColliableName( - String collliderName + const String& collliderName ); // 添加子节点 @@ -372,27 +372,27 @@ public: // 继续动画 virtual void resumeAction( - String strActionName + const String& strActionName ); // 暂停动画 virtual void pauseAction( - String strActionName + const String& strActionName ); // 停止动画 virtual void stopAction( - String strActionName + const String& strActionName ); // 获取名称相同的动画 virtual ActionBase * getAction( - String strActionName + const String& strActionName ); // 获取所有名称相同的动画 virtual std::vector getActions( - String strActionName + const String& strActionName ); // 继续所有暂停动画 @@ -412,7 +412,7 @@ public: // 设置节点是否包含默认碰撞体(默认打开) static void setDefaultColliderEnable( - bool bEnable + bool enable ); // 销毁对象 @@ -494,18 +494,18 @@ public: // 加载图片文件 Sprite( - String strFilePath /* 图片文件路径 */ + const String& filePath /* 图片文件路径 */ ); // 加载图片资源 Sprite( - int resNameId, /* 图片资源名称 */ - String resType /* 图片资源类型 */ + int resNameId, /* 图片资源名称 */ + const String& resType /* 图片资源类型 */ ); // 加载图片文件 Sprite( - String strFilePath, /* 图片文件路径 */ + const String& filePath, /* 图片文件路径 */ double x, double y, double width, @@ -514,8 +514,8 @@ public: // 加载图片资源 Sprite( - int resNameId, /* 图片资源名称 */ - String resType, /* 图片资源类型 */ + int resNameId, /* 图片资源名称 */ + const String& resType, /* 图片资源类型 */ double x, double y, double width, @@ -526,13 +526,13 @@ public: // 加载图片文件 bool open( - String strFilePath + const String& filePath ); // 加载图片资源 bool open( - int resNameId, /* 图片资源名称 */ - String resType /* 图片资源类型 */ + int resNameId, /* 图片资源名称 */ + const String& resType /* 图片资源类型 */ ); // 加载图片 @@ -569,21 +569,21 @@ public: Text(); Text( - String text /* 文字内容 */ + const String& text /* 文字内容 */ ); Text( - TextStyle textStyle /* 文字样式 */ + TextStyle textStyle /* 文字样式 */ ); Text( - String text, /* 文字内容 */ - TextStyle textStyle /* 文字样式 */ + const String& text, /* 文字内容 */ + TextStyle textStyle /* 文字样式 */ ); Text( - String text, /* 文字内容*/ - String fontFamily, /* 字体 */ + const String& text, /* 文字内容*/ + const String& fontFamily, /* 字体 */ double fontSize = 22, /* 字号 */ UINT32 color = Color::WHITE, /* 颜色 */ UINT32 fontWeight = FontWeight::NORMAL, /* 粗细值 */ @@ -645,7 +645,7 @@ public: // 设置文本 void setText( - String text + const String& text ); // 设置文本样式 @@ -655,7 +655,7 @@ public: // 设置字体 void setFontFamily( - String fontFamily + const String& fontFamily ); // 设置字号(默认值为 22) @@ -791,7 +791,7 @@ public: // 设置按钮启用或禁用 void setEnable( - bool bEnable + bool enable ); // 设置一般情况下显示的按钮 diff --git a/core/e2dtool.h b/core/e2dtool.h index a476da49..b41d86ba 100644 --- a/core/e2dtool.h +++ b/core/e2dtool.h @@ -60,70 +60,70 @@ class Music : public: // 预加载音乐资源 static bool preload( - String strFilePath /* 音乐文件路径 */ + const String& filePath /* 音乐文件路径 */ ); // 预加载音乐资源 static bool preload( - int resNameId, /* 音乐资源名称 */ - String resType /* 音乐资源类型 */ + int resNameId, /* 音乐资源名称 */ + const String& resType /* 音乐资源类型 */ ); // 播放音乐 static bool play( - String strFilePath, /* 音乐文件路径 */ - int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */ + const String& filePath, /* 音乐文件路径 */ + int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */ ); // 播放音乐 static bool play( - int resNameId, /* 音乐资源名称 */ - String resType, /* 音乐资源类型 */ - int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */ + int resNameId, /* 音乐资源名称 */ + const String& resType, /* 音乐资源类型 */ + int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */ ); // 暂停音乐 static void pause( - String strFilePath /* 音乐文件路径 */ + const String& filePath /* 音乐文件路径 */ ); // 暂停音乐 static void pause( - int resNameId, /* 音乐资源名称 */ - String resType /* 音乐资源类型 */ + int resNameId, /* 音乐资源名称 */ + const String& resType /* 音乐资源类型 */ ); // 继续播放音乐 static void resume( - String strFilePath /* 音乐文件路径 */ + const String& filePath /* 音乐文件路径 */ ); // 继续播放音乐 static void resume( - int resNameId, /* 音乐资源名称 */ - String resType /* 音乐资源类型 */ + int resNameId, /* 音乐资源名称 */ + const String& resType /* 音乐资源类型 */ ); // 停止音乐 static void stop( - String strFilePath /* 音乐文件路径 */ + const String& filePath /* 音乐文件路径 */ ); // 停止音乐 static void stop( - int resNameId, /* 音乐资源名称 */ - String resType /* 音乐资源类型 */ + int resNameId, /* 音乐资源名称 */ + const String& resType /* 音乐资源类型 */ ); // 获取音乐播放状态 static bool isPlaying( - String strFilePath /* 音乐文件路径 */ + const String& filePath /* 音乐文件路径 */ ); // 获取音乐播放状态 static bool isPlaying( - int resNameId, /* 音乐资源名称 */ - String resType /* 音乐资源类型 */ + int resNameId, /* 音乐资源名称 */ + const String& resType /* 音乐资源类型 */ ); // 获取音量 @@ -131,7 +131,7 @@ public: // 设置音量 static void setVolume( - double fVolume /* 音量范围为 -224 ~ 224,其中 0 是静音,1 是正常音量 */ + double fVolume /* 音量范围为 -224 ~ 224,0 是静音,1 是正常音量 */ ); // 暂停所有音乐 @@ -164,38 +164,38 @@ class Timer public: // 启动定时器 static void start( - Function func, /* 执行函数 */ - String name /* 定时器名称 */ + Function func, /* 执行函数 */ + const String& name /* 定时器名称 */ ); // 启动定时器 static void start( - Function func, /* 执行函数 */ - double delay = 0, /* 时间间隔(秒) */ - int times = -1, /* 执行次数(设 -1 为永久执行) */ - bool paused = false, /* 是否暂停 */ - String name = L"" /* 定时器名称 */ + Function func, /* 执行函数 */ + double delay = 0, /* 时间间隔(秒) */ + int times = -1, /* 执行次数(设 -1 为永久执行) */ + bool paused = false, /* 是否暂停 */ + const String& name = L"" /* 定时器名称 */ ); // 启动仅执行一次的定时器 static void startOnce( - Function func, /* 执行的函数 */ - double timeOut /* 等待的时长(秒) */ + Function func, /* 执行的函数 */ + double timeOut /* 等待的时长(秒) */ ); // 暂停具有相同名称的定时器 static void pause( - String name + const String& name ); // 继续具有相同名称的定时器 static void resume( - String name + const String& name ); // 停止具有相同名称的定时器 static void stop( - String name + const String& name ); // 暂停所有定时器 @@ -225,67 +225,67 @@ class Data public: // 保存 int 类型的值 static void saveInt( - String key, /* 键值 */ - int value, /* 数据 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + int value, /* 数据 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 保存 double 类型的值 static void saveDouble( - String key, /* 键值 */ - double value, /* 数据 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + double value, /* 数据 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 保存 bool 类型的值 static void saveBool( - String key, /* 键值 */ - bool value, /* 数据 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + bool value, /* 数据 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 保存 字符串 类型的值 static void saveString( - String key, /* 键值 */ - String value, /* 数据 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + const String& value, /* 数据 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 获取 int 类型的值 // (若不存在则返回 defaultValue 参数的值) static int getInt( - String key, /* 键值 */ - int defaultValue, /* 默认值 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + int defaultValue, /* 默认值 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 获取 double 类型的值 // (若不存在则返回 defaultValue 参数的值) static double getDouble( - String key, /* 键值 */ - double defaultValue, /* 默认值 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + double defaultValue, /* 默认值 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 获取 bool 类型的值 // (若不存在则返回 defaultValue 参数的值) static bool getBool( - String key, /* 键值 */ - bool defaultValue, /* 默认值 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + bool defaultValue, /* 默认值 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 获取 字符串 类型的值 // (若不存在则返回 defaultValue 参数的值) static String getString( - String key, /* 键值 */ - String defaultValue, /* 默认值 */ - String field = L"Defalut" /* 字段名称 */ + const String& key, /* 键值 */ + const String& defaultValue, /* 默认值 */ + const String& field = L"Defalut" /* 字段名称 */ ); // 修改数据文件的名称 static void setDataFileName( - String strFileName /* 文件名称 */ + const String& filePath /* 文件名称 */ ); // 获取数据文件的完整路径 @@ -307,18 +307,18 @@ public: // 获取文件扩展名 static String getFileExtension( - String filePath + const String& filePath ); // 打开保存文件对话框 static String getSaveFilePath( - const String title = L"保存到", /* 对话框标题 */ - const String defExt = L"" /* 默认扩展名 */ + const String& title = L"保存到", /* 对话框标题 */ + const String& defExt = L"" /* 默认扩展名 */ ); // 创建文件夹 static bool createFolder( - String strDirPath /* 文件夹路径 */ + const String& dirPath /* 文件夹路径 */ ); private: