修改优化等

This commit is contained in:
rucky
2026-03-18 02:01:36 +08:00
parent 2a55dd6dad
commit 923a1f9ce2
15 changed files with 1578 additions and 371 deletions

View File

@@ -177,11 +177,18 @@ local function SendTradeWhisper()
return
end
table.insert(outLines, "=== 濞存嚎鍊栧Σ妤冩媼閺夎法绉?===")
if playerMoneyStr then table.insert(outLines, "濞寸姵锚閸ゎ參鏌岄幋婵堫伈: " .. playerMoneyStr) end
if giveItems ~= "" then table.insert(outLines, "濞寸姵锚閸ゎ參鎮ч埡浣规儌: " .. giveItems) end
if targetMoneyStr then table.insert(outLines, "闁衡偓閹澘绠梺鍙夊灥缁? " .. targetMoneyStr) end
if getItems ~= "" then table.insert(outLines, "闁衡偓閹澘绠柣妞绘櫅閹? " .. getItems) end
local useCN = (SFramesDB.TradeWhisperLang == "ZH")
local header = useCN and "=== 交易完成清单 ===" or "=== Trade Summary ==="
local lblGiveG = useCN and "我方金币: " or "I gave gold: "
local lblGiveI = useCN and "我方物品: " or "I gave items: "
local lblGotG = useCN and "对方金币: " or "I got gold: "
local lblGotI = useCN and "对方物品: " or "I got items: "
table.insert(outLines, header)
if playerMoneyStr then table.insert(outLines, lblGiveG .. playerMoneyStr) end
if giveItems ~= "" then table.insert(outLines, lblGiveI .. giveItems) end
if targetMoneyStr then table.insert(outLines, lblGotG .. targetMoneyStr) end
if getItems ~= "" then table.insert(outLines, lblGotI .. getItems) end
for _, line in ipairs(outLines) do
SendLine(line, channel, target)
@@ -195,11 +202,14 @@ local function ClearTradeData()
TRADE_DATA.targetMoney = 0
end
local tradeWhisperSent = false
local function IsTradeCompleteMsg(msg)
if not msg then return false end
if string.find(msg, "Trade successful") then return true end
if string.find(msg, "Trade complete") then return true end
if string.find(msg, "Trade complete") then return true end
if string.find(msg, "交易完成") then return true end
if string.find(msg, "交易成功") then return true end
return false
end
@@ -216,6 +226,7 @@ end
TradeUI:SetScript("OnEvent", function()
if event == "TRADE_SHOW" then
tradeWhisperSent = false
TRADE_DATA.active = true
TRADE_DATA.targetName = UnitName("NPC") or ""
TRADE_DATA.playerItems = {}
@@ -243,16 +254,23 @@ TradeUI:SetScript("OnEvent", function()
SaveTradeState()
ForceRefreshTradeVisuals()
elseif event == "TRADE_CLOSED" then
if TRADE_DATA.playerAccepted and TRADE_DATA.targetAccepted and not tradeWhisperSent then
tradeWhisperSent = true
SendTradeWhisper()
ClearTradeData()
end
TRADE_DATA.active = false
TRADE_DATA.playerAccepted = false
TRADE_DATA.targetAccepted = false
elseif event == "UI_INFO_MESSAGE" then
if IsTradeCompleteMsg(arg1) then
if IsTradeCompleteMsg(arg1) and not tradeWhisperSent then
tradeWhisperSent = true
SendTradeWhisper()
ClearTradeData()
end
elseif event == "CHAT_MSG_SYSTEM" then
if IsTradeCompleteMsg(arg1) then
if IsTradeCompleteMsg(arg1) and not tradeWhisperSent then
tradeWhisperSent = true
SendTradeWhisper()
ClearTradeData()
end
@@ -305,7 +323,7 @@ local function ScanItemLevelFromTooltip()
local text = line:GetText()
if text then
local _, _, ilvl = string.find(text, "(%d+)")
if string.find(text, "Item Level") or string.find(text, "iLvl") or string.find(text, "ilvl") or string.find(text, "鐗╁搧绛夌骇") then
if string.find(text, "Item Level") or string.find(text, "iLvl") or string.find(text, "ilvl") or string.find(text, "物品等级") then
if ilvl then return tonumber(ilvl) end
end
end
@@ -1025,17 +1043,19 @@ local function SkinTradeFrame()
SFramesDB = SFramesDB or {}
local selected = SFramesDB.TradeWhisperChannel or "WHISPER"
for _, info in ipairs(channels) do
local capturedText = info.text
local capturedValue = info.value
local d = {}
d.text = info.text
d.value = info.value
d.text = capturedText
d.value = capturedValue
d.func = function()
SFramesDB = SFramesDB or {}
SFramesDB.TradeWhisperChannel = this.value
UIDropDownMenu_SetSelectedValue(drop, this.value)
SFramesDB.TradeWhisperChannel = capturedValue
UIDropDownMenu_SetSelectedValue(drop, capturedValue)
local txt = _G[drop:GetName() .. "Text"]
if txt then txt:SetText(info.text) end
if txt then txt:SetText(capturedText) end
end
d.checked = (info.value == selected)
d.checked = (capturedValue == selected)
UIDropDownMenu_AddButton(d)
end
end
@@ -1051,6 +1071,55 @@ local function SkinTradeFrame()
end
end
end
-- Language dropdown (EN / ZH)
local langDrop = CreateFrame("Frame", "SFramesTradeLangObj", TradeFrame, "UIDropDownMenuTemplate")
langDrop:SetPoint("LEFT", drop, "RIGHT", -16, 0)
UIDropDownMenu_SetWidth(50, langDrop)
local langDropText = _G[langDrop:GetName() .. "Text"]
if langDropText then
langDropText:SetFont(GetFont(), 10, "OUTLINE")
langDropText:SetTextColor(T.nameText[1], T.nameText[2], T.nameText[3])
end
local langs = {
{ text = "EN", value = "EN" },
{ text = "中文", value = "ZH" },
}
local function TradeLangDropInit()
SFramesDB = SFramesDB or {}
local selected = SFramesDB.TradeWhisperLang or "EN"
for _, info in ipairs(langs) do
local capText = info.text
local capValue = info.value
local d = {}
d.text = capText
d.value = capValue
d.func = function()
SFramesDB = SFramesDB or {}
SFramesDB.TradeWhisperLang = capValue
UIDropDownMenu_SetSelectedValue(langDrop, capValue)
local txt = _G[langDrop:GetName() .. "Text"]
if txt then txt:SetText(capText) end
end
d.checked = (capValue == selected)
UIDropDownMenu_AddButton(d)
end
end
UIDropDownMenu_Initialize(langDrop, TradeLangDropInit)
SFramesDB = SFramesDB or {}
UIDropDownMenu_SetSelectedValue(langDrop, SFramesDB.TradeWhisperLang or "EN")
if langDropText then
for _, info in ipairs(langs) do
if info.value == (SFramesDB.TradeWhisperLang or "EN") then
langDropText:SetText(info.text)
break
end
end
end
end
-- Close button