• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient [.aPNG] Not displayed from beginning when it's newly created and num_plays not readable.

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,837
Solutions
18
Reaction score
615
Location
Poland
Hello, OTLanders!

So far I read code about aPNG in OTC (default/Mehah/doesn't matter which repo) - there's an variable
C++:
apng->num_plays = loops;
which in original logic of aPNG file structure is an loop handler - if .aPNG file was rendered with this attribute (it's > 0), then it should be played num_plays times, otherwise if it's 0, it should be played infinite [loop], but the problem is - this variable I haven't seen that is used anywhere in OTC to handle thing like : Play aPNG only once or infinite times.

I'm trying to achieve this type of effect (preview from my OTC Module in-game):
6ce6fb4cea67bea9353c45b1e6516380.gif

My question is - Anyone know how to implement reading this attribute (apng->num_plays) to be working like in original .aPNG file structure - when it's 0, plays infinite, when 1 or more, play 1 or more times.

I even tried to do an "hack" with destroying widget and creating it again but this not restarting aPNG (not goes from first frame to last frame) because by default - if u destroy .aPNG the animation is going "in the background" even if widget with .aPNG doesn't exist the animation is still going in RAM, and if you even create and display same aPNG again the animation not goes from first frame / not restart timer / it goes from frame that it is in RAM.

It's kinda hard to explain, you need to check it by yourself, just try to achieve effect like - play .aPNG one time - here's my simple code for that, to help you test what I'm trying to do:
Lua:
-- put this in function that you able to use X amount of times, simple button or whatever is clickable
-- next fill the -- name -- variables with your files/positions
-- try change scheduleEvent time - destroy the .aPNG widget at any time and try to achieve :
-- play frames in order : first frame -> last frame, not possible it's playing from frame that is in RAM,
-- it should be played from first frame to last frame when new widget is created and setImageSource is executing on it
-- (the timer should be resetting and frame to 1 or something, idk, i gave up)
    local channelingEffect = g_ui.createWidget('UIWindow', --existing_place/widget_where_aPNG_should_be_displayed--)
    channelingEffect:setSize({height = 150, width = 435}) -- size of aPNG file
    channelingEffect:fill('--existing_place/widget_where_aPNG_should_be_displayed--') -- anchors to the place;
    channelingEffect:setImageSource('-- your .APNG image source --')
    scheduleEvent(function()
        channelingEffect:destroy()
    end, 5000) -- time after widget with "effect - aPNG" should be destroyed

Waiting for replies,
Anyone have any idea? For now, I already gave up on reading .aPNG loader and trying to understand .aPNG file structure to implement num_plays.
 
Last edited:
Back
Top