mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-08-27 11:11:26 -04:00
aa192d36ca
git-svn-id: svn://localhost@246 8062f311-0dae-4547-b526-b8ab9ac864a5
139 lines
5.4 KiB
C++
139 lines
5.4 KiB
C++
/**
|
|
|
|
Game Develop - Video Object Extension
|
|
Copyright (c) 2010 Florian Rival (Florian.Rival@gmail.com)
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
warranty. In no event will the authors be held liable for any damages
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely, subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
claim that you wrote the original software. If you use this software
|
|
in a product, an acknowledgment in the product documentation would be
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
distribution.
|
|
|
|
*/
|
|
|
|
#include "VideoObject.h"
|
|
|
|
#include "GDL/Instruction.h"
|
|
#include "GDL/ObjectsConcerned.h"
|
|
#include "GDL/RuntimeScene.h"
|
|
#include "GDL/CommonTools.h"
|
|
|
|
|
|
/**
|
|
* Modify opacity
|
|
*/
|
|
bool VideoObject::ActOpacity( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Set )
|
|
SetOpacity( action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this()));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Add )
|
|
SetOpacity( GetOpacity() + action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this()));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Substract )
|
|
SetOpacity( GetOpacity() - action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this()));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Multiply )
|
|
SetOpacity( GetOpacity() * action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this()));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Divide )
|
|
SetOpacity( GetOpacity() / action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this()));
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Change the color of the texte
|
|
*/
|
|
bool VideoObject::ActChangeColor( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
vector < string > colors = SpliterStringToVector <string> (action.GetParameter(1).GetAsTextExpressionResult(scene, objectsConcerned, shared_from_this()), ';');
|
|
|
|
if ( colors.size() < 3 ) return false; //La couleur est incorrecte
|
|
|
|
SetColor(ToInt(colors[0]),ToInt(colors[1]),ToInt(colors[2]));
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
/**
|
|
* Modify angle
|
|
*/
|
|
bool VideoObject::ActAngle( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Set )
|
|
SetAngle( static_cast<int>(action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this())));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Add )
|
|
SetAngle( GetAngle() + static_cast<int>(action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this())));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Substract )
|
|
SetAngle( GetAngle() - static_cast<int>(action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this())));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Multiply )
|
|
SetAngle( GetAngle() * static_cast<int>(action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this())));
|
|
else if ( action.GetParameter( 2 ).GetAsModOperator() == GDExpression::Divide )
|
|
SetAngle( GetAngle() / static_cast<int>(action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this())));
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Load a new video
|
|
*/
|
|
bool VideoObject::ActLoadVideo( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
SetVideoFile(action.GetParameter( 1 ).GetAsTextExpressionResult(scene, objectsConcerned, shared_from_this()));
|
|
ReloadVideo();
|
|
video.SetPause(false);
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Load a new video
|
|
*/
|
|
bool VideoObject::ActSetPause( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
video.SetPause(action.GetParameter( 1 ).GetAsBool());
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Set looping
|
|
*/
|
|
bool VideoObject::ActSetLooping( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
SetLooping(action.GetParameter( 1 ).GetAsBool());
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Restart video
|
|
*/
|
|
bool VideoObject::ActRestart( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
video.Restart();
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Set looping
|
|
*/
|
|
bool VideoObject::ActSeek( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, const Instruction & action )
|
|
{
|
|
video.Seek(action.GetParameter( 1 ).GetAsMathExpressionResult(scene, objectsConcerned, shared_from_this()));
|
|
|
|
return true;
|
|
}
|