欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

ct_mminbox.lua

时间太紧了
LUA
第 1 页 / 共 2 页
字号:
		OpenMailPackageButton:SetScript("OnClick", CT_MMForward_oldTakeInboxItem);
	end
end

CT_MMForward_oldOpenMail_Reply = OpenMail_Reply;
function CT_MMForward_newOpenMail_Reply()
	CT_MMForward_oldOpenMail_Reply();
	SendMailMoneyCopper:SetText("");
	SendMailMoneySilver:SetText("");
	SendMailMoneyGold:SetText("");
end
OpenMail_Reply = CT_MMForward_newOpenMail_Reply;


CT_MMInbox_oldSendMailPackageButton_OnEnter = SendMailPackageButton:GetScript("OnEnter");
function CT_MMForward_OpenReply()
	OpenMail_Reply();
	local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply = GetInboxHeaderInfo(InboxFrame.openMailID);
	
	-- Money
	local gold, silver, copper = "", "", "";
	if ( money and money > 0 ) then
		gold = floor(money / (COPPER_PER_SILVER * SILVER_PER_GOLD));
		silver = floor((money - (gold * COPPER_PER_SILVER * SILVER_PER_GOLD)) / COPPER_PER_SILVER);
		copper = mod(money, COPPER_PER_SILVER);
	end
	SendMailMoneyCopper:SetText(copper);
	SendMailMoneySilver:SetText(silver);
	SendMailMoneyGold:SetText(gold);
	
	-- Items
	local name, itemTexture, count, quality, canUse = GetInboxItem(InboxFrame.openMailID);
	SendMailPackageButton:SetNormalTexture(itemTexture);
	if ( count > 1 ) then
		SendMailPackageButtonCount:SetText(count);
	else
		SendMailPackageButtonCount:SetText("");
	end
	
	-- Text fields
	local subject = OpenMailSubject:GetText();
	local prefix = "FW:".." ";
	if ( strsub(subject, 1, strlen(prefix)) ~= prefix ) then
		subject = prefix..subject;
	end
	SendMailSubjectEditBox:SetText(subject or "")
	SendMailBodyEditBox:SetText(string.gsub(OpenMailBodyText:GetText() or "", "\n", "\n>"));
	SendMailNameEditBox:SetFocus();
	-- Set the send mode so the work flow can change accordingly
	SendMailFrame.sendMode = "reply";
	
	CT_MMForward_EnableForward(1);
	if(EasyMail_LastMailed) then
		local text = SendMailNameEditBox:GetText();
		if(not text or text == "") then
			 SendMailNameEditBox:SetText(EasyMail_LastMailed);
			 CT_MailNameEditBox:SetText(EasyMail_LastMailed);
		end
	end
end

CT_MMForward_oldSendMailMailButton_OnClick = SendMailMailButton_OnClick;
CT_MMForward_oldSendMailPackageButton_OnClick = SendMailPackageButton_OnClick;
function CT_MMForward_newSendMailMailButton_OnClick()
	local name, itemTexture, count, quality, canUse = GetInboxItem(InboxFrame.openMailID);
	local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply = GetInboxHeaderInfo(InboxFrame.openMailID);
	if ( name ) then
		CT_MMForwardFrame.searchItem = name;
		CT_MMForwardFrame.forwardStep = 1;
		CT_MMForward_oldTakeInboxItem(InboxFrame.openMailID);		
	else
		CT_MMForwardFrame.forwardStep = 2;
		if ( money and money > 0 ) then
			SetSendMailMoney(money);
			CT_MMForwardFrame.countDown = 2;
			CT_MMForward_oldTakeInboxMoney(InboxFrame.openMailID);
		else
			CT_MMForwardFrame.countDown = 0.5;
		end
	end
	SendMailMailButton:Disable();
end

function CT_MMForward_OnUpdate(elapsed)
	if ( this.forwardStep and this.forwardStep > 1 ) then
		if ( this.countDown ) then
			this.countDown = this.countDown - elapsed;
			if ( this.countDown <= 0 ) then
				if ( this.forwardStep == 2 ) then
					this.countDown = 0.5;
					this.forwardStep = 3;
					-- Send the mail					
					SendMail(SendMailNameEditBox:GetText(), SendMailSubjectEditBox:GetText(), SendMailBodyEditBox:GetText());
					SendMailMailButton:Disable();					
				elseif ( this.forwardStep == 3 ) then
					-- Delete the old one
					local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, itemID, wasRead, wasReturned, textCreated  = GetInboxHeaderInfo(InboxFrame.openMailID);
					if ( money == 0 and not itemID ) then
						DeleteInboxItem(InboxFrame.openMailID);
					end
					MailFrameTab_OnClick(1);
					HideUIPanel(OpenMailFrame);
					this.countDown = nil;
					this.forwardStep = nil;
				end
			end
		end
	end
	this.process = this.process - elapsed;
	if ( this.process <= 0 ) then
		this.process = 3;
		if ( getn(CT_MMForward_ScheduledStack) > 0 ) then
			CT_MMForward_ProcessStack();
		end
	end
end

CT_MMForward_oldInboxFrame_OnClick = InboxFrame_OnClick;
function CT_MMForward_newInboxFrame_OnClick(id)
	CT_MMForward_oldInboxFrame_OnClick(id);
	local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, itemID, wasRead, wasReturned, textCreated  = GetInboxHeaderInfo(id);
	if ( CODAmount and CODAmount > 0 ) then
		OpenMailForwardButton:Disable();
	else
		OpenMailForwardButton:Enable();
	end
end
InboxFrame_OnClick = CT_MMForward_newInboxFrame_OnClick;

