Skip to content
Merged
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
82 changes: 75 additions & 7 deletions EllesmereUIBlizzardSkin/EllesmereUIBlizzardSkin_SocketPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if EUI_CLIENT_BLOCKED then return end -- pre-12.1 client failsafe (EllesmereUI_C
--------------------------------------------------------------------------------
-- Character Sheet Socket Panel
--
-- A single bare row of socket icons in the blank strip along the bottom
-- A bounded row of socket icons in the blank strip along the bottom
-- edge of the EUI-skinned character sheet, right-aligned. Each icon is one
-- socket on a currently-equipped item:
-- filled sockets paint the gem, empty sockets paint the empty-socket texture.
Expand Down Expand Up @@ -38,6 +38,8 @@ local CHasItem = _G.CursorHasItem
-- Constants
local SIZE = 28
local PAD = 4
local MAX_SOCKET_ICONS = 6
local PAGE_BUTTON_W = 12
local ROW_H = 20 -- gem flyout row height
local FLYOUT_W = 240
local MAX_FLYOUT_ROWS = 12 -- flyout caps here; extra gems scroll with the wheel
Expand All @@ -64,6 +66,8 @@ local gemDirty = true
local pendingGemLoads = {} -- itemID -> true: bag gems whose data load we requested
local socketLoadRequested = {} -- gem itemID -> true: equipped-gem data loads we requested
local activeIcon = nil -- icon whose flyout is currently open
local socketPage = 0
local prevPage, nextPage
local flyoutScroll = 0 -- top gem index offset when the gem list overflows MAX_FLYOUT_ROWS
local flyoutHoverMode = false -- flyout opened by hovering an empty socket (auto-closes on leave)
local ourSession = false -- a socketing session WE opened is (or may still be) live
Expand Down Expand Up @@ -226,6 +230,7 @@ local function SafeCloseSession()
end

local RebuildSockets -- forward declaration
local LayoutSockets
local CloseFlyout -- forward declaration
local OpenFlyout -- forward declaration
local MaybeCloseHoverFlyout -- forward declaration
Expand Down Expand Up @@ -598,15 +603,78 @@ RebuildSockets = function()
end
end

LayoutSockets()
end

local function ChangeSocketPage(delta)
local last = math.max(0, math.ceil(#sockets / (MAX_SOCKET_ICONS - 1)) - 1)
local page = math.max(0, math.min(last, socketPage + delta))
if page == socketPage then return end
CloseFlyout()
StopSlotGlow()
GameTooltip:Hide()
if EllesmereUI.HideWidgetTooltip then EllesmereUI.HideWidgetTooltip() end
socketPage = page
LayoutSockets()
end

local function BuildPageButton(text, delta, tip)
local btn = CreateFrame("Button", nil, panel)
btn:SetSize(PAGE_BUTTON_W, SIZE)
local label = btn:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetAllPoints(btn)
label:SetText(text)
btn:SetScript("OnClick", function() ChangeSocketPage(delta) end)
btn:SetScript("OnEnter", function(self)
EllesmereUI.ShowWidgetTooltip(self, tip)
end)
btn:SetScript("OnLeave", function() EllesmereUI.HideWidgetTooltip() end)
return btn
end

LayoutSockets = function()
if not panel then return end

local count = #sockets
local paged = count > MAX_SOCKET_ICONS
-- Reserve one icon's width for the arrows, keeping the entire strip no
-- wider than the original six-socket layout, including on the last page.
local perPage = paged and (MAX_SOCKET_ICONS - 1) or MAX_SOCKET_ICONS
local last = math.max(0, math.ceil(count / perPage) - 1)
socketPage = math.min(socketPage, last)
local first = socketPage * perPage
local visible = math.min(perPage, count - first)
if activeIcon then
local old = activeIcon.euiSock
local keep = false
for i = 1, visible do
local rec = sockets[first + i]
if activeIcon == iconPool[i] and old and old.slot == rec.slot
and old.socketIndex == rec.socketIndex then keep = true; break end
end
if not keep then CloseFlyout(); StopSlotGlow() end
end
if paged and not prevPage then
prevPage = BuildPageButton("<", -1, EllesmereUI.L("Previous sockets"))
nextPage = BuildPageButton(">", 1, EllesmereUI.L("Next sockets"))
prevPage:SetPoint("LEFT", panel, "LEFT", 0, 0)
nextPage:SetPoint("RIGHT", panel, "RIGHT", 0, 0)
end
if prevPage then
prevPage:SetShown(paged)
nextPage:SetShown(paged)
prevPage:SetEnabled(socketPage > 0)
nextPage:SetEnabled(socketPage < last)
prevPage:SetAlpha(socketPage > 0 and 1 or 0.3)
nextPage:SetAlpha(socketPage < last and 1 or 0.3)
end

-- Hide all pooled icons first.
for _, btn in ipairs(iconPool) do
btn:Hide()
btn.euiSock = nil
end

local count = #sockets
if count == 0 then
panel:Hide()
if EllesmereUI and EllesmereUI._updateCharSheetDurability then
Expand All @@ -615,9 +683,8 @@ RebuildSockets = function()
return
end

-- One row, never wraps; the panel's right edge stays pinned so the row
-- grows leftward into the strip.
for i, rec in ipairs(sockets) do
for i = 1, visible do
local rec = sockets[first + i]
local btn = AcquireIcon(i)
btn.euiSock = rec
if rec.gemLink then
Expand All @@ -626,11 +693,12 @@ RebuildSockets = function()
PaintEmptyIcon(btn)
end
btn:ClearAllPoints()
btn:SetPoint("LEFT", panel, "LEFT", (i - 1) * (SIZE + PAD), 0)
btn:SetPoint("LEFT", panel, "LEFT",
(paged and (PAGE_BUTTON_W + PAD) or 0) + (i - 1) * (SIZE + PAD), 0)
btn:Show()
end

panel:SetWidth(count * (SIZE + PAD) - PAD)
panel:SetWidth((paged and MAX_SOCKET_ICONS or visible) * (SIZE + PAD) - PAD)
panel:Show()
if EllesmereUI and EllesmereUI._updateCharSheetDurability then
EllesmereUI._updateCharSheetDurability()
Expand Down
4 changes: 3 additions & 1 deletion EllesmereUILocales/_keys.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Auto-generated by .tools/extract-locale-keys.sh -- do not edit by hand.
# Canonical list of translatable English keys passed as string literals
# (798 unique). Regenerate after wrapping new strings. Keys passed as
# (791 unique). Regenerate after wrapping new strings. Keys passed as
# variables are not listed here -- use the in-game /euiloc harvester for
# the complete runtime set.
(Raid)
Expand Down Expand Up @@ -461,6 +461,7 @@ New Custom Category
New Filter
New Patch Reminder Dot
New Profile
Next sockets
No
No Bars - Click to Add
No Items
Expand Down Expand Up @@ -530,6 +531,7 @@ Preview
Preview Mode
Previewing Override: %1$s
Previewing Overrides: %1$s, %2$s
Previous sockets
Processing
Profession %1$d
Profile
Expand Down
Loading