3ce4017 - Working player frame
[wowui.git] / kehys / player.lua
index ce390f5..89e15af 100644 (file)
@@ -3,8 +3,9 @@ local _, addon = ...;
 local unpack = unpack;
 local format = string.format;
 local CFrame = CreateFrame("Frame", "kehysPlayerInit", UIParent);
 local unpack = unpack;
 local format = string.format;
 local CFrame = CreateFrame("Frame", "kehysPlayerInit", UIParent);
+local CTimerAfter = C_Timer.After;
 
 
-local barTexture = "Interface\\AddOns\\OmaRF\\images\\minimalist";
+local barTexture = "Interface\\AddOns\\kehys\\images\\minimalist";
 local vehicletoggle = [=[
     if newstate == "vehicle" then
         self:SetAttribute("displayed", self:GetAttribute("vehicle"));
 local vehicletoggle = [=[
     if newstate == "vehicle" then
         self:SetAttribute("displayed", self:GetAttribute("vehicle"));
@@ -14,7 +15,7 @@ local vehicletoggle = [=[
 ]=]
 
 local updater = nil;
 ]=]
 
 local updater = nil;
-function addon.PlayerFrame(parent, width, height, update, event)
+local function initPlayer(parent, width, height, update, event)
     assert(type(parent) == "table", "Player frame creation missing parent!");
     assert(type(width) == "number", "Player frame creation missing width!");
     assert(type(height) == "number", "Player frame creation missing height!");
     assert(type(parent) == "table", "Player frame creation missing parent!");
     assert(type(width) == "number", "Player frame creation missing width!");
     assert(type(height) == "number", "Player frame creation missing height!");
@@ -26,28 +27,25 @@ function addon.PlayerFrame(parent, width, height, update, event)
     local f = CreateFrame("Button", "kehysPlayer", parent,
                           "SecureUnitButtonTemplate,SecureHandlerStateTemplate");
     f:Hide();
     local f = CreateFrame("Button", "kehysPlayer", parent,
                           "SecureUnitButtonTemplate,SecureHandlerStateTemplate");
     f:Hide();
-    f:SetPoint("CENTER", parent, "CENTER", 10, 10);
+    f:SetPoint("CENTER", parent, "CENTER", -300, -178);
     f:SetWidth(width);
     f:SetHeight(height);
     f.barwidth = width - 2; -- 1px padding
     f:SetAttribute("unit", "player");
     f:SetAttribute("displayed", "player");
     f:SetAttribute("vehicle", "vehicle");
     f:SetWidth(width);
     f:SetHeight(height);
     f.barwidth = width - 2; -- 1px padding
     f:SetAttribute("unit", "player");
     f:SetAttribute("displayed", "player");
     f:SetAttribute("vehicle", "vehicle");
+    f.unit = "player";
+    f.displayed = "player";
+    f.vehicle = "vehicle"
     f.nonraid = true;
     f.prev = {};
     f.nonraid = true;
     f.prev = {};
-    -- empty, just to be able to use general updater
-    f.alert = {};
-    f.heal = {};
-    f.tankcd = {};
-    f.stacks = {};
-    f.buff1 = {};
-    f.incoming = {};
 
     updater = function()
         CTimerAfter(0.1, updater);
         update(f);
     end
     f:SetScript("OnEvent", event);
 
     updater = function()
         CTimerAfter(0.1, updater);
         update(f);
     end
     f:SetScript("OnEvent", event);
+    f:RegisterForClicks("AnyDown");
     f:SetAttribute("*type1", "target");
     f:SetAttribute("*type2", "togglemenu");
     f:SetAttribute("toggleForVehicle", true);
     f:SetAttribute("*type1", "target");
     f:SetAttribute("*type2", "togglemenu");
     f:SetAttribute("toggleForVehicle", true);
@@ -57,26 +55,24 @@ function addon.PlayerFrame(parent, width, height, update, event)
     -- create visuals
     f.base = f:CreateTexture(nil, "BACKGROUND");
     f.base:SetAllPoints();
     -- create visuals
     f.base = f:CreateTexture(nil, "BACKGROUND");
     f.base:SetAllPoints();
-    f.base:SetColorTexture(1, 1, 1);
-    f.base:SetVertexColor(unpack(addon.Colors.Base));
-    f.background = f:CreateTexture(nil, "BACKGROUND", nil, 2);
+    f.base:SetColorTexture(0, 0, 0, 0.5);
+    f.background = f:CreateTexture(nil, "BACKGROUND", nil, 1);
     f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
     f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1);
     f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
     f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1);
