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

📄 auctionframepost.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
				quantityErrorText:SetTextColor(RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);				quantityErrorText:Show();			else				local msg = string.format(_AUCT('UiMaxError'), quantity);				quantityErrorText:SetText(msg);				quantityErrorText:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);				quantityErrorText:Show();			end		else			quantityErrorText:Hide();		end		-- TODO: Check that the player can afford the deposit cost.		local deposit = frame:GetDeposit();		-- Update the state of the Create Auction button.		local button = getglobal(frame:GetName().."CreateAuctionButton");		if (valid) then			button:Enable();		else			button:Disable();		end		-- Update the price model to reflect bid and buyout prices.		local dropdown = getglobal(frame:GetName().."PriceModelDropDown");		local index = UIDropDownMenu_GetSelectedID(dropdown);		if (index and frame.prices and index <= table.getn(frame.prices)) then			-- Check if the current selection matches			local currentPrice = frame.prices[index];			if ((currentPrice.bid and currentPrice.bid ~= startPrice) or				(currentPrice.buyout and currentPrice.buyout ~= buyoutPrice)) then				-- Nope, find one that does.				for index,price in pairs(frame.prices) do					if ((price.bid == nil or price.bid == startPrice) and (price.buyout == nil or price.buyout == buyoutPrice)) then						if (UIDropDownMenu_GetSelectedID(dropdown) ~= index) then							AuctionFramePost_PriceModelDropDownItem_SetSelectedID(dropdown, index);						end						break;					end				end			end		end	endend--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_AuctionItem_OnClick(button)	local frame = button:GetParent();	-- If the cursor has an item, get it and put it back down in its container.	local item = AuctioneerUI_GetCursorContainerItem();	if (item) then		PickupContainerItem(item.bag, item.slot);	end	-- Update the current item displayed	if (item) then		local itemLink = GetContainerItemLink(item.bag, item.slot)		local _, _, _, _, itemName = EnhTooltip.BreakLink(itemLink);		local _, count = GetContainerItemInfo(item.bag, item.slot);		frame:SetAuctionItem(item.bag, item.slot, count);	else		frame:SetAuctionItem(nil, nil, nil);	endend--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_DurationRadioButton_OnClick(button, index)	local frame = button:GetParent();	if (index == 1) then		Auctioneer.Command.SetFilter('last-auction-duration', 120)		frame:SetDuration(120);	elseif (index == 2) then		Auctioneer.Command.SetFilter('last-auction-duration', 480)		frame:SetDuration(480);	else		Auctioneer.Command.SetFilter('last-auction-duration', 1440)		frame:SetDuration(1440);	endend--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_StartPrice_OnChanged()	local frame = this:GetParent():GetParent();	if (not frame.ignoreStartPriceChange and not updating) then		frame:ValidateAuction();	end	frame.ignoreStartPriceChange = false;end--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_BuyoutPrice_OnChanged()	local frame = this:GetParent():GetParent();	if (not frame.ignoreBuyoutPriceChange and not frame.updating) then		local updatePrice = Auctioneer.Command.GetFilter('update-price');		if (updatePrice) then			frame.updating = true;			local discountBidPercent = tonumber(Auctioneer.Command.GetFilterVal('pct-bidmarkdown'));			local bidPrice = Auctioneer.Statistic.SubtractPercent(frame:GetBuyoutPrice(), discountBidPercent);			frame:SetStartPrice(bidPrice);			frame.updating = false;		end		frame:ValidateAuction();	end	frame.ignoreBuyoutPriceChange = false;end--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_StackSize_OnTextChanged()	local frame = this:GetParent();	-- Update the stack size displayed on the graphic.	local itemID = frame:GetItemID();	local stackSize = frame:GetStackSize();	if (itemID and stackSize > 1) then		getglobal(frame:GetName().."AuctionItemCount"):SetText(stackSize);		getglobal(frame:GetName().."AuctionItemCount"):Show();	else		getglobal(frame:GetName().."AuctionItemCount"):Hide();	end	-- Update the deposit and validate the auction.	frame:UpdateDeposit();	frame:UpdatePriceModels();	frame:ValidateAuction();end--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_StackCount_OnTextChanged()	local frame = this:GetParent();	frame:UpdateDeposit();	frame:ValidateAuction();end--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_CreateAuctionButton_OnClick(button)	local frame = button:GetParent();	local id = frame:GetItemID();	local name = frame:GetItemName();	local startPrice = frame:GetStartPrice();	local buyoutPrice = frame:GetBuyoutPrice();	local stackSize = frame:GetStackSize();	local stackCount = frame:GetStackCount();	local duration = frame:GetDuration();	local deposit = frame:GetDeposit();	-- Check if we should save the pricing information.	if (frame:GetSavePrice()) then		local bag, slot, id, rprop, enchant, uniq = EnhTooltip.FindItemInBags(name);		local itemKey = id..":"..rprop..":"..enchant;		Auctioneer.Storage.SetFixedPrice(itemKey, startPrice, buyoutPrice, duration, stackSize, Auctioneer.Util.GetAuctionKey());	end	-- Post the auction.	AucPostManager.PostAuction(id, stackSize, stackCount, startPrice, buyoutPrice, duration);	-- Clear the current auction item.	frame:SetAuctionItem(nil, nil, nil);end--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_PriceModelDropDown_Initialize()	local dropdown = this:GetParent();	local frame = dropdown:GetParent();	if (frame.prices) then		for index in frame.prices do			local price = frame.prices[index];			local info = {};			info.text = price.text;			info.func = AuctionFramePost_PriceModelDropDownItem_OnClick;			info.owner = dropdown;			UIDropDownMenu_AddButton(info);		end	endend--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_PriceModelDropDownItem_OnClick()	local index = this:GetID();	local dropdown = this.owner;	local frame = dropdown:GetParent();	if (frame.prices) then		AuctionFramePost_PriceModelDropDownItem_SetSelectedID(dropdown, index);	endend--------------------------------------------------------------------------------------------------------------------------------------------------------------function AuctionFramePost_PriceModelDropDownItem_SetSelectedID(dropdown, index)	local frame = dropdown:GetParent();	frame.updating = true;	if (index) then		local price = frame.prices[index]		if (price.note) then			frame:SetNoteText(price.note);		end		if (price.buyout) then			frame:SetBuyoutPrice(price.buyout);		end		if (price.bid) then			frame:SetStartPrice(price.bid);		end		if (price.text == _AUCT('UiPriceModelCustom')) then			getglobal(frame:GetName().."SavePriceText"):Show();			getglobal(frame:GetName().."SavePriceCheckBox"):Show();			getglobal(frame:GetName().."PriceModelNoteText"):Hide();		elseif (price.text == _AUCT('UiPriceModelAuctioneer')) then			getglobal(frame:GetName().."SavePriceText"):Hide();			getglobal(frame:GetName().."SavePriceCheckBox"):Hide();			getglobal(frame:GetName().."PriceModelNoteText"):Show();		else			getglobal(frame:GetName().."SavePriceText"):Hide();			getglobal(frame:GetName().."SavePriceCheckBox"):Hide();			getglobal(frame:GetName().."PriceModelNoteText"):Hide();		end		AuctioneerDropDownMenu_Initialize(dropdown, AuctionFramePost_PriceModelDropDown_Initialize);		AuctioneerDropDownMenu_SetSelectedID(dropdown, index);	else		frame:SetNoteText("");		frame:SetStartPrice(0);		frame:SetBuyoutPrice(0);		getglobal(frame:GetName().."SavePriceText"):Hide();		getglobal(frame:GetName().."SavePriceCheckBox"):Hide();		getglobal(frame:GetName().."PriceModelNoteText"):Hide();		UIDropDownMenu_ClearAll(dropdown);	end	frame.updating = false;	frame:ValidateAuction();end--------------------------------------------------------------------------------- Calculate the deposit required for the specified item.-------------------------------------------------------------------------------function AuctionFramePost_CalculateAuctionDeposit(itemID, count, duration)	local price = Auctioneer.API.GetVendorSellPrice(itemID);	if (price) then		local base = math.floor(count * price * GetAuctionHouseDepositRate() / 100);		return base * duration / 120;	endend--------------------------------------------------------------------------------- Calculate the maximum stack size for an item based on the information returned by GetItemInfo()-------------------------------------------------------------------------------function AuctionFramePost_GetMaxStackSize(itemID)	local _, _, _, _, _, _, itemStackCount = GetItemInfo(itemID);	return itemStackCount;end--------------------------------------------------------------------------------- Filter for Auctioneer.Filter.QuerySnapshot that filters on item name.-------------------------------------------------------------------------------function AuctionFramePost_ItemNameFilter(item, signature)	local id,rprop,enchant,name,count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature);	if (item == name) then		return false;	end	return true;end--------------------------------------------------------------------------------- Returns 1.0 for player auctions and 0.4 for competing auctions-------------------------------------------------------------------------------function AuctionFramePost_GetItemAlpha(record)	if (record.owner ~= UnitName("player")) then		return 0.4;	end	return 1.0;end--------------------------------------------------------------------------------- Returns the item color for the specified result-------------------------------------------------------------------------------function AuctionFramePost_GetItemColor(auction)	_, _, rarity = GetItemInfo(auction.item);	if (rarity) then		return ITEM_QUALITY_COLORS[rarity];	end	return { r = 1.0, g = 1.0, b = 1.0 };end

⌨️ 快捷键说明

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