Go to most recent revision | Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 3 | Rilgamon-205066 | local name, addon = ... |
2 | Rilgamon-205066 | local defaults = {} |
|
3 | Rilgamon-205066 | local options, db |
|
4 | 7 | Rilgamon-205066 | local _,class = UnitClass('player') |
5 | 3 | Rilgamon-205066 | local _G = _G |
6 | 10 | Rilgamon-205066 | local xoffset, yoffset = 4,4 |
7 | Rilgamon-205066 | local buttons = {} |
|
8 | 6 | Rilgamon-205066 | |
9 | 10 | Rilgamon-205066 | addon['MSQ'] = LibStub("Masque",true) |
10 | Rilgamon-205066 | if(addon['MSQ']) then addon['MSQGroup'] = addon['MSQ']:Group(name,name) end |
|
11 | Rilgamon-205066 | ||
12 | Rilgamon-205066 | local function hideBlizz() |
|
13 | Rilgamon-205066 | local hide = { |
|
14 | Rilgamon-205066 | MainMenuBar, |
|
15 | Rilgamon-205066 | ReputationWatchBar, |
|
16 | Rilgamon-205066 | MainMenuExpBar, |
|
17 | Rilgamon-205066 | BonusActionBarFrame, |
|
18 | Rilgamon-205066 | BonusActionBarFrameTexture1, |
|
19 | Rilgamon-205066 | BonusActionBarFrameTexture2, |
|
20 | Rilgamon-205066 | BonusActionBarFrameTexture3, |
|
21 | Rilgamon-205066 | BonusActionBarFrameTexture4, |
|
22 | Rilgamon-205066 | } |
|
23 | Rilgamon-205066 | for i = 1, #hide do |
|
24 | Rilgamon-205066 | local f = hide[i] |
|
25 | Rilgamon-205066 | if(type(f.UnregisterAllEvents) == 'function') then f:UnregisterAllEvents() end |
|
26 | Rilgamon-205066 | f.Show = f.Hide |
|
27 | Rilgamon-205066 | f:Hide() |
|
28 | Rilgamon-205066 | end |
|
29 | Rilgamon-205066 | end |
|
30 | Rilgamon-205066 | ||
31 | Rilgamon-205066 | local function applySettings(bname, bh) |
|
32 | Rilgamon-205066 | ||
33 | Rilgamon-205066 | db = addon['updateDB'](addon['db']['profile']) |
|
34 | Rilgamon-205066 | local f = _G[bname] |
|
35 | Rilgamon-205066 | if(not f) then return end |
|
36 | Rilgamon-205066 | local spr = db['bars'][bname]['cols'] |
|
37 | Rilgamon-205066 | local y,row = 1,0 |
|
38 | Rilgamon-205066 | local lastbutton = f |
|
39 | Rilgamon-205066 | f:SetScale(db['bars'][bname]['scale']) |
|
40 | Rilgamon-205066 | if(f['sbuttons']) then |
|
41 | Rilgamon-205066 | for i = 1, #f['sbuttons'] do |
|
42 | Rilgamon-205066 | local btn = f['sbuttons'][i] |
|
43 | Rilgamon-205066 | bh = bh or btn:GetHeight() |
|
44 | Rilgamon-205066 | btn:SetParent(f) |
|
45 | Rilgamon-205066 | btn:ClearAllPoints() |
|
46 | Rilgamon-205066 | if(y == 1) then |
|
47 | Rilgamon-205066 | ||
48 | Rilgamon-205066 | btn:SetPoint("TOPLEFT", f, "TOPLEFT",0 , -row * bh + yoffset) |
|
49 | Rilgamon-205066 | else |
|
50 | Rilgamon-205066 | btn:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT",xoffset,0) |
|
51 | Rilgamon-205066 | end |
|
52 | Rilgamon-205066 | y = y + 1 |
|
53 | Rilgamon-205066 | if(not f['skipMasque'] and addon['MSQ'] and addon['MSQGroup'] and not buttons[btn]) then |
|
54 | Rilgamon-205066 | buttons[btn] = true |
|
55 | Rilgamon-205066 | addon['MSQGroup']:AddButton(btn) |
|
56 | Rilgamon-205066 | end |
|
57 | Rilgamon-205066 | lastbutton = btn |
|
58 | Rilgamon-205066 | if(y > spr) then |
|
59 | Rilgamon-205066 | y = 1 |
|
60 | Rilgamon-205066 | row = row + 1 |
|
61 | Rilgamon-205066 | end |
|
62 | Rilgamon-205066 | end |
|
63 | Rilgamon-205066 | end |
|
64 | Rilgamon-205066 | if(row < 1) then row = 1 end |
|
65 | Rilgamon-205066 | if(db['bars'][bname]['cols'] > f['maxslots']) then db['bars'][bname]['cols'] = f['maxslots'] end |
|
66 | Rilgamon-205066 | bh = bh or 0 |
|
67 | Rilgamon-205066 | f:SetWidth(db['bars'][bname]['cols']*(lastbutton:GetWidth() + xoffset) -xoffset) |
|
68 | Rilgamon-205066 | f:SetHeight(row * (bh + yoffset) - yoffset) |
|
69 | Rilgamon-205066 | end |
|
70 | Rilgamon-205066 | addon['applySettings'] = applySettings |
|
71 | Rilgamon-205066 | local function getButton(parent, id, offset) |
|
72 | Rilgamon-205066 | local btn |
|
73 | Rilgamon-205066 | if(offset <= 12) then |
|
74 | Rilgamon-205066 | btn = _G['ActionButton'..id] |
|
75 | Rilgamon-205066 | elseif(offset <= 24) then |
|
76 | Rilgamon-205066 | ||
77 | Rilgamon-205066 | elseif(offset <= 36) then |
|
78 | Rilgamon-205066 | btn = _G['MultiBarRightButton'..id] |
|
79 | Rilgamon-205066 | elseif(offset <= 48) then |
|
80 | Rilgamon-205066 | btn = _G['MultiBarLeftButton'..id] |
|
81 | Rilgamon-205066 | elseif(offset <= 60) then |
|
82 | Rilgamon-205066 | btn = _G['MultiBarBottomRightButton'..id] |
|
83 | Rilgamon-205066 | elseif(offset <= 72) then |
|
84 | Rilgamon-205066 | btn = _G['MultiBarBottomLeftButton'..id] |
|
85 | Rilgamon-205066 | elseif((offset > 190) and (offset <= 200)) then |
|
86 | Rilgamon-205066 | btn = _G['ShapeshiftButton'..id] |
|
87 | Rilgamon-205066 | elseif((offset > 200) and (offset <= 210)) then |
|
88 | Rilgamon-205066 | btn = _G['PetActionButton'..id] |
|
89 | Rilgamon-205066 | end |
|
90 | Rilgamon-205066 | ||
91 | Rilgamon-205066 | if(not btn) then |
|
92 | Rilgamon-205066 | btn = CreateFrame("CheckButton", "$PARENTActionButton"..offset, parent, "ActionButtonTemplate ActionBarButtonCodeTemplate",id) |
|
93 | Rilgamon-205066 | btn['buttonType'] = "ZZACTIONBUTTON" |
|
94 | Rilgamon-205066 | else |
|
95 | Rilgamon-205066 | -- btn:GetParent():UnregisterAllEvents() |
|
96 | Rilgamon-205066 | btn:GetParent():Hide() |
|
97 | Rilgamon-205066 | btn:GetParent().Show = btn:GetParent().Hide |
|
98 | Rilgamon-205066 | btn:ClearAllPoints() |
|
99 | Rilgamon-205066 | btn:SetParent(parent) |
|
100 | Rilgamon-205066 | end |
|
101 | Rilgamon-205066 | -- print(parent, id, offset, btn:GetName()) |
|
102 | Rilgamon-205066 | return btn |
|
103 | Rilgamon-205066 | end |
|
104 | Rilgamon-205066 | ||
105 | Rilgamon-205066 | local function createBar(bid,mb) |
|
106 | Rilgamon-205066 | mb = mb or 12 |
|
107 | Rilgamon-205066 | local yoff =-yoffset - 40 * (bid-1) |
|
108 | 13 | Rilgamon-205066 | local f = CreateFrame("Frame", "zzABar"..bid, UIParent, "SecureHandlerStateTemplate SecureHandlerBaseTemplate",bid == 1 and bid or nil) |
109 | 10 | Rilgamon-205066 | f['sbuttons'] = {} |
110 | Rilgamon-205066 | f['maxslots'] = mb |
|
111 | 8 | Rilgamon-205066 | f:SetWidth(1) |
112 | Rilgamon-205066 | f:SetHeight(1) |
|
113 | 10 | Rilgamon-205066 | f:SetPoint("CENTER", xoffset, yoff) |
114 | Rilgamon-205066 | if(bid > 1 and bid < 7) then |
|
115 | Rilgamon-205066 | f:SetAttribute('actionpage', bid) |
|
116 | Rilgamon-205066 | end |
|
117 | Rilgamon-205066 | if(bid == 1) then |
|
118 | 9 | Rilgamon-205066 | f:SetAttribute('_onstate-page', [[ |
119 | Rilgamon-205066 | if(self:GetID() == 1) then |
|
120 | Rilgamon-205066 | self:SetAttribute('actionpage', newstate) |
|
121 | Rilgamon-205066 | control:ChildUpdate('actionpage', newstate) |
|
122 | Rilgamon-205066 | else |
|
123 | Rilgamon-205066 | control:ChildUpdate('actionpage', self:GetID()) |
|
124 | Rilgamon-205066 | end |
|
125 | Rilgamon-205066 | ]]) |
|
126 | 10 | Rilgamon-205066 | f:SetAttribute('_onstate-possess', [[ |
127 | Rilgamon-205066 | if(self:GetID() == 1) then |
|
128 | Rilgamon-205066 | self:SetAttribute('actionpage', newstate) |
|
129 | Rilgamon-205066 | control:ChildUpdate('actionpage', newstate) |
|
130 | Rilgamon-205066 | else |
|
131 | Rilgamon-205066 | control:ChildUpdate('actionpage', self:GetID()) |
|
132 | Rilgamon-205066 | end |
|
133 | Rilgamon-205066 | ]]) |
|
134 | Rilgamon-205066 | f:SetAttribute('_onstate-vehicle', [[ |
|
135 | 12 | Rilgamon-205066 | self:SetAttribute("state",newstate) |
136 | Rilgamon-205066 | if(newstate == 'player') then |
|
137 | 10 | Rilgamon-205066 | self:SetAttribute('actionpage', nil) |
138 | 13 | Rilgamon-205066 | control:ChildUpdate('actionpage', nil) |
139 | 12 | Rilgamon-205066 | else |
140 | Rilgamon-205066 | self:SetAttribute('actionpage', 11) |
|
141 | 10 | Rilgamon-205066 | end |
142 | 12 | Rilgamon-205066 | control:ChildUpdate('actionpage', self:GetID()) |
143 | 10 | Rilgamon-205066 | ]]) |
144 | 13 | Rilgamon-205066 | RegisterStateDriver(f, "vehicle", "[vehicleui]vehicle;player") |
145 | 9 | Rilgamon-205066 | if(class == "WARRIOR") then |
146 | Rilgamon-205066 | RegisterStateDriver(f, "page", "[bonusbar:1] 7;[bonusbar:2] 8;[bonusbar:3] 9;1") |
|
147 | Rilgamon-205066 | elseif(class == "DRUID") then |
|
148 | Rilgamon-205066 | RegisterStateDriver(f, "page", "[stance:1] 9;[stance:3,stealth] 8;[stance:3] 7;[stance:5] 10;1") -- 1 bear/ 3 cat/ 5 moonkin |
|
149 | Rilgamon-205066 | elseif(class == "ROGUE") then |
|
150 | Rilgamon-205066 | RegisterStateDriver(f, "page", "[stance:1] 7;[stance:3] 8; 1") -- 1 stealth/ 3 shadow dance |
|
151 | Rilgamon-205066 | elseif(class == "PRIEST") then |
|
152 | Rilgamon-205066 | RegisterStateDriver(f, "page", "[stance:1] 7; 1") |
|
153 | Rilgamon-205066 | end |
|
154 | 10 | Rilgamon-205066 | RegisterStateDriver(f, "possess", "[bonusbar:5] 11") |
155 | 13 | Rilgamon-205066 | else |
156 | Rilgamon-205066 | ||
157 | Rilgamon-205066 | f:SetAttribute('_onstate-showvehicle', [[ |
|
158 | Rilgamon-205066 | if(newstate=='hide') then |
|
159 | Rilgamon-205066 | self:Hide() |
|
160 | Rilgamon-205066 | else |
|
161 | Rilgamon-205066 | self:Show() |
|
162 | Rilgamon-205066 | end |
|
163 | Rilgamon-205066 | ]]) |
|
164 | Rilgamon-205066 | RegisterStateDriver(f, "showvehicle", "[vehicleui]hide;show") |
|
165 | Rilgamon-205066 | RegisterAutoHide(f,0.2) |
|
166 | 10 | Rilgamon-205066 | end |
167 | 8 | Rilgamon-205066 | local lastbutton = f |
168 | 10 | Rilgamon-205066 | |
169 | Rilgamon-205066 | for i = 1, mb do |
|
170 | Rilgamon-205066 | local offset = bid*mb-mb+i |
|
171 | Rilgamon-205066 | local b = getButton(f, i, offset) |
|
172 | Rilgamon-205066 | b:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT", xoffset,0) |
|
173 | 9 | Rilgamon-205066 | yoff = 0 |
174 | 8 | Rilgamon-205066 | lastbutton = b |
175 | 10 | Rilgamon-205066 | b:SetAttribute('action--base',b:GetAttribute('action') or i) |
176 | 9 | Rilgamon-205066 | if(bid == 1) then |
177 | Rilgamon-205066 | b:SetAttribute('_childupdate-actionpage', [[ |
|
178 | 12 | Rilgamon-205066 | self:SetAttribute('action--dummy', self:GetAttribute('action--dummy')) |
179 | 9 | Rilgamon-205066 | ]]) |
180 | 10 | Rilgamon-205066 | elseif(bid<7) then |
181 | 9 | Rilgamon-205066 | b:SetAttribute('_childupdate-actionpage', [[ |
182 | 10 | Rilgamon-205066 | |
183 | 9 | Rilgamon-205066 | ]]) |
184 | Rilgamon-205066 | end |
|
185 | 10 | Rilgamon-205066 | f['sbuttons'][#f['sbuttons'] + 1] = b |
186 | Rilgamon-205066 | -- b:SetAttribute('action', i) |
|
187 | 3 | Rilgamon-205066 | end |
188 | 13 | Rilgamon-205066 | addon['addDrag'](f) |
189 | 10 | Rilgamon-205066 | addon['applySettings'](f:GetName()) |
190 | 13 | Rilgamon-205066 | |
191 | 10 | Rilgamon-205066 | return f:GetName() |
192 | 3 | Rilgamon-205066 | end |
193 | Rilgamon-205066 | ||
194 | 10 | Rilgamon-205066 | local function getBarPref(pref) |
195 | Rilgamon-205066 | return db['bars'][pref[#pref-1]][pref[#pref]] |
|
196 | Rilgamon-205066 | end |
|
197 | Rilgamon-205066 | ||
198 | Rilgamon-205066 | local function setBarPref(pref,value) |
|
199 | Rilgamon-205066 | db['bars'][pref[#pref-1]][pref[#pref]] = value |
|
200 | Rilgamon-205066 | applySettings(pref[#pref-1]) |
|
201 | Rilgamon-205066 | end |
|
202 | Rilgamon-205066 | ||
203 | Rilgamon-205066 | local function resetCenter(pref) |
|
204 | Rilgamon-205066 | _G[pref[#pref-1]]:center() |
|
205 | Rilgamon-205066 | end |
|
206 | Rilgamon-205066 | ||
207 | 8 | Rilgamon-205066 | local function init(self, event, ...) |
208 | Rilgamon-205066 | _,class = UnitClass('player') |
|
209 | 4 | Rilgamon-205066 | end |
210 | 10 | Rilgamon-205066 | addon['updateDB'] = function(db) |
211 | Rilgamon-205066 | db['bars'] = db['bars'] or {} |
|
212 | Rilgamon-205066 | db['bars']['MultiCastActionBarFrame'] = db['bars']['MultiCastActionBarFrame'] or { |
|
213 | Rilgamon-205066 | ['cols'] = 12, |
|
214 | Rilgamon-205066 | ['scale'] = 1, |
|
215 | Rilgamon-205066 | } |
|
216 | Rilgamon-205066 | return db |
|
217 | Rilgamon-205066 | end |
|
218 | 8 | Rilgamon-205066 | addon['preloads'][#addon['preloads'] + 1] = function(self,event,...) |
219 | 10 | Rilgamon-205066 | options = addon['InitConfig'](addon, name, true, { |
220 | Rilgamon-205066 | ['type'] = "launcher", |
|
221 | Rilgamon-205066 | }, getPref, setPref) |
|
222 | Rilgamon-205066 | db = addon['updateDB'](addon['db']['profile']) |
|
223 | Rilgamon-205066 | ||
224 | Rilgamon-205066 | db['bars']['MultiCastActionBarFrame']['cols'] = db['bars']['MultiCastActionBarFrame']['cols'] or 12 |
|
225 | Rilgamon-205066 | addon['AddConfigEntry'](addon, name, 'toggle', 'dragAble', 'Unlocked', 'Use alt+click to move your bars', 0) |
|
226 | Rilgamon-205066 | do |
|
227 | Rilgamon-205066 | local function addP(bname) |
|
228 | Rilgamon-205066 | local o = addon['AddConfigMenu'](addon, { |
|
229 | Rilgamon-205066 | ['name'] = bname, |
|
230 | Rilgamon-205066 | ['menuGet'] = getBarPref, |
|
231 | Rilgamon-205066 | ['menuSet'] = setBarPref, |
|
232 | Rilgamon-205066 | }, addon['options']['args'][name]) |
|
233 | Rilgamon-205066 | addon['AddConfigEntry'](addon, name, 'range', 'cols', 'Colums', 'Number of columns', 0,1,12,1,false,o) |
|
234 | Rilgamon-205066 | addon['AddConfigEntry'](addon, name, 'range', 'scale', 'Scale', 'Scale of this bar', 1,0.1,3,0.1,true,o) |
|
235 | Rilgamon-205066 | addon['AddConfigEntry'](addon, name, 'execute', 'center', 'Center', 'Reset position', 2,resetCenter,nil,nil,nil,o) |
|
236 | Rilgamon-205066 | end |
|
237 | Rilgamon-205066 | for i = 1,6 do |
|
238 | Rilgamon-205066 | addP(createBar(i, NUM_ACTIONBAR_BUTTONS)) |
|
239 | Rilgamon-205066 | end |
|
240 | Rilgamon-205066 | addP(createBar(20, NUM_SHAPESHIFT_SLOTS)) |
|
241 | Rilgamon-205066 | addP(createBar(21, NUM_PET_ACTION_SLOTS)) |
|
242 | Rilgamon-205066 | ||
243 | Rilgamon-205066 | addP("MultiCastActionBarFrame") |
|
244 | Rilgamon-205066 | addP(name.."MicroMenu") |
|
245 | Rilgamon-205066 | addP(name.."BagBar") |
|
246 | 9 | Rilgamon-205066 | end |
247 | 10 | Rilgamon-205066 | MultiCastActionBarFrame:ClearAllPoints() |
248 | Rilgamon-205066 | MultiCastActionBarFrame:SetPoint("CENTER") |
|
249 | Rilgamon-205066 | UIPARENT_MANAGED_FRAME_POSITIONS["MultiCastActionBarFrame"] = nil |
|
250 | Rilgamon-205066 | addon['addDrag'](MultiCastActionBarFrame) |
|
251 | Rilgamon-205066 | MoveMicroButtons = function() end |
|
252 | Rilgamon-205066 | VehicleMenuBar_MoveMicroButtons = function() end |
|
253 | Rilgamon-205066 | -- hooksecurefunc("ChangeMultiCastActionPage", updateMCB) |
|
254 | Rilgamon-205066 | hideBlizz() |
|
255 | 4 | Rilgamon-205066 | end |
256 | Rilgamon-205066 | ||
257 | 8 | Rilgamon-205066 | addon['startup'](addon, name, name, init, true, defaults) |