Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 14 | Seerah-7 | -- ZAM_UnitFrames © ZAM Network LLC |
2 | Seerah-7 | -- All Rights Reserved |
|
3 | 2 | Seerah-7 | |
4 | 14 | Seerah-7 | --add "you have died" text to inside player frame? |
5 | Seerah-7 | --recreate the reticleover frame |
|
6 | Seerah-7 | ||
7 | Seerah-7 | local versionNo = "1.3" |
|
8 | 2 | Seerah-7 | local wm = GetWindowManager() |
9 | Seerah-7 | local strformat = string.format |
|
10 | 14 | Seerah-7 | local LAM = LibStub("LibAddonMenu-2.0") |
11 | 5 | Seerah-7 | local LMP = LibStub("LibMediaProvider-1.0") |
12 | 12 | Seerah-7 | local targetFrame, inCombat, db |
13 | 2 | Seerah-7 | |
14 | 5 | Seerah-7 | |
15 | 2 | Seerah-7 | --create these in the main chunk |
16 | Seerah-7 | local playerFrame = wm:CreateTopLevelWindow("ZAMUnitFrames_Player") |
|
17 | Seerah-7 | do |
|
18 | 14 | Seerah-7 | playerFrame.health = wm:CreateControl("ZAMUnitFrames_PlayerHealth", playerFrame, CT_STATUSBAR) |
19 | Seerah-7 | playerFrame.magicka = wm:CreateControl("ZAMUnitFrames_PlayerMagicka", playerFrame, CT_STATUSBAR) |
|
20 | Seerah-7 | playerFrame.stamina = wm:CreateControl("ZAMUnitFrames_PlayerStamina", playerFrame, CT_STATUSBAR) |
|
21 | 2 | Seerah-7 | playerFrame.health.text = wm:CreateControl("ZAMUnitFrames_PlayerHealthText", playerFrame, CT_LABEL) |
22 | Seerah-7 | playerFrame.magicka.text = wm:CreateControl("ZAMUnitFrames_PlayerMagickaText", playerFrame, CT_LABEL) |
|
23 | Seerah-7 | playerFrame.stamina.text = wm:CreateControl("ZAMUnitFrames_PlayerStaminaText", playerFrame, CT_LABEL) |
|
24 | Seerah-7 | end |
|
25 | Seerah-7 | ||
26 | Seerah-7 | local defaults = { |
|
27 | Seerah-7 | locked = true, |
|
28 | 14 | Seerah-7 | barTexture = "ESO Basic", |
29 | 5 | Seerah-7 | font = "Arial Narrow", |
30 | Seerah-7 | fontStyle = "soft-shadow-thin", --add an option for this |
|
31 | Seerah-7 | border = "ESO Gold", |
|
32 | Seerah-7 | borderSpacing = 4, |
|
33 | Seerah-7 | borderSize = 32, |
|
34 | Seerah-7 | targetReaction = false, |
|
35 | 10 | Seerah-7 | combatFade = false, |
36 | 2 | Seerah-7 | } |
37 | Seerah-7 | ||
38 | 5 | Seerah-7 | local function SetFonts(frame) |
39 | Seerah-7 | local fontConfig = "%s|%d|%s" |
|
40 | Seerah-7 | local path = LMP:Fetch("font", db.font) |
|
41 | Seerah-7 | local fstyle = db.fontStyle |
|
42 | Seerah-7 | ||
43 | Seerah-7 | frame.health.text:SetFont(strformat(fontConfig, path, frame == playerFrame and 36 or 22, fstyle)) |
|
44 | Seerah-7 | if frame == playerFrame then |
|
45 | Seerah-7 | frame.magicka.text:SetFont(strformat(fontConfig, path, 22, fstyle)) |
|
46 | Seerah-7 | frame.stamina.text:SetFont(strformat(fontConfig, path, 22, fstyle)) |
|
47 | Seerah-7 | else --target frame |
|
48 | Seerah-7 | frame.name:SetFont(strformat(fontConfig, path, 18, fstyle)) |
|
49 | Seerah-7 | frame.level:SetFont(strformat(fontConfig, path, 18, fstyle)) |
|
50 | Seerah-7 | frame.caption:SetFont(strformat(fontConfig, path, 18, fstyle)) |
|
51 | Seerah-7 | end |
|
52 | Seerah-7 | end |
|
53 | Seerah-7 | ||
54 | 12 | Seerah-7 | local function SetBarTextures(frame) |
55 | Seerah-7 | local tex = LMP:Fetch("statusbar", db.barTexture) |
|
56 | 14 | Seerah-7 | --local tex = [[LMP_MediaStash\statusbar\Glamour7]] |
57 | 12 | Seerah-7 | if frame == playerFrame then |
58 | Seerah-7 | frame.health:SetTexture(tex) |
|
59 | Seerah-7 | frame.magicka:SetTexture(tex) |
|
60 | Seerah-7 | frame.stamina:SetTexture(tex) |
|
61 | Seerah-7 | frame.siege:SetTexture(tex) |
|
62 | Seerah-7 | frame.werewolf:SetTexture(tex) |
|
63 | Seerah-7 | frame.mount:SetTexture(tex) |
|
64 | Seerah-7 | else --target frame |
|
65 | Seerah-7 | frame.health.barLeft:SetTexture(tex) |
|
66 | Seerah-7 | frame.health.barRight:SetTexture(tex) |
|
67 | Seerah-7 | end |
|
68 | Seerah-7 | end |
|
69 | Seerah-7 | ||
70 | 5 | Seerah-7 | local function BorderConfig(frame) |
71 | Seerah-7 | local spacing = db.borderSpacing |
|
72 | Seerah-7 | frame.bg:ClearAnchors() |
|
73 | Seerah-7 | frame.bg:SetAnchor(TOPLEFT, frame, TOPLEFT, -(spacing), -(spacing)) |
|
74 | Seerah-7 | frame.bg:SetAnchor(BOTTOMRIGHT, frame, BOTTOMRIGHT, spacing, spacing) |
|
75 | Seerah-7 | frame.bg:SetInsets(spacing, spacing, -(spacing), -(spacing)) |
|
76 | Seerah-7 | frame.bg:SetEdgeTexture(LMP:Fetch("border", db.border), 256, 32, db.borderSize) |
|
77 | Seerah-7 | end |
|
78 | Seerah-7 | ||
79 | Seerah-7 | local function UnregisterAttributeBars() |
|
80 | Seerah-7 | ZO_PlayerAttributeMagicka:UnregisterForEvent(EVENT_POWER_UPDATE) |
|
81 | Seerah-7 | ZO_PlayerAttributeMagicka:UnregisterForEvent(EVENT_INTERFACE_SETTING_CHANGED) |
|
82 | Seerah-7 | ZO_PlayerAttributeMagicka:UnregisterForEvent(EVENT_PLAYER_ACTIVATED) |
|
83 | Seerah-7 | EVENT_MANAGER:UnregisterForUpdate("ZO_PlayerAttributeMagickaFadeUpdate") |
|
84 | Seerah-7 | ZO_PlayerAttributeMagicka:SetHidden(true) |
|
85 | Seerah-7 | ||
86 | Seerah-7 | ZO_PlayerAttributeStamina:UnregisterForEvent(EVENT_POWER_UPDATE) |
|
87 | Seerah-7 | ZO_PlayerAttributeStamina:UnregisterForEvent(EVENT_INTERFACE_SETTING_CHANGED) |
|
88 | Seerah-7 | ZO_PlayerAttributeStamina:UnregisterForEvent(EVENT_PLAYER_ACTIVATED) |
|
89 | Seerah-7 | EVENT_MANAGER:UnregisterForUpdate("ZO_PlayerAttributeStaminaFadeUpdate") |
|
90 | Seerah-7 | ZO_PlayerAttributeStamina:SetHidden(true) |
|
91 | Seerah-7 | ||
92 | Seerah-7 | ZO_PlayerAttributeHealth:UnregisterForEvent(EVENT_POWER_UPDATE) |
|
93 | Seerah-7 | ZO_PlayerAttributeHealth:UnregisterForEvent(EVENT_INTERFACE_SETTING_CHANGED) |
|
94 | Seerah-7 | ZO_PlayerAttributeHealth:UnregisterForEvent(EVENT_PLAYER_ACTIVATED) |
|
95 | Seerah-7 | EVENT_MANAGER:UnregisterForUpdate("ZO_PlayerAttributeHealthFadeUpdate") |
|
96 | Seerah-7 | ZO_PlayerAttributeHealth:SetHidden(true) |
|
97 | Seerah-7 | end |
|
98 | Seerah-7 | ||
99 | 2 | Seerah-7 | local function CreatePlayerFrame() |
100 | Seerah-7 | --main frame |
|
101 | Seerah-7 | playerFrame:SetDimensions(300, 54) |
|
102 | 6 | Seerah-7 | playerFrame:SetDrawLayer(DL_BACKGROUND) |
103 | 2 | Seerah-7 | if not db.playerFrame then |
104 | Seerah-7 | db.playerFrame = {} |
|
105 | Seerah-7 | db.playerFrame.point = {["a"]=BOTTOM, ["b"]=BOTTOM, ["x"]=0, ["y"]=-100} |
|
106 | Seerah-7 | end |
|
107 | Seerah-7 | local anchor = db.playerFrame.point |
|
108 | Seerah-7 | playerFrame:SetAnchor(anchor.a, GuiRoot, anchor.b or anchor.a, anchor.x, anchor.y) |
|
109 | Seerah-7 | playerFrame:SetMouseEnabled(true) |
|
110 | Seerah-7 | playerFrame:SetMovable(not db.locked) |
|
111 | Seerah-7 | playerFrame:SetClampedToScreen(true) |
|
112 | 10 | Seerah-7 | if db.combatFade then playerFrame:SetAlpha(0) end |
113 | 2 | Seerah-7 | playerFrame:SetHandler("OnMouseUp", function(self) |
114 | Seerah-7 | self:StopMovingOrResizing() |
|
115 | Seerah-7 | local _,a,_,b,x,y = self:GetAnchor() |
|
116 | Seerah-7 | db.playerFrame.point = {["a"]=a, ["b"]=b, ["x"]=x, ["y"]=y} |
|
117 | Seerah-7 | end) |
|
118 | Seerah-7 | ||
119 | Seerah-7 | --border & background |
|
120 | 5 | Seerah-7 | playerFrame.bg = wm:CreateControl("ZAMUnitFrames_PlayerBG", playerFrame, CT_BACKDROP) |
121 | Seerah-7 | playerFrame.bg:SetCenterColor(0, 0, 0, .5) |
|
122 | Seerah-7 | playerFrame.bg:SetEdgeColor(1, 1, 1, 1) |
|
123 | Seerah-7 | BorderConfig(playerFrame) |
|
124 | 2 | Seerah-7 | |
125 | Seerah-7 | --health bar |
|
126 | Seerah-7 | playerFrame.health:SetAnchor(TOPLEFT, playerFrame, TOPLEFT, 1, 1) |
|
127 | Seerah-7 | playerFrame.health:SetAnchor(TOPRIGHT, playerFrame, TOPRIGHT, -1, 1) |
|
128 | Seerah-7 | playerFrame.health:SetHeight(20) |
|
129 | Seerah-7 | playerFrame.health:SetMinMax(0, 100) |
|
130 | 5 | Seerah-7 | --playerFrame.health:SetValue(100) |
131 | Seerah-7 | playerFrame.health.text:SetAnchor(LEFT, playerFrame, RIGHT, 8, 0) |
|
132 | 2 | Seerah-7 | playerFrame.health.text:SetText("100%") |
133 | 12 | Seerah-7 | |
134 | Seerah-7 | --siege health mini-bar |
|
135 | Seerah-7 | playerFrame.siege = wm:CreateControl("ZAMUnitFrames_PlayerSiegeHealth", playerFrame.health, CT_STATUSBAR) |
|
136 | Seerah-7 | playerFrame.siege:SetAnchor(BOTTOMLEFT, playerFrame.health, BOTTOMLEFT) |
|
137 | Seerah-7 | playerFrame.siege:SetAnchor(BOTTOMRIGHT, playerFrame.health, BOTTOMRIGHT) |
|
138 | Seerah-7 | playerFrame.siege:SetHeight(8) |
|
139 | Seerah-7 | playerFrame.siege:SetMinMax(0,100) |
|
140 | Seerah-7 | playerFrame.siege:SetHidden(true) |
|
141 | Seerah-7 | --playerFrame.siege:SetValue(90) |
|
142 | 2 | Seerah-7 | do |
143 | Seerah-7 | local r1,g1,b1 = ZO_POWER_BAR_GRADIENT_COLORS[POWERTYPE_HEALTH][1]:UnpackRGBA() |
|
144 | Seerah-7 | local r2,g2,b2 = ZO_POWER_BAR_GRADIENT_COLORS[POWERTYPE_HEALTH][2]:UnpackRGBA() |
|
145 | Seerah-7 | playerFrame.health:SetGradientColors(r1, g1, b1, 1, r2, g2, b2, 1) |
|
146 | Seerah-7 | playerFrame.health.text:SetColor(r2, g2, b2) |
|
147 | 12 | Seerah-7 | --playerFrame.siege:SetColor(r1-.1, g1-.1, b1-.1) |
148 | Seerah-7 | playerFrame.siege:SetGradientColors(r1-.2, g1-.2, b1-.2, 1, r2-.2, g2-.2, b2-.2, 1) |
|
149 | 2 | Seerah-7 | end |
150 | Seerah-7 | ||
151 | Seerah-7 | --magicka bar |
|
152 | Seerah-7 | playerFrame.magicka:SetAnchor(TOPLEFT, playerFrame.health, BOTTOMLEFT, 0, 1) |
|
153 | Seerah-7 | playerFrame.magicka:SetAnchor(TOPRIGHT, playerFrame.health, BOTTOMRIGHT, 0, 1) |
|
154 | Seerah-7 | playerFrame.magicka:SetHeight(15) |
|
155 | Seerah-7 | playerFrame.magicka:SetMinMax(0,100) |
|
156 | 5 | Seerah-7 | --playerFrame.magicka:SetValue(50) |
157 | Seerah-7 | playerFrame.magicka.text:SetAnchor(TOPRIGHT, playerFrame, TOPLEFT, -8, 0) |
|
158 | 2 | Seerah-7 | playerFrame.magicka.text:SetText("100%") |
159 | 12 | Seerah-7 | |
160 | Seerah-7 | --werewolf mini-bar |
|
161 | Seerah-7 | playerFrame.werewolf = wm:CreateControl("ZAMUnitFrames_PlayerWerewolf", playerFrame.magicka, CT_STATUSBAR) |
|
162 | Seerah-7 | playerFrame.werewolf:SetAnchor(BOTTOMLEFT, playerFrame.magicka, BOTTOMLEFT) |
|
163 | Seerah-7 | playerFrame.werewolf:SetAnchor(BOTTOMRIGHT, playerFrame.magicka, BOTTOMRIGHT) |
|
164 | Seerah-7 | playerFrame.werewolf:SetHeight(5) |
|
165 | Seerah-7 | --playerFrame.mount:SetMinMax(0,100) |
|
166 | Seerah-7 | playerFrame.werewolf:SetHidden(true) |
|
167 | Seerah-7 | --playerFrame.werewolf:SetValue(70) |
|
168 | 2 | Seerah-7 | do |
169 | Seerah-7 | local r1,g1,b1 = ZO_POWER_BAR_GRADIENT_COLORS[POWERTYPE_MAGICKA][1]:UnpackRGBA() |
|
170 | Seerah-7 | local r2,g2,b2 = ZO_POWER_BAR_GRADIENT_COLORS[POWERTYPE_MAGICKA][2]:UnpackRGBA() |
|
171 | Seerah-7 | playerFrame.magicka:SetGradientColors(r1, g1, b1, 1, r2, g2, b2, 1) |
|
172 | Seerah-7 | playerFrame.magicka.text:SetColor(r2, g2, b2) |
|
173 | 12 | Seerah-7 | --playerFrame.werewolf:SetColor(r1-.1, g1-.1, b1-.1) |
174 | Seerah-7 | playerFrame.werewolf:SetGradientColors(r1-.2, g1-.2, b1-.2, 1, r2-.2, g2-.2, b2-.2, 1) |
|
175 | 2 | Seerah-7 | end |
176 | Seerah-7 | ||
177 | Seerah-7 | --stamina bar |
|
178 | Seerah-7 | playerFrame.stamina:SetAnchor(TOPLEFT, playerFrame.magicka, BOTTOMLEFT, 0, 1) |
|
179 | Seerah-7 | playerFrame.stamina:SetAnchor(TOPRIGHT, playerFrame.magicka, BOTTOMRIGHT, 0, 1) |
|
180 | Seerah-7 | playerFrame.stamina:SetHeight(15) |
|
181 | Seerah-7 | playerFrame.stamina:SetMinMax(0,100) |
|
182 | 5 | Seerah-7 | --playerFrame.stamina:SetValue(75) |
183 | Seerah-7 | playerFrame.stamina.text:SetAnchor(BOTTOMRIGHT, playerFrame, BOTTOMLEFT, -8, 0) |
|
184 | 2 | Seerah-7 | playerFrame.stamina.text:SetText("100%") |
185 | 12 | Seerah-7 | |
186 | Seerah-7 | --mount stamina mini-bar |
|
187 | Seerah-7 | playerFrame.mount = wm:CreateControl("ZAMUnitFrames_PlayerMountStamina", playerFrame.stamina, CT_STATUSBAR) |
|
188 | Seerah-7 | playerFrame.mount:SetAnchor(BOTTOMLEFT, playerFrame.stamina, BOTTOMLEFT) |
|
189 | Seerah-7 | playerFrame.mount:SetAnchor(BOTTOMRIGHT, playerFrame.stamina, BOTTOMRIGHT) |
|
190 | Seerah-7 | playerFrame.mount:SetHeight(5) |
|
191 | Seerah-7 | --playerFrame.mount:SetMinMax(0,100) |
|
192 | Seerah-7 | playerFrame.mount:SetHidden(true) |
|
193 | Seerah-7 | --playerFrame.mount:SetValue(70) |
|
194 | 2 | Seerah-7 | do |
195 | Seerah-7 | local r1,g1,b1 = ZO_POWER_BAR_GRADIENT_COLORS[POWERTYPE_STAMINA][1]:UnpackRGBA() |
|
196 | Seerah-7 | local r2,g2,b2 = ZO_POWER_BAR_GRADIENT_COLORS[POWERTYPE_STAMINA][2]:UnpackRGBA() |
|
197 | Seerah-7 | playerFrame.stamina:SetGradientColors(r1, g1, b1, 1, r2, g2, b2, 1) |
|
198 | Seerah-7 | playerFrame.stamina.text:SetColor(r2 +.05, g2 +.05, b2 +.05) |
|
199 | 12 | Seerah-7 | --playerFrame.mount:SetColor(r1-.1, g1-.1, b1-.1) |
200 | Seerah-7 | playerFrame.mount:SetGradientColors(r1-.2, g1-.2, b1-.2, 1, r2-.2, g2-.2, b2-.2, 1) |
|
201 | 2 | Seerah-7 | end |
202 | 4 | Seerah-7 | |
203 | 12 | Seerah-7 | --set the fonts & bar textures |
204 | 5 | Seerah-7 | SetFonts(playerFrame) |
205 | 12 | Seerah-7 | SetBarTextures(playerFrame) |
206 | 5 | Seerah-7 | |
207 | 4 | Seerah-7 | --reparent & reuse warner frame/animations |
208 | Seerah-7 | local healthwarner = ZO_PlayerAttributeHealthWarner |
|
209 | Seerah-7 | playerFrame.health.warner = healthwarner |
|
210 | Seerah-7 | healthwarner:SetParent(playerFrame.health) |
|
211 | Seerah-7 | healthwarner:ClearAnchors() |
|
212 | Seerah-7 | healthwarner:SetAnchor(TOPLEFT, playerFrame.health, TOPLEFT, -18, 0) |
|
213 | Seerah-7 | healthwarner:SetAnchor(BOTTOMRIGHT, playerFrame.health, BOTTOMRIGHT, 18, 0) |
|
214 | Seerah-7 | GetControl(healthwarner, "Left"):SetTextureCoords(.7578125, .5234375, 0, 1) |
|
215 | Seerah-7 | GetControl(healthwarner, "Right"):SetTextureCoords(.5234375, .7578125, 0, 1) |
|
216 | Seerah-7 | GetControl(healthwarner, "Left"):SetWidth(30) |
|
217 | Seerah-7 | GetControl(healthwarner, "Right"):SetWidth(30) |
|
218 | Seerah-7 | local magickawarner = ZO_PlayerAttributeMagickaWarner |
|
219 | Seerah-7 | playerFrame.magicka.warner = magickawarner |
|
220 | Seerah-7 | magickawarner:SetParent(playerFrame.magicka) |
|
221 | Seerah-7 | magickawarner:ClearAnchors() |
|
222 | Seerah-7 | magickawarner:SetAnchor(TOPLEFT, playerFrame.magicka, TOPLEFT, -18, 0) |
|
223 | Seerah-7 | magickawarner:SetAnchor(BOTTOMRIGHT, playerFrame.magicka, BOTTOMRIGHT, 18, 0) |
|
224 | Seerah-7 | GetControl(magickawarner, "Left"):SetTextureCoords(.7578125, .5234375, 0, 1) |
|
225 | Seerah-7 | GetControl(magickawarner, "Right"):SetTextureCoords(.5234375, .7578125, 0, 1) |
|
226 | Seerah-7 | GetControl(magickawarner, "Left"):SetWidth(30) |
|
227 | Seerah-7 | GetControl(magickawarner, "Right"):SetWidth(30) |
|
228 | Seerah-7 | local staminawarner = ZO_PlayerAttributeStaminaWarner |
|
229 | Seerah-7 | playerFrame.stamina.warner = staminawarner |
|
230 | Seerah-7 | staminawarner:SetParent(playerFrame.stamina) |
|
231 | Seerah-7 | staminawarner:ClearAnchors() |
|
232 | Seerah-7 | staminawarner:SetAnchor(TOPLEFT, playerFrame.stamina, TOPLEFT, -18, 0) |
|
233 | Seerah-7 | staminawarner:SetAnchor(BOTTOMRIGHT, playerFrame.stamina, BOTTOMRIGHT, 18, 0) |
|
234 | Seerah-7 | GetControl(staminawarner, "Left"):SetTextureCoords(.7578125, .5234375, 0, 1) |
|
235 | Seerah-7 | GetControl(staminawarner, "Right"):SetTextureCoords(.5234375, .7578125, 0, 1) |
|
236 | Seerah-7 | GetControl(staminawarner, "Left"):SetWidth(30) |
|
237 | Seerah-7 | GetControl(staminawarner, "Right"):SetWidth(30) |
|
238 | 5 | Seerah-7 | |
239 | Seerah-7 | UnregisterAttributeBars() |
|
240 | 2 | Seerah-7 | end |
241 | Seerah-7 | ||
242 | 5 | Seerah-7 | local function TargetFrameTweaks() |
243 | Seerah-7 | targetFrame = ZO_TargetUnitFramereticleover |
|
244 | Seerah-7 | targetFrame.health = {} |
|
245 | Seerah-7 | targetFrame.health.barLeft = ZO_TargetUnitFramereticleoverBarLeft |
|
246 | Seerah-7 | targetFrame.health.barRight = ZO_TargetUnitFramereticleoverBarRight |
|
247 | 14 | Seerah-7 | targetFrame.health.barRight.gloss:SetHidden(true) |
248 | Seerah-7 | targetFrame.health.barLeft.gloss:SetHidden(true) |
|
249 | 5 | Seerah-7 | targetFrame.health.text = wm:CreateControl("ZAMUnitFrames_TargetHealthText", targetFrame, CT_LABEL) |
250 | Seerah-7 | targetFrame.health.text:SetAnchor(RIGHT, targetFrame, LEFT, -5, 0) |
|
251 | Seerah-7 | targetFrame.health.text:SetText("100%") |
|
252 | Seerah-7 | targetFrame.name = ZO_TargetUnitFramereticleoverName |
|
253 | Seerah-7 | targetFrame.level = ZO_TargetUnitFramereticleoverLevel |
|
254 | Seerah-7 | targetFrame.caption = ZO_TargetUnitFramereticleoverCaption |
|
255 | 6 | Seerah-7 | |
256 | Seerah-7 | if not db.targetFrame then |
|
257 | Seerah-7 | db.targetFrame = {} |
|
258 | Seerah-7 | db.targetFrame.point = {["a"] = TOP, ["b"] = TOP, ["x"] = 0, ["y"] = 88} |
|
259 | Seerah-7 | end |
|
260 | Seerah-7 | targetFrame:ClearAnchors() |
|
261 | Seerah-7 | local anchor = db.targetFrame.point |
|
262 | Seerah-7 | targetFrame:SetAnchor(anchor.a, GuiRoot, anchor.b, anchor.x, anchor.y) |
|
263 | Seerah-7 | targetFrame.moverFrame = wm:CreateTopLevelWindow("ZAMUnitFrames_TargetMoverFrame") |
|
264 | Seerah-7 | local moverFrame = targetFrame.moverFrame |
|
265 | Seerah-7 | moverFrame:SetDrawLayer(DL_BACKGROUND) |
|
266 | Seerah-7 | moverFrame:SetAnchor(anchor.a, GuiRoot, anchor.b, anchor.x, anchor.y) |
|
267 | Seerah-7 | moverFrame:SetDimensions(280, 75) |
|
268 | Seerah-7 | moverFrame.bg = wm:CreateControl("ZAMUnitFrames_TargetMoverFrameBG", moverFrame, CT_TEXTURE) |
|
269 | Seerah-7 | moverFrame.bg:SetColor(1, 1, 1, .5) |
|
270 | Seerah-7 | moverFrame.bg:SetAnchorFill(moverFrame) |
|
271 | Seerah-7 | moverFrame:SetHidden(db.locked) |
|
272 | Seerah-7 | moverFrame:SetMouseEnabled(true) |
|
273 | Seerah-7 | moverFrame:SetMovable(not db.locked) |
|
274 | Seerah-7 | moverFrame:SetClampedToScreen(true) |
|
275 | Seerah-7 | moverFrame:SetHandler("OnMouseUp", function(self) |
|
276 | Seerah-7 | self:StopMovingOrResizing() |
|
277 | Seerah-7 | local _,a,_,b,x,y = self:GetAnchor() |
|
278 | Seerah-7 | db.targetFrame.point = {["a"] = a, ["b"] = b, ["x"] = x, ["y"] = y} |
|
279 | Seerah-7 | targetFrame:ClearAnchors() |
|
280 | Seerah-7 | targetFrame:SetAnchor(a, GuiRoot, b, x, y) |
|
281 | Seerah-7 | end) |
|
282 | 5 | Seerah-7 | |
283 | Seerah-7 | SetFonts(targetFrame) |
|
284 | Seerah-7 | ||
285 | Seerah-7 | local function UpdateColor() |
|
286 | Seerah-7 | if DoesUnitExist("reticleover") then |
|
287 | Seerah-7 | local curHealthT, maxHealthT, effMaxHealthT = GetUnitPower("reticleover", POWERTYPE_HEALTH) |
|
288 | Seerah-7 | targetFrame.health.text:SetText(strformat("%d%%", curHealthT/effMaxHealthT*100)) |
|
289 | Seerah-7 | if db.targetReaction then |
|
290 | Seerah-7 | local r, g, b = GetUnitReactionColor("reticleover") |
|
291 | Seerah-7 | targetFrame.health.barLeft:SetGradientColors(r*.52, g*.73, b*.73, 1, r, g, b, 1) |
|
292 | Seerah-7 | targetFrame.health.barRight:SetGradientColors(r*.52, g*.73, b*.73, 1, r, g, b, 1) |
|
293 | Seerah-7 | end |
|
294 | Seerah-7 | end |
|
295 | Seerah-7 | end |
|
296 | Seerah-7 | targetFrame.health.text:RegisterForEvent(EVENT_RETICLE_TARGET_CHANGED, UpdateColor) |
|
297 | Seerah-7 | targetFrame.health.text:RegisterForEvent(EVENT_DISPOSITION_UPDATE, UpdateColor) |
|
298 | Seerah-7 | end |
|
299 | Seerah-7 | ||
300 | 2 | Seerah-7 | local function InitializeBars() |
301 | Seerah-7 | local curHealth, maxHealth, effMaxHealth = GetUnitPower("player", POWERTYPE_HEALTH) |
|
302 | Seerah-7 | playerFrame.health:SetMinMax(0, effMaxHealth) |
|
303 | Seerah-7 | playerFrame.health:SetValue(curHealth) |
|
304 | Seerah-7 | local curMagicka, maxMagicka, effMaxMagicka = GetUnitPower("player", POWERTYPE_MAGICKA) |
|
305 | Seerah-7 | playerFrame.magicka:SetMinMax(0, effMaxMagicka) |
|
306 | Seerah-7 | playerFrame.magicka:SetValue(curMagicka) |
|
307 | Seerah-7 | local curStamina, maxStamina, effMaxStamina = GetUnitPower("player", POWERTYPE_STAMINA) |
|
308 | Seerah-7 | playerFrame.stamina:SetMinMax(0, effMaxStamina) |
|
309 | Seerah-7 | playerFrame.stamina:SetValue(curStamina) |
|
310 | 12 | Seerah-7 | local curWerewolf, maxWerewolf, effMaxWerewolf = GetUnitPower("player", POWERTYPE_WEREWOLF) |
311 | Seerah-7 | playerFrame.werewolf:SetMinMax(0, effMaxWerewolf) |
|
312 | Seerah-7 | playerFrame.werewolf:SetValue(curWerewolf) |
|
313 | Seerah-7 | local curMountSta, maxMountSta, effMaxMountSta = GetUnitPower("player", POWERTYPE_MOUNT_STAMINA) |
|
314 | Seerah-7 | playerFrame.mount:SetMinMax(0, effMaxMountSta) |
|
315 | Seerah-7 | playerFrame.mount:SetValue(curMountSta) |
|
316 | 2 | Seerah-7 | end |
317 | Seerah-7 | ||
318 | 12 | Seerah-7 | local function CombatFade(event, inCombatBool) --make this fade in/out instead? |
319 | Seerah-7 | if db.combatFade then |
|
320 | Seerah-7 | inCombat = inCombatBool or inCombat |
|
321 | Seerah-7 | local curHealth, maxHealth, effMaxHealth = GetUnitPower("player", POWERTYPE_HEALTH) |
|
322 | Seerah-7 | local curMagicka, maxMagicka, effMaxMagicka = GetUnitPower("player", POWERTYPE_MAGICKA) |
|
323 | Seerah-7 | if not inCombat and curHealth == effMaxHealth and curMagicka == effMaxMagicka then |
|
324 | Seerah-7 | playerFrame:SetAlpha(0) |
|
325 | Seerah-7 | else |
|
326 | Seerah-7 | playerFrame:SetAlpha(1) |
|
327 | Seerah-7 | end |
|
328 | Seerah-7 | end |
|
329 | Seerah-7 | end |
|
330 | Seerah-7 | ||
331 | Seerah-7 | local function UpdateSiegeHealthBar(event, unit) |
|
332 | Seerah-7 | unit = unit or (IsGameCameraSiegeControlled() and "controlledsiege") or (IsPlayerEscortingRam() and "escortedram") |
|
333 | Seerah-7 | if not DoesUnitExist("player") and (unit == "controlledsiege" or unit == "escortedram") then |
|
334 | Seerah-7 | playerFrame.siege:SetHidden(false) |
|
335 | Seerah-7 | local curHealth, maxHealth, effMaxHealth = GetUnitPower(unit, POWERTYPE_HEALTH) |
|
336 | Seerah-7 | ZO_StatusBar_SmoothTransition(playerFrame.siege, curHealth, effMaxHealth) |
|
337 | Seerah-7 | else |
|
338 | Seerah-7 | playerFrame.siege:SetHidden(true) |
|
339 | Seerah-7 | end |
|
340 | Seerah-7 | end |
|
341 | Seerah-7 | ||
342 | Seerah-7 | local function PowerUpdate(event, unitTag, powerIndex, powerType, powerValue, powerMax, powerEffectiveMax) |
|
343 | Seerah-7 | if unitTag == "player" then |
|
344 | Seerah-7 | if powerType == POWERTYPE_MAGICKA then |
|
345 | Seerah-7 | ZO_StatusBar_SmoothTransition(playerFrame.magicka, powerValue, powerEffectiveMax) |
|
346 | Seerah-7 | playerFrame.magicka.text:SetText(strformat("%d%%", powerValue/powerEffectiveMax*100)) |
|
347 | Seerah-7 | elseif powerType == POWERTYPE_STAMINA then |
|
348 | Seerah-7 | ZO_StatusBar_SmoothTransition(playerFrame.stamina, powerValue, powerEffectiveMax) |
|
349 | Seerah-7 | playerFrame.stamina.text:SetText(strformat("%d%%", powerValue/powerEffectiveMax*100)) |
|
350 | Seerah-7 | elseif powerType == POWERTYPE_HEALTH then |
|
351 | Seerah-7 | ZO_StatusBar_SmoothTransition(playerFrame.health, powerValue, powerEffectiveMax) |
|
352 | Seerah-7 | playerFrame.health.text:SetText(strformat("%d%%", powerValue/powerEffectiveMax*100)) |
|
353 | Seerah-7 | elseif powerType == POWERTYPE_WEREWOLF then |
|
354 | Seerah-7 | ZO_StatusBar_SmoothTransition(playerFrame.werewolf, powerValue, powerEffectiveMax) |
|
355 | Seerah-7 | elseif powerType == POWERTYPE_MOUNT_STAMINA then |
|
356 | Seerah-7 | ZO_StatusBar_SmoothTransition(playerFrame.mount, powerValue, powerEffectiveMax) |
|
357 | Seerah-7 | end |
|
358 | Seerah-7 | CombatFade() |
|
359 | Seerah-7 | elseif unitTag == "reticleover" and powerType == POWERTYPE_HEALTH then |
|
360 | Seerah-7 | targetFrame.health.text:SetText(strformat("%d%%", powerValue/powerEffectiveMax*100)) |
|
361 | Seerah-7 | elseif (unitTag == "controlledsiege" or unitTag == "escortedram") and powerType == POWERTYPE_HEALTH then --does this event fire for these units? |
|
362 | Seerah-7 | ZO_StatusBar_SmoothTransition(playerFrame.siege, powerValue, powerEffectiveMax) |
|
363 | Seerah-7 | end |
|
364 | Seerah-7 | end |
|
365 | Seerah-7 | ||
366 | 2 | Seerah-7 | local function SetUpDB() |
367 | Seerah-7 | ZAM_UnitFramesDB = ZAM_UnitFramesDB or {} |
|
368 | Seerah-7 | for k,v in pairs(defaults) do |
|
369 | Seerah-7 | if type(ZAM_UnitFramesDB[k]) == "nil" then |
|
370 | Seerah-7 | ZAM_UnitFramesDB[k] = v |
|
371 | Seerah-7 | end |
|
372 | Seerah-7 | end |
|
373 | Seerah-7 | db = ZAM_UnitFramesDB |
|
374 | Seerah-7 | end |
|
375 | Seerah-7 | ||
376 | 14 | Seerah-7 | |
377 | Seerah-7 | local panelData = { |
|
378 | Seerah-7 | type = "panel", |
|
379 | Seerah-7 | name = "ZAM UnitFrames", |
|
380 | Seerah-7 | displayName = "|t72:36:ZAM_Stats\\ZAM_Logo.dds|t UnitFrames", |
|
381 | Seerah-7 | slashCommand = "/zamuf", |
|
382 | Seerah-7 | registerForDefaults = true, |
|
383 | Seerah-7 | author = "Seerah", |
|
384 | Seerah-7 | version = versionNo, |
|
385 | Seerah-7 | } |
|
386 | Seerah-7 | local optionsData = { |
|
387 | Seerah-7 | [1] = { |
|
388 | Seerah-7 | type = "checkbox", |
|
389 | Seerah-7 | name = "Lock Frames", |
|
390 | Seerah-7 | tooltip = "Lock the unit frames in place.", |
|
391 | Seerah-7 | getFunc = function() return db.locked end, |
|
392 | Seerah-7 | setFunc = function(value) |
|
393 | Seerah-7 | db.locked = value |
|
394 | 6 | Seerah-7 | playerFrame:SetMovable(not db.locked) |
395 | Seerah-7 | targetFrame.moverFrame:SetHidden(db.locked) |
|
396 | Seerah-7 | targetFrame.moverFrame:SetMovable(not db.locked) |
|
397 | 14 | Seerah-7 | end, |
398 | Seerah-7 | default = defaults.locked |
|
399 | Seerah-7 | }, |
|
400 | Seerah-7 | [2] = { |
|
401 | Seerah-7 | type = "checkbox", |
|
402 | Seerah-7 | name = "Target Reaction", |
|
403 | Seerah-7 | tooltip = "Color the reticle target's healthbar by reaction.", |
|
404 | Seerah-7 | getFunc = function() return db.targetReaction end, |
|
405 | Seerah-7 | setFunc = function(value) |
|
406 | Seerah-7 | db.targetReaction = value |
|
407 | 5 | Seerah-7 | if not db.targetReaction then |
408 | Seerah-7 | targetFrame.health.barRight:SetGradientColors(114/255, 35/255, 35/255, 1, 218/255, 48/255, 48/255, 1) |
|
409 | Seerah-7 | targetFrame.health.barLeft:SetGradientColors(114/255, 35/255, 35/255, 1, 218/255, 48/255, 48/255, 1) |
|
410 | Seerah-7 | end |
|
411 | 14 | Seerah-7 | end, |
412 | Seerah-7 | default = defaults.targetReaction |
|
413 | Seerah-7 | }, |
|
414 | Seerah-7 | [3] = { |
|
415 | Seerah-7 | type = "checkbox", |
|
416 | Seerah-7 | name = "Show Only In Combat", |
|
417 | Seerah-7 | tooltip = "Show the player frame only when in combat or when health or magicka aren't full.", |
|
418 | Seerah-7 | getFunc = function() return db.combatFade end, |
|
419 | Seerah-7 | setFunc = function(value) |
|
420 | Seerah-7 | db.combatFade = value |
|
421 | Seerah-7 | playerFrame:SetAlpha(db.combatFade and 0 or 1) |
|
422 | Seerah-7 | end, |
|
423 | Seerah-7 | default = defaults.combatFade |
|
424 | Seerah-7 | }, |
|
425 | Seerah-7 | [4] = { |
|
426 | Seerah-7 | type = "header", |
|
427 | Seerah-7 | name = "Skinning Options", |
|
428 | Seerah-7 | }, |
|
429 | Seerah-7 | [5] = { |
|
430 | Seerah-7 | type = "dropdown", |
|
431 | Seerah-7 | name = "Bar Texture", |
|
432 | Seerah-7 | tooltip = "The texture to use for the status bars.", |
|
433 | Seerah-7 | choices = LMP:List("statusbar"), |
|
434 | Seerah-7 | getFunc = function() return db.barTexture end, |
|
435 | Seerah-7 | setFunc = function(barTexture) |
|
436 | Seerah-7 | db.barTexture = barTexture |
|
437 | Seerah-7 | SetBarTextures(playerFrame) |
|
438 | Seerah-7 | end, |
|
439 | Seerah-7 | default = defaults.barTexture |
|
440 | Seerah-7 | }, |
|
441 | Seerah-7 | [6] = { |
|
442 | Seerah-7 | type = "dropdown", |
|
443 | Seerah-7 | name = "Font", |
|
444 | Seerah-7 | tooltip = "The font to use for the text.", |
|
445 | Seerah-7 | choices = LMP:List("font"), |
|
446 | Seerah-7 | getFunc = function() return db.font end, |
|
447 | Seerah-7 | setFunc = function(font) |
|
448 | Seerah-7 | db.font = font |
|
449 | Seerah-7 | SetFonts(ZAMUnitFrames_Player) |
|
450 | Seerah-7 | end, |
|
451 | Seerah-7 | default = defaults.font |
|
452 | Seerah-7 | }, |
|
453 | Seerah-7 | [7] = { |
|
454 | Seerah-7 | type = "dropdown", |
|
455 | Seerah-7 | name = "Border", |
|
456 | Seerah-7 | tooltip = "The texture to use for the border.", |
|
457 | Seerah-7 | choices = LMP:List("border"), |
|
458 | Seerah-7 | getFunc = function() return db.border end, |
|
459 | Seerah-7 | setFunc = function(border) |
|
460 | 5 | Seerah-7 | db.border = border |
461 | Seerah-7 | playerFrame.bg:SetEdgeTexture(LMP:Fetch("border", border), 256, 32, 40) |
|
462 | 14 | Seerah-7 | end, |
463 | Seerah-7 | default = defaults.border |
|
464 | Seerah-7 | }, |
|
465 | Seerah-7 | [8] = { |
|
466 | Seerah-7 | type = "slider", |
|
467 | Seerah-7 | name = "Border Spacing", |
|
468 | Seerah-7 | tooltip = "The distance between the outside edge of the border and the background of the frame.", |
|
469 | Seerah-7 | min = 0, |
|
470 | Seerah-7 | max = 20, |
|
471 | Seerah-7 | step = 1, |
|
472 | Seerah-7 | getFunc = function() return db.borderSpacing end, |
|
473 | Seerah-7 | setFunc = function(val) |
|
474 | 5 | Seerah-7 | db.borderSpacing = val |
475 | Seerah-7 | BorderConfig(playerFrame) |
|
476 | Seerah-7 | end, |
|
477 | 14 | Seerah-7 | warning = "Each border is different in regards to what combination of spacing and size works best with it. Play with the two sliders until you reach your desired result.", |
478 | Seerah-7 | width = "half", |
|
479 | Seerah-7 | default = defaults.borderSpacing, |
|
480 | Seerah-7 | }, |
|
481 | Seerah-7 | [9] = { |
|
482 | Seerah-7 | type = "slider", |
|
483 | Seerah-7 | name = "Border Size", |
|
484 | Seerah-7 | tooltip = "The width of the border.", |
|
485 | Seerah-7 | min = 2, |
|
486 | Seerah-7 | max = 64, |
|
487 | Seerah-7 | step = 2, |
|
488 | Seerah-7 | getFunc = function() return db.borderSize end, |
|
489 | Seerah-7 | setFunc = function(val) |
|
490 | 5 | Seerah-7 | db.borderSize = val |
491 | Seerah-7 | BorderConfig(playerFrame) |
|
492 | Seerah-7 | end, |
|
493 | 14 | Seerah-7 | warning = "Each border is different in regards to what combination of spacing and size works best with it. Play with the two sliders until you reach your desired result.", |
494 | Seerah-7 | width = "half", |
|
495 | Seerah-7 | default = defaults.borderSize, |
|
496 | Seerah-7 | }, |
|
497 | Seerah-7 | } |
|
498 | Seerah-7 | ||
499 | Seerah-7 | local function CreateOptions() |
|
500 | Seerah-7 | LAM:RegisterAddonPanel("ZAMUnitFramesOptions", panelData) |
|
501 | Seerah-7 | LAM:RegisterOptionControls("ZAMUnitFramesOptions", optionsData) |
|
502 | 2 | Seerah-7 | end |
503 | Seerah-7 | ||
504 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_ADD_ON_LOADED, function(event, addon) |
|
505 | 12 | Seerah-7 | --playerFrame:RegisterForEvent(EVENT_PLAYER_ACTIVATED, function(event, addon) |
506 | 2 | Seerah-7 | if addon == "ZAM_UnitFrames" then |
507 | Seerah-7 | SetUpDB() |
|
508 | Seerah-7 | CreatePlayerFrame() |
|
509 | 5 | Seerah-7 | TargetFrameTweaks() |
510 | 2 | Seerah-7 | InitializeBars() |
511 | Seerah-7 | CreateOptions() |
|
512 | Seerah-7 | ||
513 | 12 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_POWER_UPDATE, PowerUpdate) |
514 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_PLAYER_COMBAT_STATE, CombatFade) |
|
515 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_UNIT_CREATED, UpdateSiegeHealthBar) |
|
516 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_BEGIN_SIEGE_CONTROL, UpdateSiegeHealthBar) |
|
517 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_END_SIEGE_CONTROL, UpdateSiegeHealthBar) |
|
518 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_LEAVE_RAM_ESCORT, UpdateSiegeHealthBar) |
|
519 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_WEREWOLF_STATE_CHANGED, function(event, isWerewolf) |
|
520 | Seerah-7 | playerFrame.werewolf:SetHidden(not isWerewolf) |
|
521 | Seerah-7 | end) |
|
522 | Seerah-7 | playerFrame:RegisterForEvent(EVENT_MOUNTED_STATE_CHANGED, function(event, isMounted) |
|
523 | Seerah-7 | playerFrame.mount:SetHidden(not isMounted) |
|
524 | Seerah-7 | end) |
|
525 | Seerah-7 | ||
526 | Seerah-7 | ||
527 | 2 | Seerah-7 | playerFrame:UnregisterForEvent(EVENT_ADD_ON_LOADED) |
528 | 12 | Seerah-7 | --playerFrame:UnregisterForEvent(EVENT_PLAYER_ACTIVATED) |
529 | 2 | Seerah-7 | end |
530 | Seerah-7 | end) |
|
531 | Seerah-7 | ||
532 | Seerah-7 |