重载了EString加号运算符;修复了场景动画结束后,其他动画跳帧的bug

This commit is contained in:
Nomango 2017-12-12 12:18:28 +08:00
parent 4bc613929c
commit f619414ed4
5 changed files with 49 additions and 9 deletions

View File

@ -11,13 +11,12 @@ int WINAPI WinMain(
if (!EApp::init(L"Demo", 250, 150)) if (!EApp::init(L"Demo", 250, 150))
return -1; return -1;
EString str = L"1245"; wchar_t str[] = L"1245";
EString str2 = L"1243"; EString str2 = L"1243";
bool b = str > str2; EString str3;
bool b2 = str >= str2; str + str2;
bool b3 = str < str2; str3 = str + str2;
bool b4 = str <= str2;
auto scene = new EScene(); auto scene = new EScene();
EApp::enterScene(scene); EApp::enterScene(scene);

View File

@ -341,6 +341,8 @@ void e2d::EApp::_update()
m_pTransition = nullptr; m_pTransition = nullptr;
// 进入下一场景 // 进入下一场景
_enterNextScene(); _enterNextScene();
// 刷新计时器
_updateTime();
} }
return; return;
} }

View File

@ -9,6 +9,14 @@ EString::EString()
_string = nullptr; _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) EString::EString(const wchar_t *str)
{ {
if (str) if (str)
@ -293,6 +301,26 @@ unsigned int e2d::EString::hash() const
return (hash); 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) std::wistream & e2d::operator>>(std::wistream &cin, EString &str)
{ {
const int limit_string_size = 4096; const int limit_string_size = 4096;

View File

@ -134,6 +134,7 @@ class EString
{ {
public: public:
EString(); EString();
EString(const wchar_t);
EString(const wchar_t *); EString(const wchar_t *);
EString(const EString &); EString(const EString &);
EString(const std::wstring &); EString(const std::wstring &);
@ -187,11 +188,21 @@ public:
bool operator > (EString const&) const; bool operator > (EString const&) const;
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 const wchar_t*() const { return _string; }
operator bool() const { return _size != 0; } 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<typename T>
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; } bool isEmpty() const { return _size == 0; }

View File

@ -159,11 +159,11 @@ public:
/** /**
* true * true
* *
*/ */
static EString getSaveFilePath( static EString getSaveFilePath(
const EString & title = L"保存到", const EString & title = L"保存到",
const EString & defExt = NULL const EString & defExt = L""
); );
}; };