first part of the sell refactoring
This commit is contained in:
@@ -1,9 +1,187 @@
|
||||
AuctionatorVersion = "1.2.0-Vanilla"
|
||||
AuctionatorAuthors = "Zirco (Original); Nimeral (Backport); shirsig, Zerf (Update)"
|
||||
|
||||
AuctionatorLoaded = false
|
||||
AUCTIONATOR_ENABLE_ALT = true
|
||||
AUCTIONATOR_OPEN_FIRST = false
|
||||
AUCTIONATOR_INSTANT_BUYOUT = false
|
||||
|
||||
local val2gsc
|
||||
-- global settings
|
||||
Auctionator = {
|
||||
loaded = false,
|
||||
orig = {},
|
||||
elements = {},
|
||||
tabs = {
|
||||
sell = {
|
||||
index = 4
|
||||
},
|
||||
buy = {
|
||||
index = 5
|
||||
}
|
||||
},
|
||||
item_colors = {
|
||||
"ff9d9d9d", -- poor, gray
|
||||
"ffffffff", -- common, white
|
||||
"ff1eff00", -- uncommon, green
|
||||
"ff0070dd", -- rare, blue
|
||||
"ffa335ee", -- epic, purple
|
||||
"ffff8000", -- legendary, orange
|
||||
}
|
||||
}
|
||||
|
||||
local relevel
|
||||
|
||||
function Auctionator_OnLoad()
|
||||
Auctionator_Log("Auctionator v"..AuctionatorVersion.." loaded")
|
||||
Auctionator.loaded = true
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
Auctionator_OnLoad()
|
||||
elseif event == "ADDON_LOADED" then
|
||||
Auctionator_OnAddonLoaded()
|
||||
elseif event == "AUCTION_HOUSE_SHOW" then
|
||||
Auctionator_OnAuctionHouseShow()
|
||||
elseif event == "AUCTION_HOUSE_CLOSED" then
|
||||
Auctionator_OnAuctionHouseClosed()
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_OnAddonLoaded()
|
||||
|
||||
if string.lower(arg1) == "blizzard_auctionui" then
|
||||
Auctionator_AddTabs()
|
||||
Auctionator_AddPanels()
|
||||
|
||||
Auctionator_SetupHookFunctions()
|
||||
|
||||
Auctionator.tabs.sell.hiddenElements = {
|
||||
AuctionsTitle,
|
||||
AuctionsScrollFrame,
|
||||
AuctionsButton1,
|
||||
AuctionsButton2,
|
||||
AuctionsButton3,
|
||||
AuctionsButton4,
|
||||
AuctionsButton5,
|
||||
AuctionsButton6,
|
||||
AuctionsButton7,
|
||||
AuctionsButton8,
|
||||
AuctionsButton9,
|
||||
AuctionsQualitySort,
|
||||
AuctionsDurationSort,
|
||||
AuctionsHighBidderSort,
|
||||
AuctionsBidSort,
|
||||
AuctionsCancelAuctionButton
|
||||
}
|
||||
|
||||
Auctionator.tabs.buy.hiddenElements = {
|
||||
BidTitle,
|
||||
BidScrollFrame,
|
||||
BidQualitySort,
|
||||
BidLevelSort,
|
||||
BidDurationSort,
|
||||
BidBuyoutSort,
|
||||
BidStatusSort,
|
||||
BidBidSort,
|
||||
BidBidButton,
|
||||
BidBuyoutButton,
|
||||
BidBidPrice,
|
||||
BidBidText
|
||||
}
|
||||
|
||||
Auctionator.tabs.sell.shownElements = {
|
||||
getglobal("Auctionator_Recommend_Text"),
|
||||
getglobal("Auctionator_RecommendPerItem_Text"),
|
||||
getglobal("Auctionator_RecommendPerItem_Price"),
|
||||
getglobal("Auctionator_RecommendPerStack_Text"),
|
||||
getglobal("Auctionator_RecommendPerStack_Price"),
|
||||
getglobal("Auctionator_Recommend_Basis_Text"),
|
||||
getglobal("Auctionator_RecommendItem_Tex")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_OnAuctionHouseShow()
|
||||
|
||||
AuctionatorOptionsButtonPanel:Show()
|
||||
|
||||
if AUCTIONATOR_OPEN_FIRST then
|
||||
AuctionFrameTab_OnClick(Auctionator.tabs.sell.index)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_OnAuctionHouseClosed()
|
||||
|
||||
if not Auctionator_Scan_IsIdle() then
|
||||
Auctionator_Scan_Abort()
|
||||
end
|
||||
|
||||
AuctionatorOptionsButtonPanel:Hide()
|
||||
AuctionatorOptionsFrame:Hide()
|
||||
AuctionatorDescriptionFrame:Hide()
|
||||
AuctionatorSellPanel:Hide()
|
||||
AuctionatorBuyPanel:Hide()
|
||||
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_AuctionFrameTab_OnClick(index)
|
||||
|
||||
if not index then
|
||||
index = this:GetID()
|
||||
end
|
||||
|
||||
if not Auctionator_Scan_IsIdle() then
|
||||
Auctionator_Scan_Abort()
|
||||
end
|
||||
AuctionatorSellPanel:Hide()
|
||||
AuctionatorBuyPanel:Hide()
|
||||
|
||||
if index == 2 then
|
||||
Auctionator_ShowElems(Auctionator.tabs.buy.hiddenElements)
|
||||
end
|
||||
|
||||
if index == 3 then
|
||||
Auctionator_ShowElems(Auctionator.tabs.sell.hiddenElements)
|
||||
end
|
||||
|
||||
if index == Auctionator.tabs.sell.index then
|
||||
AuctionFrameTab_OnClick(3)
|
||||
|
||||
PanelTemplates_SetTab(AuctionFrame, Auctionator.tabs.sell.index)
|
||||
|
||||
Auctionator_HideElems(Auctionator.tabs.sell.hiddenElements)
|
||||
|
||||
AuctionatorSellPanel:Show()
|
||||
AuctionFrame:EnableMouse(false)
|
||||
|
||||
Auctionator_OnNewAuctionUpdate()
|
||||
elseif index == Auctionator.tabs.buy.index then
|
||||
AuctionFrameTab_OnClick(2)
|
||||
|
||||
PanelTemplates_SetTab(AuctionFrame, Auctionator.tabs.buy.index)
|
||||
|
||||
Auctionator_HideElems(Auctionator.tabs.buy.hiddenElements)
|
||||
|
||||
AuctionatorBuyPanel:Show()
|
||||
AuctionFrame:EnableMouse(false)
|
||||
|
||||
Auctionator_Buy_ScrollbarUpdate()
|
||||
else
|
||||
Auctionator.orig.AuctionFrameTab_OnClick(index)
|
||||
lastItemPosted = nil
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
@@ -15,6 +193,80 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_AddPanels()
|
||||
|
||||
local sellFrame = CreateFrame("Frame", "AuctionatorSellPanel", AuctionFrame, "AuctionatorSellTemplate")
|
||||
sellFrame:SetParent("AuctionFrame")
|
||||
sellFrame:SetPoint("TOPLEFT", "AuctionFrame", "TOPLEFT")
|
||||
relevel(sellFrame)
|
||||
sellFrame:Hide()
|
||||
|
||||
local buyFrame = CreateFrame("Frame", "AuctionatorBuyPanel", AuctionFrame, "AuctionatorBuyTemplate")
|
||||
buyFrame:SetParent("AuctionFrame")
|
||||
buyFrame:SetPoint("TOPLEFT", "AuctionFrame", "TOPLEFT")
|
||||
relevel(buyFrame)
|
||||
buyFrame:Hide()
|
||||
|
||||
local optionsFrame = CreateFrame("Frame", "AuctionatorOptionsButtonPanel", AuctionFrame, "AuctionatorOptionsButtonTemplate")
|
||||
optionsFrame:SetParent("AuctionFrame")
|
||||
optionsFrame:SetPoint("TOPLEFT", "AuctionFrame", "TOPLEFT")
|
||||
relevel(optionsFrame)
|
||||
optionsFrame:Hide()
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_AddTabs()
|
||||
|
||||
Auctionator.tabs.sell.index = AuctionFrame.numTabs + 1
|
||||
Auctionator.tabs.buy.index = AuctionFrame.numTabs + 2
|
||||
|
||||
local sellTabName = "AuctionFrameTab"..Auctionator.tabs.sell.index
|
||||
local buyTabName = "AuctionFrameTab"..Auctionator.tabs.buy.index
|
||||
|
||||
local sellTab = CreateFrame("Button", sellTabName, AuctionFrame, "AuctionTabTemplate")
|
||||
local buyTab = CreateFrame("Button", buyTabName, AuctionFrame, "AuctionTabTemplate")
|
||||
|
||||
setglobal(sellTabName, sellTab)
|
||||
setglobal(buyTabName, buyTab)
|
||||
|
||||
sellTab:SetID(Auctionator.tabs.sell.index)
|
||||
sellTab:SetText("Sell")
|
||||
sellTab:SetPoint("LEFT", getglobal("AuctionFrameTab"..AuctionFrame.numTabs), "RIGHT", -8, 0)
|
||||
|
||||
buyTab:SetID(Auctionator.tabs.buy.index)
|
||||
buyTab:SetText("Buy")
|
||||
buyTab:SetPoint("LEFT", getglobal("AuctionFrameTab"..Auctionator.tabs.sell.index), "RIGHT", -8, 0)
|
||||
|
||||
PanelTemplates_SetNumTabs(AuctionFrame, Auctionator.tabs.buy.index)
|
||||
PanelTemplates_EnableTab(AuctionFrame, Auctionator.tabs.sell.index)
|
||||
PanelTemplates_EnableTab(AuctionFrame, Auctionator.tabs.buy.index)
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_HideElems(tt)
|
||||
|
||||
if not tt then
|
||||
return;
|
||||
end
|
||||
|
||||
for i,x in ipairs(tt) do
|
||||
x:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_ShowElems(tt)
|
||||
|
||||
for i,x in ipairs(tt) do
|
||||
x:Show()
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_PluralizeIf(word, count)
|
||||
|
||||
if count and count == 1 then
|
||||
@@ -54,15 +306,11 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_OnLoad()
|
||||
Auctionator_Log("Auctionator v"..AuctionatorVersion.." loaded")
|
||||
AuctionatorLoaded = true
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_Core_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
Auctionator_OnLoad()
|
||||
function relevel(frame)
|
||||
local myLevel = frame:GetFrameLevel() + 1
|
||||
local children = { frame:GetChildren() }
|
||||
for _,child in pairs(children) do
|
||||
child:SetFrameLevel(myLevel)
|
||||
relevel(child)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user