Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Expansion: Allows rearranging tooltip icon bar, center aligning icon bar #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions User Interface Expansion/MWSE/mods/UI Expansion/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ local defaultConfig = {
tooltip = true,
training = true,
},
iconBarLocation = "Bottom",
iconBarCenterAlign = false,
}
local config = mwse.loadConfig("UI Expansion", defaultConfig)

Expand Down
21 changes: 21 additions & 0 deletions User Interface Expansion/MWSE/mods/UI Expansion/mcm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 30 additions & 4 deletions User Interface Expansion/MWSE/mods/UI Expansion/tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down