Skip to content

Commit

Permalink
feat: support Vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
DengSir committed Nov 27, 2024
1 parent 67fb744 commit 71f322f
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 14 deletions.
22 changes: 22 additions & 0 deletions API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,33 @@ function ns.SetMoneyFrame(moneyFrame, money)
end

function ns.EasyMenu(menuList, anchor, x, y, displayMode, autoHideDelay)
-- @wlk@
local dropdown = tdEasyMenuFrame or CreateFrame('Frame', 'tdEasyMenuFrame', UIParent, 'UIDropDownMenuTemplate')
dropdown.initialize = EasyMenu_Initialize
dropdown.displayMode = displayMode or nil

ToggleDropDownMenu(1, nil, dropdown, anchor, x, y, menuList, nil, autoHideDelay)
-- @end-wlk@

-- @classic@
MenuUtil.CreateContextMenu(anchor, function(_, root)
root:SetTag('tdAuction' .. anchor:GetDebugName())

for _, menu in ipairs(menuList) do
if menu.text == '' then
root:CreateDivider()
elseif menu.isTitle then
root:CreateTitle(menu.text)
elseif menu.notCheckable then
root:CreateButton(menu.text, menu.func or nop)
elseif menu.isNotRadio then
root:CreateCheckbox(menu.text, menu.checked, menu.func)
else
root:CreateRadio(menu.text, menu.func, menu.checked)
end
end
end)
-- @end-classic@
end

