LUACN论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
热搜: YJWOW MagicStone BoL
查看: 419|回复: 0

求大神帮我把这个UI的位置,大小调整一下~谢谢啦

[复制链接]
发表于 2015-8-13 21:07:03 | 显示全部楼层 |阅读模式
RTRT
LUA如下,调整之后插件出现的X坐标750,Y300,宽80,高30。求大神帮忙指导修改一下,谢谢~~


chaosPower = CreateFrame("Frame", "chaosPower", UIParent)
chaosPower:SetScript("OnEvent", function(self, event, ...) self[event](self, event, ...) end)

----------------------------------------------------------------------------------------
local chaosPowerDisplay = nil
local chaosBoltPowerPrediction = 0
local unlocked = false
local inCombat = false

local defaults =
{
posX = 50,
posY = 300,
hideOutOfCombat = true,
width = 60,
height = 20,
fontSize = 12,
showIcon = true,
}

chaosPowerDB = {}

----------------------------------------------------------------------------------------
chaosPower:RegisterEvent("ADDON_LOADED")
chaosPower:RegisterEvent("LAYER_LOGIN")
chaosPower:RegisterEvent("LAYER_REGEN_ENABLED")
chaosPower:RegisterEvent("LAYER_REGEN_DISABLED")

chaosPower:RegisterEvent("COMBAT_RATING_UPDATE")
chaosPower:RegisterEvent("SPELL_POWER_CHANGED")
chaosPower:RegisterEvent("UNIT_STATS")
chaosPower:RegisterEvent("LAYER_DAMAGE_DONE_MODS")

----------------------------------------------------------------------------------------
function chaosPower:COMBAT_RATING_UPDATE() self:UpdateChaosBoltPowerPrediction() end
function chaosPower:SPELL_POWER_CHANGED() self:UpdateChaosBoltPowerPrediction() end
function chaosPower:UNIT_STATS() self:UpdateChaosBoltPowerPrediction() end
function chaosPowerLAYER_DAMAGE_DONE_MODS() self:UpdateChaosBoltPowerPrediction() end

----------------------------------------------------------------------------------------
local function LoadDefaults()
chaosPowerDB = chaosPowerDB or {}
for k,v in pairs(defaults) do
if(type(chaosPowerDB[k]) == 'nil') then chaosPowerDB[k] = v end
end
end

----------------------------------------------------------------------------------------
function chaosPower:ADDON_LOADED(event, addon)

if (addon ~= "ChaosPower") then return end
self:UnregisterEvent(event)
LoadDefaults()

chaosPowerDisplay = CreateFrame("Frame", "chaosPowerDisplay", UIParent)
chaosPowerDisplay:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", chaosPowerDB.posX, chaosPowerDB.posY)
chaosPowerDisplay:SetMovable(true)
chaosPowerDisplay:EnableMouse(false)
chaosPowerDisplay:RegisterForDrag("LeftButton")

local cpt = chaosPowerDisplay:CreateFontString(nil, "OVERLAY")
cpt:SetJustifyH("CENTER")
chaosPowerDisplay.text = cpt

local tex = chaosPowerDisplay:CreateTexture(nil, "BACKGROUND")
tex:SetAllPoints(chaosPowerDisplay)
chaosPowerDisplay.texture = tex

local icon = chaosPowerDisplay:CreateTexture(nil, "LOW")
icon:SetTexture(select(3, GetSpellInfo(116858)))
icon:SetPoint("BOTTOMLEFT")
chaosPowerDisplay.icon = icon

self:UpdateDisplayFrame()

_, playerClass = UnitClass("player")
if (playerClass ~= "WARLOCK") then
self:UnregisterAllEvents()
chaosPowerDisplay:Hide()
end
end

----------------------------------------------------------------------------------------
function chaosPowerLAYER_LOGIN()
self:UpdateChaosBoltPowerPrediction()
end

----------------------------------------------------------------------------------------
function chaosPowerLAYER_REGEN_ENABLED()
inCombat = false;
if chaosPowerDB.hideOutOfCombat then chaosPowerDisplay:Hide() end
end

----------------------------------------------------------------------------------------
function chaosPowerLAYER_REGEN_DISABLED()
inCombat = true;
if chaosPowerDB.hideOutOfCombat then chaosPowerDisplay:Show() end
end

----------------------------------------------------------------------------------------
function chaosPower:UpdateChaosBoltPowerPrediction()
local mastery, crit, spelldmg = GetMastery(), GetSpellCritChance(6), GetSpellBonusDamage(6)
if crit > 100 then crit = 100 end

chaosBoltPowerPrediction = floor((2400 + 2.25 * spelldmg) * (1 + crit / 100) * (1 + mastery / 100) / 1000 + .5)
chaosPowerDisplay.text:SetText(chaosBoltPowerPrediction)
end

----------------------------------------------------------------------------------------
function chaosPower:UpdateDisplayFrame()
chaosPowerDisplay:SetWidth(chaosPowerDB.width)
chaosPowerDisplay:SetHeight(chaosPowerDB.height)

chaosPowerDisplay.texture:SetTexture(0, 0, 0, .7)

chaosPowerDisplay.text:SetFont("FontsFRIZQT__.TTF", chaosPowerDB.fontSize)
chaosPowerDisplay.text:SetShadowColor(0, 0, 0)
chaosPowerDisplay.text:SetShadowOffset(0.8, -0.8)
chaosPowerDisplay.text:SetTextColor(1, 1, 1)
chaosPowerDisplay.text:SetText(chaosBoltPowerPrediction)