-    f.background:SetColorTexture(0.7, 0.7, 0.7);
     f.health = f:CreateTexture(nil, "BORDER");
     f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT");
     f.health = f:CreateTexture(nil, "BORDER");
     f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT");
-    f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, 1);
+    f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, -height/8);
     f.health:SetTexture(barTexture);
     f.health:SetTexture(barTexture);
-    f.health:SetVertexColor(0.3, 0.3, 0.3);
+    f.health:SetVertexColor(0.8, 0.8, 0.8);
     f.health:Hide();
     f.mana = f:CreateTexture(nil, "BORDER");
     f.health:Hide();
     f.mana = f:CreateTexture(nil, "BORDER");
-    f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -1);
+    f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -height/8);
     f.mana:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT");
     f.mana:SetTexture(barTexture);
     f.mana:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT");
     f.mana:SetTexture(barTexture);
-    f.mana:SetVertexColor(0.3, 0.4, 0.7);
+    f.mana:SetVertexColor(0.1, 0.5, 0.9);
     f.mana:Hide();
     f.manatext = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
     f.mana:Hide();
     f.manatext = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
-    f.manatext:SetPoint("RIGHT", frame.background, "RIGHT", -2, -height/4);
+    f.manatext:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMRIGHT", -2, 4);
     f.manatext:Hide();
     f.shield = f:CreateTexture(nil, "BORDER");
     f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
     f.manatext:Hide();
     f.shield = f:CreateTexture(nil, "BORDER");
     f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
@@ -86,7 +82,7 @@ function addon.PlayerFrame(parent, width, height, update, event)
     f.shield:Hide();
     f.shieldhl = f:CreateTexture(nil, "ARTWORK");
     f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0);
     f.shield:Hide();
     f.shieldhl = f:CreateTexture(nil, "ARTWORK");
     f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0);
-    f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT");
+    f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT", 0, -height/8);
     f.shieldhl:SetColorTexture(0.5, 0.8, 1);
     f.shieldhl:Hide();
     f.healpred = f:CreateTexture(nil, "ARTWORK");
     f.shieldhl:SetColorTexture(0.5, 0.8, 1);
     f.shieldhl:Hide();
     f.healpred = f:CreateTexture(nil, "ARTWORK");
@@ -109,12 +105,17 @@ function addon.PlayerFrame(parent, width, height, update, event)
     f.targeticon:SetHeight(12);
     f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
     f.targeticon:Hide();
     f.targeticon:SetHeight(12);
     f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
     f.targeticon:Hide();
+    f.status = f:CreateTexture(nil, "OVERLAY");
+    f.status:SetPoint("TOPLEFT", f.background, "BOTTOMLEFT", -8, 8);
+    f.status:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMLEFT", 8, -8);
+    f.status:SetTexture("Interface\\CHARACTERFRAME\\UI-StateIcon");
+    f.status:Hide();
 
 
-    registerEvents(f);
-    registerUnitEvents(f);
+    addon.RegisterEvents(f);
+    addon.RegisterUnitEvents(f);
     event(f, "UPDATE_ALL_BARS");
     updater();
     event(f, "UPDATE_ALL_BARS");
     updater();
-    f.Show();
+    f:Show();
 end
 
 CFrame:SetScript("OnEvent", function(self)
 end
 
 CFrame:SetScript("OnEvent", function(self)
@@ -123,6 +124,6 @@ CFrame:SetScript("OnEvent", function(self)
     CFrame:SetPoint("CENTER", nil, "CENTER");
     CFrame:SetWidth(2);
     CFrame:SetHeight(2);
     CFrame:SetPoint("CENTER", nil, "CENTER");
     CFrame:SetWidth(2);
     CFrame:SetHeight(2);
-    initPlayer(self, 180, 100, addon.FrameUpdate, addon.UnitEvent);
+    initPlayer(self, 160, 48, addon.FrameUpdate, addon.UnitEvent);
 end);
 CFrame:RegisterEvent("PLAYER_LOGIN");
 end);
 CFrame:RegisterEvent("PLAYER_LOGIN");