ns.MENU_SEPARATOR = {
Expand Down
2 changes: 1 addition & 1 deletion Load.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Script file="Query\PriceScaner.lua" />

<Include file="UI\Template.xml" />
<Script file="UI\ComboBox.lua" />
<Script file="UI\ComboBox.lua" build="wlk" />
<Script file="UI\FullScan.lua" />
<Script file="UI\BrowseItem.lua" />
<Script file="UI\Browse.lua" />
Expand Down
63 changes: 54 additions & 9 deletions UI/Browse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function Browse:Constructor()
end

function Browse:LayoutBlizzard()
local BrowseDropDown = BrowseDropDown or BrowseDropdown
local BrowseDropDownName = BrowseDropDownName or BrowseDropdownName

---@type tdAuctionBrowseBuyFrameTemplate
self.BuyFrame = CreateFrame('Frame', nil, self, 'tdAuctionBrowseBuyFrameTemplate')
self.Name = BrowseName
Expand Down Expand Up @@ -118,7 +121,21 @@ function Browse:LayoutBlizzard()
local nameWidth = 220

self.Name:SetWidth(nameWidth)
-- @wlk@
UIDropDownMenu_SetWidth(self.QualityDropDown, 60)
ns.UI.ComboBox:Bind(self.QualityDropDown)
self.QualityDropDown:SetItems((function()
local items = {{text = ALL, value = -1}}
for i = Enum.ItemQuality.Poor, Enum.ItemQuality.Epic do
tinsert(items, {text = ns.ITEM_QUALITY_DESCS[i], value = i})
end
return items
end)())
self.QualityDropDown:SetValue(-1)
-- @end-wlk@
-- @classic@
-- self.QualityDropDown:SetWidth(60)
-- @end-classic@

point(BrowseSearchDotsText, 'LEFT', self.NoResultsText, 'RIGHT')

Expand All @@ -134,8 +151,14 @@ function Browse:LayoutBlizzard()

point(self.Name, 'TOPLEFT', BrowseNameText, 'BOTTOMLEFT', 3, -3 + CONTROL_LABEL_SPACING)
point(self.MinLevel, 'TOPLEFT', BrowseLevelText, 'BOTTOMLEFT', 0, -3 + CONTROL_LABEL_SPACING)
-- @wlk@
point(self.QualityDropDown, 'TOPLEFT', BrowseDropDownName, 'BOTTOMLEFT', -18, 3 + CONTROL_LABEL_SPACING)
point(self.IsUsableCheckButton, 'TOPLEFT', nameWidth + 260, -38)
-- @end-wlk@
-- @non-wlk@
point(self.QualityDropDown, 'TOPLEFT', BrowseDropDownName, 'BOTTOMLEFT', -3, CONTROL_LABEL_SPACING)
point(self.IsUsableCheckButton, 'TOPLEFT', nameWidth + 300, -38)
-- @end-non-wlk@
point(ShowOnPlayerCheckButton, 'TOPLEFT', self.IsUsableCheckButton, 'BOTTOMLEFT', 0, 2)

parent(self.PrevPageButton)
Expand Down Expand Up @@ -168,15 +191,6 @@ function Browse:LayoutBlizzard()

point(self.ScrollFrame, 'TOPLEFT', self, 190 - FILTER_FRAME_SHORT, -104)

ns.UI.ComboBox:Bind(self.QualityDropDown)
self.QualityDropDown:SetItems((function()
local items = {{text = ALL, value = -1}}
for i = Enum.ItemQuality.Poor, Enum.ItemQuality.Epic do
tinsert(items, {text = ns.ITEM_QUALITY_DESCS[i], value = i})
end
return items
end)())
self.QualityDropDown:SetValue(-1)
end

function Browse:SetupScrollFrame()
Expand Down Expand Up @@ -228,6 +242,8 @@ function Browse:SetupSortButtons()
tinsert(self.sortButtons, button)
end

-- @wlk@

self.columnsMenu = {{text = L['Toggle column'], isTitle = true, notCheckable = true}, ns.MENU_SEPARATOR}

for _, info in ipairs(self.headers) do
Expand All @@ -254,6 +270,30 @@ function Browse:SetupSortButtons()
self.BuyFrame.ColumnOption:SetScript('OnClick', function(button)
return ns.EasyMenu(self.columnsMenu, button, 0, 0, 'MENU')
end)
-- @end-wlk@

-- @classic@
local function get(key)
return not ns.profile.buy.hiddenColumns[key]
end

local function set(key)
ns.profile.buy.hiddenColumns[key] = not ns.profile.buy.hiddenColumns[key]
self:UpdateColumns()
end

self.BuyFrame.ColumnOption:SetupMenu(function(_, root)
root:CreateTitle(L['Toggle column'])
root:CreateDivider()
for _, info in ipairs(self.headers) do
if info.hiddenable then
root:CreateCheckbox(info.text, get, set, info.key)
end
end
root:CreateDivider()
root:CreateButton(CANCEL, nop)
end)
-- @end-classic@
end

function Browse:GenColumnMenu()
Expand Down Expand Up @@ -527,7 +567,12 @@ function Browse:BuildSearchParams()
maxLevel = self.MaxLevel:GetNumber(),
filters = self:GetFilters(),
usable = self.IsUsableCheckButton:GetChecked(),
-- @wlk@
quality = UIDropDownMenu_GetSelectedValue(self.QualityDropDown),
-- @end-wlk@
-- @classic@
quality = self.qualityIndex,
-- @end-classic@
exact = self.ExactCheckButton:GetChecked(),
}

Expand Down
40 changes: 38 additions & 2 deletions UI/Sell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Sell:LayoutBlizzard()
self.SellFrame = CreateFrame('Frame', nil, self, 'tdAuctionSellFrameTemplate')
self.StartPrice = StartPrice
self.BuyoutPrice = BuyoutPrice
self.PriceDropDown = PriceDropDown
self.PriceDropDown = PriceDropDown or self.SellFrame.PriceDropdown
self.ItemCount = AuctionsItemButtonCount
self.StackSizeEntry = AuctionsStackSizeEntry
self.NumStacksEntry = AuctionsNumStacksEntry
Expand Down Expand Up @@ -91,6 +91,40 @@ function Sell:LayoutBlizzard()
self.PriceList.CountLabel:SetText(L['Count'])
self.PriceList.PriceLabel:SetText(L['Price'])

self.priceType = 1

-- @non-wlk@
do
local function set(value)
self:SetDuration(value)
end
local function get(value)
return self.duration == value
end
self.DurationDropDown:SetupMenu(function(_, root)
root:CreateRadio(ns.SELL_HOURS[1], get, set, 1)
root:CreateRadio(ns.SELL_HOURS[2], get, set, 2)
root:CreateRadio(ns.SELL_HOURS[3], get, set, 3)
end)
end

