From ea4476f13458e292e0b20e06a122e7ee1bc94de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 7 Aug 2014 02:57:54 -0300 Subject: [PATCH] Sys::GetDateTimeStr now returns a different format for the date string. Minor clean up. --- include/eepp/ui/uicontrolanim.hpp | 36 +++++++++++++++---------------- include/eepp/ui/uidragable.hpp | 18 ++++++++-------- src/eepp/system/sys.cpp | 20 ++++------------- src/eepp/ui/uicontrolanim.cpp | 35 +++++++++++++++++++----------- src/eepp/ui/uidropdownlist.cpp | 5 +---- src/eepp/ui/uipopupmenu.cpp | 5 +---- src/eepp/ui/uitooltip.cpp | 5 +---- src/eepp/ui/uiwindow.cpp | 6 +----- 8 files changed, 58 insertions(+), 72 deletions(-) diff --git a/include/eepp/ui/uicontrolanim.hpp b/include/eepp/ui/uicontrolanim.hpp index 53471a587..cb0f1431f 100644 --- a/include/eepp/ui/uicontrolanim.hpp +++ b/include/eepp/ui/uicontrolanim.hpp @@ -17,11 +17,11 @@ class EE_API UIControlAnim : public UIDragable { virtual bool IsType( const Uint32& type ) const; - virtual void Update(); + virtual void Update(); - const Float& Angle() const; + const Float& Angle() const; - void Angle( const Float& angle ); + void Angle( const Float& angle ); const Vector2f& Scale() const; @@ -29,31 +29,31 @@ class EE_API UIControlAnim : public UIDragable { void Scale( const Float& scale ); - const Float& Alpha() const; + const Float& Alpha() const; - virtual void Alpha( const Float& alpha ); + virtual void Alpha( const Float& alpha ); virtual void AlphaChilds( const Float& alpha ); - bool Animating(); + bool Animating(); - void StartAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); + Interpolation * StartAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); - void StartScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); + Waypoints * StartScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); - void StartScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); + Waypoints * StartScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); - void StartMovement( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Waypoints::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); + Waypoints * StartMovement( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Waypoints::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); - void StartRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); + Interpolation * StartRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type = Ease::Linear, Interpolation::OnPathEndCallback PathEndCallback = Interpolation::OnPathEndCallback() ); - void CreateFadeIn( const Time& Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); + Interpolation * CreateFadeIn( const Time& Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); - void CreateFadeOut( const Time& Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); + Interpolation * CreateFadeOut( const Time& Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); - void CloseFadeOut( const Time& Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); + Interpolation * CloseFadeOut( const Time& Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); - void DisableFadeOut( const Time & Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); + Interpolation * DisableFadeOut( const Time & Time, const bool& AlphaChilds = true, const Ease::Interpolation& Type = Ease::Linear ); Interpolation * RotationInterpolation(); @@ -69,12 +69,12 @@ class EE_API UIControlAnim : public UIDragable { protected: friend class UIManager; - Float mAngle; + Float mAngle; Vector2f mScale; - Float mAlpha; + Float mAlpha; Interpolation * mAngleAnim; - Waypoints * mScaleAnim; + Waypoints * mScaleAnim; Interpolation * mAlphaAnim; Waypoints * mMoveAnim; diff --git a/include/eepp/ui/uidragable.hpp b/include/eepp/ui/uidragable.hpp index 6f9665f29..e02051319 100644 --- a/include/eepp/ui/uidragable.hpp +++ b/include/eepp/ui/uidragable.hpp @@ -13,19 +13,19 @@ class EE_API UIDragable : public UIControl { virtual bool IsType( const Uint32& type ) const; - bool Dragging() const; - void Dragging( const bool& dragging ); + bool Dragging() const; + void Dragging( const bool& dragging ); - const Vector2i& DragPoint() const; - void DragPoint( const Vector2i& Point ); + const Vector2i& DragPoint() const; + void DragPoint( const Vector2i& Point ); - virtual void Update(); + virtual void Update(); - bool DragEnable() const; - void DragEnable( const bool& enable ); + bool DragEnable() const; + void DragEnable( const bool& enable ); - void DragButton( const Uint32& Button ); - const Uint32& DragButton() const; + void DragButton( const Uint32& Button ); + const Uint32& DragButton() const; protected: virtual ~UIDragable(); diff --git a/src/eepp/system/sys.cpp b/src/eepp/system/sys.cpp index daeb1e209..8ec778fb7 100644 --- a/src/eepp/system/sys.cpp +++ b/src/eepp/system/sys.cpp @@ -483,29 +483,17 @@ double Sys::GetSystemTime() { } std::string Sys::GetDateTimeStr() { - std::string str; - time_t rawtime; time ( &rawtime ); -#ifdef EE_COMPILER_MSVC - char buf[256]; - struct tm timeinfo; - localtime_s ( &timeinfo, &rawtime ); - asctime_s( &buf[0], 256, &timeinfo ); - str = std::string( buf ); -#else + char buf[64]; + struct tm * timeinfo; timeinfo = localtime ( &rawtime ); - str = std::string( asctime (timeinfo) ); -#endif - if ( str[ str.length() - 1 ] == '\n' ) - { - str = str.substr( 0, str.length() - 1 ); - } + strftime(buf, sizeof(buf), "%Y-%m-%d %X", timeinfo); - return str; + return std::string( buf ); } #define EE_MAX_CFG_PATH_LEN 1024 diff --git a/src/eepp/ui/uicontrolanim.cpp b/src/eepp/ui/uicontrolanim.cpp index 0ab2c6344..7c0b031a4 100644 --- a/src/eepp/ui/uicontrolanim.cpp +++ b/src/eepp/ui/uicontrolanim.cpp @@ -183,7 +183,7 @@ bool UIControlAnim::Animating() { return ( NULL != mAlphaAnim && mAlphaAnim->Enabled() ) || ( NULL != mAngleAnim && mAngleAnim->Enabled() ) || ( NULL != mScaleAnim && mScaleAnim->Enabled() ) || ( NULL != mMoveAnim && mMoveAnim->Enabled() ); } -void UIControlAnim::StartAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { +Interpolation * UIControlAnim::StartAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { if ( NULL == mAlphaAnim ) mAlphaAnim = eeNew( Interpolation, () ); @@ -210,9 +210,11 @@ void UIControlAnim::StartAlphaAnim( const Float& From, const Float& To, const Ti CurChild = CurChild->NextGet(); } } + + return mAlphaAnim; } -void UIControlAnim::StartScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { +Waypoints * UIControlAnim::StartScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { if ( NULL == mScaleAnim ) mScaleAnim = eeNew( Waypoints, () ); @@ -224,13 +226,15 @@ void UIControlAnim::StartScaleAnim( const Vector2f& From, const Vector2f& To, co mScaleAnim->Type( Type ); Scale( From ); + + return mScaleAnim; } -void UIControlAnim::StartScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { - StartScaleAnim( Vector2f( From, From ), Vector2f( To, To ), TotalTime, Type, PathEndCallback ); +Waypoints * UIControlAnim::StartScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { + return StartScaleAnim( Vector2f( From, From ), Vector2f( To, To ), TotalTime, Type, PathEndCallback ); } -void UIControlAnim::StartMovement( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& Type, Waypoints::OnPathEndCallback PathEndCallback ) { +Waypoints * UIControlAnim::StartMovement( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& Type, Waypoints::OnPathEndCallback PathEndCallback ) { if ( NULL == mMoveAnim ) mMoveAnim = eeNew( Waypoints, () ); @@ -242,9 +246,11 @@ void UIControlAnim::StartMovement( const Vector2i& From, const Vector2i& To, con mMoveAnim->Type( Type ); Pos( From ); + + return mMoveAnim; } -void UIControlAnim::StartRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { +Interpolation * UIControlAnim::StartRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation::OnPathEndCallback PathEndCallback ) { if ( NULL == mAngleAnim ) mAngleAnim = eeNew( Interpolation, () ); @@ -256,27 +262,32 @@ void UIControlAnim::StartRotation( const Float& From, const Float& To, const Tim mAngleAnim->Type( Type ); Angle( From ); + + return mAngleAnim; } -void UIControlAnim::CreateFadeIn( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - StartAlphaAnim( mAlpha, 255.f, Time, AlphaChilds, Type ); +Interpolation * UIControlAnim::CreateFadeIn( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + return StartAlphaAnim( mAlpha, 255.f, Time, AlphaChilds, Type ); } -void UIControlAnim::CreateFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - StartAlphaAnim( 255.f, mAlpha, Time, AlphaChilds, Type ); +Interpolation * UIControlAnim::CreateFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + return StartAlphaAnim( 255.f, mAlpha, Time, AlphaChilds, Type ); } -void UIControlAnim::CloseFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { +Interpolation * UIControlAnim::CloseFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { StartAlphaAnim ( mAlpha, 0.f, Time, AlphaChilds, Type ); mControlFlags |= UI_CTRL_FLAG_CLOSE_FO; + return mAlphaAnim; } -void UIControlAnim::DisableFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { +Interpolation * UIControlAnim::DisableFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { Enabled( false ); StartAlphaAnim ( mAlpha, 0.f, Time, AlphaChilds, Type ); mControlFlags |= UI_CTRL_FLAG_DISABLE_FADE_OUT; + + return mAlphaAnim; } void UIControlAnim::BackgroundDraw() { diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 1d6f8db05..3c251b07c 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -184,10 +184,7 @@ void UIDropDownList::Show() { mListBox->Visible( true ); if ( UIThemeManager::instance()->DefaultEffectsEnabled() ) { - if ( 255.f == mListBox->Alpha() ) - mListBox->StartAlphaAnim( 0.f, 255.f, UIThemeManager::instance()->ControlsFadeInTime() ); - else - mListBox->CreateFadeIn( UIThemeManager::instance()->ControlsFadeInTime() ); + mListBox->StartAlphaAnim( 255.f == mListBox->Alpha() ? 0.f : mListBox->Alpha(), 255.f, UIThemeManager::instance()->ControlsFadeInTime() ); } } diff --git a/src/eepp/ui/uipopupmenu.cpp b/src/eepp/ui/uipopupmenu.cpp index 855628199..3c775c979 100644 --- a/src/eepp/ui/uipopupmenu.cpp +++ b/src/eepp/ui/uipopupmenu.cpp @@ -38,10 +38,7 @@ bool UIPopUpMenu::Show() { ToFront(); if ( UIThemeManager::instance()->DefaultEffectsEnabled() ) { - if ( 255.f == Alpha() ) - StartAlphaAnim( 0.f, 255.f, UIThemeManager::instance()->ControlsFadeInTime() ); - else - CreateFadeIn( UIThemeManager::instance()->ControlsFadeInTime() ); + StartAlphaAnim( 255.f == mAlpha ? 0.f : mAlpha, 255.f, UIThemeManager::instance()->ControlsFadeInTime() ); } SetFocus(); diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index f72d1a5ea..c0d0015bd 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -73,10 +73,7 @@ void UITooltip::Show() { Visible( true ); if ( UIThemeManager::instance()->DefaultEffectsEnabled() ) { - if ( 255.f == mAlpha ) - StartAlphaAnim( 0.f, 255.f, UIThemeManager::instance()->ControlsFadeInTime() ); - else - CreateFadeIn( UIThemeManager::instance()->ControlsFadeInTime() ); + StartAlphaAnim( 255.f == mAlpha ? 0.f : mAlpha, 255.f, UIThemeManager::instance()->ControlsFadeInTime() ); } } } diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index b0592a60e..671b2bb4a 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -715,11 +715,7 @@ bool UIWindow::Show() { SetFocus(); - if ( mBaseAlpha == Alpha() ) { - StartAlphaAnim( 0.f, mBaseAlpha, UIThemeManager::instance()->ControlsFadeInTime() ); - } else { - StartAlphaAnim( mAlpha, mBaseAlpha, UIThemeManager::instance()->ControlsFadeInTime() ); - } + StartAlphaAnim( mBaseAlpha == Alpha() ? 0.f : mAlpha, mBaseAlpha, UIThemeManager::instance()->ControlsFadeInTime() ); if ( IsModal() ) { CreateModalControl();