vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Menu.lua |
||
3 | Functions for the Bagnon right click options menu |
||
4 | --]] |
||
5 | |||
6 | --show the menu |
||
7 | function BagnonMenu_Show(frame) |
||
8 | BagnonMenu.frame = frame; |
||
9 | |||
10 | BagnonMenu.onShow = 1; |
||
11 | BagnonMenuText:SetText(frame:GetName() .. " Settings"); |
||
12 | |||
13 | --Set values |
||
14 | BagnonMenuLocked:SetChecked(BagnonSets[frame:GetName()].locked); |
||
15 | BagnonMenuStayOnScreen:SetChecked(BagnonSets[frame:GetName()].stayOnScreen); |
||
16 | local bgSets = BagnonSets[frame:GetName()].bg; |
||
17 | BagnonMenuBGSettingsNormalTexture:SetVertexColor(bgSets.r, bgSets.g, bgSets.b, bgSets.a); |
||
18 | |||
19 | BagnonMenuReverse:SetChecked(BagnonSets[frame:GetName()].reverse); |
||
20 | BagnonMenuColumns:SetValue(frame.cols); |
||
21 | BagnonMenuSpacing:SetValue(frame.space); |
||
22 | BagnonMenuScale:SetValue(frame:GetScale() * 100); |
||
23 | BagnonMenuOpacity:SetValue(frame:GetAlpha() * 100); |
||
24 | |||
25 | if(BagnonSets[frame:GetName()].strata) then |
||
26 | BagnonMenuStrata:SetValue(BagnonSets[frame:GetName()].strata); |
||
27 | else |
||
28 | BagnonMenuStrata:SetValue(3); |
||
29 | end |
||
30 | |||
31 | --a nifty thing I saw in meta map adapted for my usage |
||
32 | --places the options menu at the cursor's position |
||
33 | local x, y = GetCursorPosition(); |
||
34 | x = x / UIParent:GetScale(); |
||
35 | y = y / UIParent:GetScale(); |
||
36 | |||
37 | BagnonMenu:ClearAllPoints(); |
||
38 | BagnonMenu:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x - 32, y + 48); |
||
39 | |||
40 | BagnonMenu:Show(); |
||
41 | BagnonMenu.onShow = nil; |
||
42 | end |
||
43 | |||
44 | --change <frame>'s transparency |
||
45 | function BagnonMenu_SetAlpha(frame, alpha) |
||
46 | if(alpha ~= 1) then |
||
47 | BagnonSets[frame:GetName()].alpha = alpha; |
||
48 | else |
||
49 | BagnonSets[frame:GetName()].alpha = nil |
||
50 | end |
||
51 | frame:SetAlpha(alpha); |
||
52 | end |
||
53 | |||
54 | --Set and scale <frame> |
||
55 | function BagnonMenu_SetScale(frame, scale) |
||
56 | BagnonSets[frame:GetName()].scale = scale; |
||
57 | |||
58 | Infield.Scale(frame, scale); |
||
59 | BagnonFrame_SavePosition(frame); |
||
60 | end |
||
61 | |||
62 | --set the background of the frame between opaque/transparent |
||
63 | function BagnonMenuBG_OnClick(frame) |
||
64 | if(ColorPickerFrame:IsShown()) then |
||
65 | ColorPickerFrame:Hide(); |
||
66 | else |
||
67 | local bgSets = BagnonSets[frame:GetName()].bg; |
||
68 | |||
69 | ColorPickerFrame.frame = frame; |
||
70 | ColorPickerFrame.func = BagnonMenuBG_ColorChange; |
||
71 | |||
72 | ColorPickerFrame.hasOpacity = 1; |
||
73 | ColorPickerFrame.opacityFunc = BagnonMenuBG_AlphaChange; |
||
74 | ColorPickerFrame.cancelFunc = BagnonMenuBG_CancelChanges; |
||
75 | |||
76 | BagnonMenuBGSettingsNormalTexture:SetVertexColor(bgSets.r, bgSets.g, bgSets.b, bgSets.a); |
||
77 | ColorPickerFrame:SetColorRGB(bgSets.r, bgSets.g, bgSets.b); |
||
78 | ColorPickerFrame.opacity = 1 - bgSets.a; |
||
79 | ColorPickerFrame.previousValues = {r = bgSets.r, g = bgSets.g, b = bgSets.b, opacity = bgSets.a}; |
||
80 | |||
81 | ShowUIPanel(ColorPickerFrame); |
||
82 | end |
||
83 | end |
||
84 | |||
85 | function BagnonMenuBG_ColorChange() |
||
86 | local r, g, b = ColorPickerFrame:GetColorRGB(); |
||
87 | local frame = ColorPickerFrame.frame; |
||
88 | local a = BagnonSets[frame:GetName()].bg.a; |
||
89 | |||
90 | frame:SetBackdropColor(r, g, b, a); |
||
91 | frame:SetBackdropBorderColor(1, 1, 1, a); |
||
92 | BagnonMenuBGSettingsNormalTexture:SetVertexColor(r, g, b, a); |
||
93 | |||
94 | BagnonSets[frame:GetName()].bg.r = r; |
||
95 | BagnonSets[frame:GetName()].bg.g = g; |
||
96 | BagnonSets[frame:GetName()].bg.b = b; |
||
97 | end |
||
98 | |||
99 | function BagnonMenuBG_AlphaChange() |
||
100 | local frame = ColorPickerFrame.frame; |
||
101 | local bgSets = BagnonSets[frame:GetName()].bg; |
||
102 | local alpha = 1 - OpacitySliderFrame:GetValue(); |
||
103 | |||
104 | frame:SetBackdropColor(bgSets.r, bgSets.g, bgSets.b, alpha); |
||
105 | frame:SetBackdropBorderColor(1, 1, 1, alpha); |
||
106 | BagnonMenuBGSettingsNormalTexture:SetVertexColor(bgSets.r, bgSets.g, bgSets.b, alpha); |
||
107 | |||
108 | BagnonSets[frame:GetName()].bg.a = alpha; |
||
109 | end |
||
110 | |||
111 | function BagnonMenuBG_CancelChanges() |
||
112 | local prevValues = ColorPickerFrame.previousValues; |
||
113 | local frame = ColorPickerFrame.frame; |
||
114 | |||
115 | frame:SetBackdropColor(prevValues.r, prevValues.g, prevValues.b, prevValues.opacity); |
||
116 | frame:SetBackdropBorderColor(1, 1, 1, prevValues.opacity); |
||
117 | |||
118 | BagnonMenuBGSettingsNormalTexture:SetVertexColor(prevValues.r, prevValues.g, prevValues.b, prevValues.opacity); |
||
119 | BagnonSets[frame:GetName()].bg.r = prevValues.r; |
||
120 | BagnonSets[frame:GetName()].bg.g = prevValues.g; |
||
121 | BagnonSets[frame:GetName()].bg.b = prevValues.b; |
||
122 | BagnonSets[frame:GetName()].bg.a = prevValues.opacity; |
||
123 | end |
||
124 | |||
125 | --set the inventory slots to be organized in either a reversed or normal order |
||
126 | function BagnonMenu_ToggleOrder(frame, checked) |
||
127 | if( checked ) then |
||
128 | BagnonSets[frame:GetName()].reverse = 1; |
||
129 | else |
||
130 | BagnonSets[frame:GetName()].reverse = nil; |
||
131 | end |
||
132 | BagnonFrame_OrderBags(frame, checked); |
||
133 | BagnonFrame_Generate(frame); |
||
134 | end |
||
135 | |||
136 | function BagnonMenu_ToggleLock(frame, checked) |
||
137 | local frameName = frame:GetName(); |
||
138 | |||
139 | if(checked) then |
||
140 | BagnonSets[frameName].locked = 1; |
||
141 | else |
||
142 | BagnonSets[frameName].locked = nil; |
||
143 | end |
||
144 | end |
||
145 | |||
146 | function BagnonMenu_ToggleStayOnScreen(frame, checked) |
||
147 | local frameName = frame:GetName(); |
||
148 | |||
149 | if(checked) then |
||
150 | BagnonSets[frameName].stayOnScreen = 1; |
||
151 | frame:SetClampedToScreen(true); |
||
152 | else |
||
153 | BagnonSets[frameName].stayOnScreen = nil; |
||
154 | frame:SetClampedToScreen(false); |
||
155 | end |
||
156 | end |