From 3c04834744cd721342f666fe3a42b0efa90bfa3b Mon Sep 17 00:00:00 2001 From: "guzhu@fairygui.com" Date: Fri, 7 Sep 2018 22:12:11 +0800 Subject: [PATCH] Add TransitionActionType.Text and TransitionActionType.Icon --- libfairygui/Classes/FieldTypes.h | 2 ++ libfairygui/Classes/Transition.cpp | 38 ++++++++++++++++++++- libfairygui/Classes/tween/TweenPropType.cpp | 12 +++---- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/libfairygui/Classes/FieldTypes.h b/libfairygui/Classes/FieldTypes.h index 16777bd..a37a0d8 100644 --- a/libfairygui/Classes/FieldTypes.h +++ b/libfairygui/Classes/FieldTypes.h @@ -156,6 +156,8 @@ enum class TransitionActionType Shake, ColorFilter, Skew, + Text, + Icon, Unknown }; diff --git a/libfairygui/Classes/Transition.cpp b/libfairygui/Classes/Transition.cpp index d07838b..295200c 100644 --- a/libfairygui/Classes/Transition.cpp +++ b/libfairygui/Classes/Transition.cpp @@ -51,6 +51,12 @@ class TValue_Shake cocos2d::Vec2 offset; }; +class TValue_Text +{ +public: + std::string text; +}; + class TValue { public: @@ -199,6 +205,11 @@ TransitionItem::TransitionItem(TransitionActionType aType) : value = new TValue_Visible(); break; + case TransitionActionType::Text: + case TransitionActionType::Icon: + value = new TValue_Text(); + break; + default: value = nullptr; break; @@ -562,6 +573,11 @@ void Transition::setValue(const std::string & label, const ValueVector& values) tvalue->f4 = values[3].asFloat(); break; } + + case TransitionActionType::Text: + case TransitionActionType::Icon: + ((TValue_Text*)value)->text = values[0].asString(); + break; } } } @@ -988,6 +1004,13 @@ void Transition::onTweenStart(GTweener* tweener) if (!startValue->b2) startValue->f2 = item->target->getY(); } + else + { + if (!startValue->b1) + startValue->f1 = item->target->getX() - _ownerBaseX; + if (!startValue->b2) + startValue->f2 = item->target->getY() - _ownerBaseY; + } } else { @@ -1230,9 +1253,16 @@ void Transition::applyValue(TransitionItem* item) break; } - case TransitionActionType::ColorFilter: break; + + case TransitionActionType::Text: + item->target->setText(((TValue_Text*)item->value)->text); + break; + + case TransitionActionType::Icon: + item->target->setIcon(((TValue_Text*)item->value)->text); + break; } item->target->_gearLocked = false; @@ -1374,6 +1404,12 @@ void Transition::decodeValue(TransitionItem* item, ByteBuffer * buffer, void* va tvalue->f4 = buffer->ReadFloat(); break; } + + case TransitionActionType::Text: + case TransitionActionType::Icon: + ((TValue_Text*)value)->text = buffer->ReadS(); + break; + default: break; } diff --git a/libfairygui/Classes/tween/TweenPropType.cpp b/libfairygui/Classes/tween/TweenPropType.cpp index 2d3324f..dabbc21 100644 --- a/libfairygui/Classes/tween/TweenPropType.cpp +++ b/libfairygui/Classes/tween/TweenPropType.cpp @@ -19,7 +19,7 @@ void TweenPropTypeUtils::setProps(GObject * target, TweenPropType propType, cons break; case TweenPropType::Y: - g->setY(value.y); + g->setY(value.x); break; case TweenPropType::Position: @@ -31,7 +31,7 @@ void TweenPropTypeUtils::setProps(GObject * target, TweenPropType propType, cons break; case TweenPropType::Height: - g->setHeight(value.y); + g->setHeight(value.x); break; case TweenPropType::Size: @@ -43,7 +43,7 @@ void TweenPropTypeUtils::setProps(GObject * target, TweenPropType propType, cons break; case TweenPropType::ScaleY: - g->setScaleY(value.y); + g->setScaleY(value.x); break; case TweenPropType::Scale: @@ -77,7 +77,7 @@ void TweenPropTypeUtils::setProps(cocos2d::Node * target, TweenPropType propType break; case TweenPropType::Y: - g->setY(value.y); + g->setY(value.x); break; case TweenPropType::Position: @@ -89,7 +89,7 @@ void TweenPropTypeUtils::setProps(cocos2d::Node * target, TweenPropType propType break; case TweenPropType::Height: - g->setHeight(value.y); + g->setHeight(value.x); break; case TweenPropType::Size: @@ -101,7 +101,7 @@ void TweenPropTypeUtils::setProps(cocos2d::Node * target, TweenPropType propType break; case TweenPropType::ScaleY: - g->setScaleY(value.y); + g->setScaleY(value.x); break; case TweenPropType::Scale: