Add controller hotkey display support

This commit is contained in:
Buurazu authored and GitHub committed 2022-01-14 16:42:29 -05:00
1 parent 15657e0b27
commit ffe82599f6
1 file changed
+25 -7
+25 -7
View File
@@ -715,23 +715,41 @@ for key,num in pairs(Keyboard) do
keyString = string.gsub(keyString, "_", " ")
HotkeyToString[num] = keyString
end
--convert controller enum to buttons
local ControllerToString = { [0] = "{{ButtonDLeft}}", "{{ButtonDRight}}", "{{ButtonDUp}}", "{{ButtonDDown}}",
"{{ButtonA}}", "{{ButtonB}}", "{{ButtonX}}", "{{ButtonY}}", "{{ButtonLB}}", "{{ButtonLT}}", "{{ButtonLStick}}",
"{{ButtonRB}}", "{{ButtonRT}}", "{{ButtonRStick}}", "{{ButtonSelect}}", "{{ButtonMenu}}" }
local function getHotkeyString()
local hotkeyString = ""
local hideDesc = EID:getDescriptionEntry("CraftingHideKey")
local previewDesc = EID:getDescriptionEntry("CraftingPreviewKey")
--we have a binding for a keyboard hide key
if HotkeyToString[EID.Config["CraftingHideKey"]] then
hotkeyString = hideDesc .. " " .. HotkeyToString[EID.Config["CraftingHideKey"]]
local controllerEnabled = EID.player.ControllerIndex > 0
local hideKey = HotkeyToString[EID.Config["CraftingHideKey"]]
local hideButton = controllerEnabled and ControllerToString[EID.Config["CraftingHideButton"]]
local previewKey = HotkeyToString[EID.Config["CraftingResultKey"]]
local previewButton = controllerEnabled and ControllerToString[EID.Config["CraftingResultButton"]]
if hideKey or hideButton then hotkeyString = hideDesc .. " " end
if hideKey and hideButton then
hotkeyString = hotkeyString .. hideKey .. "/" .. hideButton
else
hotkeyString = hotkeyString .. (hideKey or hideButton)
end
--we have a binding for a keyboard preview toggle key, and a full bag, and aren't on Preview Only mode
if #EID.BagItems >= 8 and EID.Config["BagOfCraftingDisplayMode"] ~= "Preview Only" and HotkeyToString[EID.Config["CraftingResultKey"]] then
if hotkeyString ~= "" then hotkeyString = hotkeyString .. ", " end
hotkeyString = hotkeyString .. previewDesc .. " " .. HotkeyToString[EID.Config["CraftingResultKey"]]
if #EID.BagItems >= 8 and EID.Config["BagOfCraftingDisplayMode"] ~= "Preview Only" then
if previewKey or previewButton then hotkeyString = hotkeyString .. ", " .. previewDesc .. " " end
if previewKey and previewButton then
hotkeyString = hotkeyString .. previewKey .. "/" .. previewButton
else
hotkeyString = hotkeyString .. (previewKey or previewButton)
end
end
if hotkeyString ~= "" then
hotkeyString = "!!! " .. hotkeyString .. "#"
end
return hotkeyString
end