chaosPowerDisplay.text:ClearAllPoints()
if (chaosPowerDB.showIcon) then
chaosPowerDisplay.text:SetPoint("RIGHT", -3, 0)
else
chaosPowerDisplay.text:SetPoint("CENTER")
end

chaosPowerDisplay.icon:SetWidth(chaosPowerDB.height)
chaosPowerDisplay.icon:SetHeight(chaosPowerDB.height)
if (chaosPowerDB.showIcon) then
chaosPowerDisplay.icon:Show()
else
chaosPowerDisplay.icon:Hide()
end

if chaosPowerDB.hideOutOfCombat and not inCombat then
chaosPowerDisplay:Hide()
end
end

----------------------------------------------------------------------------------------
local function SetFrameMovable(f, v)
f:EnableMouse(v)
f:SetScript("OnDragStart", v and f.StartMoving or nil)
f:SetScript("OnDragStop", v and
function(self)
self:StopMovingOrSizing()
chaosPowerDB.posX = self:GetLeft()
chaosPowerDB.posY = self:GetBottom()
end
or nil)
f:SetScript("OnHide", v and f.StopMovingOrSizing or nil)
end

----------------------------------------------------------------------------------------
local function StatusMsg(str1, str2, data, name, short)
local R,G,t = '|cFFFF0000', '|cFF00FF00', ''
if data ~= nil then t = data and G..(short and 'on|r' or 'enabled|r') or R..(short and 'off|r' or 'disabled|r') end
t = (name and '|cFFFFFF00ChaosPower:|r ' or '')..str1..t..str2
ChatFrame1:AddMessage(t)
end

----------------------------------------------------------------------------------------
local function StatusMsgVal(str1, str2, data, name)
local G,t = '|cFF00FF00', ''
if (data ~= nil) then t = G..data..'|r' end
t = (name and '|cFFFFFF00ChaosPower:|r ' or '')..str1..t..str2
ChatFrame1:AddMessage(t)
end

----------------------------------------------------------------------------------------
local function HandleSlash(str)
local str, str2 = strsplit(" ", str)
if str == 'move' then
unlocked = not unlocked
SetFrameMovable(chaosPowerDisplay, unlocked)
if not inCombat then
if unlocked then
chaosPowerDisplay:Show()
else
chaosPowerDisplay:Hide()
end
end
StatusMsg('Frame lock is now ', '.', unlocked, true, false)

elseif str == 'hideooc' then
chaosPowerDB.hideOutOfCombat = not chaosPowerDB.hideOutOfCombat
if not inCombat then
if chaosPowerDB.hideOutOfCombat then
chaosPowerDisplay:Hide()
else
chaosPowerDisplay:Show()
end
end
StatusMsg('Hiding the frame out of combat is now ', '.', unlocked, true, false)

elseif str == 'width' then
value = tonumber(str2)
if value then
chaosPowerDB.width = value
chaosPower:UpdateDisplayFrame()
StatusMsgVal('Width has been set to ', '.', chaosPowerDB.width, true)
else
StatusMsg('You have to specify a value, e.g. /cp width 60.', '', nil, true, false)
end

elseif str == 'height' then
value = tonumber(str2)
if value then
chaosPowerDB.height = value
chaosPower:UpdateDisplayFrame()
StatusMsgVal('Width has been set to ', '.', chaosPowerDB.height, true)
else
StatusMsg('You have to specify a value, e.g. /cp height 20.', '', nil, true, false)
end

elseif str == 'fontsize' then
value = tonumber(str2)
if value then
chaosPowerDB.fontSize = value
chaosPower:UpdateDisplayFrame()
StatusMsgVal('Width has been set to ', '.', chaosPowerDB.fontSize, true)
else
StatusMsg('You have to specify a value, e.g. /cp fontsize 12.', '', nil, true, false)
end

elseif str == 'icon' then
chaosPowerDB.showIcon = not chaosPowerDB.showIcon
chaosPower:UpdateDisplayFrame()
StatusMsg('The spell icon is now ', '.', unlocked, true, false)

else
ChatFrame1:AddMessage('|cFFFFFF00ChaosPower:|r')
StatusMsg('(', ') |cFFFFFF00move|r - Toggle movable status.', unlocked, false, true)
StatusMsg('(', ') |cFFFFFF00hideooc|r - Toggle hiding the frame out of combat.', chaosPowerDB.hideOutOfCombat, false, true)
StatusMsgVal('(', ') |cFFFFFF00width|r - Set the width of the frame.', chaosPowerDB.width, false)
StatusMsgVal('(', ') |cFFFFFF00height|r - Set the height of the frame.', chaosPowerDB.height, false)
StatusMsgVal('(', ') |cFFFFFF00fontsize|r - Set the font size.', chaosPowerDB.fontSize, false)
StatusMsg('(', ') |cFFFFFF00icon|r - Show or hide the spell icon.', chaosPowerDB.showIcon, false, true)
end
end

----------------------------------------------------------------------------------------
SLASH_CHAOSPOWER1 = '/chaosPower'
SLASH_CHAOSPOWER2 = '/cp'
SlashCmdList.CHAOSPOWER = HandleSlash
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

小黑屋|手机版|Archiver|LUACN论坛

GMT+8, 2025-5-8 09:08 AM , Processed in 0.041319 second(s), 14 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表