do
local function set(value)
self.priceType = value
end
local function get(value)
return self.priceType == value
end
self.PriceDropDown:SetupMenu(function(_, root)
root:CreateRadio(AUCTION_PRICE_PER_ITEM, get, set, 1)
root:CreateRadio(AUCTION_PRICE_PER_STACK, get, set, 2)
end)

point(self.PriceDropDown, 'TOPRIGHT', self, 'TOPLEFT', 207, -192)
end
-- @end-non-wlk@

-- @wlk@
ns.UI.ComboBox:Bind(self.DurationDropDown)
self.DurationDropDown:SetItems{
{text = ns.SELL_HOURS[1], value = 1},
Expand All @@ -101,8 +135,8 @@ function Sell:LayoutBlizzard()
self:SetDuration(value)
end)

self.priceType = 1
self.DurationDropDown:SetValue(self.duration)
-- @end-wlk@

HybridScrollFrame_CreateButtons(self.PriceList.ScrollFrame, 'tdAuctionPriceItemTemplate')
self.PriceList.ScrollFrame.update = function()
Expand Down Expand Up @@ -359,6 +393,8 @@ end

function Sell:SetDuration(duration)
self.duration = duration
-- @wlk@
self.DurationDropDown:SetValue(duration)
-- @end-wlk@
UpdateDeposit()
end
30 changes: 28 additions & 2 deletions UI/Template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
</Button>
</Frames>
</Frame>
<Button parentKey="ColumnOption">
<Button parentKey="ColumnOption" build="wlk">
<Size x="16" y="16" />
<Anchors>
<Anchor point="RIGHT" relativeKey="$parent.SortButtonFrame" relativePoint="LEFT" x="-3" y="0"/>
Expand All @@ -497,6 +497,23 @@
</OnClick>
</Scripts>
</Button>
<DropdownButton parentKey="ColumnOption" build="non-wlk">
<KeyValues>
<KeyValue key="menuMixin" value="MenuStyle2Mixin" type="global"/>
</KeyValues>
<Size x="16" y="16" />
<Anchors>
<Anchor point="RIGHT" relativeKey="$parent.SortButtonFrame" relativePoint="LEFT" x="-3" y="0"/>
</Anchors>
<NormalTexture file="Interface\GossipFrame\BinderGossipIcon" setAllPoints="true" />
<HighlightTexture file="Interface\GossipFrame\BinderGossipIcon" setAllPoints="true" alphaMode="ADD" />
<!-- <Scripts>
<OnLoad method="OnLoad"/>
<OnShow method="OnShow"/>
<OnEnter method="OnEnter"/>
<OnLeave method="OnLeave"/>
</Scripts> -->
</DropdownButton>
<CheckButton parentKey="ExactCheckButton" inherits="UICheckButtonTemplate">
<Size x="24" y="24" />
<Anchors>
Expand All @@ -517,7 +534,7 @@

<Frame name="tdAuctionSellFrameTemplate" setAllPoints="true" virtual="true">
<Frames>
<Frame name="tdAuctionSellDurationDropDown" parentKey="DurationDropDown" inherits="UIDropDownMenuTemplate">
<Frame name="tdAuctionSellDurationDropDown" parentKey="DurationDropDown" inherits="UIDropDownMenuTemplate" build="wlk">
<Anchors>
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMLEFT" x="217" y="89"/>
</Anchors>
Expand All @@ -527,6 +544,15 @@
</OnLoad>
</Scripts>
</Frame>
<DropdownButton parentKey="DurationDropDown" inherits="WowStyle1DropdownTemplate" build="non-wlk">
<Size x="80" y="24"/>
<Anchors>
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMLEFT" x="207" y="89"/>
</Anchors>
</DropdownButton>
<DropdownButton parentKey="PriceDropdown" inherits="WowStyle1DropdownTemplate" build="non-wlk">
<Size x="80" y="24"/>
</DropdownButton>
<Button parentKey="PriceListButton" hidden="true">
<Size x="26" y="26"/>
<Anchors>
Expand Down

0 comments on commit 71f322f

Please sign in to comment.