diff --git a/SM_CollectionSystem.lua b/SM_CollectionSystem.lua index cd75bf5..c4cb48b 100644 --- a/SM_CollectionSystem.lua +++ b/SM_CollectionSystem.lua @@ -5,6 +5,13 @@ SM_Collections.MainFrame = nil SM_Collections.CurrentPanel = nil SM_Collections.CurrentTab = 1 +-- 创建自定义字体对象 +local titleFont = CreateFont("SM_TitleFont") +titleFont:SetFont("Fonts\\ZYKai_T.ttf", 20, "MONOCHROME") + +local descFont = CreateFont("SM_DescFont") +descFont:SetFont("Fonts\\ZYKai_T.ttf", 10, "MONOCHROME") + -- 添加坐骑数据 SM_Collections.Mounts = { [458] = { 284, 2, 0, "Brown Horse", "A favorite among Stormwind's guards thanks to its patience and stamina.", 2, "|cFFFFD200Vendor: |rWorld Vendors|n|cFFFFD200Cost: |r1|TINTERFACE\\MONEYFRAME\\UI-GOLDICON.BLP:0|t" }, @@ -109,8 +116,21 @@ SM_Collections.Data = { { id = 33132, name = "精致焰红石", icon = "Interface\\Icons\\INV_Helmet_01", obtained = true }, { id = 33133, name = "胡里奥之心", icon = "Interface\\Icons\\INV_Chest_Plate01", obtained = false }, + }, + Attribute = { + { Name = "生命值", value = 999 }, + { Name = "近战攻强", value = 999 }, + { Name = "法术强度", value = 999 }, + { Name = "暴击等级", value = 999 }, + { Name = "造成奥术伤害", value = 999 }, + { Name = "造成火焰伤害", value = 999 }, + { Name = "受到所有伤害", value = 999 }, + { Name = "造成暴击伤害", value = 999 }, + { Name = "造成所有伤害", value = 999 }, + { Name = "治疗效果", value = 999 }, } } + -- 创建主界面 function SM_Collections:CreateMainFrame() if self.MainFrame then @@ -125,6 +145,12 @@ function SM_Collections:CreateMainFrame() SM_Collections_Frame_Texture:SetAllPoints(SM_Collections_Frame) SM_Collections_Frame_Texture:SetTexture("Interface\\AddOns\\SM_CollectionSystem\\Textures\\back") + -- 左上角圆形头像/LOGO + local icon = SM_Collections_Frame:CreateTexture(nil, "ARTWORK") + icon:SetSize(80, 80) + icon:SetPoint("TOPLEFT", 5, -5) + SetPortraitToTexture(icon, "Interface\\ICONS\\INV_Misc_QuestionMark") -- 圆形肖像-默认问号图标 可以自行替换 + -- 标题 local title = SM_Collections_Frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") title:SetPoint("TOP", 0, -20) @@ -136,6 +162,55 @@ function SM_Collections:CreateMainFrame() closeBtn:SetPoint("TOPRIGHT", 4, -8) closeBtn:SetScript("OnClick", function() SM_Collections_Frame:Hide() end) + -- 坐骑名称文本 - 使用自定义字体 + local MountNama = SM_Collections_Frame:CreateFontString(nil, "OVERLAY") + MountNama:SetPoint("TOPRIGHT", -80, -100) + MountNama:SetFontObject(titleFont) -- 使用 SetFontObject 而不是 SetFont + MountNama:SetText("墨洛墨洛根怪兽") + MountNama:SetJustifyH("LEFT") + MountNama:SetJustifyV("TOP") + MountNama:SetTextColor(230 / 255, 150 / 255, 0 / 255) + + -- 右上角介绍文本的框体 + local introFrame = CreateFrame("Frame", nil, SM_Collections_Frame) + local width = MountNama:GetStringWidth() + introFrame:SetSize(width + 80, 80) -- 增加高度 + introFrame:SetPoint("TOPLEFT", MountNama, "BOTTOMLEFT", 0, -10) + + -- 介绍文本 - 使用自定义字体 + local introText = introFrame:CreateFontString(nil, "OVERLAY") + introText:SetPoint("TOPLEFT", 0, -5) + introText:SetJustifyH("LEFT") + introText:SetJustifyV("TOP") + introText:SetWidth(introFrame:GetWidth() - 20) + introText:SetWordWrap(true) + introText:SetFontObject(descFont) -- 使用 SetFontObject + local text = + "|cFFe59700成就:|r领导骑兵|r\r|cFFe59700类别:|r将军即使是龙族原住民协会的测试也证明,在确定白化公鸭是否与已知的蜻蜓有关方面没有定论。\r\r |cFFe59700--布雷安尼|r" + introText:SetText(text) + introFrame:SetHeight(introText:GetStringHeight() + 20) + introText:SetJustifyH("LEFT") + introText:SetJustifyV("TOP") + introText:SetWidth(introFrame:GetWidth() - 20) + introText:SetWordWrap(true) + + -- 属性加成标题 + local AttributeBonusFrame = CreateFrame("Frame", "AttributeBonusFrame", introFrame) + AttributeBonusFrame:SetSize(120, 20) -- 增加高度 + AttributeBonusFrame:SetPoint("CENTER", introFrame, "CENTER", -12, -60) + AttributeBonusFrame:SetBackdrop({ bgFile = "Interface\\AddOns\\SM_CollectionSystem\\Textures\\AttributeBonusFrame" }) + AttributeBonusFrameText = AttributeBonusFrame:CreateFontString(nil, "OVERLAY") + AttributeBonusFrameText:SetPoint("CENTER", 0, 0) + AttributeBonusFrameText:SetFontObject(titleFont) -- 使用 SetFontObject 而不是 SetFont + AttributeBonusFrameText:SetText("属性加成") + AttributeBonusFrameText:SetFont("Fonts\\ZYKai_T.ttf", 16, "MONOCHROME") + + self:CreateAttribute(AttributeBonusFrame) + + -- 自动换行 + introText:SetWordWrap(true) + introText:SetWidth(introFrame:GetWidth() - 20) -- 保证和边距一致 + -- 拖拽功能 SM_Collections_Frame:SetScript("OnMouseDown", function(self, button) if button == "LeftButton" then @@ -147,7 +222,6 @@ function SM_Collections:CreateMainFrame() self:StopMovingOrSizing() end end) - -- 创建标签页 self:CreateTabs(SM_Collections_Frame) @@ -161,6 +235,47 @@ function SM_Collections:CreateMainFrame() return SM_Collections_Frame end +function SM_Collections:CreateAttribute(parent) + local buttonH = 150 + local buttonW = 20 + local spacing = 2 + local AttributeName = nil + local AttributeValue = 0 + + for i, companion in ipairs(self.Data.Attribute) do + AttributeName = companion.Name + AttributeValue = companion.value + local button = CreateFrame("Button", "SM_CollectionsAttributeutton" .. i, parent) + button:SetSize(buttonH, buttonW) + button:SetNormalTexture("Interface\\AddOns\\SM_CollectionSystem\\Textures\\AttributeuttonTexture") + + -- 垂直排列:只需要按索引计算Y坐标 + button:SetPoint("TOPLEFT", -15, -30 - (i - 1) * (buttonW + spacing)) + + -- 创建左侧文本框 - 属性名称 + local nameText = button:CreateFontString(nil, "OVERLAY") + nameText:SetPoint("LEFT", 5, 0) -- 左侧对齐,5像素边距 + nameText:SetFontObject(titleFont) + nameText:SetFont("Fonts\\ZYKai_T.ttf", 10, "MONOCHROME") + nameText:SetText(AttributeName) + nameText:SetJustifyH("LEFT") + nameText:SetJustifyV("CENTER") + nameText:SetTextColor(1, 1, 1) -- 白色 + + -- 创建右侧文本框 - 属性值 + local valueText = button:CreateFontString(nil, "OVERLAY") + valueText:SetPoint("RIGHT", -5, 0) -- 右侧对齐,-5像素边距 + valueText:SetFontObject(titleFont) + valueText:SetFont("Fonts\\ZYKai_T.ttf", 10, "MONOCHROME") + valueText:SetText(tostring(AttributeValue)) + valueText:SetJustifyH("RIGHT") + valueText:SetJustifyV("CENTER") + valueText:SetTextColor(0, 1, 0) -- 绿色,用于区分数值 + + button:Show() + end +end + -- 创建标签页 function SM_Collections:CreateTabs(parent) local tabs = {} @@ -367,22 +482,14 @@ function SM_Collections:CreateSplitPanel(parent, data, itemType) scrollFrame:SetScrollChild(scrollChild) -- 右侧模型显示 - local modelFrame = CreateFrame("Frame", "SM_CollectionsModelFrame", panel) + local modelFrame = CreateFrame("Frame", "SM_CollectionsModelFrame", self.MainFrame) modelFrame:SetSize(380, 410) - modelFrame:SetPoint("TOPRIGHT", -10, -13) - modelFrame:SetBackdrop({ - bgFile = "Interface\\AddOns\\SM_CollectionSystem\\Interface\\DialogFrame\\UI-DialogBox-Background", - edgeFile = "Interface\\AddOns\\SM_CollectionSystem\\Interface\\DialogFrame\\UI-DialogBox-Border", - tile = true, - tileSize = 32, - edgeSize = 32, - insets = { left = 11, right = 12, top = 12, bottom = 11 } - }) + modelFrame:SetPoint("CENTER", 30, 0) -- 3D模型 - 添加完整的初始化 local model = CreateFrame("PlayerModel", "SM_CollectionsModel", modelFrame) model:SetSize(350, 350) - model:SetPoint("TOP", 0, -20) + model:SetPoint("TOP", 0, -30) -- 关键的模型初始化设置 model:SetCamera(0) @@ -390,9 +497,85 @@ function SM_Collections:CreateSplitPanel(parent, data, itemType) model.zoomLevel = 0 model:SetPosition(0, 0, 0) + -- 鼠标拖拽旋转 + model:EnableMouse(true) + model:SetScript("OnMouseDown", function(self, button) + if button == "LeftButton" then + self.isRotating = true + self.lastX = GetCursorPosition() + end + end) + model:SetScript("OnMouseUp", function(self, button) + if button == "LeftButton" then + self.isRotating = false + end + end) + + -- 旋转速度(每秒弧度) + local ROTATE_SPEED = math.rad(90) -- 每秒90度 + + -- 按钮旋转状态 + model.isRotatingLeft = false + model.isRotatingRight = false + + -- 左旋转按钮 + local rotateLeftBtn = CreateFrame("Button", nil, modelFrame) + rotateLeftBtn:SetSize(32, 32) + rotateLeftBtn:SetPoint("BOTTOM", modelFrame, "BOTTOM", -100, 10) + + rotateLeftBtn:SetNormalTexture("Interface\\Buttons\\UI-RotationLeft-Button-Up") + rotateLeftBtn:SetPushedTexture("Interface\\Buttons\\UI-RotationLeft-Button-Down") + rotateLeftBtn:SetHighlightTexture("Interface\\Buttons\\UI-RotationLeft-Button-Highlight") + + rotateLeftBtn:SetScript("OnMouseDown", function() + model.isRotatingLeft = true + end) + rotateLeftBtn:SetScript("OnMouseUp", function() + model.isRotatingLeft = false + end) + rotateLeftBtn:HookScript("OnLeave", function() + model.isRotatingLeft = false + end) + + -- 右旋转按钮 + local rotateRightBtn = CreateFrame("Button", nil, modelFrame) + rotateRightBtn:SetSize(32, 32) + rotateRightBtn:SetPoint("BOTTOM", modelFrame, "BOTTOM", 100, 10) + + rotateRightBtn:SetNormalTexture("Interface\\Buttons\\UI-RotationRight-Button-Up") + rotateRightBtn:SetPushedTexture("Interface\\Buttons\\UI-RotationRight-Button-Down") + rotateRightBtn:SetHighlightTexture("Interface\\Buttons\\UI-RotationRight-Button-Highlight") + + rotateRightBtn:SetScript("OnMouseDown", function() + model.isRotatingRight = true + end) + rotateRightBtn:SetScript("OnMouseUp", function() + model.isRotatingRight = false + end) + rotateRightBtn:HookScript("OnLeave", function() + model.isRotatingRight = false + end) + + -- OnUpdate 统一处理拖拽和按钮旋转 + model:SetScript("OnUpdate", function(self, elapsed) + -- 鼠标拖拽旋转 + if self.isRotating then + local x = GetCursorPosition() + local delta = (x - (self.lastX or x)) * 0.01 -- 旋转灵敏度 + self.lastX = x + self:SetFacing(self:GetFacing() + delta) + end + -- 按钮持续旋转 + if self.isRotatingLeft then + self:SetFacing(self:GetFacing() + ROTATE_SPEED * elapsed) + elseif self.isRotatingRight then + self:SetFacing(self:GetFacing() - ROTATE_SPEED * elapsed) + end + end) + -- 其余UI元素 local nameText = modelFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") - nameText:SetPoint("BOTTOM", 0, 80) + nameText:SetPoint("BOTTOM", 0, 20) nameText:SetTextColor(1, 1, 1) local descText = modelFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") diff --git a/Textures/AttributeBonusFrame.blp b/Textures/AttributeBonusFrame.blp new file mode 100644 index 0000000..30d109c Binary files /dev/null and b/Textures/AttributeBonusFrame.blp differ diff --git a/Textures/AttributeuttonTexture.blp b/Textures/AttributeuttonTexture.blp new file mode 100644 index 0000000..3bb7057 Binary files /dev/null and b/Textures/AttributeuttonTexture.blp differ diff --git a/Textures/back.blp b/Textures/back.blp index e697dd9..8e32ffa 100644 Binary files a/Textures/back.blp and b/Textures/back.blp differ