+ Reply to Thread
Results 1 to 4 of 4

Thread: LibAsyncTextures

  1. #1
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default LibAsyncTextures

    Hello everybody.

    Since the Watchdog is nearing closer and closer I stumbled upon a few issues with texture-intensive addons. The solution I came up with for ImhoBags is general enough that I squeezed it in a library, hoping to help others who have problems with the Watchdog and texture loading.

    So I present: LibAsyncTextures!

    It is available at CurseForge and RiftUI.

    What does it do? Well let me quote the summary:
    LibAsyncTextures makes it possible to have all your textures loaded in the background asynchronously, thus enabling you to load texture-rich frames without risking the Watchdog barking at you and lifts you of the burdon of having to deal with coroutines and stuff.
    The library adds a new method to Texture widgets:

    Texture:SetTextureAsync(source, texture[, callback])
    This method enqueues the given frame for asynchronous texture loading. The function is non-blocking and returns immediately, loading the texture content at a later time. The source and texture parameters are the same as in SetTexture. You can optionally add a callback to get called when the texture finished loading. It receives frame as its only parameter. You should not perform time intensive tasks in the callback.

    Example:
    Code:
    local texture = UI.CreateFrame("Texture", "Example texture", parent)
    texture:SetTextureAsync("MyAddon", "textures/example.png", function(frame)
        print("done", frame)
    end)
    As the callback parameter is optional you can use SetTextureAsync as a drop-in replacement for SetTexture.
    There are other functions and details on how the library works I suggest reading the description at your favourite developer site.

    Hope you enjoy it and find it useful!
    Last edited by Imhothar; 06-28-2012 at 10:56 AM.

  2. #2
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    I approved on CurseForge, and you can now find it at Curse: http://www.curse.com/addons/rift/lib-async-textures

  3. #3
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    The library has been updated to 1.1.1

    BREAKING CHANGE!
    The weighting has been completely removed and the library is instead now tracking loading times of textures. If you did not specify any weights or callbacks in SetTextureAsync() then you don't need to change anything. Otherwise remove the weight argument from your calls!

    The new signature is:
    Code:
    Texture:SetTextureAsync(source, texture[, callback])
    Last edited by Imhothar; 06-28-2012 at 10:56 AM.

  4. #4
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    New function:
    Code:
    LibAsyncTextures.EnqueueCallback(callback)
    Using it you can enqueue any arbitrary callback which is called after all the textures have been loaded which are queued up for your addon up to now.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts