-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandler.lua
More file actions
146 lines (117 loc) · 4.7 KB
/
Copy pathHandler.lua
File metadata and controls
146 lines (117 loc) · 4.7 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
-- ------------------------------------------------------------------------
-- Callbacks
-- ------------------------------------------------------------------------
function AddCallback(object, event, callback)
if (object[event] == nil) then
object[event] = callback;
else
if (type(object[event]) == "table") then
table.insert(object[event], callback);
else
object[event] = {object[event], callback};
end
end
return callback;
end
function RemoveCallback(object, event, callback)
if (object[event] == callback) then
object[event] = nil;
else
if (type(object[event]) == "table") then
local size = table.getn(object[event]);
for i = 1, size do
if (object[event][i] == callback) then
table.remove(object[event], i);
break;
end
end
end
end
end
-- ------------------------------------------------------------------------
-- Morale Change Handler
-- ------------------------------------------------------------------------
function MoraleChangedHandler(sender, args)
local CurrentFrame = OBJECT
if not CurrentFrame.TARGET then
return
end
local TargetMorale = CurrentFrame.TARGET:GetMorale()
local TargetMaxMorale = CurrentFrame.TARGET:GetMaxMorale()
if CurrentFrame.STARTMORALE == 0 and TargetMorale > 0 then
CurrentFrame.STARTMORALE = TargetMorale
CurrentFrame.STARTTIME = Turbine.Engine:GetGameTime()
end
if TargetMorale <= 1 then
CurrentFrame.percentLabel:SetText(string.format("0.0%%"))
else
CurrentFrame.percentLabel:SetText(string.format("%.1f", 100 * TargetMorale / TargetMaxMorale).."%")
end
local BarSize = math.floor(TargetMorale/TargetMaxMorale * ACTUALWIDTH)
CurrentFrame.moraleBar:SetWidth(BarSize)
if REVERSE_BAR then
CurrentFrame.moraleBar:SetLeft(ACTUALWIDTH - BarSize)
else
CurrentFrame.moraleBar:SetLeft(0)
end
if SHOW_TTKSPACE then
local elapsed = Turbine.Engine:GetGameTime()
if CurrentFrame.STARTMORALE ~= TargetMorale then
local timetokill = TargetMorale*(elapsed-CurrentFrame.STARTTIME)/(CurrentFrame.STARTMORALE-TargetMorale)
if timetokill > 0 and timetokill < 6000 then
local minu = math.floor(timetokill/60)
local seco = math.floor(timetokill % 60)
local dps = math.floor((CurrentFrame.STARTMORALE-TargetMorale)/(elapsed-CurrentFrame.STARTTIME)/1000)
CurrentFrame.raidDPSLabel:SetText(dps.."k")
CurrentFrame.ttkLabel:SetText(string.format("%02d:%02d", minu, seco))
else
CurrentFrame.ttkLabel:SetText("--")
CurrentFrame.raidDPSLabel:SetText("--")
end
else
CurrentFrame.ttkLabel:SetText("--")
CurrentFrame.raidDPSLabel:SetText("--")
end
end
end
function TempMoraleChangedHandler(sender, args)
local CurrentFrame = OBJECT
if not CurrentFrame.TARGET then
return
end
local TargetTempMorale = CurrentFrame.TARGET:GetTemporaryMorale()
local TargetMaxMorale = CurrentFrame.TARGET:GetMaxMorale()
local TargetMorale = CurrentFrame.TARGET:GetMorale()
if TargetTempMorale ~= 0 then
local TargetMaxTempMorale = CurrentFrame.TARGET:GetMaxTemporaryMorale()
CurrentFrame.percentLabel:SetHeight(HEIGHT/2+4)
CurrentFrame.bubbleValue:SetText(math.floor(TargetTempMorale))
ACTUALWIDTH = math.floor(WIDTH*(1-(TargetMaxTempMorale/TargetMaxMorale)))
local mBarWidth = TargetMorale/TargetMaxMorale * ACTUALWIDTH
local bBarWidth = (WIDTH-ACTUALWIDTH)*(TargetTempMorale/TargetMaxTempMorale)
if REVERSE_BAR then
CurrentFrame.moraleBar:SetWidth(mBarWidth)
CurrentFrame.moraleBar:SetLeft(ACTUALWIDTH - mBarWidth)
CurrentFrame.bubbleBar:SetLeft(0)
CurrentFrame.bubbleBar:SetWidth(bBarWidth)
else
CurrentFrame.moraleBar:SetWidth(mBarWidth)
CurrentFrame.moraleBar:SetLeft(0)
CurrentFrame.bubbleBar:SetLeft(ACTUALWIDTH)
CurrentFrame.bubbleBar:SetWidth(bBarWidth)
end
CurrentFrame.bubbleBar:SetVisible(true)
else
local BarSize = math.floor(TargetMorale/TargetMaxMorale * ACTUALWIDTH)
CurrentFrame.moraleBar:SetWidth(BarSize)
if REVERSE_BAR then
CurrentFrame.moraleBar:SetLeft(ACTUALWIDTH - BarSize)
else
CurrentFrame.moraleBar:SetLeft(0)
end
CurrentFrame.bubbleBar:SetVisible(false)
CurrentFrame.percentLabel:SetHeight(HEIGHT+4)
CurrentFrame.bubbleValue:SetText("")
ACTUALWIDTH = WIDTH
end
end