4 local format = string.format;
5 local CFrame = CreateFrame("Frame", "kehysPlayerInit", UIParent);
7 local barTexture = "Interface\\AddOns\\OmaRF\\images\\minimalist";
8 local vehicletoggle = [=[
9 if newstate == "vehicle" then
10 self:SetAttribute("displayed", self:GetAttribute("vehicle"));
12 self:SetAttribute("displayed", self:GetAttribute("unit"));
17 function addon.PlayerFrame(parent, width, height, update, event)
18 assert(type(parent) == "table", "Player frame creation missing parent!");
19 assert(type(width) == "number", "Player frame creation missing width!");
20 assert(type(height) == "number", "Player frame creation missing height!");
21 assert(type(update) == "function",
22 "Player frame creation missing update function!");
23 assert(type(event) == "function",
24 "Player frame creation missing event function!");
26 local f = CreateFrame("Button", "kehysPlayer", parent,
27 "SecureUnitButtonTemplate,SecureHandlerStateTemplate");
29 f:SetPoint("CENTER", parent, "CENTER", 10, 10);
32 f.barwidth = width - 2; -- 1px padding
33 f:SetAttribute("unit", "player");
34 f:SetAttribute("displayed", "player");
35 f:SetAttribute("vehicle", "vehicle");
38 -- empty, just to be able to use general updater
47 CTimerAfter(0.1, updater);
50 f:SetScript("OnEvent", event);
51 f:SetAttribute("*type1", "target");
52 f:SetAttribute("*type2", "togglemenu");
53 f:SetAttribute("toggleForVehicle", true);
54 RegisterStateDriver(f, "vehicleui", "[vehicleui] vehicle; no");
55 f:SetAttribute("_onstate-vehicleui", vehicletoggle);
58 f.base = f:CreateTexture(nil, "BACKGROUND");
59 f.base:SetAllPoints();
60 f.base:SetColorTexture(1, 1, 1);
61 f.base:SetVertexColor(unpack(addon.Colors.Base));
62 f.background = f:CreateTexture(nil, "BACKGROUND", nil, 2);
63 f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
64 f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1);
65 f.background:SetColorTexture(0.7, 0.7, 0.7);
66 f.health = f:CreateTexture(nil, "BORDER");
67 f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT");
68 f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, 1);
69 f.health:SetTexture(barTexture);
70 f.health:SetVertexColor(0.3, 0.3, 0.3);
72 f.mana = f:CreateTexture(nil, "BORDER");
73 f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -1);
74 f.mana:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT");
75 f.mana:SetTexture(barTexture);
76 f.mana:SetVertexColor(0.3, 0.4, 0.7);
78 f.manatext = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
79 f.manatext:SetPoint("RIGHT", frame.background, "RIGHT", -2, -height/4);
81 f.shield = f:CreateTexture(nil, "BORDER");
82 f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
83 f.shield:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
84 f.shield:SetTexture(barTexture);
85 f.shield:SetVertexColor(0, 0.7, 1);
87 f.shieldhl = f:CreateTexture(nil, "ARTWORK");
88 f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0);
89 f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT");
90 f.shieldhl:SetColorTexture(0.5, 0.8, 1);
92 f.healpred = f:CreateTexture(nil, "ARTWORK");
93 f.healpred:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
94 f.healpred:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
95 f.healpred:SetColorTexture(0.5, 0.6, 0.5);
97 f.healabsorb = f:CreateTexture(nil, "ARTWORK");
98 f.healabsorb:SetPoint("TOPRIGHT", f.health, "TOPRIGHT");
99 f.healabsorb:SetPoint("BOTTOMRIGHT", f.health, "BOTTOMRIGHT");
100 f.healabsorb:SetColorTexture(0.1, 0.1, 0.1);
102 f.text = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
103 f.text:SetPoint("LEFT", f.health, "LEFT", 10, 0);
104 f.text:SetFont(STANDARD_TEXT_FONT, 13);
106 f.targeticon = f:CreateTexture(nil, "OVERLAY");
107 f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1);
108 f.targeticon:SetWidth(12);
109 f.targeticon:SetHeight(12);
110 f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
114 registerUnitEvents(f);
115 event(f, "UPDATE_ALL_BARS");
120 CFrame:SetScript("OnEvent", function(self)
121 self:UnregisterAllEvents();
122 CFrame:SetFrameStrata("LOW");
123 CFrame:SetPoint("CENTER", nil, "CENTER");
126 initPlayer(self, 180, 100, addon.FrameUpdate, addon.UnitEvent);
128 CFrame:RegisterEvent("PLAYER_LOGIN");