Nenue@6: -- KrakTool Nenue@6: -- UI.lua Nenue@6: -- Created: 7/28/2016 3:39 PM Nenue@6: -- %file-revision% Nenue@6: -- Nenue@6: Nenue@6: local kb, print = LibStub("LibKraken").register(KeyBinder, 'KeySlot') Nenue@6: local BINDS_PER_ROW = 2 Nenue@6: local BUTTON_HSPACING = 128 Nenue@6: local BUTTON_SPACING = 4 Nenue@6: local BUTTON_PADDING = 12 Nenue@6: local BINDING_TYPE_SPECIALIZATION = 3 Nenue@6: local BINDING_TYPE_CHARACTER = 2 Nenue@6: local BINDING_TYPE_GLOBAL = 1 Nenue@6: local KEY_BUTTON_SIZE = 48 Nenue@6: local MIN_BIND_SLOTS = 32 Nenue@6: local TAB_OFFSET = 12 Nenue@6: local TAB_HEIGHT = 40 Nenue@6: local TAB_SPACING = 2 Nenue@6: local BORDER_UNASSIGNED = {0.2,0.2,0.2,1 } Nenue@6: local BORDER_ASSIGNED = {0.5,0.5,0.5,1 } Nenue@6: local BORDER_DYNAMIC = {1,1,0,1} Nenue@6: local BORDER_PENDING = {1,0.5,0,1 } Nenue@6: Nenue@6: local BUTTON_HEADERS = { Nenue@6: ['spell'] = SPELLS, Nenue@6: ['macro'] = MACRO, Nenue@6: ['petaction'] = PET, Nenue@6: ['mount'] = MOUNT, Nenue@6: ['battlepet'] = BATTLEPET, Nenue@6: Nenue@6: Nenue@6: [5] = PROFESSIONS_FIRST_AID, Nenue@6: [7] = PROFESSIONS_COOKING, Nenue@6: [9] = PROFESSIONS_FISHING, Nenue@6: [10] = PROFESSIONS_ARCHAEOLOGY, Nenue@6: Nenue@6: } Nenue@6: Nenue@6: local BINDING_SCHEME_COLOR = { Nenue@6: [BINDING_TYPE_GLOBAL] = {0,.125,.5,.5}, Nenue@6: [BINDING_TYPE_CHARACTER] = {0,0.25,0,0.5}, Nenue@6: [BINDING_TYPE_SPECIALIZATION] = {.25,0,0,0.5}, Nenue@6: } Nenue@6: local BINDING_SCHEME_VERTEX = { Nenue@6: [BINDING_TYPE_GLOBAL] = {0,.5,1,1}, Nenue@6: [BINDING_TYPE_CHARACTER] = {0,1,0,1}, Nenue@6: [BINDING_TYPE_SPECIALIZATION] = {1,1,1,1}, Nenue@6: } Nenue@6: local BINDING_SCHEME_TEXT = { Nenue@6: [BINDING_TYPE_SPECIALIZATION] = {0, 1, 1}, Nenue@6: [BINDING_TYPE_CHARACTER] = {0, 1, 0}, Nenue@6: [BINDING_TYPE_GLOBAL] = {0, 1, 1} Nenue@6: } Nenue@6: Nenue@6: local restingAlpha = 0.7 Nenue@6: local fadeTime, fadeDelay = .30, 0.15 Nenue@6: local numButtons = BINDS_PER_ROW * 8 Nenue@6: local saveButton Nenue@6: local KeyButton_OnKeyDown = function(self, key) Nenue@6: kb.StoreBinding(self, key) Nenue@6: end Nenue@6: local KeyButton_OnClick = function(self, click) Nenue@6: print(self:GetName(), 'OnMouseDown', click) Nenue@6: if click == 'LeftButton' then Nenue@6: kb.DropToSlot(self) Nenue@6: elseif click == 'RightButton' then Nenue@6: kb.ReleaseSlot(self) Nenue@6: else Nenue@6: kb.StoreBinding(self, click:upper()) Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: local KeyButton_OnDragStart = function(self) Nenue@6: kb.PickupSlot(self) Nenue@6: end Nenue@6: Nenue@6: local KeyButton_OnReceiveDrag = function(self, ...) Nenue@6: kb.DropToSlot(self) Nenue@6: end Nenue@6: Nenue@6: Nenue@6: local KeyBinder_OnUpdate = function(self, elapsed) Nenue@6: self.elapsed = self.elapsed + elapsed Nenue@6: self.throttle = self.throttle + elapsed Nenue@6: Nenue@6: if (self.throttle >= 0.032) then Nenue@6: self.throttle = 0 Nenue@6: else Nenue@6: return Nenue@6: end Nenue@6: Nenue@6: local progress = 1 Nenue@6: if self.elapsed > fadeTime then Nenue@6: self.elapsed = 0 Nenue@6: self.fadeStep = 0 Nenue@6: --self.statustext:SetText(nil) Nenue@6: --self.bindingstext:SetText(nil) Nenue@6: self:SetScript('OnUpdate', nil) Nenue@6: else Nenue@6: if self.elapsed < fadeDelay then Nenue@6: progress = 0 Nenue@6: else Nenue@6: self.fadeStep = self.fadeStep + 1 Nenue@6: progress = (self.elapsed - fadeDelay) /(fadeTime - fadeDelay) Nenue@6: end Nenue@6: --print(self.fadeStep, format('%.02f/%.02f', (self.elapsed - fadeDelay) ,(fadeTime - fadeDelay)) , progress) Nenue@6: end Nenue@6: Nenue@6: local alpha = 1 - progress * (1- restingAlpha) Nenue@6: self.statustext:SetAlpha(alpha) Nenue@6: self.bindingstext:SetAlpha(alpha) Nenue@6: end Nenue@6: Nenue@6: local KeyButton_OnUpdate = function(self) Nenue@6: if not self.command then Nenue@6: return Nenue@6: end Nenue@6: Nenue@6: if self:IsMouseOver() then Nenue@6: kb.elapsed = 0 Nenue@6: if not self.active then Nenue@6: -- only set this handler when the button is activated/mouseOver Nenue@6: self.active = true Nenue@6: self:SetScript('OnKeyDown', KeyButton_OnKeyDown) Nenue@6: Nenue@6: kb.statustext:SetText(self.statusText .. ': '..self.actionName) Nenue@6: kb.bindingstext:SetText(self.bindingText) Nenue@6: kb.fadeStep = 0 Nenue@6: kb.throttle = 0 Nenue@6: kb:SetScript('OnUpdate', KeyBinder_OnUpdate) Nenue@6: Nenue@6: end Nenue@6: else Nenue@6: if self.active then Nenue@6: self.active = nil Nenue@6: self:SetScript('OnKeyDown', nil) Nenue@6: end Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: local KeyBinder_OnMouseWheel = function(self, delta) Nenue@6: print(self, delta, self.scrollOffset, (self.scrollOffset <= 0)) Nenue@6: Nenue@6: Nenue@6: if IsControlKeyDown() then Nenue@6: KEY_BUTTON_SIZE = KEY_BUTTON_SIZE - delta Nenue@6: else Nenue@6: Nenue@6: Nenue@6: if (delta > 0) and (self.scrollOffset <= 0) then Nenue@6: return Nenue@6: elseif delta < 0 and kb.scrollOffset >= 42 then Nenue@6: return Nenue@6: end Nenue@6: kb.scrollOffset = ceil(kb.scrollOffset - (delta * BINDS_PER_ROW)) Nenue@6: end Nenue@6: Nenue@6: kb.ui(true) Nenue@6: end Nenue@6: Nenue@6: local KeyBinder_OnHide = function() Nenue@6: KeyBinderImportLog:Hide() Nenue@6: end Nenue@6: Nenue@6: local CloseButton_OnClick = function() Nenue@6: db.showUI = false Nenue@6: kb:Hide() Nenue@6: end Nenue@6: local CancelButton_OnClick = function() Nenue@6: kb.RevertBindings() Nenue@6: end Nenue@6: local SaveButton_OnClick = function() Nenue@6: kb.ConfirmBindings() Nenue@6: end Nenue@6: Nenue@6: local KeyBinder_Initialize = function() Nenue@6: Nenue@6: Nenue@6: kb.scrollOffset = 0 Nenue@6: kb.tabAnchor = {'TOPLEFT', kb.profilebg, 'TOPLEFT', BUTTON_PADDING, -BUTTON_SPACING} Nenue@6: kb.tabGrowth = {'TOPLEFT', nil,'TOPRIGHT', BUTTON_SPACING, 0} Nenue@6: kb.tabSize = {TAB_HEIGHT, TAB_HEIGHT } Nenue@6: kb.UIPanelAnchor = {'TOPLEFT', kb.sourcesbg, 'TOPLEFT', BUTTON_PADDING, -BUTTON_SPACING} Nenue@6: kb.UIPanelGrowth = {'TOPLEFT', nil, 'BOTTOMLEFT', 0, -2 } Nenue@6: kb.UIPanelSize = {84, 32 } Nenue@6: kb.UIPanelIcon = {24, 32, 'LEFT', -12, 0} Nenue@6: kb.controlsAnchor = {'BOTTOMLEFT', kb.footer, BUTTON_PADDING, BUTTON_PADDING } Nenue@6: kb.controlsGrowth = {'BOTTOMLEFT', nil, 'BOTTOMRIGHT', BUTTON_SPACING, 0} Nenue@6: Nenue@6: -- order of these is important Nenue@6: kb:tab('KeyBinderGlobalTab', Nenue@6: kb.configTitle[BINDING_TYPE_GLOBAL] .. '\n' .. kb.configDescription[BINDING_TYPE_GLOBAL], "Interface\\ICONS\\item_azereansphere", {0.15,.85,.15,.85}) Nenue@6: kb:tab('KeyBinderCharacterTab', Nenue@6: kb.configHeaders[BINDING_TYPE_CHARACTER] .. '\n' .. kb.configDescription[BINDING_TYPE_CHARACTER], nil) Nenue@6: kb:tab('KeyBinderSpecTab', Nenue@6: kb.configHeaders[BINDING_TYPE_SPECIALIZATION] .. '\n' .. kb.configDescription[BINDING_TYPE_SPECIALIZATION], kb.specInfo.texture) Nenue@6: KeyBinderCharacterTab.icon:SetTexCoord(0.15,.85,.15,.85) Nenue@6: Nenue@6: Nenue@6: Nenue@6: --portraitLayers[1] = KeyBinderCharacterTab.icon Nenue@6: Nenue@6: saveButton = kb:button('KeyBinderSaveButton', 'Save', 'Commit all changes.', SaveButton_OnClick) Nenue@6: --restoreButton = kb:button('KeyBinderRestoreButton', 'Discard', 'Revert all changes.', CancelButton_OnClick) Nenue@6: --clearButton = kb:button('KeyBinderClearButton', 'Clear Page', 'Release all buttons.', ResetButton_OnClick) Nenue@6: Nenue@6: kb:uibutton( Nenue@6: 'KeyBinderSpellBookButton', 'SpellBook', nil, Nenue@6: function() ToggleSpellBook(BOOKTYPE_SPELL) end, Nenue@6: "Interface\\BUTTONS\\UI-MicroButton-Spellbook-Up", {0, 1, .4, 1}) Nenue@6: kb:uibutton( Nenue@6: 'KeyBinderTalentFrameButton', TALENTS, SPECIALIZATION, Nenue@6: function() ToggleTalentFrame() end, Nenue@6: "Interface\\BUTTONS\\UI-MicroButton-Talents-Up", {0, 1, .4, 1}) Nenue@6: Nenue@6: kb:uibutton( Nenue@6: 'KeyBinderMacroFrameButton', 'Macros', nil, Nenue@6: function() if MacroFrame and MacroFrame:IsVisible() then Nenue@6: HideUIPanel(MacroFrame) Nenue@6: else Nenue@6: ShowMacroFrame() end Nenue@6: end, Nenue@6: "Interface\\BUTTONS\\UI-MicroButton-Help-Up", {0, 1, .4, 1}) Nenue@6: Nenue@6: kb:uibutton( Nenue@6: 'KeyBinderInventoryButton', 'Bags', nil, Nenue@6: function() OpenAllBags() end, Nenue@6: "Interface\\BUTTONS\\UI-MicroButtonCharacter-Up", {0, 1, .4, 1}) Nenue@6: Nenue@6: Nenue@6: Nenue@6: kb.info:SetPoint('TOPLEFT', kb.UIPanels[1], 'BOTTOMLEFT', 0, -BUTTON_SPACING) Nenue@6: HEADER_OFFSET = kb.UIPanels[1]:GetHeight() + BUTTON_PADDING Nenue@6: + kb.info:GetHeight() Nenue@6: FOOTER_OFFSET = saveButton:GetHeight() + BUTTON_PADDING Nenue@6: Nenue@6: kb:SetScript('OnHide', KeyBinder_OnHide) Nenue@6: kb:SetScript('OnMouseWheel', KeyBinder_OnMouseWheel) Nenue@6: kb.CloseButton:SetScript('OnClick', CloseButton_OnClick) Nenue@6: Nenue@6: end Nenue@6: Nenue@6: --- Resets button command Nenue@6: kb.ReleaseSlot = function(self) Nenue@6: local slot = self:GetID() Nenue@6: Nenue@6: Nenue@6: if kb.currentProfile.buttons[slot] then Nenue@6: kb.currentProfile.buttons[slot] = nil Nenue@6: end Nenue@6: if self.command then Nenue@6: kb.currentProfile.commands[self.command] = nil Nenue@6: end Nenue@6: if self.actionType == 'spell' and IsTalentSpell(self.actionName) then Nenue@6: if kb.currentProfile.talents[self.actionID] then Nenue@6: kb.currentProfile.talents[self.actionID] = nil Nenue@6: end Nenue@6: end Nenue@6: local droppedKeys = {} Nenue@6: Nenue@6: -- doing removal in second loop to avoid possible iterator shenanigans Nenue@6: for k,v in pairs(kb.currentProfile.bindings) do Nenue@6: if v == self.command then Nenue@6: tinsert(droppedKeys, k) Nenue@6: end Nenue@6: end Nenue@6: if #droppedKeys >=1 then Nenue@6: for i, k in ipairs(droppedKeys) do Nenue@6: kb.currentProfile.bindings[k] = nil Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: self.isAvailable = nil Nenue@6: self.isDynamic = nil Nenue@6: self.bindingText = nil Nenue@6: self.statusText = nil Nenue@6: self.command = nil Nenue@6: self.actionType = nil Nenue@6: self.actionID = nil Nenue@6: self.actionName = nil Nenue@6: self.pickupSlot = nil Nenue@6: self.pickupBook = nil Nenue@6: self.macroName = nil Nenue@6: self.profile = nil Nenue@6: self.icon:SetTexture(nil) Nenue@6: self.border:SetColorTexture(unpack(BORDER_UNASSIGNED)) Nenue@6: self:EnableKeyboard(false) Nenue@6: self:SetScript('OnKeyDown', nil) Nenue@6: end Nenue@6: Nenue@6: kb.SetSlot = function(self, command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook) Nenue@6: local slot = self:GetID() Nenue@6: local isDynamic, isAvailable Nenue@6: Nenue@6: print('|cFFFFFF00SetSlot|r:', self:GetID()) Nenue@6: if command then Nenue@6: Nenue@6: if actionType == 'spell' then Nenue@6: local professionNum, spellNum = command:match("profession_(%d)_(%d)") Nenue@6: Nenue@6: if (professionNum and spellNum) then Nenue@6: isDynamic = 'profession' Nenue@6: local cacheInfo = kb.ProfessionCache[professionNum..'_'..spellNum] Nenue@6: if cacheInfo then Nenue@6: isAvailable = true Nenue@6: name = cacheInfo.spellName Nenue@6: icon = cacheInfo.icon Nenue@6: actionID = cacheInfo.spellID Nenue@6: self.profIndex = cacheInfo.profIndex Nenue@6: self.spellOffset = cacheInfo.spellOffset Nenue@6: end Nenue@6: print(' Special slot: |cFF00FFFFProfession|r', professionNum, spellNum, isDynamic, isAvailable) Nenue@6: Nenue@6: self.professionNum = tonumber(professionNum) Nenue@6: self.spellNum = tonumber(spellNum) Nenue@6: Nenue@6: else Nenue@6: if kb.TalentCache[actionID] then Nenue@6: isDynamic = 'talent' Nenue@6: print(' Special slot: |cFFBBFF00talent|r', name, isAvailable) Nenue@6: end Nenue@6: Nenue@6: isAvailable = GetSpellInfo(name) Nenue@6: end Nenue@6: actionID = name Nenue@6: elseif actionType == 'macro' then Nenue@6: if not actionID then Nenue@6: actionID = GetMacroIndexByName(name) Nenue@6: end Nenue@6: isAvailable = true Nenue@6: else Nenue@6: --- Journal selections Nenue@6: -- todo: consider using the deep end of blizzard action bar instead Nenue@6: if not actionID then Nenue@6: actionID = command:match("^KeyBinderMacro:(.+)") Nenue@6: end Nenue@6: isAvailable = true Nenue@6: end Nenue@6: Nenue@6: if isAvailable then Nenue@6: local oldCommand = command Nenue@6: macroName, macroText, command = kb.RegisterAction(actionType, actionID) Nenue@6: if oldCommand ~= command then Nenue@6: print('|cFFFF4400fixing command string', actionType, actionID, name) Nenue@6: kb.currentProfile.bound[oldCommand] = nil Nenue@6: kb.currentProfile.bound[command] = slot Nenue@6: for k,v in pairs(kb.currentProfile.bindings) do Nenue@6: if v == oldCommand then Nenue@6: kb.currentProfile.bindings[k] = command Nenue@6: end Nenue@6: end Nenue@6: end Nenue@6: kb.LoadBinding(command, name, icon, actionType, actionID, macroName, macroText) Nenue@6: end Nenue@6: Nenue@6: if actionType == 'petaction' then Nenue@6: self.pickupSlot = pickupSlot Nenue@6: self.pickupBook = pickupBook Nenue@6: else Nenue@6: self.pickupSlot = nil Nenue@6: self.pickupBook = nil Nenue@6: end Nenue@6: Nenue@6: actionID = actionID or 0 Nenue@6: self:EnableKeyboard(true) Nenue@6: print(' |cFF00FF00kb.currentProfile.buttons['..slot..'] |cFF00FFFF=|r |cFF00FFFF"'.. command.. '"|r |cFF00FF00"'.. name, '"|r |cFFFFFF00icon:'.. icon .. '|r |cFFFF8800"'.. actionType, '"|r |cFFFF0088id:'.. actionID ..'|r |cFF00FF00"'.. macroName .. '"|r') Nenue@6: kb.currentProfile.buttons[slot] = {command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook} Nenue@6: Nenue@6: -- Clean up conflicting entries for loaded button Nenue@6: local previous = kb.currentProfile.commands[command] Nenue@6: if previous ~= slot and kb.buttons[previous] then Nenue@6: kb.ReleaseSlot(kb.buttons[previous]) Nenue@6: end Nenue@6: kb.currentProfile.commands[command] = slot Nenue@6: end Nenue@6: Nenue@6: self.isAvailable = isAvailable Nenue@6: self.isDynamic = isDynamic Nenue@6: Nenue@6: self.macroText = macroText Nenue@6: self.macroName = macroName Nenue@6: self.actionType = actionType Nenue@6: self.actionID = actionID Nenue@6: self.actionName = name Nenue@6: self.command = command Nenue@6: self.icon:SetTexture(icon) Nenue@6: self.profile = kb.db.bindMode Nenue@6: self:RegisterForDrag('LeftButton') Nenue@6: end Nenue@6: Nenue@6: --- Retrieves button at index; creates said button and instates any stored parameters Nenue@6: local leftSlot, upSlot Nenue@6: local buttonsDepth = 0 Nenue@6: kb.GetSlot = function(index) Nenue@6: Nenue@6: local slot = index + kb.scrollOffset Nenue@6: Nenue@6: if not kb.buttons[index] then Nenue@6: local button = CreateFrame('CheckButton', 'KeyBinderSlot'..index, kb, 'KeyButton') Nenue@6: button:SetScript('OnClick', KeyButton_OnClick) Nenue@6: button:SetScript('OnUpdate', KeyButton_OnUpdate) Nenue@6: button:SetScript('OnDragStart', KeyButton_OnDragStart) Nenue@6: button:SetScript('OnReceiveDrag', KeyButton_OnReceiveDrag) Nenue@6: button:RegisterForClicks('AnyUp') Nenue@6: Nenue@6: Nenue@6: local newRow = (mod(index, BINDS_PER_ROW) == 1) Nenue@6: Nenue@6: if index == 1 then Nenue@6: button:SetPoint('TOPLEFT', kb.bg, 'TOPLEFT', BUTTON_PADDING, - BUTTON_PADDING) Nenue@6: upSlot = button Nenue@6: buttonsDepth = KEY_BUTTON_SIZE + BUTTON_PADDING * 2 Nenue@6: elseif newRow then Nenue@6: button:SetPoint('TOPLEFT', upSlot, 'BOTTOMLEFT', 0, -BUTTON_SPACING) Nenue@6: upSlot = button Nenue@6: buttonsDepth = buttonsDepth + KEY_BUTTON_SIZE + BUTTON_SPACING Nenue@6: else Nenue@6: button:SetPoint('TOPLEFT', leftSlot, 'TOPRIGHT', BUTTON_HSPACING, 0) Nenue@6: end Nenue@6: Nenue@6: button:SetSize(KEY_BUTTON_SIZE, KEY_BUTTON_SIZE) Nenue@6: button:Show() Nenue@6: kb.buttons[index] = button Nenue@6: leftSlot = button Nenue@6: end Nenue@6: return kb.buttons[index] Nenue@6: end Nenue@6: Nenue@6: --- Updates profile assignment and button contents Nenue@6: kb.UpdateSlot = function(self, force) Nenue@6: local slot = self:GetID() Nenue@6: Nenue@6: if force then Nenue@6: if kb.currentProfile.buttons[slot] then Nenue@6: kb.SetSlot(self, unpack(kb.currentProfile.buttons[slot])) Nenue@6: else Nenue@6: kb.ReleaseSlot(self) Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: if self.command then Nenue@6: print('['..slot..'] =', self.command, GetBindingKey(self.command)) Nenue@6: Nenue@6: if self.pending then Nenue@6: self.border:SetColorTexture(unpack(BORDER_PENDING)) Nenue@6: elseif self.isDynamic then Nenue@6: self.border:SetColorTexture(unpack(BORDER_DYNAMIC)) Nenue@6: else Nenue@6: self.border:SetColorTexture(unpack(BORDER_ASSIGNED)) Nenue@6: end Nenue@6: Nenue@6: if self.actionType == 'macro' then Nenue@6: self.macro:Show() Nenue@6: else Nenue@6: self.macro:Hide() Nenue@6: if self.actionType == 'spell' then Nenue@6: local dummy = GetSpellInfo(self.actionName) Nenue@6: if not dummy then Nenue@6: self.icon:SetDesaturated(true) Nenue@6: else Nenue@6: self.icon:SetDesaturated(false) Nenue@6: end Nenue@6: Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: if self.isDynamic then Nenue@6: print('|cFFFFBB00UpdateSlot|r: ', self.isDynamic, self.isAvailable, self.actionID) Nenue@6: end Nenue@6: Nenue@6: if self.isDynamic == 'profession' then Nenue@6: local profText = (self.spellNum == 1) and TRADE_SKILLS or (BUTTON_HEADERS[self.profIndex] or GetProfessionInfo(self.profIndex)) Nenue@6: if self.isAvailable then Nenue@6: print(self.profIndex, 'spnum', type(self.spellNum), (self.spellNum == 1)) Nenue@6: Nenue@6: self.statusText = '|cFFFFFF00'..profText..'|r' Nenue@6: self.bindingText = kb.BindingString(GetBindingKey(self.command)) Nenue@6: else Nenue@6: self.statusText = '|cFFFF4400'..profText..'|r' Nenue@6: self.actionName = '(need to train profession #'..self.profNum..')' Nenue@6: self.bindingText ='?' Nenue@6: end Nenue@6: elseif self.isDynamic == 'talent' then Nenue@6: Nenue@6: self.statusText = '|cFF00FFFF'.. TALENT .. '|r' Nenue@6: if self.isAvailable then Nenue@6: self.bindingText = kb.BindingString(GetBindingKey(self.command)) Nenue@6: else Nenue@6: if kb.inactiveTalentBindings[self.actionID] then Nenue@6: print(self.actionID, #kb.inactiveTalentBindings[self.actionID]) Nenue@6: self.bindingText= kb.BindingString(unpack(kb.inactiveTalentBindings[self.actionID])) Nenue@6: end Nenue@6: Nenue@6: end Nenue@6: else Nenue@6: self.statusText = '|cFF00FF00'.. (BUTTON_HEADERS[self.actionType] and BUTTON_HEADERS[self.actionType] or self.actionType) .. '|r' Nenue@6: self.bindingText = kb.BindingString(GetBindingKey(self.command)) Nenue@6: end Nenue@6: Nenue@6: local locked, layer = kb.IsCommandBound(self) Nenue@6: if locked then Nenue@6: self.icon:SetAlpha(0.5) Nenue@6: else Nenue@6: self.icon:SetAlpha(1) Nenue@6: end Nenue@6: Nenue@6: if self.actionType == 'spell' then Nenue@6: self.icon:SetTexture(GetSpellTexture(self.actionID)) Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: if not self.isAvailable then Nenue@6: self.bind:SetTextColor(0.7,0.7,0.7,1) Nenue@6: else Nenue@6: self.bind:SetTextColor(1,1,1,1) Nenue@6: end Nenue@6: Nenue@6: self.header:SetText(self.statusText) Nenue@6: self.bind:SetText(self.bindingText) Nenue@6: self.macro:SetText(self.macroName) Nenue@6: self.details:SetText(self.actionName) Nenue@6: end Nenue@6: Nenue@6: --- push current information into living UI Nenue@6: kb.ui = function(force) Nenue@6: for i, module in ipairs(kb.modules) do Nenue@6: if module.ui then Nenue@6: module.ui(force) Nenue@6: end Nenue@6: end Nenue@6: Nenue@6: if not kb.db.showUI then Nenue@6: print('---end of refresh') Nenue@6: return Nenue@6: end Nenue@6: if not kb.loaded then Nenue@6: KeyBinder_Initialize() Nenue@6: kb.loaded = true Nenue@6: end Nenue@6: for i = 1, numButtons do Nenue@6: local button = kb.GetSlot(i) Nenue@6: button:SetID(i+kb.scrollOffset) Nenue@6: kb.UpdateSlot(button, force) Nenue@6: end Nenue@6: Nenue@6: if kb.bindsCommitted then Nenue@6: KeyBinderSaveButton:Disable() Nenue@6: --KeyBinderRestoreButton:Disable() Nenue@6: else Nenue@6: KeyBinderSaveButton:Enable() Nenue@6: --KeyBinderRestoreButton:Enable() Nenue@6: end Nenue@6: Nenue@6: --- Frame Sizing Nenue@6: kb.profilebg:SetHeight(kb.tabSize[2] + BUTTON_PADDING * 2 + kb.profiletext:GetStringHeight()) Nenue@6: Nenue@6: kb.bg:SetWidth((KEY_BUTTON_SIZE + BUTTON_HSPACING + BUTTON_SPACING) * BINDS_PER_ROW + BUTTON_PADDING*2 - BUTTON_SPACING) Nenue@6: local numRows = numButtons/BINDS_PER_ROW Nenue@6: Nenue@6: kb.bg:SetHeight((KEY_BUTTON_SIZE + BUTTON_SPACING) * numRows + BUTTON_PADDING*2 - BUTTON_SPACING) Nenue@6: Nenue@6: kb:SetHeight(kb.headerbg:GetHeight() + kb.profilebg:GetHeight() + kb.bg:GetHeight() + kb.footer:GetHeight()) Nenue@6: kb:SetWidth((kb.sourcesbg:GetWidth() +(BINDS_PER_ROW * (KEY_BUTTON_SIZE + BUTTON_HSPACING) + (BINDS_PER_ROW - 1) * BUTTON_SPACING + BUTTON_PADDING * 2) )) Nenue@6: Nenue@6: kb.bg:SetColorTexture(unpack(BINDING_SCHEME_COLOR[kb.db.bindMode])) Nenue@6: for i, tab in ipairs(kb.tabButtons) do Nenue@6: local border = tab:GetNormalTexture() Nenue@6: local tabTexture = "Interface\\Buttons\\UI-Quickslot2" Nenue@6: local left, top, right, bottom = -12, 12, 13, -13 Nenue@6: if i == kb.db.bindMode then Nenue@6: tabTexture = "Interface\\Buttons\\CheckButtonGlow" Nenue@6: left, top, right, bottom = -14, 14, 15, -15 Nenue@6: tab.icon:SetDesaturated(false) Nenue@6: if tab.icon2 then tab.icon2:SetDesaturated(false) end Nenue@6: border:SetDesaturated(true) Nenue@6: border:SetVertexColor(1,1,1, 1) Nenue@6: else Nenue@6: tab.icon:SetDesaturated(true) Nenue@6: if tab.icon2 then tab.icon2:SetDesaturated(true) end Nenue@6: border:SetDesaturated(false) Nenue@6: border:SetVertexColor(1,1,1) Nenue@6: end Nenue@6: border:SetTexture(tabTexture) Nenue@6: border:SetPoint('TOPLEFT', tab, 'TOPLEFT', left, top) Nenue@6: border:SetPoint('BOTTOMRIGHT', tab, 'BOTTOMRIGHT', right, bottom) Nenue@6: end Nenue@6: Nenue@6: KeyBinderSpecTab.icon:SetTexture(kb.specInfo.texture) Nenue@6: Nenue@6: kb.profiletext:SetText(kb.configHeaders[kb.db.bindMode]) Nenue@6: print(kb.db.bindMode, kb.configHeaders[kb.db.bindMode], kb:GetSize()) Nenue@6: print(kb:GetPoint(1)) Nenue@6: Nenue@6: kb:Show() Nenue@6: Nenue@6: -- Reset this so talent cache can be rebuilt Nenue@6: kb.talentsPushed = nil Nenue@6: end Nenue@6: Nenue@6: kb.AcceptAssignment = function(self, ...) Nenue@6: local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] Nenue@6: local source = loadedProfiles[popup.oldProfile] Nenue@6: kb.SetSlot(popup.slot, unpack(popup.args)) Nenue@6: kb.UpdateSlot(popup.slot) Nenue@6: kb:SetScript('OnMouseWheel', KeyBinder_OnMouseWheel) -- re-enable scrolling Nenue@6: ClearCursor() Nenue@6: ResetCursor() Nenue@6: end Nenue@6: Nenue@6: Nenue@6: --- Add to blizzard interfaces Nenue@6: StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] = { Nenue@6: text = "Confirm moving an assigned command.", Nenue@6: button1 = OKAY, Nenue@6: button2 = CANCEL, Nenue@6: timeout = 0, Nenue@6: whileDead = 1, Nenue@6: showAlert = 1, Nenue@6: OnAccept = kb.AcceptAssignment, Nenue@6: OnCancel = function() kb:SetScript('OnMouseWheel', KeyBinder_OnMouseWheel) end Nenue@6: }