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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
return mod1 == modifierKeyToMatch
or mod2 == modifierKeyToMatch
or mod3 == modifierKeyToMatch
or mod4 == modifierKeyToMatch
end
if key == KEY_CTRL and ctrl then ctrl = false end
if key == KEY_ALT and alt then alt = false end
if key == KEY_SHIFT and shift then shift = false end
if key == KEY_COMMAND and command then command = false end
return keyId == key and bindingCtrl == ctrl and bindingAlt == alt and bindingShift == shift and bindingCommand == command
end
--[[
This function performs binding matching based on key inputs.
The checks are a little convoluted:
1. Base keys need to match
2. mod1, 2, 3 and 4 come in in some arbitrary order, so they have to get mapped properly to match the arguments that are passed to OnKeyDown
3. If the base keypress is a modifier key, the appropriate modifier needs to be turned off for this keypress; because bindings like Ctrl+Ctrl make no sense.
--]]
if layerIndex then
local keyId1 , mod1 , mod2 , mod3 , mod4 = GetActionBindingInfo ( layerIndex , categoryIndex , actionIndex , 1 )
local keyId2 , mod21 , mod22 , mod23 , mod24 = GetActionBindingInfo ( layerIndex , categoryIndex , actionIndex , 2 )
end
return false
end
if mouseIcon then
return mouseIcon , mouseWidth , mouseHeight
end
end
end
KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME = 1
KEYBIND_TEXT_OPTIONS_FULL_NAME = 2
KEYBIND_TEXT_OPTIONS_FULL_NAME_SEPARATE_MODS = 3
KEYBIND_TEXTURE_OPTIONS_NONE = 1
KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP = 2
end
if path then
end
return ""
end
do
local keyNameTable = { }
local EXPECTED_ICON_SIZE = 64
local DEFAULT_SCALE_PERCENT = 180
if textureOptions == KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP then
if path then
local widthPercent = ( width / EXPECTED_ICON_SIZE ) * ( textureWidthPercent or DEFAULT_SCALE_PERCENT ) ;
local heightPercent = ( height / EXPECTED_ICON_SIZE ) * ( textureHeightPercent or DEFAULT_SCALE_PERCENT ) ;
end
end
end
local function TranslateKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , textureWidthPercent , textureHeightPercent )
if key ~= KEY_INVALID then
textOptions = textOptions or KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME
textureOptions = textureOptions or KEYBIND_TEXTURE_OPTIONS_NONE
if mod1 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod1 , textureOptions , textureWidthPercent , textureHeightPercent ) ) end
if mod2 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod2 , textureOptions , textureWidthPercent , textureHeightPercent ) ) end
if mod3 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod3 , textureOptions , textureWidthPercent , textureHeightPercent ) ) end
if mod4 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod4 , textureOptions , textureWidthPercent , textureHeightPercent ) ) end
if textOptions == KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME and # keyNameTable > 0 then
end
table . insert ( keyNameTable , GetKeyOrTexture ( key , textureOptions , textureWidthPercent , textureHeightPercent ) )
if textOptions == KEYBIND_TEXT_OPTIONS_FULL_NAME_SEPARATE_MODS then
elseif textOptions == KEYBIND_TEXT_OPTIONS_FULL_NAME then
else
end
end
end
function ZO_Keybindings_GetBindingStringFromKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , textureWidthPercent , textureHeightPercent )
return TranslateKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , textureWidthPercent , textureHeightPercent )
end
function ZO_Keybindings_GetBindingStringFromAction ( actionName , textOptions , textureOptions , bindingIndex )
if layerIndex then
local key , mod1 , mod2 , mod3 , mod4 = GetActionBindingInfo ( layerIndex , categoryIndex , actionIndex , bindingIndex or 1 )
return ZO_Keybindings_GetBindingStringFromKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions )
end
return ""
end
-- Doesn't return the GetString(SI_ACTION_IS_NOT_BOUND) automatically, just nil if theres no binds
function ZO_Keybindings_GetHighestPriorityBindingStringFromAction ( actionName , textOptions , textureOptions , alwaysPreferGamepadMode )
local preferGamepadMode
if alwaysPreferGamepadMode == nil then
else
preferGamepadMode = alwaysPreferGamepadMode
end
local key , mod1 , mod2 , mod3 , mod4 = GetHighestPriorityActionBindingInfoFromName ( actionName , preferGamepadMode )
if key ~= KEY_INVALID then
return ZO_Keybindings_GetBindingStringFromKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions ) , key , mod1 , mod2 , mod3 , mod4
end
return nil
end
end
function ZO_Keybindings_RegisterLabelForBindingUpdate ( label , actionName , showUnbound , gamepadActionName , onChangedCallback , alwaysPreferGamepadMode )
local bindingText , key , mod1 , mod2 , mod3 , mod4
bindingText , key , mod1 , mod2 , mod3 , mod4 = ZO_Keybindings_GetHighestPriorityBindingStringFromAction ( gamepadActionName , KEYBIND_TEXT_OPTIONS_FULL_NAME , KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP , alwaysPreferGamepadMode )
end
if not bindingText or # bindingText == 0 then
bindingText , key , mod1 , mod2 , mod3 , mod4 = ZO_Keybindings_GetHighestPriorityBindingStringFromAction ( actionName , KEYBIND_TEXT_OPTIONS_FULL_NAME , KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP , alwaysPreferGamepadMode )
end
if showUnbound or showUnbound == nil then
else
bindingText = bindingText or ""
end
end
end
end
end
end
end
if localizedGamepadActionName ~= "" then
return localizedGamepadActionName
else
return localizedActionName
end
end |