mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
(Mostly) updated verve implementation.
This commit is contained in:
parent
775ca57047
commit
87ee749801
538 changed files with 68727 additions and 49 deletions
111
Engine/source/Verve/Extension/GUI/VFadeEvent.cpp
Normal file
111
Engine/source/Verve/Extension/GUI/VFadeEvent.cpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "Verve/Extension/GUI/VFadeEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VFadeEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VFadeEvent::VFadeEvent( void )
|
||||
{
|
||||
setLabel( "FadeEvent" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Callback Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Start the fade sequence if a valid fade control can be found.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VFadeEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl;
|
||||
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
// Start Fade.
|
||||
fadeControl->start( getFadeType(), mDuration );
|
||||
|
||||
// Set Elapsed Time.
|
||||
fadeControl->mElapsedTime = mAbs( pTime - getStartTime() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeEvent::onComplete( pTime, pDelta );
|
||||
//
|
||||
// Tidy up the fade control once the event has finished.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VFadeEvent::onComplete( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl;
|
||||
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Elapsed Time.
|
||||
fadeControl->mElapsedTime = mDuration;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Property Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeEvent::getFadeType();
|
||||
//
|
||||
// Returns the type of fade (in or out) that this event will use. Zero and Even
|
||||
// indices will Fade Out, while Odd numbers will Fade In.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VFadeControl::eFadeType VFadeEvent::getFadeType( void )
|
||||
{
|
||||
if ( !isControllerPlayingForward() )
|
||||
{
|
||||
return ( getIndex() % 2 == 0 ) ? VFadeControl::k_TypeOut : VFadeControl::k_TypeIn;
|
||||
}
|
||||
|
||||
return ( getIndex() % 2 == 0 ) ? VFadeControl::k_TypeIn : VFadeControl::k_TypeOut;
|
||||
}
|
||||
60
Engine/source/Verve/Extension/GUI/VFadeEvent.h
Normal file
60
Engine/source/Verve/Extension/GUI/VFadeEvent.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_VFADEEVENT_H_
|
||||
#define _VT_VFADEEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VFADECONTROL_H_
|
||||
#include "Verve/GUI/VFadeControl.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VFadeEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VFadeEvent( void );
|
||||
|
||||
// Callback Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VFadeEvent );
|
||||
|
||||
public:
|
||||
|
||||
VFadeControl::eFadeType getFadeType( void );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VFADEEVENT_H_
|
||||
139
Engine/source/Verve/Extension/GUI/VFadeTrack.cpp
Normal file
139
Engine/source/Verve/Extension/GUI/VFadeTrack.cpp
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "Verve/Extension/GUI/VFadeTrack.h"
|
||||
#include "Verve/Extension/GUI/VFadeEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VFadeTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VFadeTrack::VFadeTrack( void )
|
||||
{
|
||||
setLabel( "FadeTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeTrack::onControllerEvent( pEvent );
|
||||
//
|
||||
// When the controller's state changes, this method is called. If the
|
||||
// controller is paused, or stops playing, then the fade control will cease
|
||||
// playing. If the controller resumes play, the fade control will continue.
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VFadeTrack::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !Parent::onControllerEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fetch the next Event.
|
||||
VFadeEvent *event;
|
||||
if ( !getNextEvent( event ) )
|
||||
{
|
||||
// No Event.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl = dynamic_cast<VFadeControl*>( Sim::findObject( "VFadeControlGui" ) );
|
||||
if ( !fadeControl )
|
||||
{
|
||||
// No Control.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( pEvent )
|
||||
{
|
||||
case VController::k_EventPlay:
|
||||
{
|
||||
// Play?
|
||||
const S32 &time = getControllerTime();
|
||||
fadeControl->mActive = ( time > event->getTriggerTime()
|
||||
&& time < event->getFinishTime() ) ;
|
||||
|
||||
} break;
|
||||
|
||||
case VController::k_EventPause :
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Pause.
|
||||
fadeControl->mActive = false;
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VFadeTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Reset the fade state of the fade control.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VFadeTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
// Fetch GUI Control.
|
||||
VFadeControl *fadeControl;
|
||||
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
VFadeEvent *event;
|
||||
if ( !getNextEvent( event ) )
|
||||
{
|
||||
// No Events.
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply Settings.
|
||||
fadeControl->mActive = false;
|
||||
fadeControl->mFadeType = event->getFadeType();
|
||||
fadeControl->mDuration = event->getDuration();
|
||||
fadeControl->mElapsedTime = getMax( pTime - event->getTriggerTime(), 0 );
|
||||
}
|
||||
52
Engine/source/Verve/Extension/GUI/VFadeTrack.h
Normal file
52
Engine/source/Verve/Extension/GUI/VFadeTrack.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_VFADETRACK_H_
|
||||
#define _VT_VFADETRACK_H_
|
||||
|
||||
#ifndef _VT_VTRACK_H_
|
||||
#include "Verve/Core/VTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VFadeTrack : public VTrack
|
||||
{
|
||||
typedef VTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VFadeTrack( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VFadeTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VFADETRACK_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue