Skip to content

Commit

Permalink
change skinning function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils89 committed Jun 4, 2024
1 parent f44f6ce commit da5b133
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 48 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
6.14.9
CHANGES
- Export some api

6.14.8
CHANGES
- Update toc
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG_NEW_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
6.14.9
CHANGES
- Export some api

6.14.8
CHANGES
- Update toc
Expand Down
3 changes: 3 additions & 0 deletions changelog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ AddChange(string addonVersion, table changeList)
}
]]

addChange("6.14.9",{
{ct.change, [=[Export some api]=]},
})

addChange("6.14.8",{
{ct.change, [=[Update toc]=]},
Expand Down
32 changes: 11 additions & 21 deletions inventory/bag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ local UpdateMoney = GW.UpdateMoney
local EnableTooltip = GW.EnableTooltip
local inv

local BAG_ITEM_SIZE = 40
local BAG_ITEM_LARGE_SIZE = 40
local BAG_ITEM_COMPACT_SIZE = 32
local BAG_ITEM_PADDING = 5
local BAG_WINDOW_SIZE = 480

local function setBagHeaders()
for i = 1, 5 do
Expand Down Expand Up @@ -37,7 +35,7 @@ local function layoutBagItems(f)
local rev = GW.settings.BAG_REVERSE_SORT
local sep = GW.settings.BAG_SEPARATE_BAGS
local row = sep and 1 or 0
local item_off = BAG_ITEM_SIZE + BAG_ITEM_PADDING
local item_off = GW.settings.BAG_ITEM_SIZE + BAG_ITEM_PADDING
local unfinishedRow = false
local finishedRows = 0

Expand All @@ -61,8 +59,8 @@ local function layoutBagItems(f)
_G["GwBagFrameGwBagHeader" .. bag_id]:Show()
_G["GwBagFrameGwBagHeader" .. bag_id]:ClearAllPoints()
_G["GwBagFrameGwBagHeader" .. bag_id]:SetPoint("TOPLEFT", f, "TOPLEFT", 0, (-row + 1) * item_off)
_G["GwBagFrameGwBagHeader" .. bag_id]:SetWidth(BAG_WINDOW_SIZE - BAG_ITEM_PADDING)
_G["GwBagFrameGwBagHeader" .. bag_id].background:SetWidth(BAG_WINDOW_SIZE - BAG_ITEM_PADDING)
_G["GwBagFrameGwBagHeader" .. bag_id]:SetWidth(GW.settings.BAG_WIDTH - BAG_ITEM_PADDING)
_G["GwBagFrameGwBagHeader" .. bag_id].background:SetWidth(GW.settings.BAG_WIDTH - BAG_ITEM_PADDING)
else
_G["GwBagFrameGwBagHeader" .. bag_id] :Hide()
end
Expand Down Expand Up @@ -114,7 +112,7 @@ local function snapFrameSize(f)
if f.ItemFrame:IsShown() then
cfs = f.ItemFrame.Containers
end
inv.snapFrameSize(f, cfs, BAG_ITEM_SIZE, BAG_ITEM_PADDING, 350)
inv.snapFrameSize(f, cfs, GW.settings.BAG_ITEM_SIZE, BAG_ITEM_PADDING, 350)
end
GW.AddForProfiling("bag", "snapFrameSize", snapFrameSize)

Expand Down Expand Up @@ -363,14 +361,13 @@ end
GW.AddForProfiling("bag", "updateBagBar", updateBagBar)

local function onBagResizeStop(self)
BAG_WINDOW_SIZE = self:GetWidth()
GW.settings.BAG_WIDTH = BAG_WINDOW_SIZE
GW.settings.BAG_WIDTH = self:GetWidth()
inv.onMoved(self, "BAG_POSITION", snapFrameSize)
end
GW.AddForProfiling("bag", "onBagResizeStop", onBagResizeStop)

local function onBagFrameChangeSize(self, _, _, skip)
local cols = inv.colCount(BAG_ITEM_SIZE, BAG_ITEM_PADDING, self:GetWidth())
local cols = inv.colCount(GW.settings.BAG_ITEM_SIZE, BAG_ITEM_PADDING, self:GetWidth())

if not self.gw_bag_cols or self.gw_bag_cols ~= cols then
self.gw_bag_cols = cols
Expand All @@ -383,16 +380,13 @@ GW.AddForProfiling("bag", "onBagFrameChangeSize", onBagFrameChangeSize)

-- toggles the setting for compact/large icons
local function compactToggle()
if BAG_ITEM_SIZE == BAG_ITEM_LARGE_SIZE then
BAG_ITEM_SIZE = BAG_ITEM_COMPACT_SIZE
GW.settings.BAG_ITEM_SIZE = BAG_ITEM_SIZE
if GW.settings.BAG_ITEM_SIZE == BAG_ITEM_LARGE_SIZE then
GW.settings.BAG_ITEM_SIZE = BAG_ITEM_COMPACT_SIZE
inv.resizeInventory()
return true
end

BAG_ITEM_SIZE = BAG_ITEM_LARGE_SIZE
GW.settings.BAG_ITEM_SIZE = BAG_ITEM_SIZE
GW.
GW.settings.BAG_ITEM_SIZE = BAG_ITEM_LARGE_SIZE
inv.resizeInventory()
return false
end
Expand Down Expand Up @@ -574,10 +568,7 @@ local function LoadBag(helpers)

inv = helpers

BAG_WINDOW_SIZE = GW.settings.BAG_WIDTH
BAG_ITEM_SIZE = GW.settings.BAG_ITEM_SIZE
if BAG_ITEM_SIZE > 40 then
BAG_ITEM_SIZE = 40
if GW.settings.BAG_ITEM_SIZE > 40 then
GW.settings.BAG_ITEM_SIZE = 40
end

Expand All @@ -586,7 +577,7 @@ local function LoadBag(helpers)
tinsert(UISpecialFrames, "GwBagFrame")
f.gw_state = "closed"
f:ClearAllPoints()
f:SetWidth(BAG_WINDOW_SIZE)
f:SetWidth(GW.settings.BAG_WIDTH)
onBagFrameChangeSize(f, nil, nil, true)
f:SetClampedToScreen(true)

Expand Down Expand Up @@ -973,7 +964,6 @@ local function LoadBag(helpers)

-- return a callback that should be called when item size changes
local changeItemSize = function()
BAG_ITEM_SIZE = GW.settings.BAG_ITEM_SIZE
layoutItems(f)
snapFrameSize(f)
end
Expand Down
30 changes: 11 additions & 19 deletions inventory/bank.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local L = GW.L
local EnableTooltip = GW.EnableTooltip
local inv

local BANK_ITEM_SIZE = 40
local BANK_ITEM_LARGE_SIZE = 40
local BANK_ITEM_COMPACT_SIZE = 32
local BANK_ITEM_PADDING = 5
Expand All @@ -16,7 +15,7 @@ local function layoutBankItems(f)
local col = 0
local rev = GW.settings.BANK_REVERSE_SORT

local item_off = BANK_ITEM_SIZE + BANK_ITEM_PADDING
local item_off = GW.settings.BAG_ITEM_SIZE + BANK_ITEM_PADDING

local iS = NUM_TOTAL_EQUIPPED_BAG_SLOTS
local iE = NUM_TOTAL_EQUIPPED_BAG_SLOTS + NUM_BANKBAGSLOTS
Expand Down Expand Up @@ -45,7 +44,7 @@ local function layoutReagentItems(f)
local row = 0
local col = 0

local item_off = BANK_ITEM_SIZE + BANK_ITEM_PADDING
local item_off = GW.settings.BAG_ITEM_SIZE + BANK_ITEM_PADDING

local cf = f.Containers[REAGENTBANK_CONTAINER]
inv.layoutContainerFrame(cf, max_col, row, col, true, item_off)
Expand All @@ -70,7 +69,7 @@ local function snapFrameSize(f)
elseif f.ReagentFrame:IsShown() and IsReagentBankUnlocked() then
cfs = f.ReagentFrame.Containers
end
inv.snapFrameSize(f, cfs, BANK_ITEM_SIZE, BANK_ITEM_PADDING, 370)
inv.snapFrameSize(f, cfs, GW.settings.BAG_ITEM_SIZE, BANK_ITEM_PADDING, 370)
end
GW.AddForProfiling("bank", "snapFrameSize", snapFrameSize)

Expand Down Expand Up @@ -271,14 +270,13 @@ end
GW.AddForProfiling("bank", "updateBagBar", updateBagBar)

local function onBankResizeStop(self)
BANK_WINDOW_SIZE = self:GetWidth()
GW.settings.BANK_WIDTH = BANK_WINDOW_SIZE
GW.settings.BANK_WIDTH = self:GetWidth()
inv.onMoved(self, "BANK_POSITION", snapFrameSize)
end
GW.AddForProfiling("bank", "onBankResizeStop", onBankResizeStop)

local function onBankFrameChangeSize(self, _, _, skip)
local cols = inv.colCount(BANK_ITEM_SIZE, BANK_ITEM_PADDING, self:GetWidth())
local cols = inv.colCount(GW.settings.BAG_ITEM_SIZE, BANK_ITEM_PADDING, self:GetWidth())

if not self.gw_bank_cols or self.gw_bank_cols ~= cols then
self.gw_bank_cols = cols
Expand All @@ -291,15 +289,13 @@ GW.AddForProfiling("bank", "onBankFrameChangeSize", onBankFrameChangeSize)

-- toggles the setting for compact/large icons
local function compactToggle()
if BANK_ITEM_SIZE == BANK_ITEM_LARGE_SIZE then
BANK_ITEM_SIZE = BANK_ITEM_COMPACT_SIZE
GW.settings.BAG_ITEM_SIZE = BANK_ITEM_SIZE
if GW.settings.BAG_ITEM_SIZE == BANK_ITEM_LARGE_SIZE then
GW.settings.BAG_ITEM_SIZE = BANK_ITEM_COMPACT_SIZE
inv.resizeInventory()
return true
end

BANK_ITEM_SIZE = BANK_ITEM_LARGE_SIZE
GW.settings.BAG_ITEM_SIZE = BANK_ITEM_SIZE
GW.settings.BAG_ITEM_SIZE = BANK_ITEM_LARGE_SIZE
inv.resizeInventory()
return false
end
Expand Down Expand Up @@ -451,18 +447,15 @@ GW.AddForProfiling("bank", "tab_OnLeave", tab_OnLeave)
local function LoadBank(helpers)
inv = helpers

BANK_WINDOW_SIZE = GW.settings.BANK_WIDTH
BANK_ITEM_SIZE = GW.settings.BAG_ITEM_SIZE
if BANK_ITEM_SIZE > 40 then
BANK_ITEM_SIZE = 40
if GW.settings.BAG_ITEM_SIZE > 40 then
GW.settings.BAG_ITEM_SIZE = 40
end

-- create bank frame, restore its saved size, and init its many pieces
local f = CreateFrame("Frame", "GwBankFrame", UIParent, "GwBankFrameTemplate")
tinsert(UISpecialFrames, "GwBankFrame")
f:ClearAllPoints()
f:SetWidth(BANK_WINDOW_SIZE)
f:SetWidth(GW.settings.BANK_WIDTH)
onBankFrameChangeSize(f, nil, nil, true)
f:SetClampedToScreen(true)

Expand Down Expand Up @@ -613,7 +606,7 @@ local function LoadBank(helpers)
dd.compactBank.checkbutton:SetScript(
"OnClick",
function(self)
self:SetText(compactToggle())
self:SetChecked(compactToggle())
dd:Hide()
end
)
Expand Down Expand Up @@ -707,7 +700,6 @@ local function LoadBank(helpers)

-- return a callback that should be called when item size changes
local changeItemSize = function()
BANK_ITEM_SIZE = GW.settings.BAG_ITEM_SIZE
reskinBankItemButtons()
reskinReagentItemButtons()
layoutItems(f)
Expand Down
13 changes: 5 additions & 8 deletions inventory/inventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ local setItemLevel = GW.setItemLevel
local MAX_CONTAINER_ITEMS = 36

-- reskins an ItemButton to use GW2_UI styling
local item_size
local function reskinItemButton(iname, b)
b:SetSize(item_size, item_size)
local function reskinItemButton(iname, b, overrideIconSize)
local iconSize = overrideIconSize or GW.settings.BAG_ITEM_SIZE
b:SetSize(iconSize, iconSize)

b.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
b.icon:SetAllPoints(b)
Expand Down Expand Up @@ -39,7 +39,7 @@ local function reskinItemButton(iname, b)

local qtex = b.IconQuestTexture or (iname and _G[iname .. "IconQuestTexture"])
if qtex then
qtex:SetSize(item_size + 2, item_size + 2)
qtex:SetSize(iconSize + 2, iconSize + 2)
qtex:ClearAllPoints()
qtex:SetPoint("CENTER", b, "CENTER", 0, 0)
end
Expand Down Expand Up @@ -206,9 +206,7 @@ GW.AddForProfiling("inventory", "hookItemQuality", hookItemQuality)
local bag_resize
local bank_resize
local function resizeInventory()
item_size = GW.settings.BAG_ITEM_SIZE
if item_size > 40 then
item_size = 40
if GW.settings.BAG_ITEM_SIZE > 40 then
GW.settings.BAG_ITEM_SIZE = 40
end
reskinItemButtons()
Expand Down Expand Up @@ -739,7 +737,6 @@ local function LoadInventory()
BagBarExpandToggle:SetParent(GW.HiddenFrame)
SetCVar("expandBagBar", "1")
end
item_size = GW.settings.BAG_ITEM_SIZE

-- anytime a ContainerFrame has its anchors set, we re-hide it
hooksecurefunc("UpdateContainerFrameAnchors", hookUpdateAnchors)
Expand Down

0 comments on commit da5b133

Please sign in to comment.