WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   AceConfig-3.0 Options: How to pass imageCoords? (https://www.wowinterface.com/forums/showthread.php?t=58493)

LudiusMaximus 12-28-20 06:00 PM

AceConfig-3.0 Options: How to pass imageCoords?
 
In AceConfig-3.0 Options you can set an image to be displayed instead of an execute button.

But I don't understand how you are supposed to pass the imageCoords, as it says in the manual:
  • image (string|function) - path to image texture, if this is a function it can optionally return the width and height of the image as the 2nd and 3rd value, these will be used instead of imageWidth and imageHeight.
    • imageCoords (table|methodname|function) - arguments to pass to SetTexCoord, e.g. {0.1,0.9,0.1,0.9}.
    • imageWidth (number) - Width of the displayed image
    • imageHeight (number) - Height of the displayed image

The 1st return value is the image string, the 2nd and 3rd is are width and height. But what about the imageCoords table??

Lua Code:
  1. image = function()
  2.     -- What do I do with this?
  3.     local myCoords = {0.4, 0.6, 0.4, 0.6}
  4.                                  
  5.     return "Interface\\Transmogrify\\Transmogrify", "20", "20"
  6.   end,

Seerah 12-28-20 07:36 PM

Lua Code:
  1. myOptions = {
  2.      type = "group",
  3.      args = {
  4.           myButton = {
  5.                name = "My Button",
  6.                type = "execute",
  7.                desc = "Click me to do stuff!",
  8.                func = function()
  9.                               --do something here
  10.                          end,
  11.                image = "Interface\\Transmogrify\\Transmogrify",
  12.                imageCoords = {0.4, 0.6, 0.4, 0.6},
  13.                imageWidth = 20,
  14.                imageHeight = 20,
  15.           },
  16.      },
  17. }

LudiusMaximus 12-28-20 07:55 PM

Brilliant!! Thanks a lot. Kind of stupid that I did not think of this, but this "2nd and 3rd value" thing got me thinking that this is the only way. It works now.

Seerah 12-28-20 08:23 PM

Yes, if you wanted to do it that way, then it'd look like this.
Lua Code:
  1. myOptions = {
  2.      type = "group",
  3.      args = {
  4.           myButton = {
  5.                name = "My Button",
  6.                type = "execute",
  7.                desc = "Click me to do stuff!",
  8.                func = function()
  9.                               --do something here
  10.                          end,
  11.                image = function()
  12.                               return "Interface\\Transmogrify\\Transmogrify", 20, 20
  13.                          end,
  14.                imageCoords = {0.4, 0.6, 0.4, 0.6},
  15.           },
  16.      },
  17. }

But if your image is static, then don't create an extra function.


All times are GMT -6. The time now is 02:13 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI