完成多出修改
修复拾取界面点击无效问题 修复宠物训练界面不显示训练点问题 新增天赋分享到聊天界面 修复飞行界面无法关闭问题 修复术士宠物的显示问题 为天赋界面添加默认数据库支持 框架现在也可自主选择是否启用 玩家框架和目标框架可取消显示3D头像以及透明度修改 背包和银行也添加透明度自定义支持 优化tooltip性能和背包物品显示方式 修复布局模式在ui缩放后不能正常定位的问题 添加硬核模式危险和死亡的工会通报 添加拾取和已拾取的框体 等等
This commit is contained in:
232
Units/Pet.lua
232
Units/Pet.lua
@@ -7,6 +7,220 @@ local function Clamp(value, minValue, maxValue)
|
||||
return value
|
||||
end
|
||||
|
||||
function SFrames.Pet:ShowContextMenu()
|
||||
if not self.contextMenu then
|
||||
self.contextMenu = CreateFrame("Frame", "SFramesPetContextDD", UIParent, "UIDropDownMenuTemplate")
|
||||
end
|
||||
UIDropDownMenu_Initialize(self.contextMenu, function()
|
||||
local info
|
||||
|
||||
info = {}
|
||||
info.text = "查看属性"
|
||||
info.notCheckable = 1
|
||||
info.func = function()
|
||||
ToggleCharacter("PetPaperDollFrame")
|
||||
end
|
||||
UIDropDownMenu_AddButton(info)
|
||||
|
||||
local hasPetUI, isHunterPet = HasPetUI()
|
||||
if isHunterPet then
|
||||
info = {}
|
||||
info.text = "重命名"
|
||||
info.notCheckable = 1
|
||||
info.func = function() SFrames.Pet:ShowRenameDialog() end
|
||||
UIDropDownMenu_AddButton(info)
|
||||
|
||||
info = {}
|
||||
info.text = "解散宠物"
|
||||
info.notCheckable = 1
|
||||
info.func = function() if PetDismiss then PetDismiss() end end
|
||||
UIDropDownMenu_AddButton(info)
|
||||
|
||||
info = {}
|
||||
info.text = "放弃宠物"
|
||||
info.notCheckable = 1
|
||||
info.textR = 1; info.textG = 0.3; info.textB = 0.3
|
||||
info.func = function() if PetAbandon then PetAbandon() end end
|
||||
UIDropDownMenu_AddButton(info)
|
||||
else
|
||||
info = {}
|
||||
info.text = "解散宠物"
|
||||
info.notCheckable = 1
|
||||
info.func = function() if PetDismiss then PetDismiss() end end
|
||||
UIDropDownMenu_AddButton(info)
|
||||
end
|
||||
|
||||
info = {}
|
||||
info.text = CANCEL or "取消"
|
||||
info.notCheckable = 1
|
||||
info.func = function() CloseDropDownMenus() end
|
||||
UIDropDownMenu_AddButton(info)
|
||||
end, "MENU")
|
||||
ToggleDropDownMenu(1, nil, self.contextMenu, "SFramesPetFrame", 106, 27)
|
||||
end
|
||||
|
||||
function SFrames.Pet:CreateRenameFrame()
|
||||
local T = SFrames.ActiveTheme
|
||||
local font = SFrames:GetFont()
|
||||
local outline = (SFrames.Media and SFrames.Media.fontOutline) or "OUTLINE"
|
||||
|
||||
local f = CreateFrame("Frame", "SFramesPetRenameDialog", UIParent)
|
||||
f:SetWidth(300)
|
||||
f:SetHeight(120)
|
||||
f:SetPoint("CENTER", UIParent, "CENTER", 0, 80)
|
||||
f:SetFrameStrata("DIALOG")
|
||||
f:SetToplevel(true)
|
||||
f:EnableMouse(true)
|
||||
f:SetMovable(true)
|
||||
f:RegisterForDrag("LeftButton")
|
||||
f:SetScript("OnDragStart", function() this:StartMoving() end)
|
||||
f:SetScript("OnDragStop", function() this:StopMovingOrSizing() end)
|
||||
|
||||
f: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 },
|
||||
})
|
||||
f:SetBackdropColor(T.panelBg[1], T.panelBg[2], T.panelBg[3], T.panelBg[4])
|
||||
f:SetBackdropBorderColor(T.panelBorder[1], T.panelBorder[2], T.panelBorder[3], T.panelBorder[4])
|
||||
|
||||
local shadow = CreateFrame("Frame", nil, f)
|
||||
shadow:SetPoint("TOPLEFT", f, "TOPLEFT", -4, 4)
|
||||
shadow:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 4, -4)
|
||||
shadow:SetBackdrop({
|
||||
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true, tileSize = 16, edgeSize = 16,
|
||||
insets = { left = 4, right = 4, top = 4, bottom = 4 },
|
||||
})
|
||||
shadow:SetBackdropColor(0, 0, 0, 0.45)
|
||||
shadow:SetBackdropBorderColor(0, 0, 0, 0.6)
|
||||
shadow:SetFrameLevel(math.max(0, f:GetFrameLevel() - 1))
|
||||
|
||||
local header = CreateFrame("Frame", nil, f)
|
||||
header:SetPoint("TOPLEFT", f, "TOPLEFT", 3, -3)
|
||||
header:SetPoint("TOPRIGHT", f, "TOPRIGHT", -3, -3)
|
||||
header:SetHeight(26)
|
||||
header:SetBackdrop({ bgFile = "Interface\\Buttons\\WHITE8X8" })
|
||||
header:SetBackdropColor(T.headerBg[1], T.headerBg[2], T.headerBg[3], T.headerBg[4])
|
||||
|
||||
local titleFS = header:CreateFontString(nil, "OVERLAY")
|
||||
titleFS:SetFont(font, 12, outline)
|
||||
titleFS:SetPoint("CENTER", header, "CENTER", 0, 0)
|
||||
titleFS:SetText("宠物重命名")
|
||||
titleFS:SetTextColor(T.gold[1], T.gold[2], T.gold[3])
|
||||
|
||||
local hsep = f:CreateTexture(nil, "ARTWORK")
|
||||
hsep:SetTexture("Interface\\Buttons\\WHITE8X8")
|
||||
hsep:SetHeight(1)
|
||||
hsep:SetPoint("TOPLEFT", f, "TOPLEFT", 4, -29)
|
||||
hsep:SetPoint("TOPRIGHT", f, "TOPRIGHT", -4, -29)
|
||||
hsep:SetVertexColor(T.divider[1], T.divider[2], T.divider[3], T.divider[4])
|
||||
|
||||
local eb = CreateFrame("EditBox", "SFramesPetRenameEditBox", f)
|
||||
eb:SetWidth(260)
|
||||
eb:SetHeight(24)
|
||||
eb:SetPoint("TOP", f, "TOP", 0, -42)
|
||||
eb:SetFont(font, 12, outline)
|
||||
eb:SetAutoFocus(false)
|
||||
eb:SetMaxLetters(24)
|
||||
eb:SetBackdrop({
|
||||
bgFile = "Interface\\Buttons\\WHITE8X8",
|
||||
edgeFile = "Interface\\Buttons\\WHITE8X8",
|
||||
tile = false, tileSize = 0, edgeSize = 1,
|
||||
insets = { left = 1, right = 1, top = 1, bottom = 1 },
|
||||
})
|
||||
eb:SetBackdropColor(T.inputBg[1], T.inputBg[2], T.inputBg[3], T.inputBg[4])
|
||||
eb:SetBackdropBorderColor(T.inputBorder[1], T.inputBorder[2], T.inputBorder[3], T.inputBorder[4])
|
||||
eb:SetTextInsets(8, 8, 0, 0)
|
||||
eb:SetTextColor(1, 1, 1)
|
||||
|
||||
eb:SetScript("OnEnterPressed", function()
|
||||
SFrames.Pet:DoRename(this:GetText())
|
||||
end)
|
||||
eb:SetScript("OnEscapePressed", function()
|
||||
SFrames.Pet.renameFrame:Hide()
|
||||
end)
|
||||
eb:SetScript("OnEditFocusGained", function()
|
||||
this:SetBackdropBorderColor(T.accent[1], T.accent[2], T.accent[3], 1)
|
||||
end)
|
||||
eb:SetScript("OnEditFocusLost", function()
|
||||
this:SetBackdropBorderColor(T.inputBorder[1], T.inputBorder[2], T.inputBorder[3], T.inputBorder[4])
|
||||
end)
|
||||
|
||||
f.editBox = eb
|
||||
|
||||
local function CreateBtn(text, parent)
|
||||
local btn = CreateFrame("Button", nil, parent)
|
||||
btn:SetWidth(120)
|
||||
btn:SetHeight(26)
|
||||
btn:SetBackdrop({
|
||||
bgFile = "Interface\\Buttons\\WHITE8X8",
|
||||
edgeFile = "Interface\\Buttons\\WHITE8X8",
|
||||
tile = false, tileSize = 0, edgeSize = 1,
|
||||
insets = { left = 1, right = 1, top = 1, bottom = 1 },
|
||||
})
|
||||
btn:SetBackdropColor(T.btnBg[1], T.btnBg[2], T.btnBg[3], T.btnBg[4])
|
||||
btn:SetBackdropBorderColor(T.btnBorder[1], T.btnBorder[2], T.btnBorder[3], T.btnBorder[4])
|
||||
local fs = btn:CreateFontString(nil, "OVERLAY")
|
||||
fs:SetFont(font, 11, outline)
|
||||
fs:SetPoint("CENTER", 0, 0)
|
||||
fs:SetText(text)
|
||||
fs:SetTextColor(T.btnText[1], T.btnText[2], T.btnText[3])
|
||||
btn.label = fs
|
||||
btn:SetScript("OnEnter", function()
|
||||
this:SetBackdropColor(T.btnHoverBg[1], T.btnHoverBg[2], T.btnHoverBg[3], T.btnHoverBg[4])
|
||||
this:SetBackdropBorderColor(T.btnHoverBd[1], T.btnHoverBd[2], T.btnHoverBd[3], T.btnHoverBd[4])
|
||||
this.label:SetTextColor(T.btnActiveText[1], T.btnActiveText[2], T.btnActiveText[3])
|
||||
end)
|
||||
btn: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])
|
||||
this.label:SetTextColor(T.btnText[1], T.btnText[2], T.btnText[3])
|
||||
end)
|
||||
return btn
|
||||
end
|
||||
|
||||
local confirmBtn = CreateBtn("确定", f)
|
||||
confirmBtn:SetPoint("BOTTOMRIGHT", f, "BOTTOM", -4, 10)
|
||||
confirmBtn:SetScript("OnClick", function()
|
||||
SFrames.Pet:DoRename(f.editBox:GetText())
|
||||
end)
|
||||
|
||||
local cancelBtn = CreateBtn("取消", f)
|
||||
cancelBtn:SetPoint("BOTTOMLEFT", f, "BOTTOM", 4, 10)
|
||||
cancelBtn:SetScript("OnClick", function()
|
||||
f:Hide()
|
||||
end)
|
||||
|
||||
f:Hide()
|
||||
table.insert(UISpecialFrames, "SFramesPetRenameDialog")
|
||||
self.renameFrame = f
|
||||
end
|
||||
|
||||
function SFrames.Pet:ShowRenameDialog()
|
||||
if not UnitExists("pet") then return end
|
||||
if not self.renameFrame then
|
||||
self:CreateRenameFrame()
|
||||
end
|
||||
local currentName = UnitName("pet") or ""
|
||||
self.renameFrame.editBox:SetText(currentName)
|
||||
self.renameFrame:Show()
|
||||
self.renameFrame.editBox:SetFocus()
|
||||
self.renameFrame.editBox:HighlightText()
|
||||
end
|
||||
|
||||
function SFrames.Pet:DoRename(name)
|
||||
if not name or name == "" then return end
|
||||
if PetRename then
|
||||
PetRename(name)
|
||||
end
|
||||
if self.renameFrame then
|
||||
self.renameFrame:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function SFrames.Pet:Initialize()
|
||||
local f = CreateFrame("Button", "SFramesPetFrame", UIParent)
|
||||
f:SetWidth(150)
|
||||
@@ -45,7 +259,7 @@ function SFrames.Pet:Initialize()
|
||||
TargetUnit("pet")
|
||||
end
|
||||
else
|
||||
ToggleDropDownMenu(1, nil, PetFrameDropDown, "SFramesPetFrame", 106, 27)
|
||||
SFrames.Pet:ShowContextMenu()
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -158,6 +372,22 @@ function SFrames.Pet:Initialize()
|
||||
|
||||
self:InitFoodFeature()
|
||||
self:UpdateAll()
|
||||
|
||||
if SFrames.Movers and SFrames.Movers.RegisterMover and self.frame then
|
||||
SFrames.Movers:RegisterMover("PetFrame", self.frame, "宠物",
|
||||
"TOPLEFT", "SFramesPlayerFrame", "BOTTOMLEFT", 10, -55)
|
||||
end
|
||||
|
||||
if StaticPopup_Show then
|
||||
local origStaticPopupShow = StaticPopup_Show
|
||||
StaticPopup_Show = function(which, a1, a2, a3)
|
||||
if which == "RENAME_PET" then
|
||||
SFrames.Pet:ShowRenameDialog()
|
||||
return
|
||||
end
|
||||
return origStaticPopupShow(which, a1, a2, a3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function SFrames.Pet:UpdateAll()
|
||||
|
||||
Reference in New Issue
Block a user