Skip to content

Commit 3555e29

Browse files
committed
Make placeholder scene text positioning automatic
1 parent 6cc2937 commit 3555e29

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

sp/src/game/server/baseflex.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,51 @@ bool CBaseFlex::StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CCh
807807
textParams.fadeinTime = 0.5f;
808808
textParams.fadeoutTime = 0.5f;
809809

810-
textParams.channel = 3;
810+
// Push text farther down if the previous one is still active
811+
static float g_flLastTextStartTime = 0.0f;
812+
static float g_flLastTextEndTime = 0.0f;
813+
static int g_nLastTextActor = 0;
814+
static int g_nTextSlot = 0;
815+
816+
// Which actor am I?
817+
int nActor = 0;
818+
for ( int i = 0; i < scene->GetNumActors(); i++ )
819+
{
820+
if (scene->GetActor( i ) == actor)
821+
{
822+
nActor = i;
823+
break;
824+
}
825+
}
826+
827+
float flStartTime = event->GetStartTime();
828+
if ( g_flLastTextStartTime > flStartTime )
829+
{
830+
// New scene, reset slot
831+
g_nTextSlot = 0;
832+
}
833+
else if ( nActor != g_nLastTextActor )
834+
{
835+
if ( g_flLastTextEndTime > flStartTime )
836+
{
837+
// Put it on another slot
838+
g_nTextSlot++;
839+
}
840+
else
841+
{
842+
g_nTextSlot = 0;
843+
}
844+
}
845+
846+
g_flLastTextStartTime = flStartTime;
847+
g_flLastTextEndTime = event->GetEndTime() + textParams.fadeoutTime;
848+
g_nLastTextActor = nActor;
849+
850+
const int nMaxActors = 2;
851+
852+
textParams.channel = 2 + ( g_nTextSlot % nMaxActors );
811853
textParams.x = -1;
812-
textParams.y = 0.6;
854+
textParams.y = 0.6 + (( g_nTextSlot % nMaxActors ) * 0.1);
813855
textParams.effect = 0;
814856

815857
textParams.r1 = 255;

0 commit comments

Comments
 (0)