//===========================================================================
function CinematicFadeCommonForPlayer takes player fadePlayer, real red, real green, real blue, real duration, string tex, real startTrans, real endTrans returns nothing
if (GetLocalPlayer() == fadePlayer) then
call CinematicFadeCommonBJ(red, green, blue, duration, tex, startTrans, endTrans)
endif
endfunction
//===========================================================================
function FinishCinematicFadeForPlayer takes nothing returns nothing
local integer fadePlayerId = 1
// We don't know which player the expired timer belongs to,
// so we check each player's timer to see if it matches the one that just expired.
loop
exitwhen udg_cineFadeFinishTimer[fadePlayerId] == GetExpiredTimer()
set fadePlayerId = fadePlayerId + 1
endloop
call DestroyTimer(udg_cineFadeFinishTimer[fadePlayerId])
set udg_cineFadeFinishTimer[fadePlayerId] = null
if (GetConvertedPlayerId(GetLocalPlayer()) == fadePlayerId) then
call DisplayCineFilter(false)
call EnableUserUI(true)
endif
endfunction
//===========================================================================
function FinishCinematicFadeAfterForPlayer takes player fadePlayer, real duration returns nothing
local integer fadePlayerId = GetConvertedPlayerId(fadePlayer)
// Create a timer to end the cinematic fade.
set udg_cineFadeFinishTimer[fadePlayerId] = CreateTimer()
call TimerStart(udg_cineFadeFinishTimer[fadePlayerId], duration, false, function FinishCinematicFadeForPlayer)
endfunction
//===========================================================================
function ContinueCinematicFadeForPlayer takes nothing returns nothing
local integer fadePlayerId = 1
// We don't know which player the expired timer belongs to,
// so we check each player's timer to see if it matches the one that just expired.
loop
exitwhen udg_cineFadeContinueTimer[fadePlayerId] == GetExpiredTimer()
set fadePlayerId = fadePlayerId + 1
endloop
call DestroyTimer(udg_cineFadeContinueTimer[fadePlayerId])
set udg_cineFadeContinueTimer[fadePlayerId] = null
call CinematicFadeCommonForPlayer(ConvertedPlayer(fadePlayerId), udg_cineFadeContinueRed, udg_cineFadeContinueGreen, udg_cineFadeContinueBlue, udg_cineFadeContinueDuration, udg_cineFadeContinueTex, udg_cineFadeContinueTrans, 100)
endfunction
//===========================================================================
function ContinueCinematicFadeAfterForPlayer takes player fadePlayer, real duration, real red, real green, real blue, real trans, string tex returns nothing
local integer fadePlayerId = GetConvertedPlayerId(fadePlayer)
if (GetLocalPlayer() == fadePlayer) then
set udg_cineFadeContinueRed = red
set udg_cineFadeContinueGreen = green
set udg_cineFadeContinueBlue = blue
set udg_cineFadeContinueTrans = trans
set udg_cineFadeContinueDuration = duration
set udg_cineFadeContinueTex = tex
endif
// Create a timer to continue the cinematic fade.
set udg_cineFadeContinueTimer[fadePlayerId] = CreateTimer()
call TimerStart(udg_cineFadeContinueTimer[fadePlayerId], duration, false, function ContinueCinematicFadeForPlayer)
endfunction
//===========================================================================
function AbortCinematicFadeForPlayer takes player fadePlayer returns nothing
local integer fadePlayerId = GetConvertedPlayerId(fadePlayer)
if (udg_cineFadeContinueTimer[fadePlayerId] != null) then
call DestroyTimer(udg_cineFadeContinueTimer[fadePlayerId])
endif
if (udg_cineFadeFinishTimer[fadePlayerId] != null) then
call DestroyTimer(udg_cineFadeFinishTimer[fadePlayerId])
endif
endfunction
function CinematicFadeForPlayer takes player fadePlayer, integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing
if (fadetype == bj_CINEFADETYPE_FADEOUT) then
// Fade out to the requested color.
call AbortCinematicFadeForPlayer(fadePlayer)
call CinematicFadeCommonForPlayer(fadePlayer, red, green, blue, duration, tex, 100, trans)
elseif (fadetype == bj_CINEFADETYPE_FADEIN) then
// Fade in from the requested color.
call AbortCinematicFadeForPlayer(fadePlayer)
call CinematicFadeCommonForPlayer(fadePlayer, red, green, blue, duration, tex, trans, 100)
call FinishCinematicFadeAfterForPlayer(fadePlayer, duration)
elseif (fadetype == bj_CINEFADETYPE_FADEOUTIN) then
// Fade out to the requested color, and then fade back in from it.
if (duration > 0) then
call AbortCinematicFadeForPlayer(fadePlayer)
call CinematicFadeCommonForPlayer(fadePlayer, red, green, blue, duration * 0.5, tex, 100, trans)
call ContinueCinematicFadeAfterForPlayer(fadePlayer, duration * 0.5, red, green, blue, trans, tex)
call FinishCinematicFadeAfterForPlayer(fadePlayer, duration)
endif
else
// Unrecognized fadetype - ignore the request.
endif
endfunction