Skip to content
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
Binary file added src/Assets/icon_flask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Assets/icon_jewel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions src/Classes/DropDownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ function DropDownClass:DropDownControl(anchor, rect, list, selFunc, tooltipText,
self.enableDroppedWidth = false
-- Set by the parent control. Activates the auto width of the box component.
self.enableChangeBoxWidth = false
-- Set by the parent control. Hides the detail text of the selected entry in the box component.
self.hideSelDetail = false
-- self.tag = "-"
return self
end
Expand Down Expand Up @@ -323,8 +325,10 @@ function DropDownClass:Draw(viewPort, noTooltip)
local selItem = self.list[self.selIndex]
if type(selItem) == "table" then
selLabel = selItem.label
selDetail = selItem.detail
selStrikethrough = selItem.strikethrough
if not self.hideSelDetail then
selDetail = selItem.detail
end
else
selLabel = selItem
end
Expand Down Expand Up @@ -379,7 +383,8 @@ function DropDownClass:Draw(viewPort, noTooltip)
end

-- draw dropdown items
SetViewport(x + 2, dropY + 2, scrollBar.enabled and width - 22 or width - 4, self.dropHeight)
local listWidth = scrollBar.enabled and width - 22 or width - 4
SetViewport(x + 2, dropY + 2, listWidth, self.dropHeight)
local dropIndex = 0
for index, listVal in ipairs(self.list) do
local searchInfo = self.searchInfos[index]
Expand Down Expand Up @@ -424,14 +429,14 @@ function DropDownClass:Draw(viewPort, noTooltip)
else
SetDrawColor(0, 0, 0)
end
DrawImage(nil, width - dx - 8 - 22, y, width - 4, lineHeight)
DrawImage(nil, listWidth - dx - 6, y, dx + 6, lineHeight)
-- highlight font color if hovered or selected
if index == self.hoverSel or index == self.selIndex then
SetDrawColor(1, 1, 1)
else
SetDrawColor(0.66, 0.66, 0.66)
end
DrawString(width - dx - 4 - 22, y, "LEFT", lineHeight, "VAR", detail)
DrawString(listWidth - dx - 2, y, "LEFT", lineHeight, "VAR", detail)
end
self:DrawSearchHighlights(label, searchInfo, 0, y, width - 4, lineHeight)
end
Expand Down
5 changes: 5 additions & 0 deletions src/Classes/ItemDBControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function ItemDBClass:ItemDBControl(anchor, rect, itemsTab, db, dbType)
self.itemsTab = itemsTab
self.db = db
self.dbType = dbType
self.reserveIconSpace = true
self.dragTargetList = { }
self.sortControl = {
NAME = { key = "name", dir = "ASCEND", func = function(a,b) return a:gsub("^The ","") < b:gsub("^The ","") end },
Expand Down Expand Up @@ -336,6 +337,10 @@ function ItemDBClass:GetRowValue(column, index, item)
end
end

function ItemDBClass:GetRowIcon(column, index, item)
return item and self.itemsTab:GetItemIcon(item)
end

function ItemDBClass:AddValueTooltip(tooltip, index, item)
if main.popups[1] then
tooltip:Clear()
Expand Down
5 changes: 5 additions & 0 deletions src/Classes/ItemListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function ItemListClass:ItemListControl(anchor, rect, itemsTab, forceTooltip)
self.itemsTab = itemsTab
self.defaultText = "^x7F7F7FThis is the list of items that have been added to this build.\nYou can add items to this list by dragging them from\none of the other lists, or by clicking 'Add to build' when\nviewing an item."
self.dragTargetList = { }
self.reserveIconSpace = true
self.controls.loadoutFilter = new("DropDownControl"):DropDownControl({"BOTTOMLEFT",self,"TOPLEFT"}, {0, -2, 110, 18}, nil, function()
self:UpdateList()
end)
Expand Down Expand Up @@ -265,6 +266,10 @@ function ItemListClass:GetRowValue(column, index, itemId)
end
end

function ItemListClass:GetRowIcon(column, index, itemId)
return self.itemsTab:GetItemIcon(self.itemsTab.items[itemId])
end

function ItemListClass:AddValueTooltip(tooltip, index, itemId)
if main.popups[1] then
tooltip:Clear()
Expand Down
23 changes: 21 additions & 2 deletions src/Classes/ItemSlotControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function ItemSlotClass:ItemSlotControl(anchor, x, y, itemsTab, slotName, slotLab
end
end
self.label = slotLabel or slotName
self.hideSelDetail = true
self.nodeId = nodeId
return self
end
Expand Down Expand Up @@ -96,7 +97,7 @@ function ItemSlotClass:Populate()
for _, item in pairs(self.itemsTab.items) do
if self.itemsTab:IsItemValidForSlot(item, self.slotName) then
t_insert(self.items, item.id)
t_insert(self.list, colorCodes[item.rarity]..item.name)
t_insert(self.list, { label = colorCodes[item.rarity]..item.name })
if item.id == self.selItemId then
self.selIndex = #self.list
end
Expand All @@ -122,6 +123,20 @@ function ItemSlotClass:Populate()
end
end

function ItemSlotClass:UpdateEquippedDetails()
local equipped = { }
for _, slot in ipairs(self.itemsTab.orderedSlots) do
if not slot.inactive then
equipped[slot.selItemId] = true
end
end
for index, entry in ipairs(self.list) do
if type(entry) == "table" then
entry.detail = equipped[self.items[index]] and "^8(equipped)" or nil
end
end
end

function ItemSlotClass:CanReceiveDrag(type, value)
return type == "Item" and self.itemsTab:IsItemValidForSlot(value, self.slotName)
end
Expand Down Expand Up @@ -168,7 +183,11 @@ function ItemSlotClass:OnKeyDown(key)
if mOverControl and mOverControl == self.controls.activate then
return mOverControl:OnKeyDown(key)
end
return self.DropDownControl:OnKeyDown(key)
local ret = self.DropDownControl:OnKeyDown(key)
if self.dropped then
self:UpdateEquippedDetails()
end
return ret
end

function ItemSlotClass:OnHoverKeyUp(key)
Expand Down
26 changes: 26 additions & 0 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ local buySimilar = require("Classes.CompareBuySimilar")
local addImplicit = require("Modules.AddImplicitPopup")
local gemTooltip = require("Classes.GemTooltip")

local itemTypeIcons = { }
for itemType, file in pairs({
["Weapon"] = "icon_weapon",
["Bow"] = "icon_bow",
["Quiver"] = "icon_quiver",
["Shield"] = "icon_shield",
["Helmet"] = "icon_helmet",
["Body Armour"] = "icon_body_armour",
["Gloves"] = "icon_gloves",
["Boots"] = "icon_boots",
["Amulet"] = "icon_amulet",
["Ring"] = "icon_ring_left",
["Belt"] = "icon_belt",
["Flask"] = "icon_flask",
["Tincture"] = "icon_flask",
["Jewel"] = "icon_jewel",
}) do
itemTypeIcons[itemType] = NewImageHandle()
itemTypeIcons[itemType]:Load("Assets/"..file..".png")
end

local rarityDropList = {
{ label = colorCodes.NORMAL.."Normal", rarity = "NORMAL" },
{ label = colorCodes.MAGIC.."Magic", rarity = "MAGIC" },
Expand Down Expand Up @@ -2598,6 +2619,11 @@ function ItemsTabClass:AddModComparisonTooltip(tooltip, mod, replaceImplicits)
self.build:AddStatComparesToTooltip(tooltip, outputBase, outputNew, "\nAdding this mod will give: ")
end

-- Returns the slot icon matching the item's type, if there is one
function ItemsTabClass:GetItemIcon(item)
return itemTypeIcons[item.type] or (item.base and item.base.weapon and itemTypeIcons["Weapon"])
end

-- Returns the first slot in which the given item is equipped
function ItemsTabClass:GetEquippedSlotForItem(item, activeOnly)
for _, slot in ipairs(self.orderedSlots) do
Expand Down
19 changes: 8 additions & 11 deletions src/Classes/ListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-- .label [Adds a label above the top left corner]
-- .dragTargetList [List of controls that can receive drag events from this list control]
-- .showRowSeparators [Shows separators between rows]
-- .reserveIconSpace [Indents text of rows without an icon so they align with rows that have one]
-- :GetRowValue(column, index, value) [Required; called to retrieve the text for the given column of the given list value]
-- :GetRowIcon(column, index, value) [Called to retrieve the icon for the given column of the given list value]
-- :AddValueTooltip(index, value) [Called to add the tooltip for the given list value]
Expand Down Expand Up @@ -225,13 +226,11 @@ function ListClass:Draw(viewPort, noTooltip)
local lineY = rowHeight * (index - 1) - scrollOffsetV + (self.colLabels and 18 or 0)
local value = list[index]
local text = self:GetRowValue(colIndex, index, value)
local icon = nil
if self.GetRowIcon then
icon = self:GetRowIcon(colIndex, index, value)
end
local icon = self.GetRowIcon and self:GetRowIcon(colIndex, index, value)
local textX = (icon or self.reserveIconSpace) and 18 or 0
local textWidth = DrawStringWidth(textHeight, colFont, text)
if textWidth > colWidth - 2 then
local clipIndex = DrawStringCursorIndex(textHeight, colFont, text, colWidth - clipWidth - 2, 0)
if textWidth > colWidth - textX - 2 then
local clipIndex = DrawStringCursorIndex(textHeight, colFont, text, colWidth - textX - clipWidth - 2, 0)
text = text:sub(1, clipIndex - 1) .. "..."
textWidth = DrawStringWidth(textHeight, colFont, text)
end
Expand All @@ -241,7 +240,7 @@ function ListClass:Draw(viewPort, noTooltip)
ttValue = value
ttX = x + 2 + colOffset
ttY = lineY + y + 2
ttWidth = m_max(textWidth + 8, relX - colOffset)
ttWidth = m_max(textX + textWidth + 8, relX - colOffset)
end
end
if self.showRowSeparators then
Expand Down Expand Up @@ -283,12 +282,10 @@ function ListClass:Draw(viewPort, noTooltip)
SetDrawColor(1, 1, 1)
end
-- TODO: handle icon size properly, for now assume they are 16x16
if icon == nil then
DrawString(colOffset, lineY + textOffsetY, "LEFT", textHeight, colFont, text)
else
if icon then
DrawImage(icon, colOffset, lineY, 16, 16)
DrawString(colOffset + 16 + 2, lineY + textOffsetY, "LEFT", textHeight, colFont, text)
end
DrawString(colOffset + textX, lineY + textOffsetY, "LEFT", textHeight, colFont, text)
end
if self.colLabels then
local mOver = relX >= colOffset and relX <= colOffset + colWidth and relY >= 0 and relY <= 18
Expand Down
Loading