//===========================================================================
function CinematicFadeCommonBJ takes real red, real green, real blue, real duration, string tex, real startTrans, real endTrans returns nothing
if (duration == 0) then
// If the fade is instant, use the same starting and ending values,
// so that we effectively do a set rather than a fade.
set startTrans = endTrans
endif
call EnableUserUI(false)
call SetCineFilterTexture(tex)
call SetCineFilterBlendMode(BLEND_MODE_BLEND)
call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
call SetCineFilterStartUV(0, 0, 1, 1)
call SetCineFilterEndUV(0, 0, 1, 1)
call SetCineFilterStartColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100-startTrans))
call SetCineFilterEndColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100-endTrans))
call SetCineFilterDuration(duration)
call DisplayCineFilter(true)
endfunction
//===========================================================================
function FinishCinematicFadeBJ takes nothing returns nothing
call DestroyTimer(bj_cineFadeFinishTimer)
set bj_cineFadeFinishTimer = null
call DisplayCineFilter(false)
call EnableUserUI(true)
endfunction
//===========================================================================
function FinishCinematicFadeAfterBJ takes real duration returns nothing
// Create a timer to end the cinematic fade.
set bj_cineFadeFinishTimer = CreateTimer()
call TimerStart(bj_cineFadeFinishTimer, duration, false, function FinishCinematicFadeBJ)
endfunction
//===========================================================================
function ContinueCinematicFadeBJ takes nothing returns nothing
call DestroyTimer(bj_cineFadeContinueTimer)
set bj_cineFadeContinueTimer = null
call CinematicFadeCommonBJ(bj_cineFadeContinueRed, bj_cineFadeContinueGreen, bj_cineFadeContinueBlue, bj_cineFadeContinueDuration, bj_cineFadeContinueTex, bj_cineFadeContinueTrans, 100)
endfunction
//===========================================================================
function ContinueCinematicFadeAfterBJ takes real duration, real red, real green, real blue, real trans, string tex returns nothing
set bj_cineFadeContinueRed = red
set bj_cineFadeContinueGreen = green
set bj_cineFadeContinueBlue = blue
set bj_cineFadeContinueTrans = trans
set bj_cineFadeContinueDuration = duration
set bj_cineFadeContinueTex = tex
// Create a timer to continue the cinematic fade.
set bj_cineFadeContinueTimer = CreateTimer()
call TimerStart(bj_cineFadeContinueTimer, duration, false, function ContinueCinematicFadeBJ)
endfunction
//===========================================================================
function AbortCinematicFadeBJ takes nothing returns nothing
if (bj_cineFadeContinueTimer != null) then
call DestroyTimer(bj_cineFadeContinueTimer)
endif
if (bj_cineFadeFinishTimer != null) then
call DestroyTimer(bj_cineFadeFinishTimer)
endif
endfunction
//===========================================================================
function CinematicFadeBJ takes 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 AbortCinematicFadeBJ()
call CinematicFadeCommonBJ(red, green, blue, duration, tex, 100, trans)
elseif (fadetype == bj_CINEFADETYPE_FADEIN) then
// Fade in from the requested color.
call AbortCinematicFadeBJ()
call CinematicFadeCommonBJ(red, green, blue, duration, tex, trans, 100)
call FinishCinematicFadeAfterBJ(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 AbortCinematicFadeBJ()
call CinematicFadeCommonBJ(red, green, blue, duration * 0.5, tex, 100, trans)
call ContinueCinematicFadeAfterBJ(duration * 0.5, red, green, blue, trans, tex)
call FinishCinematicFadeAfterBJ(duration)
endif
else
// Unrecognized fadetype - ignore the request.
endif
endfunction