📄 ct_mailmod.lua
字号:
end
return nil;
end
function CT_Mail_GetNumMails()
local i;
local num = 0;
for i = 1, CT_MAIL_NUMITEMBUTTONS, 1 do
local btn = getglobal("CT_MailButton" .. i);
if ( btn.item and btn.bag ) then
num = num + 1;
end
end
return num;
end
function CT_Mail_ClearItems()
local i;
local num = 0;
for i = 1, CT_MAIL_NUMITEMBUTTONS, 1 do
local btn = getglobal("CT_MailButton" .. i);
btn.item = nil;
btn.count = nil;
btn.bag = nil;
btn.texture = nil;
end
CT_Mail_UpdateItemButtons();
CT_MailMailButton:Disable();
CT_MailNameEditBox:SetText("");
CT_MailSubjectEditBox:SetText("");
CT_MailStatusText:SetText("");
CT_MailAbortButton:Hide();
CT_Mail_AcceptSendFrame:Hide();
end
function CT_Mail_AutoComplete()
local text = this:GetText();
local textlen = strlen(text);
local numFriends = GetNumFriends();
local name;
if ( numFriends > 0 ) then
for i=1, numFriends do
name = GetFriendInfo(i);
if ( name ) then
if ( strfind(strupper(name), "^"..strupper(text)) ) then
this:SetText(name);
this:HighlightText(textlen, -1);
return;
end
end
end
end
-- Hack to scan offline members
local oldOffline = GetGuildRosterShowOffline();
SetGuildRosterShowOffline(true);
local numGuildMembers = GetNumGuildMembers();
if ( numGuildMembers > 0 ) then
for i=1, numGuildMembers do
name = GetGuildRosterInfo(i);
if ( strfind(strupper(name), "^"..strupper(text)) ) then
this:SetText(name);
this:HighlightText(textlen, -1);
return;
end
end
end
-- Revert to old scanning
SetGuildRosterShowOffline(oldOffline);
end
SendMailFrame_SendeeAutocomplete = CT_Mail_AutoComplete; -- No need for a before/after hook, since our function does both friends & guildies
function CT_Mail_CanSend(eb)
if ( not eb ) then eb = this; end
if ( strlen(eb:GetText()) > 0 and CT_MailFrame.num > 0 and GetSendMailPrice()*CT_MailFrame.num <= GetMoney() ) then
CT_MailMailButton:Enable();
else
CT_MailMailButton:Disable();
end
end
function CT_Mail_SendMail()
for key, val in this.queue do
CT_MailStatusText:SetText(format(CT_MAIL_SENDING, key, this.total));
CT_MailAbortButton:Show();
if ( GetSendMailItem() and CT_MailFrame.mailbag and CT_MailFrame.mailitem ) then
-- There's already an item in the slot
ClickSendMailItemButton();
CT_oldPickupContainerItem(CT_MailFrame.mailbag, CT_MailFrame.mailitem);
CT_MailFrame.mailbag = nil;
CT_MailFrame.mailitem = nil;
elseif ( CursorHasItem() and CT_MailFrame.bag and CT_MailFrame.item ) then
PickupContainerItem(CT_MailFrame.bag, CT_MailFrame.item);
CT_MailFrame.bag = nil;
CT_MailFrame.item = nil;
end
CT_oldPickupContainerItem(val.bag, val.item);
ClickSendMailItemButton();
local name, useless, count = GetSendMailItem();
if ( not name ) then
DEFAULT_CHAT_FRAME:AddMessage("<CTMod> " .. CT_MAIL_ERROR, 1, 0, 0);
else
local subjectstr = CT_MailSubjectEditBox:GetText();
if ( strlen(subjectstr) > 0 ) then
subjectstr = subjectstr .. " ";
end
if ( count > 1 ) then
subjectstr = subjectstr .. "[" .. name .. " x" .. count .. "]";
else
subjectstr = subjectstr .. "[" .. name .. "]";
end
SendMail(val.to, subjectstr, format(CT_MAIL_ITEMNUM, key, this.total));
end
CT_MailGlobalFrame.queue[key] = nil;
return;
end
CT_MailStatusText:SetText(format(CT_MAIL_DONESENDING, this.total));
CT_MailAbortButton:Hide();
CT_MailGlobalFrame:Hide();
CT_MailGlobalFrame.total = 0;
CT_MailGlobalFrame.queue = { };
end
function CT_Mail_FillItemTable()
local arr = { };
for i = 1, CT_MAIL_NUMITEMBUTTONS, 1 do
local btn = getglobal("CT_MailButton" .. i);
if ( btn.item and btn.bag ) then
tinsert(arr, { ["item"] = btn.item, ["bag"] = btn.bag, ["to"] = CT_MailNameEditBox:GetText() });
end
end
return arr;
end
function CT_Mail_ProcessQueue(elapsed)
if ( not CT_Mail_CanSendNext ) then
return;
end
this.sendmail = this.sendmail + elapsed;
if ( this.sendmail > 0.5 ) then
this.sendmail = 0;
if ( this.total > 0 ) then
CT_Mail_SendMail();
CT_Mail_CanSendNext = nil;
end
end
end
local CT_oldMM_CF_U = ContainerFrame_Update
function CT_Mail_ContainerFrame_Update(frame)
CT_oldMM_CF_U(frame);
local id = frame:GetID();
if ( CT_MailFrame:IsVisible() ) then
local i;
for i = 1, CT_MAIL_NUMITEMBUTTONS, 1 do
local btn = getglobal("CT_MailButton" .. i);
if ( btn.item and btn.bag ) then
if ( btn.bag == frame:GetID() ) then
SetItemButtonDesaturated(getglobal(frame:GetName() .. "Item" .. (frame.size-btn.item)+1), 1, 0.5, 0.5, 0.5);
end
end
end
end
if ( CT_Mail_addItem and CT_Mail_addItem[1] == frame:GetID() ) then
SetItemButtonDesaturated(getglobal(frame:GetName() .. "Item" .. (frame.size-CT_Mail_addItem[2])+1), 1, 0.5, 0.5, 0.5);
end
end
ContainerFrame_Update = CT_Mail_ContainerFrame_Update;
function CT_Mail_AddSubject()
if ( not SendMailFrame:IsVisible() ) then return; end
local name, useless, count = GetSendMailItem();
if ( name and strlen(SendMailSubjectEditBox:GetText()) == 0 ) then
if ( count > 1 ) then
name = name .. " x" .. count;
end
SendMailSubjectEditBox:SetText(name);
end
end
function CT_Mail_OnEvent(event)
if ( event == "MAIL_SEND_SUCCESS" ) then
CT_Mail_CanSendNext = 1;
else
CT_Mail_AddSubject();
end
end
-- Show item link if there is one
CT_Mail_oldInboxFrameItem_OnEnter = InboxFrameItem_OnEnter;
function CT_Mail_newInboxFrameItem_OnEnter()
local didSetTooltip;
if ( this.index ) then
if ( GetInboxItem(this.index) ) then
GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
GameTooltip:SetInboxItem(this.index);
didSetTooltip = 1;
end
end
if ( not didSetTooltip ) then
GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
end
if (this.money) then
GameTooltip:AddLine(ENCLOSED_MONEY, "", 1, 1, 1);
SetTooltipMoney(GameTooltip, this.money);
SetMoneyFrameColor("GameTooltipMoneyFrame", HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
elseif (this.cod) then
GameTooltip:AddLine(COD_AMOUNT, "", 1, 1, 1);
SetTooltipMoney(GameTooltip, this.cod);
if ( this.cod > GetMoney() ) then
SetMoneyFrameColor("GameTooltipMoneyFrame", RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);
else
SetMoneyFrameColor("GameTooltipMoneyFrame", HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
end
end
if ( didSetTooltip and ( this.money or this.cod ) ) then
GameTooltip:SetHeight(GameTooltip:GetHeight()+getglobal("GameTooltipTextLeft" .. GameTooltip:NumLines()):GetHeight());
if ( GameTooltipMoneyFrame:IsVisible() ) then
GameTooltip:SetHeight(GameTooltip:GetHeight()+GameTooltipMoneyFrame:GetHeight());
end
end
GameTooltip:Show();
end
InboxFrameItem_OnEnter = CT_Mail_newInboxFrameItem_OnEnter;
-- Hook the TradeFrame OnShow
CT_Mail_oldTradeFrameShow = TradeFrame:GetScript("OnShow");
function CT_Mail_newTradeFrameShow()
CT_Mail_oldTradeFrameShow();
if ( CT_Mail_addItem and not CursorHasItem() and UnitName("NPC") == CT_Mail_addItem[3] ) then
CT_oldPickupContainerItem(CT_Mail_addItem[1], CT_Mail_addItem[2]);
ClickTradeButton(1);
end
CT_Mail_addItem = nil;
end
TradeFrame:SetScript("OnShow", CT_Mail_newTradeFrameShow);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -