DICE PACKS BUNDLE
  1. #1

    getImageSize() missing in FGU

    Seems like getImageSize() is not in FGU at this time?

    Code:
        local w = Interface.openWindow("imagewindow",nodeImage);
        if w then 
          local ctrl = w.createControl("image_refblock", "image");
    Debug.console("manager_author_adnd.lua","createBlockImage","window (w)",w);   
    Debug.console("manager_author_adnd.lua","createBlockImage","ctrl",ctrl);      
          nXOriginal, nYOriginal = ctrl.getImageSize();
          nX, nY = getAdjustedImageSize(win,ctrl);
          w.close();
        end
    The above code fails when the values "w" and "ctrl" seem valid.

    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'sImageNode' | s'image.id-00002'
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'sImageCaption' | s'Image tsr'
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'nodeImage' | databasenode = { image.id-00002 }
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'window (w)' | windowinstance = { class = imagewindow, node = image.id-00002, x,y,w,h = 658,44,778,765 }
    [10/20/2020 5:09:50 PM] s'manager_author_adnd.lua' | s'createBlockImage' | s'ctrl' | genericcontrol = { name = s'image', x,y,w,h = 0,0,0,0 }
    [10/20/2020 5:09:50 PM] [<color="red">ERROR</color>] Script execution error: [string "scripts/manager_author_adnd.lua"]:398: attempt to call field 'getImageSize' (a nil value)
    Same output in FGC except getImageSize() works.

    If there is a better method to collect this data now I'd be happy to switch to it. I always thought loading the image to get the image size then closing it was a bit... clunky. The reason I do this is to find out the size of the image, adjust so that it fits within the requirements for inline image views in a ref-manual.
    Last edited by celestian; October 22nd, 2020 at 15:34.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  2. #2
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    17,244
    Blog Entries
    9
    I don't think images have a size anymore. If I'm right, this is because images are compilations of assets and the image canvas itself is infinitely large. This is a supposition, but it seems to fit your issue.

    Problems? See; How to Report Issues, Bugs & Problems
    On Licensing & Distributing Community Content
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
    Note, I am not a SmiteWorks employee or representative, I'm just a user like you.

  3. #3
    If you are using the latest version of FGU and CoreRPG ruleset; the image_refblock is no longer an imagecontrol. Instead, it is implemented in FGU as a genericcontrol using a new setAsset API we're trying out for improved performance in reference manuals. So, getImageSize is not valid on the new template which uses a genericcontrol.

    Regards,
    JPG

  4. #4
    Quote Originally Posted by Moon Wizard View Post
    If you are using the latest version of FGU and CoreRPG ruleset; the image_refblock is no longer an imagecontrol. Instead, it is implemented in FGU as a genericcontrol using a new setAsset API we're trying out for improved performance in reference manuals. So, getImageSize is not valid on the new template which uses a genericcontrol.

    Regards,
    JPG
    Not entirely clear, so you're saying there isn't a method to get the image size yet? Or that there is some mechanism within the "genericcontrol" ? I did a quick search of the doc site and didn't get a hit on setAsset(). What I did see in CoreRPG 3.3.12 didn't clear up my mind on how to do it either ;(
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  5. #5
    It's a brand new API that is still in testing that enhances genericcontrols to be able to display an "asset" fitted within the control area.

    There is no mechanism to get the image size from the genericcontrol. The assumption is that the control is set to the desired size; and the asset is scaled to fit within that space regardless of it's actual size.

    JPG

  6. #6
    Quote Originally Posted by Moon Wizard View Post
    It's a brand new API that is still in testing that enhances genericcontrols to be able to display an "asset" fitted within the control area.

    There is no mechanism to get the image size from the genericcontrol. The assumption is that the control is set to the desired size; and the asset is scaled to fit within that space regardless of it's actual size.

    JPG
    Okay, I'll wait about for docs and/or update on how this works. The way the extension works currently is to get the image size and if it's bigger than the "best practices" it scales it down to fit in that for the ref-manual and is set in the nodeBlock.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  7. #7
    I'll add a genericcontrol.getAsset API and an Interface.getAssetSize API to the next release build that you can use to query the asset name and then the size of an asset.

    Regards,
    JPG

  8. #8
    Quote Originally Posted by Moon Wizard View Post
    I'll add a genericcontrol.getAsset API and an Interface.getAssetSize API to the next release build that you can use to query the asset name and then the size of an asset.

    Regards,
    JPG
    Did this ever get added? I still have a need to re-implement the code from FGC...

    (trimmed out and compacted this for simplicity, these are the key fragments so there is a work process to follow, the key issue is the size)

    Code:
        local sNoteText = DB.getValue(nodeStory,"text","");
    
        local sPatternMatchFGU = '<linklist><link class="imagewindow" recordname="[^\"]+">[^<]+</link></linklist>';
        local sPatternMatchFGC = '<linklist>[^<]+<link class="imagewindow" recordname="[^\"]+">[^<]+</link>[^<]+</linklist>';
        local sPatternMatch = sPatternMatchFGC;
    
        if UtilityManager.isClientFGU() then
          sPatternMatch = sPatternMatchFGU;
        end
    
        local nStart, nEnd = string.find(sNoteText,sPatternMatch,1);
        local sText= string.sub(sNoteText,nStart,nEnd);
    
        local sImageNode = sText:match("recordname=\"([^\"]+)\"");
        local sImageCaption = sText:match("<link class=\"imagewindow\" recordname=\"[^\"]+\">([^<]+)</link>");
    
        local nodeImage = DB.findNode(sImageNode);
        local w = Interface.openWindow("imagewindow",nodeImage);
        if w then 
         if not UtilityManager.isClientFGU() then
            local ctrl = w.createControl("image_refblock", "image");
            local nXX,nYY = ctrl.getImageSize();
            nX, nY = getAdjustedImageSize(nXX,nYY);
          else
     ....
    Into FGU so inline images will work as expected using the Author conversion tool.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  9. #9
    Actually it looks like :

    Code:
            local sAsset = DB.getText(w.getDatabaseNode(), "image", "");
            local nAssetX, nAssetY = Interface.getAssetSize(sAsset);
    Works.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
Starfinder Playlist

Log in

Log in