Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 10 | Seerah-7 | --[[textureData = { |
2 | Seerah-7 | type = "texture", |
|
3 | Seerah-7 | image = "file/path.dds", |
|
4 | Seerah-7 | imageWidth = 64, --max of 250 for half width, 510 for full |
|
5 | Seerah-7 | imageHeight = 32, --max of 100 |
|
6 | Seerah-7 | tooltip = "Image's tooltip text.", --(optional) |
|
7 | Seerah-7 | width = "full", --or "half" (optional) |
|
8 | 11 | Seerah-7 | reference = "MyAddonTexture" --(optional) unique global reference to control |
9 | 10 | Seerah-7 | } ]] |
10 | Seerah-7 | ||
11 | Seerah-7 | --add texture coords support? |
|
12 | Seerah-7 | ||
13 | 16 | Seerah-7 | local widgetVersion = 5 |
14 | 10 | Seerah-7 | local LAM = LibStub("LibAddonMenu-2.0") |
15 | Seerah-7 | if not LAM:RegisterWidget("texture", widgetVersion) then return end |
|
16 | Seerah-7 | ||
17 | Seerah-7 | local wm = WINDOW_MANAGER |
|
18 | Seerah-7 | ||
19 | Seerah-7 | function LAMCreateControl.texture(parent, textureData, controlName) |
|
20 | 11 | Seerah-7 | local control = wm:CreateTopLevelWindow(controlName or textureData.reference) |
21 | 10 | Seerah-7 | control:SetResizeToFitDescendents(true) |
22 | 13 | Seerah-7 | control:SetParent(parent.scroll or parent) |
23 | 10 | Seerah-7 | |
24 | Seerah-7 | local isHalfWidth = textureData.width == "half" |
|
25 | Seerah-7 | if isHalfWidth then |
|
26 | Seerah-7 | control:SetDimensionConstraints(250, 55, 250, 100) |
|
27 | Seerah-7 | control:SetDimensions(250, 55) |
|
28 | Seerah-7 | else |
|
29 | Seerah-7 | control:SetDimensionConstraints(510, 30, 510, 100) |
|
30 | Seerah-7 | control:SetDimensions(510, 30) |
|
31 | Seerah-7 | end |
|
32 | Seerah-7 | ||
33 | Seerah-7 | control.texture = wm:CreateControl(nil, control, CT_TEXTURE) |
|
34 | Seerah-7 | local texture = control.texture |
|
35 | Seerah-7 | texture:SetAnchor(CENTER) |
|
36 | Seerah-7 | texture:SetDimensions(textureData.imageWidth, textureData.imageHeight) |
|
37 | Seerah-7 | texture:SetTexture(textureData.image) |
|
38 | Seerah-7 | ||
39 | Seerah-7 | if textureData.tooltip then |
|
40 | Seerah-7 | texture:SetMouseEnabled(true) |
|
41 | 16 | Seerah-7 | --texture.tooltipText = textureData.tooltip |
42 | Seerah-7 | texture.data = {tooltipText = textureData.tooltip} |
|
43 | 10 | Seerah-7 | texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) |
44 | Seerah-7 | texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) |
|
45 | Seerah-7 | end |
|
46 | Seerah-7 | ||
47 | Seerah-7 | control.panel = parent.panel or parent --if this is in a submenu, panel is its parent |
|
48 | Seerah-7 | control.data = textureData |
|
49 | Seerah-7 | ||
50 | Seerah-7 | return control |
|
51 | Seerah-7 | end |