aboutsummaryrefslogtreecommitdiff
path: root/mp/src/vgui2/vgui_controls/AnimationController.cpp
diff options
context:
space:
mode:
authorJohn Schoenick <[email protected]>2015-09-09 18:35:41 -0700
committerJohn Schoenick <[email protected]>2015-09-09 18:35:41 -0700
commit0d8dceea4310fde5706b3ce1c70609d72a38efdf (patch)
treec831ef32c2c801a5c5a80401736b52c7b5a528ec /mp/src/vgui2/vgui_controls/AnimationController.cpp
parentUpdated the SDK with the latest code from the TF and HL2 branches. (diff)
downloadsource-sdk-2013-master.tar.xz
source-sdk-2013-master.zip
Updated the SDK with the latest code from the TF and HL2 branches.HEADmaster
Diffstat (limited to 'mp/src/vgui2/vgui_controls/AnimationController.cpp')
-rw-r--r--mp/src/vgui2/vgui_controls/AnimationController.cpp122
1 files changed, 121 insertions, 1 deletions
diff --git a/mp/src/vgui2/vgui_controls/AnimationController.cpp b/mp/src/vgui2/vgui_controls/AnimationController.cpp
index 6da33a38..b8780a89 100644
--- a/mp/src/vgui2/vgui_controls/AnimationController.cpp
+++ b/mp/src/vgui2/vgui_controls/AnimationController.cpp
@@ -68,6 +68,8 @@ AnimationController::AnimationController(Panel *parent) : BaseClass(parent, NULL
m_sWide = g_ScriptSymbols.AddString("wide");
m_sTall = g_ScriptSymbols.AddString("tall");
+ m_sModelPos = g_ScriptSymbols.AddString( "model_pos" );
+
m_flCurrentTime = 0.0f;
}
@@ -508,6 +510,34 @@ bool AnimationController::ParseScriptFile(char *pMem, int length)
pMem = ParseFile(pMem, token, NULL);
animCmd.cmdData.runEvent.timeDelay = (float)atof(token);
}
+ else if (!stricmp(token, "runeventchild"))
+ {
+ animCmd.commandType = CMD_RUNEVENTCHILD;
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.variable = g_ScriptSymbols.AddString(token);
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.event = g_ScriptSymbols.AddString(token);
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.timeDelay = (float)atof(token);
+ }
+ else if (!stricmp(token, "firecommand"))
+ {
+ animCmd.commandType = CMD_FIRECOMMAND;
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.timeDelay = (float)atof(token);
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.variable = g_ScriptSymbols.AddString(token);
+ }
+ else if (!stricmp(token, "setvisible"))
+ {
+ animCmd.commandType = CMD_SETVISIBLE;
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.variable = g_ScriptSymbols.AddString(token);
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.variable2 = atoi(token);
+ pMem = ParseFile(pMem, token, NULL);
+ animCmd.cmdData.runEvent.timeDelay = (float)atof(token);
+ }
else if (!stricmp(token, "stopevent"))
{
animCmd.commandType = CMD_STOPEVENT;
@@ -659,9 +689,11 @@ void AnimationController::UpdatePostedMessages(bool bRunToCompletion)
case CMD_RUNEVENT:
{
RanEvent_t curEvent;
+ curEvent.pParent = NULL;
curEvent.event = msg.event;
- curEvent.pParent = msg.parent.Get();
+ curEvent.pParent = msg.parent.Get();
+
// run the event, but only if we haven't already run it this frame, for this parent
if (!eventsRanThisFrame.HasElement(curEvent))
{
@@ -670,6 +702,37 @@ void AnimationController::UpdatePostedMessages(bool bRunToCompletion)
}
}
break;
+ case CMD_RUNEVENTCHILD:
+ {
+ RanEvent_t curEvent;
+ curEvent.pParent = NULL;
+ curEvent.event = msg.event;
+
+ curEvent.pParent = msg.parent.Get()->FindChildByName( g_ScriptSymbols.String(msg.variable) );
+ msg.parent = curEvent.pParent;
+
+ // run the event, but only if we haven't already run it this frame, for this parent
+ if (!eventsRanThisFrame.HasElement(curEvent))
+ {
+ eventsRanThisFrame.AddToTail(curEvent);
+ RunCmd_RunEvent(msg);
+ }
+ }
+ break;
+ case CMD_FIRECOMMAND:
+ {
+ msg.parent->OnCommand( g_ScriptSymbols.String(msg.variable) );
+ }
+ break;
+ case CMD_SETVISIBLE:
+ {
+ Panel* pPanel = msg.parent.Get()->FindChildByName( g_ScriptSymbols.String(msg.variable) );
+ if ( pPanel )
+ {
+ pPanel->SetVisible( msg.variable2 == 1 );
+ }
+ }
+ break;
case CMD_STOPEVENT:
RunCmd_StopEvent(msg);
break;
@@ -947,6 +1010,63 @@ bool AnimationController::StartAnimationSequence(Panel *pWithinParent, const cha
}
//-----------------------------------------------------------------------------
+// Purpose: stops an animation sequence script
+//-----------------------------------------------------------------------------
+bool AnimationController::StopAnimationSequence( Panel *pWithinParent, const char *sequenceName )
+{
+ Assert( pWithinParent );
+
+ // lookup the symbol for the name
+ UtlSymId_t seqName = g_ScriptSymbols.Find( sequenceName );
+ if (seqName == UTL_INVAL_SYMBOL)
+ return false;
+
+ // remove the existing command from the queue
+ RemoveQueuedAnimationCommands( seqName, pWithinParent );
+
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Runs a custom command from code, not from a script file
+//-----------------------------------------------------------------------------
+void AnimationController::CancelAnimationsForPanel( Panel *pWithinParent )
+{
+ // Msg("Removing queued anims for sequence %s\n", g_ScriptSymbols.String(seqName));
+
+ // remove messages posted by this sequence
+ // if pWithinParent is specified, remove only messages under that parent
+ {
+ for (int i = 0; i < m_PostedMessages.Count(); i++)
+ {
+ if ( m_PostedMessages[i].parent == pWithinParent )
+ {
+ m_PostedMessages.Remove(i);
+ --i;
+ }
+ }
+ }
+
+ // remove all animations
+ // if pWithinParent is specified, remove only animations under that parent
+ for (int i = 0; i < m_ActiveAnimations.Count(); i++)
+ {
+ Panel *animPanel = m_ActiveAnimations[i].panel;
+
+ if ( !animPanel )
+ continue;
+
+ Panel *foundPanel = pWithinParent->FindChildByName(animPanel->GetName(),true);
+
+ if ( foundPanel != animPanel )
+ continue;
+
+ m_ActiveAnimations.Remove(i);
+ --i;
+ }
+}
+
+//-----------------------------------------------------------------------------
// Purpose: Runs a custom command from code, not from a script file
//-----------------------------------------------------------------------------
void AnimationController::RunAnimationCommand(vgui::Panel *panel, const char *variable, float targetValue, float startDelaySeconds, float duration, Interpolators_e interpolator, float animParameter /* = 0 */ )