From ffe82599f6b90ce91b1865369fc6c25989a5b7e5 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Fri, 14 Jan 2022 16:42:29 -0500 Subject: [PATCH] Add controller hotkey display support --- eid_bagofcrafting.lua | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/eid_bagofcrafting.lua b/eid_bagofcrafting.lua index 3a4c289d..7b30cead 100644 --- a/eid_bagofcrafting.lua +++ b/eid_bagofcrafting.lua @@ -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