• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Why won't my images fade properly?

Status
Not open for further replies.
I'm totally puzzled on this.
The images just won't crossfade properly.

JASS:
private function FadeImageCallback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local player p = LoadPlayerHandle(TimerHash, GetHandleId(t), 0)
    local image which = LoadImageHandle(TimerHash, GetHandleId(t), 1)
    local image into = LoadImageHandle(TimerHash, GetHandleId(t), 2)
    local integer count = LoadInteger(TimerHash, GetHandleId(t), 3)
    if count < 9 then
        set count = count + 1
        call SetImageColor(which, 255, 255, 255, 255-count*25)
        if into != null then
            call SetImageColor(into, 255, 255, 255, count*25)
        endif
        call SaveInteger(TimerHash, GetHandleId(t), 3, count)
    else
        call SetImageColor(which, 255, 255, 255, 0)
        if into != null then
            call SetImageColor(into, 255, 255, 255, 255)
        endif
        call FlushChildHashtable(TimerHash, GetHandleId(t))
        call DestroyTimer(t)
    endif
    set which = null
    set into = null
    set p = null
    set t = null
endfunction

private function FadeImage takes player p, image which, image into returns nothing
    local timer t = CreateTimer()
    call SavePlayerHandle(TimerHash, GetHandleId(t), 0, p)
    call SaveImageHandle(TimerHash, GetHandleId(t), 1, which)
    call SaveImageHandle(TimerHash, GetHandleId(t), 2, into)
    call SaveInteger(TimerHash, GetHandleId(t), 3, 0)
    call TimerStart(t, 0.2, true, function FadeImageCallback)
    set t = null
endfunction

The first image will just instantly vanish, no matter what. I'm not even sure if images actually allow transparency at this point...

Note that I'm using them as TGA, not BLP. But I don't think this should make a difference, right? They display correctly after all, they just won't crossfade.
 
Last edited by a moderator:
I just tried a blizzard image and it still doesn't work in my map; it did work in the testmap though. I have no fucking idea where the difference is; i tried to most obvious things already:
Disabling fog of war, disabling fog, changing the image type, etc. ... but nothing. It vanishes instantly. I am completely lost here.
Btw, the fading text doesn't work either.

This is the entire script; maybe you can spot the difference to your testmap:


EDIT: Nevermind. It's working now. It was always working. I'm just a complete idiot who panned the camera instantly away from where the image was and never noticed that I did because the background was black...


Another thing though, the fade in of texts isn't working either:

JASS:
private function init takes nothing returns nothing
    set FadeTextColor[0] = "|c15ffffff"
    set FadeTextColor[1] = "|c30ffffff"
    set FadeTextColor[2] = "|c45ffffff"
    set FadeTextColor[3] = "|c60ffffff"
    set FadeTextColor[4] = "|c75ffffff"
    set FadeTextColor[5] = "|c90ffffff"
    set FadeTextColor[6] = "|cA5ffffff"
    set FadeTextColor[7] = "|cC0ffffff"
    set FadeTextColor[8] = "|cE5ffffff"
    set FadeTextColor[9] = "|cffffffff"
endfunction

private function TextFadeCallback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local player p = LoadPlayerHandle(TimerHash, GetHandleId(t), 0)
    local string s = LoadStr(TimerHash, GetHandleId(t), 1)
    local real duration = LoadReal(TimerHash, GetHandleId(t), 2)
    local integer count = LoadInteger(TimerHash, GetHandleId(t), 3)
    local real x = LoadReal(TimerHash, GetHandleId(t), 4)
    local real y = LoadReal(TimerHash, GetHandleId(t), 5)
    if count < 9 then
        if GetLocalPlayer() == p then
            call ClearTextMessages()
        endif
        set count = count + 1
        call DisplayTimedTextToPlayer(p, x, y, duration - I2R(count)*0.5, FadeTextColor[count]+s+"|r")
        if count >= 9 then
            call FlushChildHashtable(TimerHash, GetHandleId(t))
            call DestroyTimer(t)
        else
            call SaveInteger(TimerHash, GetHandleId(t), 3, count)
        endif
    endif
    set s = ""
    set p = null
    set t = null
endfunction

private function SimpleTextFade takes player p, real duration, real x, real y, string s returns nothing
    local timer t = CreateTimer()
    call SavePlayerHandle(TimerHash, GetHandleId(t), 0, p)
    call SaveStr(TimerHash, GetHandleId(t), 1, s)
    call SaveReal(TimerHash, GetHandleId(t), 2, duration)
    call SaveInteger(TimerHash, GetHandleId(t), 3, 0)
    call SaveReal(TimerHash, GetHandleId(t), 4, x)
    call SaveReal(TimerHash, GetHandleId(t), 5, y)
    if GetLocalPlayer() == p then
        call ClearTextMessages()
    endif
    call DisplayTimedTextToPlayer(p, x, y, duration, FadeTextColor[0]+s+"|r")
    call TimerStart(t, 0.5, true, function TextFadeCallback)
    set t = null
endfunction


Hmm... no matter what I can't get the alpha channel of color codes on text messages working. Looks like this is a bug on the WC3 engine.
 
Last edited:
Yeah, game text messages can't be faded. The alpha part of color codes is always ignored (for everything, afaik).

If you have a black screen, then you can use a ghetto solution by fading the text to black.
Yeah... that's what I did now.

On the bright side, this also fixes my cinematic portrait box problem, as now I can freely use text messages to display subtitles instead of transmissions, as the fading credits look too ugly without actual fading, so I just got rid of it.
 
Status
Not open for further replies.
Top