diff --git a/Demo/main.cpp b/Demo/main.cpp index 6ff350d7..8ffc99f0 100644 --- a/Demo/main.cpp +++ b/Demo/main.cpp @@ -11,13 +11,12 @@ int WINAPI WinMain( if (!EApp::init(L"Demo", 250, 150)) return -1; - EString str = L"1245"; + wchar_t str[] = L"1245"; EString str2 = L"1243"; - bool b = str > str2; - bool b2 = str >= str2; - bool b3 = str < str2; - bool b4 = str <= str2; + EString str3; + str + str2; + str3 = str + str2; auto scene = new EScene(); EApp::enterScene(scene); diff --git a/Easy2D/Base/EApp.cpp b/Easy2D/Base/EApp.cpp index 3c64439b..1647a675 100644 --- a/Easy2D/Base/EApp.cpp +++ b/Easy2D/Base/EApp.cpp @@ -341,6 +341,8 @@ void e2d::EApp::_update() m_pTransition = nullptr; // 进入下一场景 _enterNextScene(); + // 刷新计时器 + _updateTime(); } return; } diff --git a/Easy2D/Common/EString.cpp b/Easy2D/Common/EString.cpp index dc56ba42..ea29e761 100644 --- a/Easy2D/Common/EString.cpp +++ b/Easy2D/Common/EString.cpp @@ -9,6 +9,14 @@ EString::EString() _string = nullptr; } +e2d::EString::EString(const wchar_t ch) +{ + _size = 1; + _string = new wchar_t[2]; + _string[0] = ch; + _string[1] = 0; +} + EString::EString(const wchar_t *str) { if (str) @@ -293,6 +301,26 @@ unsigned int e2d::EString::hash() const return (hash); } +EString e2d::operator+(const wchar_t ch, const EString &str) +{ + return std::move((EString(ch) + str)); +} + +EString e2d::operator+(const wchar_t *str1, const EString &str2) +{ + return std::move((EString(str1) + str2)); +} + +EString e2d::operator+(const EString &str1, const EString &str2) +{ + return std::move((EString(str1) + str2)); +} + +EString e2d::operator+(const std::wstring &str1, const EString &str2) +{ + return std::move((EString(str1) + str2)); +} + std::wistream & e2d::operator>>(std::wistream &cin, EString &str) { const int limit_string_size = 4096; diff --git a/Easy2D/ecommon.h b/Easy2D/ecommon.h index a5d9a5c9..4c3212df 100644 --- a/Easy2D/ecommon.h +++ b/Easy2D/ecommon.h @@ -134,6 +134,7 @@ class EString { public: EString(); + EString(const wchar_t); EString(const wchar_t *); EString(const EString &); EString(const std::wstring &); @@ -187,11 +188,21 @@ public: bool operator > (EString const&) const; bool operator >= (EString const&) const; - friend std::wistream &operator>>(std::wistream &, EString &); - operator const wchar_t*() const { return _string; } operator bool() const { return _size != 0; } + friend EString operator+(const wchar_t, const EString &); + friend EString operator+(const wchar_t*, const EString &); + friend EString operator+(const EString &, const EString &); + friend EString operator+(const std::wstring &, const EString &); + template + friend EString operator+(const T &value, const EString &str) + { + return std::move((EString::parse(value) + str2)); + } + + friend std::wistream &operator>>(std::wistream &, EString &); + // 判断字符串是否为空 bool isEmpty() const { return _size == 0; } diff --git a/Easy2D/etools.h b/Easy2D/etools.h index da2bf206..ea82c1e6 100644 --- a/Easy2D/etools.h +++ b/Easy2D/etools.h @@ -159,11 +159,11 @@ public: /** * 打开保存文件对话框,得到有效保存路径返回 true - * 参数:返回文件路径的字符串,窗口标题,设置扩展名过滤,设置默认扩展名 + * 参数:窗口标题,默认扩展名 */ static EString getSaveFilePath( const EString & title = L"保存到", - const EString & defExt = NULL + const EString & defExt = L"" ); };