• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Fade in Credits v1.1

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Fixed the bugs due to a request.

A system used in my map posted on a request.
Fades in and out Credits, just like they do in the movies.
Gives a chance to actually make people read credits for a change!
Easy to use for GUI/MUI/JASSer's and whatever is left.

---Notes---
- Requires vJASS
- You cannot display other texts while fading out credits

JASS:
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

Keywords:
credits, credit, fade in, fade out, fade in credits, fade, string, system, credit system, credits system
Contents

Fade in Credits v1.1 (Map)

Reviews
12th Dec 2015 IcemanBo: For long time as NeedsFix. Rejected. 14:47, 5th Jan 2015 IcemanBo: http://www.hiveworkshop.com/forums/spells-569/fade-credits-v1-1-a-257134/#post2636016

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
  • JASS:
    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
    Man, you should make something like a queue instead of that very-limited and long function. Your queue will have something like .push() => register a string to be displayed to at the screen, and .pop() => immediately clear current displayed text and play the next node.
  • And this?
    JASS:
        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
    It looks ugly, doesn't it? Why don't use an array if necessary?
  • JASS:
    if (IsPlayerInForce(GetLocalPlayer(),GetPlayersAll())) then
    Create a player force which only contains players who can see the credit screen.
  • JASS:
        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
    It's too unreadable. Also, in the if block and else block looks very similliar, could you just somehow merge them? Yes you can.
  • JASS:
        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
    It's just poorly approached.
    You should utilize something like Hex2Int converter, to make better fading transition? First, get the alpha channel => convert to integer => add/substract the integer by fadingRate => convert back to Hexadecimal => insert to the string. And you got nice fading effect without overburden functions.

Good luck... ^)^

EDIT:
Have just realized this in not fading. Screen messages do not support alpha channel, have just remembered it. Except you can somehow manipulate this function:
DisplayTimedTextToPlayer()
 
  • The API should be improved. It's ugly you have to insert all these null for unused strings.
  • fic_duration = fic_duration-0.01
    ->
    fic_duration = fic_duration-speed
  • The "slow" parameter is not really needed. Or make the timer interval user-configurable, or constant.
  • Some short and useful documentation, please.

You always check for exactly 5 potential strings to make actions, I don't like this. For the effort it's usefulnes is seems limited for now. Maybe you can make it simpler and the usage easier.

It would be nice, if user would not have to set all texts into one function call, even he wants to break lines.
The system would need to manage multiple instances, which would make it more dynamic.
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
816
EDIT:
Have just realized this in not fading. Screen messages do not support alpha channel, have just remembered it. Except you can somehow manipulate this function:
DisplayTimedTextToPlayer()

This doesnt try to use the alpha channel. It just fades the color of the text from black to white to black.

What it does however do, is display way too many text messages (up to 500 times per second). Testing i did a couple years back indicated that after about 10000 displayed text messages displaying another one caused a severe hit in performance.
 
Top