From c27692552f7834b0c1fbb4aeca51bb6d58635c3e Mon Sep 17 00:00:00 2001 From: Buurazu Date: Fri, 19 Nov 2021 02:09:46 -0500 Subject: [PATCH] add new hotkey settings --- mod_config_menu.lua | 55 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/mod_config_menu.lua b/mod_config_menu.lua index 777c0f8e..922f90ca 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -65,6 +65,49 @@ function EID:buildColorArray() table.sort(colorNameArray) end +function EID:AddHotkeySetting(category, isController, optionName, displayText, infoText) + local optionType = ModConfigMenu.OptionType.KEYBIND_KEYBOARD + local hotkeyToString = InputHelper.KeyboardToString + local deviceString = "keyboard" + local backString = "ESCAPE" + if isController then + optionType = ModConfigMenu.OptionType.KEYBIND_CONTROLLER + hotkeyToString = InputHelper.ControllerToString + deviceString = "controller" + backString = "BACK" + end + MCM.AddSetting( + "EID", + category, + { + Type = optionType, + CurrentSetting = function() + return EID.Config[optionName] + end, + Display = function() + local key = "None" + if (hotkeyToString[EID.Config[optionName]]) then key = hotkeyToString[EID.Config[optionName]] end + return displayText .. ": " .. key + end, + OnChange = function(currentNum) + EID.Config[optionName] = currentNum or -1 + end, + PopupGfx = ModConfigMenu.PopupGfx.WIDE_SMALL, + PopupWidth = 280, + Popup = function() + local currentValue = EID.Config[optionName] + local keepSettingString = "" + if currentValue > -1 then + local currentSettingString = hotkeyToString[currentValue] + keepSettingString = "This setting is currently set to \"" .. currentSettingString .. "\".$newlinePress this button to keep it unchanged.$newline$newline" + end + return "Press a button on your "..deviceString.." to change this setting.$newline$newline" .. keepSettingString .. "Press "..backString.." to go back and clear this setting." + end, + Info = {infoText} + } + ) +end + if MCMLoaded then function AnIndexOf(t, val) for k, v in ipairs(t) do @@ -133,7 +176,11 @@ if MCMLoaded then Info = {"If translated names are available,","this changes how item names are displayed."} } ) - + + -- Hide Key + EID:AddHotkeySetting("General", false, "HideKey", "Toggle (Keyboard)", "Press this key to toggle the description display") + EID:AddHotkeySetting("General", true, "HideButton", "Toggle (Controller)", "Press this button to toggle the description display (Left Stick or Right Stick recommended; most other buttons will not work)") + MCM.AddSpace("EID", "General") -- Position X @@ -1106,6 +1153,12 @@ if MCMLoaded then } ) + EID:AddHotkeySetting("Crafting", false, "CraftingHideKey", "Toggle (Keyboard)", "Press this key to toggle the crafting display, allowing you to check descriptions of items/pickups on the floor") + EID:AddHotkeySetting("Crafting", true, "CraftingHideButton", "Display Toggle (Controller)", "Press this button to toggle the crafting display (Left Stick or Right Stick recommended; most other buttons will not work)") + + EID:AddHotkeySetting("Crafting", false, "CraftingResultKey", "Result Info Toggle (Keyboard)", "Press this key to toggle showing the description of the item ready to be crafted") + EID:AddHotkeySetting("Crafting", true, "CraftingResultButton", "Result Info Toggle (Controller)", "Press this key to toggle showing the description of the item ready to be crafted (Left Stick or Right Stick recommended; most other buttons will not work)") + MCM.AddSpace("EID", "Crafting") --------Clear Floor--------- MCM.AddSetting(