|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
end end EVENT_MANAGER:RegisterForEvent("KeybindingsManager", EVENT_KEYBINDINGS_LOADED, function(eventCode, ...) self:OnKeybindingsLoaded(...) end) EVENT_MANAGER:RegisterForEvent("KeybindingsManager", EVENT_KEYBINDING_SET, function(eventCode, ...) self:OnKeybindingSet(...) end) EVENT_MANAGER:RegisterForEvent("KeybindingsManager", EVENT_KEYBINDING_CLEARED, function(eventCode, ...) self:OnKeybindingCleared(...) end) EVENT_MANAGER:RegisterForEvent("KeybindingsManager", EVENT_INPUT_LANGUAGE_CHANGED, function(eventCode, ...) self:OnInputLanguageChanged(...) end)endendendendend local categoryList = {} for categoryIndex = 1, numCategories do local actionList = {} for actionIndex = 1, numActions do if not isHidden then if localizedActionName ~= "" then { actionName = actionName, localizedActionName = localizedActionName, isRebindable = isRebindable, layerIndex = layerIndex, categoryIndex = categoryIndex, actionIndex = actionIndex, } end end end if #actionList > 0 then local categoryData = ZO_EntryData:New({ layerIndex = layerIndex, categoryIndex = categoryIndex, categoryName = categoryName, actions = actionList }) end end if #categoryList > 0 then local layerData = ZO_EntryData:New({ layerIndex = layerIndex, layerName = layerName, categories = categoryList }) end endendend if key ~= KEY_LWINDOWS and key ~= KEY_RWINDOWS then return true end return falseendfunction KeybindingsManager:GetNumChangedSavedKeybindings(layerIndex, categoryIndex, actionIndex, bindingIndex, pendingKey, pendingMod1, pendingMod2, pendingMod3, pendingMod4) local numChangedSavedKeybinds = 0 -- first check how changing the current keybind to the pending keybind will change what's saved local currentKey, currentMod1, currentMod2, currentMod3, currentMod4 = GetActionBindingInfo(layerIndex, categoryIndex, actionIndex, bindingIndex) local defaultKey, defaultMod1, defaultMod2, defaultMod3, defaultMod4 = GetActionDefaultBindingInfo(layerIndex, categoryIndex, actionIndex, bindingIndex) local isCurrentDefault = currentKey == defaultKey and currentMod1 == defaultMod1 and currentMod2 == defaultMod2 and currentMod3 == defaultMod3 and currentMod4 == defaultMod4 local isPendingDefault = pendingKey == defaultKey and pendingMod1 == defaultMod1 and pendingMod2 == defaultMod2 and pendingMod3 == defaultMod3 and pendingMod4 == defaultMod4 if isCurrentDefault and not isPendingDefault then -- current key was default, and setting it to pending will cause a save numChangedSavedKeybinds = numChangedSavedKeybinds + 1 elseif not isCurrentDefault and isPendingDefault then -- current key is not defualt, but pending key is, so we won't have to save it anymore numChangedSavedKeybinds = numChangedSavedKeybinds - 1 end -- then check if the pending key is already bound somewhere else and how unbinding it will affect what's saved local existingCategoryIndex, existingActionIndex, existingBindingIndex = GetBindingIndicesFromKeys(layerIndex, pendingKey, pendingMod1, pendingMod2, pendingMod3, pendingMod4) if existingCategoryIndex and existingActionIndex and existingBindingIndex and (existingCategoryIndex ~= categoryIndex or existingActionIndex ~= actionIndex or existingBindingIndex ~= bindingIndex) then local existingDefaultKey, existingDefaultMod1, existingDefaultMod2, existingDefaultMod3, existingDefaultMod4 = GetActionDefaultBindingInfo(layerIndex, existingCategoryIndex, existingActionIndex, existingBindingIndex) local isExistingDefault = pendingKey == existingDefaultKey and pendingMod1 == existingDefaultMod1 and pendingMod2 == existingDefaultMod2 and pendingMod3 == existingDefaultMod3 and pendingMod4 == existingDefaultMod4 if isExistingDefault then -- The pending key is already bound as the default of something else, so unbinding it will increase the number of saved binds numChangedSavedKeybinds = numChangedSavedKeybinds + 1 else local isDefaultUnbound = existingDefaultKey == KEY_INVALID if isDefaultUnbound then -- Unbinding the pending key from the existing will set it to not bound, which is the default, removing a save numChangedSavedKeybinds = numChangedSavedKeybinds - 1 end end end return numChangedSavedKeybindsendfunction KeybindingsManager:GetNumChangedSavedKeybindingsIfUnbound(layerIndex, categoryIndex, actionIndex, bindingIndex) return self:GetNumChangedSavedKeybindings(layerIndex, categoryIndex, actionIndex, bindingIndex, KEY_INVALID, KEY_INVALID, KEY_INVALID, KEY_INVALID, KEY_INVALID)endinternalassert(GetMaxBindingsPerAction() == 4, "Max bindings per action changes, update KeybindingsManager:GetBindTypeTextFromIndex") if bindingIndex == 1 then elseif bindingIndex == 2 then elseif bindingIndex == 3 then else endendendend |