-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerFrame.lua
More file actions
177 lines (160 loc) · 6.89 KB
/
PlayerFrame.lua
File metadata and controls
177 lines (160 loc) · 6.89 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
local _, core = ...; -- Namespace
local PF = {};
core.PF = PF;
local media = LibStub("LibSharedMedia-3.0")
local playerSecondaryPowerTypes = {
ROGUE = {4},
DRUID = {4},
DEATHKNIGHT = {6},
WARLOCK = {7},
PALADIN = {9},
MONK = {12},
MAGE = {16},
EVOKER = {19}
}
-- Player frame
local playerFrame = _G["PlayerFrame"];
local healthBar = playerFrame.PlayerFrameContent.PlayerFrameContentMain.HealthBarsContainer.HealthBar;
local defaultHealthBarColor = {
r = 1,
g = 1,
b = 1,
a = 1
}
function PF:SetHealthBarColor(color)
healthBar:SetStatusBarDesaturated(true)
healthBar:SetStatusBarColor(color.r, color.g, color.b, color.a)
end
function PF:GetPlayerClassColor()
local _, englishClass = UnitClass("player")
local r, g, b, hex = GetClassColor(englishClass)
return {
r = r,
g = g,
b = b,
a = 1
}
end
function PF:ToggleHealthBarColor(value)
if value then
if EHUD.db.profile.playerFrame.healthBarColor.useClassColor then
local classColor = PF:GetPlayerClassColor();
PF:SetHealthBarColor(classColor)
else
PF:SetHealthBarColor(EHUD.db.profile.playerFrame.healthBarColor.color)
end
else
healthBar:SetStatusBarDesaturated(false)
healthBar:SetStatusBarColor(defaultHealthBarColor.r, defaultHealthBarColor.g, defaultHealthBarColor.b,
defaultHealthBarColor.a)
end
end
-- local playerSecondaryPowerType = nil
-- local playerSecondaryPowerBars = {}
-- local dimension = core.config.dimensions.playerFrame
-- local playerFrame, healthBar, resourceBar = core:CreateUnitFrame(dimension, "player")
-- playerFrame:Hide()
-- playerFrame:SetPoint("CENTER", UIParent, "CENTER", -dimension.width, 0)
-- playerFrame:HookScript("OnLoad", function(self)
-- self:RegisterEvent("PLAYER_LEVEL_CHANGED");
-- self:RegisterEvent("UNIT_FACTION");
-- self:RegisterEvent("PLAYER_ENTERING_WORLD");
-- self:RegisterEvent("PLAYER_ENTER_COMBAT");
-- self:RegisterEvent("PLAYER_LEAVE_COMBAT");
-- self:RegisterEvent("PLAYER_REGEN_DISABLED");
-- self:RegisterEvent("PLAYER_REGEN_ENABLED");
-- self:RegisterEvent("PLAYER_UPDATE_RESTING");
-- self:RegisterEvent("PARTY_LEADER_CHANGED");
-- self:RegisterEvent("GROUP_ROSTER_UPDATE");
-- self:RegisterEvent("READY_CHECK");
-- self:RegisterEvent("READY_CHECK_CONFIRM");
-- self:RegisterEvent("READY_CHECK_FINISHED");
-- self:RegisterEvent("UNIT_ENTERED_VEHICLE");
-- self:RegisterEvent("UNIT_EXITING_VEHICLE");
-- self:RegisterEvent("UNIT_EXITED_VEHICLE");
-- self:RegisterEvent("PVP_TIMER_UPDATE");
-- self:RegisterEvent("PLAYER_ROLES_ASSIGNED");
-- self:RegisterEvent("HONOR_LEVEL_UPDATE");
-- self:RegisterUnitEvent("UNIT_COMBAT", "player", "vehicle");
-- self:RegisterUnitEvent("UNIT_MAXPOWER", "player", "vehicle");
-- end)
-- function EHUD:OnEnable()
-- self:RegisterEvent("PLAYER_ENTERING_WORLD");
-- end
-- function OnUpdateHandler()
-- local playerInfo = core:GetUnitInfo("player")
-- for i = 1, #playerSecondaryPowerBars do
-- if playerInfo.secondaryPower and i <= playerInfo.secondaryPower then
-- playerSecondaryPowerBars[i]:SetValue(100)
-- else
-- playerSecondaryPowerBars[i]:SetValue(0)
-- end
-- end
-- end
-- playerFrame:AddUpdateHandler(OnUpdateHandler)
-- -- Create partial power bar
-- local partialPowerBar = CreateFrame("Frame", nil, playerFrame)
-- partialPowerBar:SetPoint("TOPLEFT", resourceBar, "BOTTOMLEFT", 0, 1)
-- partialPowerBar:SetPoint("TOPRIGHT", resourceBar, "BOTTOMRIGHT", 0, 0)
-- partialPowerBar:SetFrameLevel(1)
-- partialPowerBar:SetHeight(10)
-- partialPowerBar:Hide()
-- local onePartialPowerBackground = partialPowerBar:CreateTexture(nil, "BACKGROUND")
-- onePartialPowerBackground:SetAllPoints(partialPowerBar)
-- onePartialPowerBackground:SetColorTexture(0, 0, 0, 0.8)
-- onePartialPowerBackground:SetDrawLayer("BACKGROUND", 2)
-- -- _G["PlayerFrame"]:SetScript("OnEvent", nil);
-- -- _G["PlayerFrame"]:Hide();
-- function EHUD:PLAYER_ENTERING_WORLD()
-- local secondaryPowerMax = 1
-- local unitSecondaryPowerType = core:GetUnitSecondaryPowerType();
-- if (unitSecondaryPowerType) then
-- partialPowerBar:Show()
-- secondaryPowerMax = UnitPowerMax("player", unitSecondaryPowerType)
-- end
-- -- Create partial power bar
-- if (secondaryPowerMax > 0) then
-- for i = 1, secondaryPowerMax do
-- local onePartialPower = playerSecondaryPowerBars[i] or CreateFrame("StatusBar", nil, partialPowerBar)
-- local partialPowerColor = { r = 0.52, g = 1, b = 0.52 }
-- local relativeParent = playerSecondaryPowerBars[i - 1] or partialPowerBar
-- local relativePoint = playerSecondaryPowerBars[i - 1] and "RIGHT" or "LEFT"
-- onePartialPower:SetStatusBarTexture("Interface\\Buttons\\WHITE8x8")
-- onePartialPower:SetStatusBarColor(partialPowerColor.r, partialPowerColor.g, partialPowerColor.b, 1)
-- onePartialPower:SetFrameLevel(2)
-- onePartialPower:SetHeight(10)
-- onePartialPower:SetWidth(math.ceil(core.config.dimensions.playerFrame.width / secondaryPowerMax))
-- onePartialPower:SetMinMaxValues(0, 100)
-- onePartialPower:SetValue(0)
-- onePartialPower:SetPoint("LEFT", relativeParent, relativePoint, 0, 0)
-- onePartialPower.border = CreateFrame("Frame", nil, onePartialPower, "BackdropTemplate")
-- onePartialPower.border:SetPoint("TOPLEFT", onePartialPower, 0, 0)
-- onePartialPower.border:SetPoint("BOTTOMRIGHT", onePartialPower, 0, 0)
-- onePartialPower.border:SetBackdrop({
-- edgeFile = "Interface\\Buttons\\WHITE8x8",
-- edgeSize = 1,
-- })
-- onePartialPower.border:SetBackdropBorderColor(0, 0, 0)
-- onePartialPower.border:SetFrameLevel(3)
-- onePartialPower.texture = onePartialPower:CreateTexture(nil, "OVERLAY")
-- onePartialPower.texture:SetAllPoints(onePartialPower)
-- onePartialPower.texture:SetAtlas("UI-HUD-UnitFrame-Player-PortraitOn-Bar-Mana", true)
-- onePartialPower.texture:SetVertexColor(1, 1, 1, 1)
-- onePartialPower:SetStatusBarTexture(onePartialPower.texture)
-- table.insert(playerSecondaryPowerBars, onePartialPower)
-- end
-- end
-- end
-- function core:GetUnitSecondaryPowerType()
-- local _, unitClass, _ = UnitClass("player")
-- if playerSecondaryPowerTypes[unitClass] then
-- local powerTypes = playerSecondaryPowerTypes[unitClass]
-- for _, value in ipairs(powerTypes) do
-- local secondaryPowerMax = UnitPowerMax("player", value)
-- if secondaryPowerMax > 0 then
-- return value;
-- end
-- end
-- end
-- return nil;
-- end