4 local format = string.format;
5 local CFrame = CreateFrame("Frame", "kehysPlayerInit", UIParent);
6 local CTimerAfter = C_Timer.After;
8 local barTexture = "Interface\\AddOns\\kehys\\images\\minimalist";
9 local vehicletoggle = [=[
10 if newstate == "vehicle" then
11 self:SetAttribute("displayed", self:GetAttribute("vehicle"));
13 self:SetAttribute("displayed", self:GetAttribute("unit"));
18 local function initPlayer(parent, width, height, update, event)
19 assert(type(parent) == "table", "Player frame creation missing parent!");
20 assert(type(width) == "number", "Player frame creation missing width!");
21 assert(type(height) == "number", "Player frame creation missing height!");
22 assert(type(update) == "function",
23 "Player frame creation missing update function!");
24 assert(type(event) == "function",
25 "Player frame creation missing event function!");
27 local f = CreateFrame("Button", "kehysPlayer", parent,
28 "SecureUnitButtonTemplate,SecureHandlerStateTemplate");
30 f:SetPoint("CENTER", parent, "CENTER", -300, -178);
33 f.barwidth = width - 2; -- 1px padding
34 f:SetAttribute("unit", "player");
35 f:SetAttribute("displayed", "player");
36 f:SetAttribute("vehicle", "vehicle");
38 f.displayed = "player";
44 CTimerAfter(0.1, updater);
47 f:SetScript("OnEvent", event);
48 f:RegisterForClicks("AnyDown");
49 f:SetAttribute("*type1", "target");
50 f:SetAttribute("*type2", "togglemenu");
51 f:SetAttribute("toggleForVehicle", true);
52 RegisterStateDriver(f, "vehicleui", "[vehicleui] vehicle; no");
53 f:SetAttribute("_onstate-vehicleui", vehicletoggle);
56 f.base = f:CreateTexture(nil, "BACKGROUND");
57 f.base:SetAllPoints();
58 f.base:SetColorTexture(0, 0, 0, 0.5);
59 f.background = f:CreateTexture(nil, "BACKGROUND", nil, 1);
60 f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
61 f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1);
62 f.health = f:CreateTexture(nil, "BORDER");
63 f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT");
64 f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, -height/8);
65 f.health:SetTexture(barTexture);
66 f.health:SetVertexColor(0.8, 0.8, 0.8);
68 f.mana = f:CreateTexture(nil, "BORDER");
69 f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -height/8);
70 f.mana:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT");
71 f.mana:SetTexture(barTexture);
72 f.mana:SetVertexColor(0.1, 0.5, 0.9);
74 f.manatext = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
75 f.manatext:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMRIGHT", -2, 4);
77 f.shield = f:CreateTexture(nil, "BORDER");
78 f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
79 f.shield:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
80 f.shield:SetTexture(barTexture);
81 f.shield:SetVertexColor(0, 0.7, 1);
83 f.shieldhl = f:CreateTexture(nil, "ARTWORK");
84 f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0);
85 f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT", 0, -height/8);
86 f.shieldhl:SetColorTexture(0.5, 0.8, 1);
88 f.healpred = f:CreateTexture(nil, "ARTWORK");
89 f.healpred:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
90 f.healpred:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
91 f.healpred:SetColorTexture(0.5, 0.6, 0.5);
93 f.healabsorb = f:CreateTexture(nil, "ARTWORK");
94 f.healabsorb:SetPoint("TOPRIGHT", f.health, "TOPRIGHT");
95 f.healabsorb:SetPoint("BOTTOMRIGHT", f.health, "BOTTOMRIGHT");
96 f.healabsorb:SetColorTexture(0.1, 0.1, 0.1);
98 f.text = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
99 f.text:SetPoint("LEFT", f.health, "LEFT", 10, 0);
100 f.text:SetFont(STANDARD_TEXT_FONT, 13);
102 f.targeticon = f:CreateTexture(nil, "OVERLAY");
103 f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1);
104 f.targeticon:SetWidth(12);
105 f.targeticon:SetHeight(12);
106 f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
108 f.status = f:CreateTexture(nil, "OVERLAY");
109 f.status:SetPoint("TOPLEFT", f.background, "BOTTOMLEFT", -8, 8);
110 f.status:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMLEFT", 8, -8);
111 f.status:SetTexture("Interface\\CHARACTERFRAME\\UI-StateIcon");
114 addon.RegisterEvents(f);
115 addon.RegisterUnitEvents(f);
116 event(f, "UPDATE_ALL_BARS");
121 CFrame:SetScript("OnEvent", function(self)
122 self:UnregisterAllEvents();
123 CFrame:SetFrameStrata("LOW");
124 CFrame:SetPoint("CENTER", nil, "CENTER");
127 initPlayer(self, 160, 48, addon.FrameUpdate, addon.UnitEvent);
129 CFrame:RegisterEvent("PLAYER_LOGIN");