library FadeInCredits
globals
private timer fic_timer = CreateTimer()
private string fic_s1
private string fic_s2
private string fic_s3
private string fic_s4
private string fic_s5
private string fic_f1
private string fic_f2
private string fic_f3
private string fic_f4
private string fic_f5
private real fic_x
private real fic_y
private real fic_duration
private boolean fic_fade_out
private boolean fic_slow
endglobals
private function FiC_text_to_all takes string s, real r1, real r2 returns nothing
if (IsPlayerInForce(GetLocalPlayer(),GetPlayersAll())) then
call DisplayTimedTextFromPlayer(GetLocalPlayer(),r1,r2,5.00,s)
endif
endfunction
private function FiC_inc_main takes string s returns string
if (s == "A") then
return "C"
elseif (s == "C") then
return "E"
elseif (s == "E") then
return "0"
elseif (s == "8") then
return "A"
else
return I2S(S2I(s)+2)
endif
return s
endfunction
private function FiC_inc_sub takes string s returns string
local string m = SubString(s,0,1)
local string sub = SubString(s,1,2)
if (sub=="A") then
set sub = "C"
elseif (sub == "C") then
set sub = "E"
elseif (sub == "E") then
set m = FiC_inc_main(m)
set sub = "0"
elseif (sub == "8") then
set sub = "A"
else
set sub = I2S(S2I(sub)+2)
endif
return m+sub+m+sub+m+sub
endfunction
private function FiC_sub_block takes string s returns string
return (SubString(s,4,6))
endfunction
private function FiC_dec_main takes string s returns string
if (s == "0") then
return "E"
elseif (s == "E") then
return "C"
elseif (s == "C") then
return "A"
elseif (s == "A") then
return "8"
else
return I2S(S2I(s)-2)
endif
return s
endfunction
private function FiC_dec_sub takes string s returns string
local string m = SubString(s,0,1)
local string sub = SubString(s,1,2)
if (sub == "0") then
set m = FiC_dec_main(m)
set sub = "E"
elseif (sub == "E") then
set sub = "C"
elseif (sub == "C") then
set sub = "A"
elseif (sub == "A") then
set sub = "8"
else
set sub = I2S(S2I(sub)-2)
endif
return m+sub+m+sub+m+sub
endfunction
private function FiC_print_fading takes nothing returns nothing
if (not fic_fade_out) then
call ClearTextMessages()
set fic_f1 = "|c00"+FiC_inc_sub(FiC_sub_block(fic_f1))+fic_s1
set fic_f2 = "|c00"+FiC_inc_sub(FiC_sub_block(fic_f2))+fic_s2
call FiC_text_to_all(fic_f1,fic_x,fic_y)
call FiC_text_to_all(fic_f2,fic_x,fic_y)
if (fic_s3 != null) then
set fic_f3 = "|c00"+FiC_inc_sub(FiC_sub_block(fic_f3))+fic_s3
call FiC_text_to_all(fic_f3,fic_x,fic_y)
endif
if (fic_s4 != null) then
set fic_f4 = "|c00"+FiC_inc_sub(FiC_sub_block(fic_f4))+fic_s4
call FiC_text_to_all(fic_f4,fic_x,fic_y)
endif
if (fic_s5 != null) then
set fic_f5 = "|c00"+FiC_inc_sub(FiC_sub_block(fic_f5))+fic_s5
call FiC_text_to_all(fic_f5,fic_x,fic_y)
endif
if (FiC_sub_block(fic_f1) == "EC") then
if (not fic_slow) then
set fic_fade_out = true
else
call PauseTimer(fic_timer)
endif
set fic_duration = fic_duration-0.01
endif
elseif (fic_fade_out) and (fic_duration > 0.00) then
set fic_duration = fic_duration-0.01
else
call ClearTextMessages()
set fic_f1 = "|c00"+FiC_dec_sub(FiC_sub_block(fic_f1))+fic_s1
set fic_f2 = "|c00"+FiC_dec_sub(FiC_sub_block(fic_f2))+fic_s2
call FiC_text_to_all(fic_f1,fic_x,fic_y)
call FiC_text_to_all(fic_f2,fic_x,fic_y)
if (fic_s3 != null) then
set fic_f3 = "|c00"+FiC_dec_sub(FiC_sub_block(fic_f3))+fic_s3
call FiC_text_to_all(fic_f3,fic_x,fic_y)
endif
if (fic_s4 != null) then
set fic_f4 = "|c00"+FiC_dec_sub(FiC_sub_block(fic_f4))+fic_s4
call FiC_text_to_all(fic_f4,fic_x,fic_y)
endif
if (fic_s5 != null) then
set fic_f5 = "|c00"+FiC_dec_sub(FiC_sub_block(fic_f5))+fic_s5
call FiC_text_to_all(fic_f5,fic_x,fic_y)
endif
if (FiC_sub_block(fic_f1) == "00") then
call ClearTextMessages()
call PauseTimer(fic_timer)
endif
endif
endfunction
public function fade_in_credits takes string s1, string s2, string s3, string s4, string s5, real x, real y, real duration, boolean slow returns nothing
local real speed = 0.01
set fic_s1 = s1
set fic_f1 = "|c00000000"+s1
set fic_s2 = s2
set fic_f2 = "|c00000000"+s2
set fic_s3 = s3
set fic_f3 = "|c00000000"+s3
set fic_s4 = s4
set fic_f4 = "|c00000000"+s4
set fic_s5 = s5
set fic_f5 = "|c00000000"+s5
set fic_x = x
set fic_y = y
set fic_duration = duration
set fic_slow = slow
set fic_fade_out = false
if (slow) then
set speed = 0.04
endif
call TimerStart(fic_timer,speed,true,function FiC_print_fading)
endfunction
endlibrary