⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 auctionframesearch.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 4 页
字号:
			MoneyInputFrame_GetCopper(getglobal(frameName.."BidMinProfit")),			getglobal(frameName.."BidMinPercentLessEdit"):GetText(),			UIDropDownMenu_GetSelectedID(getglobal(frameName.."BidTimeLeftDropDown")),			UIDropDownMenu_GetSelectedID(getglobal(frameName.."BidCategoryDropDown")),			UIDropDownMenu_GetSelectedID(getglobal(frameName.."BidMinQualityDropDown")),			getglobal(frameName.."BidSearchEdit"):GetText()		);	elseif (searchType == 2) then		-- Buyout-based search		searchData = string.format("%d\t%d\t%s\t%d\t%d\t%s",			searchType,			MoneyInputFrame_GetCopper(getglobal(frameName.."BuyoutMinProfit")),			getglobal(frameName.."BuyoutMinPercentLessEdit"):GetText(),			UIDropDownMenu_GetSelectedID(getglobal(frameName.."BuyoutCategoryDropDown")),			UIDropDownMenu_GetSelectedID(getglobal(frameName.."BuyoutMinQualityDropDown")),			getglobal(frameName.."BuyoutSearchEdit"):GetText()		);	elseif (searchType == 3) then		-- Compete-based search		searchData = string.format("%d\t%d",			searchType,			MoneyInputFrame_GetCopper(getglobal(frameName.."CompeteUndercut"))		);	elseif (searchType == 4) then		-- Plain-based search		searchData = string.format("%d\t%d\t%d\t%d\t%s",			searchType,			MoneyInputFrame_GetCopper(getglobal(frameName.."PlainMaxPrice")),			UIDropDownMenu_GetSelectedID(getglobal(frameName.."PlainCategoryDropDown")),			UIDropDownMenu_GetSelectedID(getglobal(frameName.."PlainMinQualityDropDown")),			getglobal(frameName.."PlainSearchEdit"):GetText()		);	end	if (searchData) then		local searchName = getglobal(frameName.."SaveSearchEdit"):GetText()		if (not AuctionConfig.SavedSearches) then			AuctionConfig.SavedSearches = {}		end		AuctionConfig.SavedSearches[searchName] = searchData	endend--------------------------------------------------------------------------------- The Bid button has been clicked-------------------------------------------------------------------------------function AuctionFrameSearch_BidButton_OnClick(button)	local frame = button:GetParent();	local result = frame.selectedResult;	if (result and result.name and result.count and result.bid) then		result.status = AUCTION_STATUS_BIDDING;		result.pendingBidCount = result.pendingBidCount + 1;		local bidLimit = Auctioneer.Command.GetFilterVal('bid-limit');		local context = { frame = frame, auction = result };		AucBidManager.BidAuction(result.bid, result.signature, bidLimit, AuctionFrameSearch_OnBidResult, context);		AuctionFrameSearch_UpdateButtons(frame);		AuctionFrameSearch_UpdatePendingBidStatus(frame);		ListTemplateScrollFrame_Update(getglobal(frame.resultsList:GetName().."ScrollFrame"));	endend--------------------------------------------------------------------------------- The Buyout button has been clicked.-------------------------------------------------------------------------------function AuctionFrameSearch_BuyoutButton_OnClick(button)	local frame = button:GetParent();	local result = frame.selectedResult;	if (result and result.name and result.count and result.buyout) then		result.status = AUCTION_STATUS_BIDDING;		result.pendingBidCount = result.pendingBidCount + 1;		local bidLimit = Auctioneer.Command.GetFilterVal('bid-limit');		local context = { frame = frame, auction = result };		AucBidManager.BidAuction(result.buyout, result.signature, bidLimit, AuctionFrameSearch_OnBidResult, context);		AuctionFrameSearch_UpdateButtons(frame);		AuctionFrameSearch_UpdatePendingBidStatus(frame);		ListTemplateScrollFrame_Update(getglobal(frame.resultsList:GetName().."ScrollFrame"));	endend--------------------------------------------------------------------------------- Updates the pending bid status text-------------------------------------------------------------------------------function AuctionFrameSearch_UpdatePendingBidStatus(frame)	local count = AucBidManager.GetRequestCount();	if (count == 1) then		frame.pendingBidStatusText:SetText(_AUCT('UiPendingBidInProgress'));	elseif (count > 1) then		local output = string.format(_AUCT('UiPendingBidsInProgress'), count);		frame.pendingBidStatusText:SetText(output);	elseif (frame.pendingBidStatusText:GetText() ~= "") then		frame.pendingBidStatusText:SetText(_AUCT('UiNoPendingBids'));	endend--------------------------------------------------------------------------------- Returns the item color for the specified result-------------------------------------------------------------------------------function AuctionFrameSearch_GetItemColor(result)	_, _, rarity = GetItemInfo(result.item);	if (rarity) then		return ITEM_QUALITY_COLORS[rarity];	end	return { r = 1.0, g = 1.0, b = 1.0 };end--------------------------------------------------------------------------------- Perform a bid search (aka bidBroker)-------------------------------------------------------------------------------function AuctionFrameSearch_SearchBids(frame, minProfit, minPercentLess, maxTimeLeft, category, minQuality, itemName)	-- Create the content from auctioneer.	frame.results = {};	local itemNames = Auctioneer.Util.Split(itemName, "|");	local bidWorthyAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.BidBrokerFilter, minProfit, maxTimeLeft, category, minQuality, itemNames);	if (bidWorthyAuctions) then		local player = UnitName("player");		for pos,a in pairs(bidWorthyAuctions) do			if (a.owner ~= player) then				local id,rprop,enchant,name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);				local itemKey = id .. ":" .. rprop..":"..enchant;				local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, Auctioneer.Util.GetAuctionKey());				local currentBid = Auctioneer.Statistic.GetCurrentBid(a.signature);				-- rounding down the hsp, to get a better selling price				local hspBuyout = Auctioneer.Statistic.RoundDownTo95(hsp * count);				local percentLess = 100 - math.floor(100 * currentBid / (hspBuyout));				if (percentLess >= minPercentLess) then					local auction = {};					auction.id = id;					auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);					auction.link = a.itemLink;					auction.name = name;					auction.count = count;					auction.owner = a.owner;					auction.timeLeft = a.timeLeft;					auction.bid = currentBid;					auction.bidPer = math.floor(auction.bid / count);					auction.buyout = buyout;					auction.buyoutPer = math.floor(auction.buyout / count);					auction.profit = hspBuyout - currentBid;					auction.profitPer = math.floor(auction.profit / count);					auction.percentLess = percentLess;					auction.signature = a.signature;					if (a.highBidder) then						auction.status = AUCTION_STATUS_HIGH_BIDDER;					else						auction.status = AUCTION_STATUS_UNKNOWN;					end					auction.pendingBidCount = 0;					table.insert(frame.results, auction);				end			end		end	end	-- Hand the updated results to the list.	frame.resultsType = "BidSearch";	frame:SelectResultByIndex(nil);	ListTemplate_Initialize(frame.resultsList, frame.bidSearchPhysicalColumns, frame.auctioneerListLogicalColumns);	ListTemplate_SetContent(frame.resultsList, frame.results);	ListTemplate_Sort(frame.resultsList, 2);	ListTemplate_Sort(frame.resultsList, 3);end--------------------------------------------------------------------------------- Perform a buyout search (aka percentLess)-------------------------------------------------------------------------------function AuctionFrameSearch_SearchBuyouts(frame, minProfit, minPercentLess, category, minQuality, itemName)	-- Create the content from auctioneer.	frame.results = {};	local itemNames = Auctioneer.Util.Split(itemName, "|");	local buyoutWorthyAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.PercentLessFilter, minPercentLess, category, minQuality, itemNames);	if (buyoutWorthyAuctions) then		local player = UnitName("player");		for pos,a in pairs(buyoutWorthyAuctions) do			if (a.owner ~= player) then				local id,rprop,enchant,name,count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);				local itemKey = id .. ":" .. rprop..":"..enchant;				local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, Auctioneer.Util.GetAuctionKey());				-- rounding down the hsp, to get a better selling price				local hspBuyout = Auctioneer.Statistic.RoundDownTo95(hsp * count);				local profit = hspBuyout - buyout;				if (profit >= minProfit) then					local auction = {};					auction.id = id;					auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);					auction.link = a.itemLink;					auction.name = name;					auction.count = count;					auction.owner = a.owner;					auction.timeLeft = a.timeLeft;					auction.buyout = buyout;					auction.buyoutPer = math.floor(auction.buyout / count);					auction.profit = profit;					auction.profitPer = math.floor(auction.profit / count);					auction.percentLess = 100 - math.floor(100 * buyout / hspBuyout);					auction.signature = a.signature;					if (a.highBidder) then						auction.status = AUCTION_STATUS_HIGH_BIDDER;					else						auction.status = AUCTION_STATUS_UNKNOWN;					end					auction.pendingBidCount = 0;					table.insert(frame.results, auction);				end			end		end	end	-- Hand the updated content to the list.	frame.resultsType = "BuyoutSearch";	frame:SelectResultByIndex(nil);	ListTemplate_Initialize(frame.resultsList, frame.buyoutSearchPhysicalColumns, frame.auctioneerListLogicalColumns);	ListTemplate_SetContent(frame.resultsList, frame.results);	ListTemplate_Sort(frame.resultsList, 5);end--------------------------------------------------------------------------------- Perform a competition search (aka compete)-------------------------------------------------------------------------------function AuctionFrameSearch_SearchCompetition(frame, minUndercut)	-- Create the content from auctioneer.	frame.results = {};	-- Get the highest prices for my auctions.	local myAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.AuctionOwnerFilter, UnitName("player"));	local myHighestPrices = {}	local id,rprop,enchant,name,count,min,buyout,uniq,itemKey,competingAuctions,currentBid,buyoutForOne,bidForOne,bidPrice,myBuyout,buyPrice,myPrice,priceLess,lessPrice,output;	if (myAuctions) then		for pos,a in pairs(myAuctions) do			id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);			if (count > 1) then buyout = buyout/count; end			itemKey = id .. ":" .. rprop..":"..enchant;			if (not myHighestPrices[itemKey]) or (myHighestPrices[itemKey] < buyout) then				myHighestPrices[itemKey] = buyout;			end		end	end	-- Search for competing auctions less than mine.	competingAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.CompetingFilter, minUndercut, myHighestPrices);	if (competingAuctions) then		table.sort(competingAuctions, Auctioneer.Statistic.ProfitComparisonSort);		for pos,a in pairs(competingAuctions) do			local id,rprop,enchant,name,count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);			local itemKey = id .. ":" .. rprop..":"..enchant;			local myBuyout = myHighestPrices[itemKey];			local currentBid = Auctioneer.Statistic.GetCurrentBid(a.signature);			local auction = {};			auction.id = id;			auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);			auction.link = a.itemLink;			auction.name = name;			auction.count = count;			auction.owner = a.owner;			auction.timeLeft = a.timeLeft;			auction.bid = currentBid;			auction.bidPer = math.floor(auction.bid / count);			auction.buyout = buyout;			auction.buyoutPer = math.floor(auction.buyout / count);			auction.percentLess = math.floor(((myBuyout - auction.buyoutPer) / myBuyout) * 100);			auction.signature = a.signature;			if (a.highBidder) then				auction.status = AUCTION_STATUS_HIGH_BIDDER;			else				auction.status = AUCTION_STATUS_UNKNOWN;			end			auction.pendingBidCount = 0;			table.insert(frame.results, auction);		end	end	-- Hand the updated content to the list.	frame.resultsType = "CompeteSearch";	frame:SelectResultByIndex(nil);	ListTemplate_Initialize(frame.resultsList, frame.competeSearchPhysicalColumns, frame.auctioneerListLogicalColumns);	ListTemplate_SetContent(frame.resultsList, frame.results);end--------------------------------------------------------------------------------- Perform a plain search-------------------------------------------------------------------------------function AuctionFrameSearch_SearchPlain(frame, maxPrice, category, minQuality, itemName)	-- Create the content from auctioneer.	frame.results = {};	local itemNames = Auctioneer.Util.Split(itemName, "|");	local bidWorthyAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.PlainFilter, maxPrice, category, minQuality, itemNames);	if (bidWorthyAuctions) then		local player = UnitName("player");		for pos,a in pairs(bidWorthyAuctions) do			if (a.owner ~= player) then				local id,rprop,enchant,name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);				local itemKey = id .. ":" .. rprop..":"..enchant;				local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, Auctioneer.Util.GetAuctionKey());				local currentBid = Auctioneer.Statistic.GetCurrentBid(a.signature);				-- rounding down the hsp, to get a better selling price				local hspBuyout = Auctioneer.Statistic.RoundDownTo95(hsp * count);				local percentLess = 100 - math.floor(100 * currentBid / hspBuyout);				local _,_,_,iLevel = GetItemInfo(id);				local auction = {};				auction.id = id;				auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);				auction.link = a.itemLink;				auction.level = iLevel;				auction.name = name;				auction.count = count;				auction.owner = a.owner;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -