I'm added an new interpolator in the source code. It's named StringScrollInterpolator and of course it scrolles the text.
It can be used in the text label to show text too long or other.
The code is very simple :
In the end of CEGUIBasicInterpolators.h
Code: Select all
class CEGUIEXPORT StringScrollInterpolator : public Interpolator
{
public:
virtual ~StringScrollInterpolator(void) {};
virtual const String& getType() const;
virtual String interpolateAbsolute(const String& value1,
const String& value2,
float position);
virtual String interpolateRelative(const String& base,
const String& value1,
const String& value2,
float position);
virtual String interpolateRelativeMultiply(const String& base,
const String& value1,
const String& value2,
float position);
protected:
String combineStrings(const String& str1,
const String& str2,
float position);
};In the end of CEGUIBasicInterpolators.cpp
Code: Select all
/********************************************
* String scroll interpolator
********************************************/
const String& StringScrollInterpolator::getType() const
{
static String type = "StringScroll";
return type;
}
//----------------------------------------------------------------------------//
String StringScrollInterpolator::interpolateAbsolute(const String& value1,
const String& value2,
float position)
{
return combineStrings(value1, value2, position);
}
//----------------------------------------------------------------------------//
String StringScrollInterpolator::interpolateRelative(const String& base,
const String& value1,
const String& value2,
float position)
{
return base + combineStrings(value1, value2, position);
}
//----------------------------------------------------------------------------//
String StringScrollInterpolator::interpolateRelativeMultiply(const String& base,
const String& value1,
const String& value2,
float position)
{
// ????
return base;
}
//----------------------------------------------------------------------------//
String StringScrollInterpolator::combineStrings(const String& str1,
const String& str2,
float position)
{
String::size_type s1size = str1.size();
String::size_type s2size = str2.size();
String fullText = str1 + str2;
String::size_type maxsize = fullText.size();
String res("");
res.resize(maxsize);
String::size_type startIndex = maxsize * position;
String::size_type textIntex = 0;
for(String::size_type i = startIndex; i< maxsize; ++i)
{
res[textIntex] = fullText[i];
++textIntex;
}
for(String::size_type i = 0; i < startIndex; ++i){
res[textIntex] = fullText[i];
++textIntex;
}
return res;
}Finally, add this line in the function AnimationManager from CEGUIAnimationManager.cpp
Code: Select all
addBasicInterpolator(new StringScrollInterpolator());To test this animation, you can write this code :
Code: Select all
// TEST //////////////////////////////
CEGUI::Animation* anim = CEGUI::AnimationManager::getSingleton().createAnimation("Testing");
anim->setDuration(10.0f);
CEGUI::Affector* affector = anim->createAffector("Text", "StringScroll");
affector->createKeyFrame(0.0f, " Je suis en train de ");
affector->createKeyFrame(10.0f, "defiler devant vous !!"));
CEGUI::AnimationInstance* instance = CEGUI::AnimationManager::getSingleton().instantiateAnimation(anim);
instance->setTargetWindow(_px_contextualTextWindow);
instance->start();
//////////////////////////////////////Yes I'm French
Is it possible to add this sources in cegui source code ?
My name is Arnaud Moura.
Good luck.
