更新配置相关显示等

This commit is contained in:
rucky
2026-03-20 14:04:51 +08:00
parent 923a1f9ce2
commit 63337b14d2
14 changed files with 886 additions and 98 deletions

View File

@@ -1526,6 +1526,9 @@ local function ShortKeyText(key)
key = string.gsub(key, "ALT%-", "A-")
key = string.gsub(key, "MOUSEWHEELUP", "WhlUp")
key = string.gsub(key, "MOUSEWHEELDOWN", "WhlDn")
key = string.gsub(key, "BUTTON3", "M3")
key = string.gsub(key, "BUTTON4", "M4")
key = string.gsub(key, "BUTTON5", "M5")
return key
end
@@ -1547,21 +1550,29 @@ local function UpdateOverlayText(button)
ov.label:SetText(t)
end
local CLICK_TO_KEY = {
MiddleButton = "BUTTON3",
Button4 = "BUTTON4",
Button5 = "BUTTON5",
}
local function CreateBindOverlay(button)
if keyBindOverlays[button] then return keyBindOverlays[button] end
local ov = CreateFrame("Button", nil, button)
ov:SetAllPoints(button)
ov:SetFrameLevel(button:GetFrameLevel() + 10)
ov:RegisterForClicks("RightButtonUp")
ov:RegisterForClicks("RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up")
local bg = ov:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetTexture(0, 0, 0, 0.55)
local label = ov:CreateFontString(nil, "OVERLAY")
label:SetFont(SFrames:GetFont(), 9, "OUTLINE")
label:SetFont(SFrames:GetFont(), 7, "OUTLINE")
label:SetPoint("CENTER", ov, "CENTER", 0, 0)
label:SetWidth(button:GetWidth() - 2)
label:SetJustifyH("CENTER")
label:SetTextColor(1, 0.82, 0)
ov.label = label
@@ -1576,11 +1587,11 @@ local function CreateBindOverlay(button)
if cmd then
GameTooltip:AddLine(cmd, 1, 0.82, 0)
local k1, k2 = GetBindingKey(cmd)
if k1 then GameTooltip:AddLine("Key 1: " .. k1, 1, 1, 1) end
if k2 then GameTooltip:AddLine("Key 2: " .. k2, 0.7, 0.7, 0.7) end
if k1 then GameTooltip:AddLine("按键 1: " .. k1, 1, 1, 1) end
if k2 then GameTooltip:AddLine("按键 2: " .. k2, 0.7, 0.7, 0.7) end
end
GameTooltip:AddLine("Press key to bind / Wheel to bind", 0.5, 0.8, 0.5)
GameTooltip:AddLine("Right-click to clear", 0.8, 0.5, 0.5)
GameTooltip:AddLine("按下按键/鼠标键/滚轮绑定", 0.5, 0.8, 0.5)
GameTooltip:AddLine("右键点击清除绑定", 0.8, 0.5, 0.5)
GameTooltip:Show()
end)
ov:SetScript("OnLeave", function()
@@ -1597,7 +1608,22 @@ local function CreateBindOverlay(button)
SaveBindings(2)
UpdateOverlayText(button)
RefreshButtonHotkey(button)
DEFAULT_CHAT_FRAME:AddMessage("|cff88ccff[Nanami-UI]|r Cleared bindings for " .. cmd)
DEFAULT_CHAT_FRAME:AddMessage("|cff88ccff[Nanami-UI]|r 已清除 " .. cmd .. " 的绑定")
end
else
local mouseKey = CLICK_TO_KEY[arg1]
if mouseKey then
local cmd = GetButtonBindingCmd(button)
if not cmd then return end
local keyStr = BuildKeyString(mouseKey)
if not keyStr then return end
local old = GetBindingAction(keyStr)
if old and old ~= "" and old ~= cmd then SetBinding(keyStr, nil) end
SetBinding(keyStr, cmd)
SaveBindings(2)
UpdateOverlayText(button)
RefreshButtonHotkey(button)
DEFAULT_CHAT_FRAME:AddMessage("|cff88ccff[Nanami-UI]|r " .. keyStr .. " -> " .. cmd)
end
end
end)
@@ -1702,7 +1728,7 @@ function AB:EnterKeyBindMode()
desc:SetPoint("TOP", title, "BOTTOM", 0, -6)
desc:SetWidth(300)
desc:SetJustifyH("CENTER")
desc:SetText("悬停按钮 + 按键绑定 | 右键清除 | 滚轮绑定")
desc:SetText("悬停按钮 + 按键/鼠标键/滚轮绑定 | 右键清除")
desc:SetTextColor(0.82, 0.82, 0.82)
local saveBtn = CreateFrame("Button", "SFramesKeyBindSave", statusFrame, "UIPanelButtonTemplate")
@@ -1713,12 +1739,57 @@ function AB:EnterKeyBindMode()
saveBtn:SetScript("OnClick", function()
AB:ExitKeyBindMode()
end)
local _T = SFrames.ActiveTheme
local function HideBindBtnTex(tex)
if not tex then return end
if tex.SetTexture then tex:SetTexture(nil) end
if tex.SetAlpha then tex:SetAlpha(0) end
if tex.Hide then tex:Hide() end
end
HideBindBtnTex(saveBtn:GetNormalTexture())
HideBindBtnTex(saveBtn:GetPushedTexture())
HideBindBtnTex(saveBtn:GetHighlightTexture())
HideBindBtnTex(saveBtn:GetDisabledTexture())
for _, sfx in ipairs({"Left","Right","Middle"}) do
local t = _G["SFramesKeyBindSave"..sfx]
if t then t:SetAlpha(0); t:Hide() end
end
saveBtn:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 14,
insets = { left = 3, right = 3, top = 3, bottom = 3 },
})
saveBtn:SetBackdropColor(_T.btnBg[1], _T.btnBg[2], _T.btnBg[3], _T.btnBg[4])
saveBtn:SetBackdropBorderColor(_T.btnBorder[1], _T.btnBorder[2], _T.btnBorder[3], _T.btnBorder[4])
local fs = saveBtn:GetFontString()
if fs then fs:SetFont(SFrames:GetFont(), 11) end
if fs then
fs:SetFont(SFrames:GetFont(), 11, "OUTLINE")
fs:SetTextColor(_T.btnText[1], _T.btnText[2], _T.btnText[3])
end
saveBtn:SetScript("OnEnter", function()
this:SetBackdropColor(_T.btnHoverBg[1], _T.btnHoverBg[2], _T.btnHoverBg[3], _T.btnHoverBg[4])
this:SetBackdropBorderColor(_T.btnHoverBorder[1], _T.btnHoverBorder[2], _T.btnHoverBorder[3], _T.btnHoverBorder[4])
local t = this:GetFontString()
if t then t:SetTextColor(_T.btnActiveText[1], _T.btnActiveText[2], _T.btnActiveText[3]) end
end)
saveBtn:SetScript("OnLeave", function()
this:SetBackdropColor(_T.btnBg[1], _T.btnBg[2], _T.btnBg[3], _T.btnBg[4])
this:SetBackdropBorderColor(_T.btnBorder[1], _T.btnBorder[2], _T.btnBorder[3], _T.btnBorder[4])
local t = this:GetFontString()
if t then t:SetTextColor(_T.btnText[1], _T.btnText[2], _T.btnText[3]) end
end)
saveBtn:SetScript("OnMouseDown", function()
this:SetBackdropColor(_T.btnDownBg[1], _T.btnDownBg[2], _T.btnDownBg[3], _T.btnDownBg[4])
end)
saveBtn:SetScript("OnMouseUp", function()
this:SetBackdropColor(_T.btnHoverBg[1], _T.btnHoverBg[2], _T.btnHoverBg[3], _T.btnHoverBg[4])
end)
end
statusFrame:Show()
DEFAULT_CHAT_FRAME:AddMessage("|cff88ccff[Nanami-UI]|r 按键绑定模式已开启。悬停按钮后按键绑定,右键清除,点击保存退出。")
DEFAULT_CHAT_FRAME:AddMessage("|cff88ccff[Nanami-UI]|r 按键绑定模式已开启。悬停按钮后按键/鼠标键/滚轮绑定,右键清除,ESC或点击保存退出。")
end
function AB:ExitKeyBindMode()