-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleCastBar.lua
134 lines (115 loc) · 5.41 KB
/
SimpleCastBar.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
--[[
系统施法条美化
摘自 https://bbs.nga.cn/read.php?tid=14573258 powered by 简繁
提供两种样式
基于原始的 将第一行改为 `local bOriginal=true` 需要新样式 将第一行改为 `local bOriginal=false`
]]
local bOriginal = true -- 是否更接近原始施法条
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", function(self, event, ...)
if type( self[event] ) == "function" then return self[ event ] ( self, ... ) end
end )
function frame:ADDON_LOADED()
local function CreateFontString(self)
local parent = self:GetParent()
if self:IsForbidden() then return end
self.CooldownText = self:CreateFontString(nil)
self.CooldownText:SetFont(SystemFont_Outline_Small:GetFont(), 16, "OUTLINE") --施法时间文字大小
self.CooldownText:SetWidth(100)
self.CooldownText:SetJustifyH("RIGHT")
self.CooldownText:SetPoint("TOP", self, "RIGHT", -46, 26) --施法条时间位置
if parent.unit == 'target' or parent.unit == 'focus' then --目标和焦点时间位置
self.CooldownText:SetPoint("TOP", self, "RIGHT", -46, 24) --施法条时间位置
end
local fontFile, fontSize, fontFlags = self.Text:GetFont()
self.Text:SetFont(fontFile, fontSize- -2, fontFlags) --施法条法术名称大小
end
-- 自身施法条修改
if not bOriginal then
CastingBarFrame:SetHeight(20) --施法条高度
CastingBarFrame:SetWidth(260) --施法条宽度
CastingBarFrame.Spark:SetHeight(60) --施法条闪光高度
CastingBarFrame.Border:SetTexture(nil) --关闭原始施法条边框
else
CastingBarFrame.Icon:SetPoint( "RIGHT", CastingBarFrame, "LEFT", -10, 3) --施法图标位置
end
CastingBarFrame.Flash:SetTexture(nil)
CastingBarFrame:SetFrameStrata("HIGH") --施法条框架优先级
CastingBarFrame.Icon:SetSize(25,25) --施法条图标大小
CastingBarFrame.Icon:Show() --施法条图标显示
local function ShowCastingTimer(self, elapsed)
if self:IsForbidden() then return end
if self:GetParent():GetName():find("NamePlate%d") then return end
if (not self.CooldownText) then
CreateFontString(self)
self.timer = 0
if (self:GetName() == "CastingBarFrame") then
-- self.Border:SetTexture("Interface\\CastingBar\\UI-CastingBar-Border-Small")
-- self.Flash:SetTexture("Interface\\CastingBar\\UI-CastingBar-Flash-Small")
-- self.Border:SetPoint("TOP", 0, 26) --施法条外框体位置
if not bOriginal then self.Text:SetPoint("TOP", 0, -1) end --施法条法术名称位置
-- self.Icon:Show()
end
end
self.timer = self.timer + elapsed
if (self.timer > 0.1) then
self.timer = 0
if self.casting then
self.CooldownText:SetText(format("%.1f/%.1f", max(self.value, 0), self.maxValue))
elseif self.channeling then
self.CooldownText:SetText(format("%.1f", max(self.value, 0)))
else
self.CooldownText:SetText("")
end
end
end
hooksecurefunc("CastingBarFrame_OnUpdate", ShowCastingTimer)
hooksecurefunc("CastingBarFrame_OnEvent", function(self, event, ...)
if self:IsForbidden() then return end
if (not self.hasRegisterCastingTimer) then
self.hasRegisterCastingTimer = true
local func = self:GetScript("OnUpdate")
if (func ~= CastingBarFrame_OnUpdate) then
self:SetScript("OnUpdate", CastingBarFrame_OnUpdate)
end
end
end)
if (CastingBarFrame) then
CastingBarFrame:HookScript("OnUpdate", ShowCastingTimer)
end
hooksecurefunc("MirrorTimerFrame_OnUpdate", function(self, elapsed)
if (self.paused) then return end
if (not self.CooldownText) then
self.CooldownText = self:CreateFontString(nil)
self.CooldownText:SetFont(SystemFont_Outline_Small:GetFont(), 8, "OUTLINE")
self.CooldownText:SetWidth(100)
self.CooldownText:SetJustifyH("RIGHT")
self.CooldownText:SetPoint("RIGHT", self, "RIGHT", -100, 6)
self.itimer = 0
end
self.itimer = self.itimer + elapsed
if (self.itimer > 0.5) then
self.itimer = 0
self.CooldownText:SetText(floor(self.value))
end
end)
--施法延迟
-- local lagmeter = CastingBarFrame:CreateTexture(nil,"OVERLAYER");
-- lagmeter:SetHeight(CastingBarFrame:GetHeight());
-- lagmeter:SetWidth(0);
-- lagmeter:SetPoint("RIGHT", CastingBarFrame, "RIGHT", 0, 0);
-- lagmeter:SetTexture("Interface\\ChatFrame\\ChatFrameBackground");
-- lagmeter:SetVertexColor(1,0.3,0); -- red color
-- hooksecurefunc(CastingBarFrame, "Show", function()
-- down, up, lag = GetNetStats();
-- local castingmin, castingmax = CastingBarFrame:GetMinMaxValues();
-- local lagvalue = ( lag / 1000 ) / ( castingmax - castingmin );
-- if ( lagvalue < 0 ) then
-- lagvalue = 0;
-- elseif ( lagvalue > 1 ) then
-- lagvalue = 1;
-- end;
-- lagmeter:SetWidth(CastingBarFrame:GetWidth() * lagvalue);
-- end);
end