From 4094e9601887257d5749e77f84a0363e9dea7cb5 Mon Sep 17 00:00:00 2001 From: Alana Gilston Date: Mon, 2 Aug 2021 00:06:50 -0700 Subject: [PATCH] UI Expansion: Allows rearranging tooltip icon bar, center aligning icon bar --- .../MWSE/mods/UI Expansion/main.lua | 2 ++ .../MWSE/mods/UI Expansion/mcm.lua | 21 ++++++++++++ .../MWSE/mods/UI Expansion/tooltip.lua | 34 ++++++++++++++++--- .../MWSE/mods/UI Expansion/translations.lua | 5 +++ 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/User Interface Expansion/MWSE/mods/UI Expansion/main.lua b/User Interface Expansion/MWSE/mods/UI Expansion/main.lua index 8db3a22..9677dc8 100644 --- a/User Interface Expansion/MWSE/mods/UI Expansion/main.lua +++ b/User Interface Expansion/MWSE/mods/UI Expansion/main.lua @@ -53,6 +53,8 @@ local defaultConfig = { tooltip = true, training = true, }, + iconBarLocation = "Bottom", + iconBarCenterAlign = false, } local config = mwse.loadConfig("UI Expansion", defaultConfig) diff --git a/User Interface Expansion/MWSE/mods/UI Expansion/mcm.lua b/User Interface Expansion/MWSE/mods/UI Expansion/mcm.lua index b3c3530..24a41b4 100644 --- a/User Interface Expansion/MWSE/mods/UI Expansion/mcm.lua +++ b/User Interface Expansion/MWSE/mods/UI Expansion/mcm.lua @@ -72,6 +72,27 @@ local function registerModConfig() description = common.dictionary.configRatioDisplayDescription, variable = mwse.mcm.createTableVariable({ id = "displayRatio", table = common.config }), }) + + -- Center-align icon bar + category:createOnOffButton({ + label = common.dictionary.configIconBarCenterAlign, + description = common.dictionary.configIconBarCenterAlignDescription, + variable = mwse.mcm.createTableVariable({ id = "iconBarCenterAlign", table = common.config }) + }) + + -- Icon bar location + category:createDropdown({ + label = common.dictionary.configIconBarLocation, + description = common.dictionary.configIconBarLocationDescription, + options = { + { label = common.dictionary.configIconBarLocationOptions[1], value = "Top" }, + { label = common.dictionary.configIconBarLocationOptions[2], value = "Below item name" }, + { label = common.dictionary.configIconBarLocationOptions[3], value = "Above enchantments" }, + { label = common.dictionary.configIconBarLocationOptions[4], value = "Above flavor text" }, + { label = common.dictionary.configIconBarLocationOptions[5], value = "Bottom" }, + }, + variable = mwse.mcm.createTableVariable({ id = "iconBarLocation", table = common.config }), + }) end -- Category: Search & Filtering diff --git a/User Interface Expansion/MWSE/mods/UI Expansion/tooltip.lua b/User Interface Expansion/MWSE/mods/UI Expansion/tooltip.lua index aace5bb..943f543 100644 --- a/User Interface Expansion/MWSE/mods/UI Expansion/tooltip.lua +++ b/User Interface Expansion/MWSE/mods/UI Expansion/tooltip.lua @@ -330,7 +330,12 @@ local function extraTooltipEarly(e) container.autoHeight = true container.paddingAllSides = 2 container.paddingTop = 4 - container.childAlignX = 1.0 + + if common.config.iconBarCenterAlign then + container.childAlignX = 0.5 + else + container.childAlignX = 1.0 + end -- Value local valueBlock = container:createBlock{ id = GUI_ID_TooltipIconGoldBlock } @@ -422,11 +427,32 @@ local function extraTooltipLate(e) end end - -- Now, we'll make sure our icon bar is in the position we want (currently the very bottom). - -- TODO: add MCM option to set the position of the iconbar. Top, above enchants, above flavortext, bottom. + -- Now, we'll make sure our icon bar is in the position we want. for i = #children, 1, -1 do if children[i].id == GUI_ID_TooltipIconBar then - element:reorderChildren(#children, i - 1, 1) + if common.config.iconBarLocation == "Top" then + element:reorderChildren(0, i - 1, 1) + + elseif common.config.iconBarLocation == "Below item name" then + element:reorderChildren(1, i - 1, 1) + + elseif common.config.iconBarLocation == "Above enchantments" then + local enchantmentDivider = element:findChild(GUI_ID_TooltipEnchantmentDivider) + + if enchantmentDivider == nil then + enchantmentDivider = element:findChild("HelpMenu_castType") + end + + element:reorderChildren(enchantmentDivider, i - 1, 1) + + elseif common.config.iconBarLocation == "Above flavor text" then + local extraDivider = element:findChild(GUI_ID_TooltipExtraDivider) + element:reorderChildren(extraDivider, i - 1, 1) + + elseif common.config.iconBarLocation == "Bottom" then + element:reorderChildren(#children, i - 1, 1) + end + break end end diff --git a/User Interface Expansion/MWSE/mods/UI Expansion/translations.lua b/User Interface Expansion/MWSE/mods/UI Expansion/translations.lua index 92f177b..18a785d 100644 --- a/User Interface Expansion/MWSE/mods/UI Expansion/translations.lua +++ b/User Interface Expansion/MWSE/mods/UI Expansion/translations.lua @@ -59,6 +59,11 @@ return { configDisplayRestTargetHourDescription = "When enabled, the hour to wait or rest until will be displayed after the number of hours to wait or rest.", configFilterButtons = "Use verbose buttons instead of icons for inventory filtering?", configFilterButtonsDescription = "When enabled, the vanilla-style filters are given on the inventory menus. When disabled, compact icons will be used instead. This can be useful when playing with narrower menu windows.", + configIconBarCenterAlign = "Center align tooltip icon bar?", + configIconBarCenterAlignDescription = "When enabled, an item's tooltip icon bar with its value, weight, and value/weight ratio will be center-aligned. When disabled, the icon bar will be right-aligned.", + configIconBarLocation = "Tooltip icon bar location:", + configIconBarLocationDescription = "The location of an item's icon bar containing its gold value, weight, and value/weight ratio.", + configIconBarLocationOptions = { "Top", "Below item name", "Above enchantments", "Above flavor text", "Bottom" }, configMapSwitchKey = "Keybind for map mode switching.", configMapSwitchKeyDescription = "This key combination will switch from map between world and local modes.", configMaxWaitDays = "Maximum wait days:",