comparison SkeletonKey/BindingsFrame.lua @ 34:daff39af0c6d

changeset logjam
author Nenue
date Tue, 16 Aug 2016 10:24:55 -0400
parents b0e4d04d428a
children 9a9d7f2a7c07
comparison
equal deleted inserted replaced
33:d5e6b2265d6f 34:daff39af0c6d
30 [BINDING_TYPE_SPECIALIZATION] = {0, 1, 1}, 30 [BINDING_TYPE_SPECIALIZATION] = {0, 1, 1},
31 [BINDING_TYPE_CHARACTER] = {0, 1, 0}, 31 [BINDING_TYPE_CHARACTER] = {0, 1, 0},
32 [BINDING_TYPE_GLOBAL] = {0, 1, 1} 32 [BINDING_TYPE_GLOBAL] = {0, 1, 1}
33 } 33 }
34 34
35 --[=[
36 -- some useful texture paths
37 [[Interface\PaperDollInfoFrame\UI-GearManager-Undo]]
38 [[Interface\PetPaperDollFrame\UI-PetHappiness]]
39 [[Interface\RAIDFRAME\ReadyCheck-Waiting]]
40 [[Interface\RAIDFRAME\ReadyCheck-Read]]
41 [[Interface\RAIDFRAME\ReadyCheck-NotReady]]
42 [[Interface\TradeSkillFrame\UI-TradeSkill-LinkButton]]
43 [[Interface\TUTORIALFRAME\UI-TUTORIAL-FRAME]]
44 [[Interface\UI-TutorialFrame-QuestGiver\UI-TutorialFrame-QuestGray]]
45 --]=]
46 local lastFolder
47 local addT = function(frame, key, folder, name)
48 folder = folder or lastFolder
49 frame[key] = frame:CreateTexture()
50 frame[key]:SetTexture('Interface\\' .. folder .. '\\' .. name)
51 frame[key]:SetPoint('TOPLEFT')
52 lastFolder = folder
53 end
54
35 local restingAlpha = 0.7 55 local restingAlpha = 0.7
36 local fadeTime, fadeDelay = .30, 0.15 56 local fadeTime, fadeDelay = .30, 0.15
37 local saveButton 57 local saveButton
38 58
39 local KeyButton_OnKeyDown = function(self, key) 59 local KeyButton_OnKeyDown = function(self, key)
80 end 100 end
81 101
82 end 102 end
83 elseif click == 'RightButton' then 103 elseif click == 'RightButton' then
84 kb.ReleaseSlot(self) 104 kb.ReleaseSlot(self)
105 kb.ui()
85 end 106 end
86 end 107 end
87 108
88 local KeyButton_OnDragStart = function(self) 109 local KeyButton_OnDragStart = function(self)
89 kb.PickupSlot(self) 110 kb.PickupSlot(self)
179 end 200 end
180 201
181 kb.ui(true) 202 kb.ui(true)
182 end 203 end
183 204
184 local KeyBinder_CheckButton = function(frame ,enableText, disableText, dbKey, tooltipText, callback) 205 local frameCount = 0
206 local lastCheckFrame
207 local KeyBinder_CheckButton = function(frame ,enableText, disableText, dbKey, tooltipText, callback, header)
185 if kb.db[dbKey] then 208 if kb.db[dbKey] then
186 frame:SetChecked(true) 209 frame:SetChecked(true)
187 end 210 end
188 frame.label:SetText(kb.db[dbKey] and enableText or disableText) 211
189 frame:SetWidth(frame.label:GetStringWidth()+8) 212 frame.header:SetText(header)
190 213
191 frame:SetScript('OnClick', function(self) 214 frame:SetScript('OnClick', function(self)
192 if callback then 215 if callback then
193 callback(self) 216 callback(self)
194 end 217 end
196 if not kb.db[dbKey] then 219 if not kb.db[dbKey] then
197 if kb.saveTarget then 220 if kb.saveTarget then
198 kb.DeactivateSlot(kb.saveTarget) 221 kb.DeactivateSlot(kb.saveTarget)
199 end 222 end
200 end 223 end
201 self.label:SetText(kb.db[dbKey] and enableText or disableText)
202 self:SetWidth(self.label:GetStringWidth()+8)
203 kb.ui() 224 kb.ui()
204 end) 225 end)
205 226
206 frame:SetScript('OnEnter', function(self) 227 frame:SetScript('OnEnter', function(self)
207 if tooltipText then 228 if tooltipText then
214 frame:SetScript('OnLeave', function(self) 235 frame:SetScript('OnLeave', function(self)
215 if tooltipText and GameTooltip:GetOwner() == self then 236 if tooltipText and GameTooltip:GetOwner() == self then
216 GameTooltip:Hide() 237 GameTooltip:Hide()
217 end 238 end
218 end) 239 end)
240
241 if frame:GetID() == 0 then
242 frameCount = frameCount + 1
243 frame:SetID(frameCount)
244 print('checkbutton #', frameCount)
245 if frameCount == 1 then
246 frame:ClearAllPoints()
247 frame:SetPoint('TOP', KeyBinderInventoryButton, 'BOTTOM', 0, -22)
248 frame:SetPoint('LEFT', kb.sourcesbg, 'LEFT', 2, 0)
249 else
250 frame:ClearAllPoints()
251 frame:SetPoint('TOPLEFT', lastCheckFrame, 'BOTTOMLEFT', 0, -2)
252 end
253
254 frame.header:ClearAllPoints()
255 frame.header:SetPoint('LEFT', frame, 'RIGHT', 2, 0)
256
257 lastCheckFrame = frame
258 end
219 end 259 end
220 260
221 local KeyBinder_OnHide = function() 261 local KeyBinder_OnHide = function()
222 KeyBinderImportLog:Hide() 262 KeyBinderImportLog:Hide()
223 end 263 end
317 kb:uibutton( 357 kb:uibutton(
318 'KeyBinderInventoryButton', 'Bags', nil, 358 'KeyBinderInventoryButton', 'Bags', nil,
319 function() OpenAllBags() end, 359 function() OpenAllBags() end,
320 "Interface\\BUTTONS\\UI-MicroButtonCharacter-Up", {0, 1, .4, 1}) 360 "Interface\\BUTTONS\\UI-MicroButtonCharacter-Up", {0, 1, .4, 1})
321 361
322 KeyBinder_CheckButton(KeyBinderStickyMode, 'Enabled', 'Disabled', 'stickyMode', 'Keep input active after receiving a key.') 362 KeyBinder_CheckButton(KeyBinderStickyMode, 'Enabled', 'Disabled', 'stickyMode', 'Keep input active after receiving a key.', nil, 'Sticky:')
323 KeyBinder_CheckButton(KeyBinderHoverInput, 'MouseOver', 'Click', 'hoverInput', 'Enable key input when the cursor is over a binding slot.') 363 KeyBinder_CheckButton(KeyBinderHoverInput, 'MouseOver', 'Click', 'hoverInput', 'Enable key input when the cursor is over a binding slot.', nil, 'Bind by:')
364 KeyBinder_CheckButton(KeyBinderProtectBindings, 'Block', 'Allow', 'protectBlizKeys', 'Allow overwriting Blizzard UI bindings.', nil, 'Safety:')
324 365
325 366
326 KeyBinderUnbindButton:SetScript('OnClick', function() 367 KeyBinderUnbindButton:SetScript('OnClick', function()
327 if kb.saveTarget then 368 if kb.saveTarget then
328 kb.UnbindSlot(kb.saveTarget) 369 kb.UnbindSlot(kb.saveTarget)