function CT_MMForward_EnableForward(enable)
	if ( enable ) then
		OpenMailForwardButton:Disable();
		SendMailPackageButton:SetScript("OnEnter", function() GameTooltip:SetOwner(SendMailPackageButton, "ANCHOR_RIGHT") GameTooltip:SetInboxItem(InboxFrame.openMailID) end);
		SendMailCODButton:Disable();
		CT_MMForward_DisableAttachments(1);
		SendMailMailButton_OnClick = CT_MMForward_newSendMailMailButton_OnClick;
		SendMailPackageButton_OnClick = function() end;
	else
		OpenMailForwardButton:Enable();
		SendMailPackageButton:SetScript("OnEnter", CT_MMInbox_oldSendMailPackageButton_OnEnter);
		SendMailCODButton:Enable();
		CT_MMForward_DisableAttachments(nil);
		SendMailPackageButton_OnClick = CT_MMForward_oldSendMailPackageButton_OnClick;
		SendMailMailButton_OnClick = CT_MMForward_oldSendMailMailButton_OnClick;
	end
end

function CT_MMForward_AttachSlot(container, item)
	PickupContainerItem(container, item);
	ClickSendMailItemButton();
	CT_MMForwardFrame.searchItem = nil;
	CT_MMForwardFrame.forwardStep = 2;
	CT_MMForwardFrame.countDown = 1.5;
end

function CT_MMForward_ScanItems()
	local old = { };
	for k, v in CT_MMForward_BagLinks do
		if ( type(v) == "table" ) then
			old[k] = { };
			for key, val in v do
				old[k][key] = val;
			end
		end
	end
	CT_MMForward_BagLinks = { };
	for i = 0, 4, 1 do
		CT_MMForward_BagLinks[i] = { };
		for y = 1, GetContainerNumSlots(i), 1 do
			local curr = GetContainerItemLink(i, y);
			local _, _, name = string.find(( curr or "" ), "%[(.+)%]");
			if ( name ) then
				if ( CT_MMForwardFrame.searchItem ) then
					if ( name and name == CT_MMForwardFrame.searchItem and not old[i][y] ) then
						CT_MMForward_AttachSlot(i, y);
					end
				else
					local _, _, name = string.find(( curr or "" ), "%[(.+)%]");
					if ( name and name == CT_MMForwardFrame.pickItem[1] and not old[i][y] ) then
						tremove(CT_MMForwardFrame.pickItem, 1);
						for k, v in old do
							local hasFound;
							for key, val in v do
								if ( val == name and ( k ~= i or key ~= y ) ) then
									local _,_, link = string.find((GetContainerItemLink(k, key) or ""), "(item:[%d:]+)")
									if ( link ) then
										local texture, itemCount = GetContainerItemInfo(k,key);
										local tex, iC = GetContainerItemInfo(i, y);
										local sName, sLink, iQuality, iLevel, sType, sSubType, iCount = GetItemInfo(link);
										if ( sName and itemCount and iCount and iC ) then
											if ( iCount >= (itemCount+iC) ) then
												if ( getn(CT_MMForward_ScheduledStack) == 0 ) then
													CT_MMForwardFrame.process = 2;
												end
												tinsert(CT_MMForward_ScheduledStack, { i, y, k, key });
												hasFound = 1;
												break;
											end
										end
									end
								end
							end
							if ( hasFound ) then
								break;
							end
						end
					end
				end
				CT_MMForward_BagLinks[i][y] = name;
			end
		end
	end
end

CT_MMForward_ScheduledStack = { };

function CT_MMForward_ProcessStack()
	local val = tremove(CT_MMForward_ScheduledStack, 1);
	PickupContainerItem(val[1], val[2]);
	PickupContainerItem(val[3], val[4]);
end

CT_MMForward_oldMailFrameTab_OnClick = MailFrameTab_OnClick;
function CT_MMForward_newMailFrameTab_OnClick(id)
	if(EasyMail_LastMailed) then
		local text = SendMailNameEditBox:GetText();
		if(not text or text == "") then
			 SendMailNameEditBox:SetText(EasyMail_LastMailed);
			 CT_MailNameEditBox:SetText(EasyMail_LastMailed);
		end
	end
	CT_MMForward_EnableForward();
	CT_MMForward_oldMailFrameTab_OnClick(id);	
end
MailFrameTab_OnClick = CT_MMForward_newMailFrameTab_OnClick;

local oldSMMFfunc = SendMailMoneyFrame.onvalueChangedFunc;
SendMailMoneyFrame.onvalueChangedFunc = function()
	if ( oldSMMFfunc ) then
		oldSMMFfunc();
	end
	local subject = SendMailSubjectEditBox:GetText();
	if ( subject == "" or string.find(subject, "%[%d+G, %d+S, %d+C%]") ) then
		local copper, silver, gold = SendMailMoneyFrameCopper:GetText(), SendMailMoneyFrameSilver:GetText(), SendMailMoneyFrameGold:GetText();
		if ( not tonumber(copper) ) then
			copper = 0;
		end
		if ( not tonumber(silver) ) then
			silver = 0;
		end
		if ( not tonumber(gold) ) then
			gold = 0;
		end
		SendMailSubjectEditBox:SetText(format("[%sG, %sS, %sC]", gold, silver, copper));
	end
end

--hook friend

--Sea.util.hook("SendMailFrame_SendMail","EasyMail_SendMail","before");
function EasyMailFriendButton_OnClick()
	local index=this:GetID()
	if index > 0 then
		EasyMail_LastMailed=GetFriendInfo(index)
	end
end
function EasyMailGuild_OnClick()
	local index=GuildFrame.selectedGuildMember
	if index > 0 then
		EasyMail_LastMailed=GetGuildRosterInfo(index)
	end
end

⌨️ 快捷键说明

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