fdbd89d - Refactor OmaUF for more flexible frames
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Fri, 2 Feb 2018 01:38:19 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Fri, 2 Feb 2018 01:38:19 +0000
OmaUF/Auras.lua
OmaUF/Events.lua
OmaUF/OmaUF.toc
OmaUF/PlayerFrame.lua [new file with mode: 0644]
OmaUF/Settings.lua
OmaUF/TargetFrame.lua [new file with mode: 0644]
OmaUF/UnitFrames.lua

index 3af6ac5..499bd77 100644 (file)
@@ -77,7 +77,6 @@ end
 
 function M.UpdateAuras(frame, unit)
     local auras = frame.auras;
-    if not auras then return end
     for _, aura in ipairs(auras) do
         if not aura:IsShown() then break end
         aura:Hide();
index cbc8b0a..fa8965a 100644 (file)
@@ -1,12 +1,10 @@
 -- Events.lua
--- TODO -- recheck these, pvp functions not added yet
 local _;
 local unpack = unpack;
 local ssub = string.sub;
 local min = math.min;
 local ceil = math.ceil;
 local UnitName, UnitClass, UnitExists = UnitName, UnitClass, UnitExists;
-local UnitDebuff, UnitIsCharmed, UnitIsFriend = UnitDebuff, UnitIsCharmed, UnitIsFriend;
 local UnitPower, UnitPowerMax, UnitPowerType = UnitPower, UnitPowerMax, UnitPowerType;
 local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax;
 local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetTotalAbsorbs;
@@ -14,8 +12,14 @@ local UnitThreatSituation, GetThreatStatusColor = UnitThreatSituation, GetThreat
 local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected;
 local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs;
 local UnitHasVehicleUI, UnitTargetsVehicleInRaidUI = UnitHasVehicleUI, UnitTargetsVehicleInRaidUI;
-local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
 local UnitLevel, UnitClassification = UnitLevel, UnitClassification;
+local UnitAffectingCombat, IsResting = UnitAffectingCombat, IsResting;
+local UnitIsPVPFreeForAll, UnitIsPVP = UnitIsPVPFreeForAll, UnitIsPVP;
+local UnitFactionGroup, UnitIsMercenary = UnitFactionGroup, UnitIsMercenary;
+local UnitIsGroupLeader, UnitIsGroupAssistant = UnitIsGroupLeader, UnitIsGroupAssistant;
+local HasLFGRestrictions = HasLFGRestrictions;
+local UnitPlayerControlled, UnitIsPlayer = UnitPlayerControlled, UnitIsPlayer;
+local UnitIsTapDenied, UnitSelectionColor = UnitIsTapDenied, UnitSelectionColor;
 local RAID_CLASS_COLORS = RAID_CLASS_COLORS;
 
 local updateAuraFrames = OmaUFAuras.UpdateAuras;
@@ -27,7 +31,7 @@ local powerColors = Settings.PowerColors;
 
 local M = {};
 OmaUFEvents = M;
-function M.RegisterEvents(frame)
+function M.RegisterUnitEvents(frame)
     -- events are taken from FrameXML/CompactUnitFrame.lua
     -- TODO raid marker support,
     -- player flags support (/afk, /dnd)
@@ -49,42 +53,34 @@ function M.RegisterEvents(frame)
     frame:RegisterUnitEvent("UNIT_CONNECTION", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_FACTION", frame.unit, displayed);
 end
-local registerEvents = M.RegisterEvents;
+local registerUnitEvents = M.RegisterUnitEvents;
+
+local function updateMaxHealth(frame, unit)
+    frame.health.max = UnitHealthMax(unit);
+end
 
 local function updateHealth(frame, unit)
     local current, max = UnitHealth(unit), frame.health.max;
-    frame.health:Show();
-    -- sanity check, occasionally UnitHealthMax gives zero
-    if current > max then
+    if current > max or max <= 0 then
         -- somehow current health has gone over the maximum (missed maxhealth event)
-        frame.health.max = UnitHealthMax(unit);
-        max = frame.health.max;
-        if current > max then
-            -- error state, still over maximum
-            frame.health:SetWidth(frame.width);
-            return;
-        end
-    elseif max > 0 then
-        frame.health:SetWidth(current/frame.health.max*frame.width);
-    else
         frame.health:SetWidth(frame.width);
-        return;
-    end
-
-    if UnitIsDeadOrGhost(unit) then
+        updateMaxHealth(frame, unit);
+        frame.health:Show();
+    elseif current <= 0 or UnitIsDeadOrGhost(unit) then
         frame.health:Hide();
+    else
+        frame.health:SetWidth(current/max*frame.width);
+        frame.health:Show();
     end
 end
 
 local function updateHealthText(frame, unit)
-    local current, max = UnitHealth(unit), frame.health.max;
     if UnitIsDeadOrGhost(unit) then
         frame.healthText:SetText("Dead");
-        frame.healthText:Show();
     elseif not UnitIsConnected(unit) then
         frame.healthText:SetText("DC");
-        frame.healthText:Show();
-    elseif max > 0 then
+    else
+        local current = UnitHealth(unit);
         if current > 1200000000 then -- 1.2B
             frame.healthText:SetFormattedText("%.1fB", current / 1000000000);
         elseif current > 1200000 then -- 1.2M
@@ -94,37 +90,23 @@ local function updateHealthText(frame, unit)
         else
             frame.healthText:SetFormattedText("%d", current)
         end
-        frame.healthText:Show();
-    else
-        frame.healthText:Hide();
     end
 end
 
-local function updateMaxHealth(frame, unit)
-    frame.health.max = UnitHealthMax(unit);
+local function updateMaxPower(frame, unit)
+    frame.mana.max = UnitPowerMax(unit);
 end
 
 local function updatePower(frame, unit)
     local current, max = UnitPower(unit), frame.mana.max;
-    -- sanity check, occasionally UnitPowerMax gives zero
-    if current == 0 then
+    if current <= 0 then
         frame.mana:Hide();
-        return;
-    elseif current > max then
-        frame.mana:Show();
-        frame.mana.max = UnitPowerMax(unit);
-        max = frame.mana.max;
-        if current > max then
-            -- error
-            frame.mana:SetWidth(frame.width);
-            return;
-        end
-    end
-    if max > 0 then
-        frame.mana:SetWidth(UnitPower(unit)/max*frame.width);
+    elseif current > max or max <= 0 then
+        frame.mana:SetWidth(frame.width);
+        updateMaxPower(frame, unit);
         frame.mana:Show();
     else
-        frame.mana:SetWidth(frame.width);
+        frame.mana:SetWidth(current/max*frame.width);
         frame.mana:Show();
     end
 end
@@ -132,7 +114,7 @@ end
 local function updatePowerText(frame, unit)
     local current, max = UnitPower(unit), frame.mana.max;
     if UnitIsDeadOrGhost(unit) or not UnitIsConnected(unit) then
-        frame.healthText:Hide();
+        frame.manaText:Hide();
     elseif max > 0 and current > 0 and current < max then
         frame.manaText:SetText(ceil(current/max*100));
         frame.manaText:Show();
@@ -141,16 +123,11 @@ local function updatePowerText(frame, unit)
     end
 end
 
-local function updateMaxPower(frame, unit)
-    frame.mana.max = UnitPowerMax(unit);
-end
-
 local function updatePowerColor(frame, unit)
     frame.mana:SetVertexColor(unpack(powerColors[UnitPowerType(unit)]));
 end
 
 local function updateName(frame, unit)
-    if not frame.name then return end
     local name = UnitName(unit);
     if not name then return end
     frame.name:SetText(ssub(name, 1, 10));
@@ -159,10 +136,9 @@ end
 local function updateHealPred(frame, unit)
     local incoming = UnitGetIncomingHeals(unit) or 0;
     if incoming > 0 then
-        local max = frame.health.max;
         local space = frame.width - frame.health:GetWidth() + 1;
-        local pred = (incoming / max) * frame.width;
-        frame.healpred:SetWidth(min(space, pred));
+        incoming = (incoming / frame.health.max) * frame.width;
+        frame.healpred:SetWidth(min(space, incoming));
         frame.healpred:Show();
     else
         frame.healpred:Hide();
@@ -172,9 +148,8 @@ end
 local function updateShield(frame, unit)
     local shield = UnitGetTotalAbsorbs(unit) or 0;
     if shield > 0 then
-        local max = frame.health.max;
         local space = frame.width - frame.health:GetWidth();
-        shield = (shield / max) * frame.width;
+        shield = (shield / frame.health.max) * frame.width;
         if space == 0 then
             frame.shield:Hide();
             frame.shieldhl:Show();
@@ -196,9 +171,8 @@ end
 local function updateHealAbsorb(frame, unit)
     local absorb = UnitGetTotalHealAbsorbs(unit) or 0;
     if absorb > 0 then
-        local max = frame.health.max;
         local space = frame.health:GetWidth();
-        absorb = (absorb / max) * frame.width;
+        absorb = (absorb / frame.health.max) * frame.width;
         frame.healabsorb:SetWidth(min(space, absorb));
         frame.healabsorb:Show();
     else
@@ -207,7 +181,7 @@ local function updateHealAbsorb(frame, unit)
 end
 
 local function updateAuras(frame, unit)
-    updateAuraFrames(frame, unit);
+    if frame.auras then updateAuraFrames(frame, unit) end
 end
 
 local function updateAggro(frame, unit)
@@ -220,32 +194,22 @@ local function updateAggro(frame, unit)
 end
 
 local function updateVehicle(frame)
-    local shouldTargetVehicle = UnitHasVehicleUI(frame.unit) and UnitTargetsVehicleInRaidUI(frame.unit) and UnitExists(frame.vehicle);
+    local shouldTargetVehicle = UnitHasVehicleUI(frame.unit) and
+        UnitTargetsVehicleInRaidUI(frame.unit) and UnitExists(frame.vehicle);
     if shouldTargetVehicle then
         if not frame.inVehicle then
             frame.inVehicle = true;
             frame.displayed = frame.vehicle;
-            registerEvents(frame);
+            registerUnitEvents(frame);
         end
     elseif frame.inVehicle then
         frame.inVehicle = false;
         frame.displayed = frame.unit;
-        registerEvents(frame);
-    end
-end
-
-local function updateRole(frame, unit)
-    local role = UnitGroupRolesAssigned(unit);
-    if role == "HEALER" or role == "TANK" or role == "DAMAGER" then
-        frame.role:SetTexCoord(GetTexCoordsForRoleSmallCircle(role));
-        frame.role:Show();
-    else
-        frame.role:Hide();
+        registerUnitEvents(frame);
     end
 end
 
 local function updateLevelText(frame, unit, levelup)
-    if not frame.level then return end
     if levelup then
         -- PLAYER_LEVEL_UP
         frame.level:SetText(levelup);
@@ -276,7 +240,7 @@ local function updateLevelText(frame, unit, levelup)
 end
 
 local function updateStatus(frame, unit)
-    -- coords from PlayerFrame
+    -- coords from FrameXML/PlayerFrame.lua
     if frame.inCombat or UnitAffectingCombat(unit) then
         frame.status:SetTexCoord(0.5, 1, 0, 0.484375);
         frame.status:Show();
@@ -295,7 +259,7 @@ local function updatePVP(frame, unit)
     elseif UnitIsPVP(unit) then
         local faction = UnitFactionGroup(unit);
         if faction and faction ~= "Neutral" then
-            -- from PlayerFrame, mercenary checks
+            -- from FrameXML/PlayerFrame.lua, mercenary checks
             if UnitIsMercenary(unit) then
                 if faction == "Horde" then
                     faction = "Alliance";
@@ -356,7 +320,6 @@ local eventFuncs = {
         updateHealthText(frame, frame.displayed);
         updateShield(frame, frame.displayed);
         updateHealAbsorb(frame, frame.displayed);
-        -- no heal prediction update, that doesn't overflow too much
     end,
     ["UNIT_POWER"] = function(frame)
         updatePower(frame, frame.displayed);
@@ -396,42 +359,41 @@ local eventFuncs = {
         updatePowerText(frame, frame.displayed);
     end,
     ["UNIT_NAME_UPDATE"] = function(frame)
-        updateName(frame, frame.displayed);
+        if frame.name then updateName(frame, frame.displayed) end
         updateHealthColor(frame, frame.displayed);
     end,
     ["UNIT_CONNECTION"] = function(frame)
         updateHealthText(frame, frame.displayed);
         updatePowerText(frame, frame.displayed);
     end,
-    ["PLAYER_ROLES_ASSIGNED"] = function(frame)
-        updateRole(frame, frame.unit);
-    end,
     ["UNIT_LEVEL"] = function(frame)
+        -- if this is registered, frame has frame.level
         updateLevelText(frame, frame.unit);
     end,
     ["PLAYER_LEVEL_UP"] = function(frame, arg1)
         updateLevelText(frame, frame.unit, arg1);
     end,
     ["PLAYER_UPDATE_RESTING"] = function(frame)
+        -- player frame has frame.status
         updateStatus(frame, frame.unit);
     end,
     ["PLAYER_REGEN_DISABLED"] = function(frame)
         frame.inCombat = true;
-        updateStatus(frame, frame.unit);
+        if frame.status then updateStatus(frame, frame.unit) end
     end,
     ["PLAYER_REGEN_ENABLED"] = function(frame)
         frame.inCombat = false;
-        updateStatus(frame, frame.unit);
+        if frame.status then updateStatus(frame, frame.unit) end
     end,
     ["UNIT_FACTION"] = function(frame)
-        updatePVP(frame, frame.unit);
+        if frame.pvp then updatePVP(frame, frame.unit) end
         updateHealthColor(frame, frame.displayed);
     end,
     ["PARTY_LEADER_CHANGED"] = function(frame)
         updateLeaderIcon(frame, frame.unit);
     end,
     ["UPDATE_ALL_BARS"] = function(frame)
-        updateVehicle(frame);
+        if frame.vehicle then updateVehicle(frame) end
         updateMaxHealth(frame, frame.displayed);
         updateMaxPower(frame, frame.displayed);
         updateHealth(frame, frame.displayed);
@@ -444,12 +406,11 @@ local eventFuncs = {
         updateHealAbsorb(frame, frame.displayed);
         updatePowerColor(frame, frame.displayed);
         updateAggro(frame, frame.displayed);
-        updateName(frame, frame.displayed);
-        updateRole(frame, frame.unit);
-        updateLevelText(frame, frame.unit);
-        updateStatus(frame, frame.unit);
-        updatePVP(frame, frame.unit);
-        updateLeaderIcon(frame, frame.unit);
+        if frame.name then updateName(frame, frame.displayed) end
+        if frame.level then updateLevelText(frame, frame.unit) end
+        if frame.status then updateStatus(frame, frame.unit) end
+        if frame.pvp then updatePVP(frame, frame.unit) end
+        if frame.leader then updateLeaderIcon(frame, frame.unit) end
         updateHealthColor(frame, frame.displayed);
     end,
 };
index 15facee..62573bf 100644 (file)
@@ -8,3 +8,5 @@ Settings.lua
 Auras.lua
 Events.lua
 UnitFrames.lua
+PlayerFrame.lua
+TargetFrame.lua
diff --git a/OmaUF/PlayerFrame.lua b/OmaUF/PlayerFrame.lua
new file mode 100644 (file)
index 0000000..25d361e
--- /dev/null
@@ -0,0 +1,161 @@
+-- PlayerFrame.lua
+local _;
+local unpack, pairs = unpack, pairs;
+local format = string.format;
+local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch;
+local STANDARD_TEXT_FONT = STANDARD_TEXT_FONT;
+local GameTooltip = nil;
+local GameTooltip_SetDefaultAnchor = nil;
+
+local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
+local unitEvent = OmaUFEvents.UnitEvent;
+local createAuraFrame = OmaUFAuras.CreateAuraFrame;
+
+local Settings = OmaUFSettings;
+local baseColor = Settings.BaseColor;
+local bgColor = Settings.BgColor;
+local healthColor = Settings.HealthColor;
+local shieldColor = Settings.ShieldColor;
+local shieldhlColor = Settings.ShieldhlColor;
+local healpredColor = Settings.HealpredColor;
+local healabsorbColor = Settings.HealabsorbColor;
+local width, height = Settings.Player.Width, Settings.Player.Height;
+local anchorX, anchorY = Settings.Player.AnchorX, Settings.Player.AnchorY;
+-- placeholders with visible values when error happens
+local attributes = {};
+
+local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate";
+
+local function frameShow(frame)
+    frame:RegisterEvent("UNIT_ENTERED_VEHICLE");
+    frame:RegisterEvent("UNIT_EXITED_VEHICLE");
+    frame:RegisterEvent("UNIT_PET"); -- TODO needed?
+    frame:RegisterEvent("PLAYER_ENTERING_WORLD");
+    frame:RegisterEvent("PLAYER_LEVEL_UP");
+    frame:RegisterEvent("PLAYER_REGEN_DISABLED");
+    frame:RegisterEvent("PLAYER_REGEN_ENABLED");
+    frame:RegisterEvent("PLAYER_UPDATE_RESTING");
+    frame:RegisterEvent("PARTY_LEADER_CHANGED");
+    registerUnitEvents(frame);
+    unitEvent(frame, "UPDATE_ALL_BARS");
+end
+
+local function frameHide(frame)
+    frame:UnregisterAllEvents();
+end
+
+local function showTooltip(secure)
+    GameTooltip_SetDefaultAnchor(GameTooltip, secure);
+    GameTooltip:SetUnit(secure:GetAttribute("unit"));
+end
+
+local function hideTooltip(secure)
+    GameTooltip:FadeOut();
+end
+
+function OmaUnitFrames.InitializePlayer(parent)
+    GameTooltip = _G["GameTooltip"];
+    GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
+    attributes = Settings.Character.Clickheal;
+
+    local secure = CreateFrame("Button", "OmaPlayerSecure", parent, inheritedFrames);
+    local frame = CreateFrame("Frame", "OmaPlayer", parent);
+    local unit = "player";
+    secure:SetPoint("CENTER", parent, "CENTER", anchorX, anchorY);
+    secure:SetAttribute("unit", unit);
+    frame:SetPoint("CENTER", parent, "CENTER", anchorX, anchorY);
+    frame:SetAttribute("unit", unit);
+    frame.unit = unit;
+    frame.displayed = unit;
+    frame.vehicle = "vehicle";
+    -- hide frame to get initial frameShow call
+    frame:Hide();
+    -- create visuals
+    secure:SetWidth(width+2);
+    secure:SetHeight(height+2);
+    frame:SetWidth(width+2);
+    frame:SetHeight(height+2);
+    frame.width = width;
+    frame.base = frame:CreateTexture(nil, "BACKGROUND");
+    frame.base:SetAllPoints();
+    frame.base:SetColorTexture(1, 1, 1);
+    frame.base:SetVertexColor(unpack(baseColor));
+    frame.healthback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
+    frame.healthback:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -1);
+    frame.healthback:SetPoint("BOTTOMRIGHT", frame, "RIGHT", -1, -5);
+    frame.healthback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.healthback:SetVertexColor(unpack(bgColor));
+    frame.health = frame:CreateTexture(nil, "BORDER");
+    frame.health:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT");
+    frame.health:SetPoint("BOTTOMLEFT", frame.healthback, "BOTTOMLEFT");
+    frame.health:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.health:SetVertexColor(unpack(healthColor));
+    frame.healthText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge");
+    frame.healthText:SetPoint("RIGHT", frame.healthback, "RIGHT", -2, 0);
+    frame.manaback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
+    frame.manaback:SetPoint("TOPLEFT", frame, "LEFT", 1, -5);
+    frame.manaback:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
+    frame.manaback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.manaback:SetVertexColor(unpack(bgColor));
+    frame.mana = frame:CreateTexture(nil, "BORDER");
+    frame.mana:SetPoint("TOPLEFT", frame.manaback, "TOPLEFT");
+    frame.mana:SetPoint("BOTTOMLEFT", frame.manaback, "BOTTOMLEFT");
+    frame.mana:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.manaText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
+    frame.manaText:SetPoint("RIGHT", frame.manaback, "RIGHT", -2, 0);
+    frame.manaText:Hide();
+    frame.shield = frame:CreateTexture(nil, "BORDER");
+    frame.shield:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
+    frame.shield:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
+    frame.shield:SetTexture("Interface\\RaidFrame\\Shield-Fill");
+    frame.shield:SetVertexColor(unpack(shieldColor));
+    frame.shield:Hide();
+    frame.shieldhl = frame:CreateTexture(nil, "ARTWORK");
+    frame.shieldhl:SetPoint("TOPLEFT", frame.healthback, "TOPRIGHT", -1, 0);
+    frame.shieldhl:SetPoint("BOTTOMRIGHT", frame.healthback, "BOTTOMRIGHT", 1, 0);
+    frame.shieldhl:SetColorTexture(unpack(shieldhlColor));
+    frame.shieldhl:Hide();
+    frame.healpred = frame:CreateTexture(nil, "ARTWORK");
+    frame.healpred:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
+    frame.healpred:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
+    frame.healpred:SetColorTexture(unpack(healpredColor));
+    frame.healpred:Hide();
+    frame.healabsorb = frame:CreateTexture(nil, "ARTWORK");
+    frame.healabsorb:SetPoint("TOPRIGHT", frame.health, "TOPRIGHT");
+    frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT");
+    frame.healabsorb:SetColorTexture(unpack(healabsorbColor));
+    frame.healabsorb:Hide();
+    frame.status = frame:CreateTexture(nil, "OVERLAY");
+    frame.status:SetPoint("TOPLEFT", frame.manaback, "BOTTOMLEFT", -8, 8);
+    frame.status:SetPoint("BOTTOMRIGHT", frame.manaback, "BOTTOMLEFT", 8, -8);
+    frame.status:SetTexture("Interface\\CHARACTERFRAME\\UI-StateIcon");
+    frame.status:Hide();
+    frame.pvp = frame:CreateTexture(nil, "OVERLAY");
+    frame.pvp:SetPoint("TOPLEFT", frame.manaback, "BOTTOMLEFT", 8, 6);
+    frame.pvp:SetPoint("BOTTOMRIGHT", frame.manaback, "BOTTOMLEFT", 32, -18);
+    frame.pvp:SetTexture("Interface\\TARGETINGFRAME\\UI-PVP-Horde");
+    frame.pvp:Hide();
+    frame.leader = frame:CreateTexture(nil, "OVERLAY");
+    frame.leader:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT", -6, 6);
+    frame.leader:SetPoint("BOTTOMRIGHT", frame.healthback, "TOPLEFT", 6, -6);
+    frame.leader:Hide();
+    frame.level = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
+    frame.level:SetPoint("LEFT", frame.manaback, "LEFT", 2, 1);
+    -- set scripts
+    frame:SetScript("OnShow", frameShow);
+    frame:SetScript("OnHide", frameHide);
+    frame:SetScript("OnEvent", unitEvent);
+    secure:SetScript("OnEnter", showTooltip);
+    secure:SetScript("OnLeave", hideTooltip);
+    -- set attributes
+    secure:RegisterForClicks("AnyDown");
+    for attr, val in pairs(attributes) do
+        secure:SetAttribute(attr, val);
+    end
+    -- rest give target and menu
+    secure:SetAttribute("*type1", "target");
+    secure:SetAttribute("*type2", "togglemenu");
+    RegisterUnitWatch(frame);
+    RegisterUnitWatch(secure);
+    return frame;
+end
index 836835c..8b3e67e 100644 (file)
@@ -17,8 +17,6 @@ local charDefaults = {
 local chars = {
     ["Stormreaver"] = {
         ["Vildan"] = {
-            AnchorX = 0,
-            AnchorY = -330,
             Clickheal = {
                 ["type1"] = "spell",
                 ["type2"] = "spell",
@@ -39,8 +37,6 @@ local chars = {
             },
         },
         ["Gedren"] = {
-            AnchorX = 0,
-            AnchorY = -330,
             Clickheal = {
                 ["type1"] = "spell",
                 ["type2"] = "spell",
@@ -61,8 +57,30 @@ local chars = {
 
 -- account-wide settings
 local settings = {
-    Width = 160,
-    Height = 50,
+    Player = {
+        Width = 160,
+        Height = 50,
+        AnchorX = -300,
+        AnchorY = -175,
+    },
+    Pet = {
+        Width = 80,
+        Height = 25,
+        AnchorX = -10,
+        AnchorY = 0,
+    },
+    Target = {
+        Width = 160,
+        Height = 50,
+        AnchorX = 300,
+        AnchorY = -175,
+    },
+    ToT = {
+        Width = 80,
+        Height = 25,
+        AnchorX = 10,
+        AnchorY = 0,
+    },
     BaseColor = {0, 0, 0, 0.5},
     BgColor = {0.1, 0.1, 0.1, 0.4},
     HealthColor = {0.5, 0.5, 0.5},
diff --git a/OmaUF/TargetFrame.lua b/OmaUF/TargetFrame.lua
new file mode 100644 (file)
index 0000000..c88519d
--- /dev/null
@@ -0,0 +1,163 @@
+-- TargetFrame.lua
+local _;
+local unpack, pairs = unpack, pairs;
+local format = string.format;
+local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch;
+local STANDARD_TEXT_FONT = STANDARD_TEXT_FONT;
+local GameTooltip = nil;
+local GameTooltip_SetDefaultAnchor = nil;
+
+local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
+local unitEvent = OmaUFEvents.UnitEvent;
+local createAuraFrame = OmaUFAuras.CreateAuraFrame;
+
+local Settings = OmaUFSettings;
+local baseColor = Settings.BaseColor;
+local bgColor = Settings.BgColor;
+local healthColor = Settings.HealthColor;
+local shieldColor = Settings.ShieldColor;
+local shieldhlColor = Settings.ShieldhlColor;
+local healpredColor = Settings.HealpredColor;
+local healabsorbColor = Settings.HealabsorbColor;
+local width, height = Settings.Target.Width, Settings.Target.Height;
+local anchorX, anchorY = Settings.Target.AnchorX, Settings.Target.AnchorY;
+-- placeholders with visible values when error happens
+local attributes = {};
+
+local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate";
+
+local function frameShow(frame)
+    frame:RegisterEvent("UNIT_ENTERED_VEHICLE");
+    frame:RegisterEvent("UNIT_EXITED_VEHICLE");
+    frame:RegisterEvent("UNIT_PET");
+    frame:RegisterEvent("GROUP_ROSTER_UPDATE"); -- TODO needed? won't be having group number in frames
+    frame:RegisterEvent("PLAYER_ENTERING_WORLD");
+    frame:RegisterEvent("PLAYER_TARGET_CHANGED");
+    frame:RegisterEvent("PARTY_LEADER_CHANGED");
+    frame:RegisterUnitEvent("UNIT_LEVEL", frame.unit);
+    registerUnitEvents(frame);
+    unitEvent(frame, "UPDATE_ALL_BARS");
+end
+
+local function frameHide(frame)
+    frame:UnregisterAllEvents();
+end
+
+local function showTooltip(secure)
+    GameTooltip_SetDefaultAnchor(GameTooltip, secure);
+    GameTooltip:SetUnit(secure:GetAttribute("unit"));
+end
+
+local function hideTooltip(secure)
+    GameTooltip:FadeOut();
+end
+
+function OmaUnitFrames.InitializeTarget(parent)
+    GameTooltip = _G["GameTooltip"];
+    GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
+    attributes = Settings.Character.Clickheal;
+
+    local secure = CreateFrame("Button", "OmaTargetSecure", parent, inheritedFrames);
+    local frame = CreateFrame("Frame", "OmaTarget", parent);
+    local unit = "target";
+    secure:SetPoint("CENTER", parent, "CENTER", anchorX, anchorY);
+    secure:SetAttribute("unit", unit);
+    frame:SetPoint("CENTER", parent, "CENTER", anchorX, anchorY);
+    frame:SetAttribute("unit", unit);
+    frame.unit = unit;
+    frame.displayed = unit;
+    --frame.vehicle = unit.."pet"; -- TODO nothing extra needed for target vehicles?
+    -- hide frame to get initial frameShow call
+    frame:Hide();
+    -- create visuals
+    secure:SetWidth(width+2);
+    secure:SetHeight(height+2);
+    frame:SetWidth(width+2);
+    frame:SetHeight(height+2);
+    frame.width = width;
+    frame.base = frame:CreateTexture(nil, "BACKGROUND");
+    frame.base:SetAllPoints();
+    frame.base:SetColorTexture(1, 1, 1);
+    frame.base:SetVertexColor(unpack(baseColor));
+    frame.healthback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
+    frame.healthback:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -1);
+    frame.healthback:SetPoint("BOTTOMRIGHT", frame, "RIGHT", -1, -5);
+    frame.healthback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.healthback:SetVertexColor(unpack(bgColor));
+    frame.health = frame:CreateTexture(nil, "BORDER");
+    frame.health:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT");
+    frame.health:SetPoint("BOTTOMLEFT", frame.healthback, "BOTTOMLEFT");
+    frame.health:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.health:SetVertexColor(unpack(healthColor));
+    frame.healthText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge");
+    frame.healthText:SetPoint("RIGHT", frame.healthback, "RIGHT", -2, 0);
+    frame.manaback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
+    frame.manaback:SetPoint("TOPLEFT", frame, "LEFT", 1, -5);
+    frame.manaback:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
+    frame.manaback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.manaback:SetVertexColor(unpack(bgColor));
+    frame.mana = frame:CreateTexture(nil, "BORDER");
+    frame.mana:SetPoint("TOPLEFT", frame.manaback, "TOPLEFT");
+    frame.mana:SetPoint("BOTTOMLEFT", frame.manaback, "BOTTOMLEFT");
+    frame.mana:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+    frame.manaText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
+    frame.manaText:SetPoint("RIGHT", frame.manaback, "RIGHT", -2, 0);
+    frame.manaText:Hide();
+    frame.shield = frame:CreateTexture(nil, "BORDER");
+    frame.shield:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
+    frame.shield:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
+    frame.shield:SetTexture("Interface\\RaidFrame\\Shield-Fill");
+    frame.shield:SetVertexColor(unpack(shieldColor));
+    frame.shield:Hide();
+    frame.shieldhl = frame:CreateTexture(nil, "ARTWORK");
+    frame.shieldhl:SetPoint("TOPLEFT", frame.healthback, "TOPRIGHT", -1, 0);
+    frame.shieldhl:SetPoint("BOTTOMRIGHT", frame.healthback, "BOTTOMRIGHT", 1, 0);
+    frame.shieldhl:SetColorTexture(unpack(shieldhlColor));
+    frame.shieldhl:Hide();
+    frame.healpred = frame:CreateTexture(nil, "ARTWORK");
+    frame.healpred:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
+    frame.healpred:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
+    frame.healpred:SetColorTexture(unpack(healpredColor));
+    frame.healpred:Hide();
+    frame.healabsorb = frame:CreateTexture(nil, "ARTWORK");
+    frame.healabsorb:SetPoint("TOPRIGHT", frame.health, "TOPRIGHT");
+    frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT");
+    frame.healabsorb:SetColorTexture(unpack(healabsorbColor));
+    frame.healabsorb:Hide();
+    frame.status = frame:CreateTexture(nil, "OVERLAY");
+    frame.status:SetPoint("TOPLEFT", frame.manaback, "BOTTOMLEFT", -8, 8);
+    frame.status:SetPoint("BOTTOMRIGHT", frame.manaback, "BOTTOMLEFT", 8, -8);
+    frame.status:SetTexture("Interface\\CHARACTERFRAME\\UI-StateIcon");
+    frame.status:Hide();
+    frame.pvp = frame:CreateTexture(nil, "OVERLAY");
+    frame.pvp:SetPoint("TOPLEFT", frame.manaback, "BOTTOMLEFT", 8, 6);
+    frame.pvp:SetPoint("BOTTOMRIGHT", frame.manaback, "BOTTOMLEFT", 32, -18);
+    frame.pvp:SetTexture("Interface\\TARGETINGFRAME\\UI-PVP-Horde");
+    frame.pvp:Hide();
+    frame.leader = frame:CreateTexture(nil, "OVERLAY");
+    frame.leader:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT", -6, 6);
+    frame.leader:SetPoint("BOTTOMRIGHT", frame.healthback, "TOPLEFT", 6, -6);
+    frame.leader:Hide();
+    frame.name = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge");
+    frame.name:SetPoint("LEFT", frame.healthback, "LEFT", 2, 1);
+    frame.level = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
+    frame.level:SetPoint("LEFT", frame.manaback, "LEFT", 2, 1);
+    -- set scripts
+    frame:SetScript("OnShow", frameShow);
+    frame:SetScript("OnHide", frameHide);
+    frame:SetScript("OnEvent", unitEvent);
+    secure:SetScript("OnEnter", showTooltip);
+    secure:SetScript("OnLeave", hideTooltip);
+    -- set attributes
+    secure:RegisterForClicks("AnyDown");
+    for attr, val in pairs(attributes) do
+        secure:SetAttribute(attr, val);
+    end
+    -- rest give target and menu
+    secure:SetAttribute("*type1", "target");
+    secure:SetAttribute("*type2", "togglemenu");
+    createAuraFrame(frame, unit);
+    RegisterUnitWatch(frame);
+    RegisterUnitWatch(secure);
+    return frame;
+end
index 2c338f0..0a812d4 100644 (file)
--- RaidFrame.lua
+-- UnitFrames.lua
 local _;
-local unpack, pairs = unpack, pairs;
-local format = string.format;
-local UnitHealthMax, UnitPowerMax = UnitHealthMax, UnitPowerMax;
-local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch;
-local STANDARD_TEXT_FONT = STANDARD_TEXT_FONT;
-local GameTooltip = nil;
-local GameTooltip_SetDefaultAnchor = nil;
-
-local registerEvents = OmaUFEvents.RegisterEvents;
-local unitEvent = OmaUFEvents.UnitEvent;
-local createAuraFrame = OmaUFAuras.CreateAuraFrame;
-
-local Settings = OmaUFSettings;
-local indSize = Settings.IndSize;
-local baseColor = Settings.BaseColor;
-local bgColor = Settings.BgColor;
-local healthColor = Settings.HealthColor;
-local shieldColor = Settings.ShieldColor;
-local shieldhlColor = Settings.ShieldhlColor;
-local healpredColor = Settings.HealpredColor;
-local healabsorbColor = Settings.HealabsorbColor;
-local width, height = Settings.Width, Settings.Height;
--- placeholders with visible values when error happens
-local anchorX, anchorY = 10, 10;
-local attributes = {};
+local pairs = pairs;
 
 local UnitFrames = CreateFrame("Frame", "OmaUnitFrames");
-local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate";
-
-local events = {
-    ["player"] = {
-        "UNIT_ENTERED_VEHICLE",
-        "UNIT_EXITED_VEHICLE",
-        "UNIT_PET",
-        "PLAYER_ROLES_ASSIGNED",
-        "PLAYER_ENTERING_WORLD",
-        "PLAYER_LEVEL_UP",
-        "PLAYER_REGEN_DISABLED",
-        "PLAYER_REGEN_ENABLED",
-        "PLAYER_UPDATE_RESTING",
-    },
-    ["target"] = {
-        "UNIT_ENTERED_VEHICLE",
-        "UNIT_EXITED_VEHICLE",
-        "UNIT_PET",
-        "UNIT_LEVEL",
-        "GROUP_ROSTER_UPDATE",
-        "PLAYER_ROLES_ASSIGNED",
-        "PLAYER_ENTERING_WORLD",
-        "PLAYER_TARGET_CHANGED",
-    },
-    ["pet"] = {
-        "UNIT_ENTERED_VEHICLE",
-        "UNIT_EXITED_VEHICLE",
-        "UNIT_PET",
-        "PLAYER_ENTERING_WORLD",
-        "PLAYER_LEVEL_UP",
-        "PLAYER_REGEN_DISABLED",
-        "PLAYER_REGEN_ENABLED",
-    },
-};
 
 local M = {};
 OmaUnitFrames = M;
 
-local function frameShow(frame)
-    for _, ev in pairs(events[frame.unit]) do
-        frame:RegisterEvent(ev);
-    end
-    registerEvents(frame);
-    unitEvent(frame, "UPDATE_ALL_BARS");
-end
-
-local function frameHide(frame)
-    frame:UnregisterAllEvents();
-end
-
-local function showTooltip(secure)
-    GameTooltip_SetDefaultAnchor(GameTooltip, secure);
-    GameTooltip:SetUnit(secure:GetAttribute("unit"));
-end
-
-local function hideTooltip(secure)
-    GameTooltip:FadeOut();
-end
-
-local function setupFrame(frame, secure, unit, width, height)
-    secure:SetAttribute("unit", unit);
-    frame:SetAttribute("unit", unit);
-    frame.unit = unit;
-    frame.displayed = unit;
-    -- hide frame to get initial frameShow call
-    frame:Hide();
-    if unit == "player" then
-        frame.vehicle = "vehicle";
-    else
-        frame.vehicle = unit.."pet";
-    end
-    -- create visuals
-    secure:SetWidth(width+2);
-    secure:SetHeight(height+2);
-    frame:SetWidth(width+2);
-    frame:SetHeight(height+2);
-    frame.width = width;
-    frame.base = frame:CreateTexture(nil, "BACKGROUND");
-    frame.base:SetAllPoints();
-    frame.base:SetColorTexture(1, 1, 1);
-    frame.base:SetVertexColor(unpack(baseColor));
-    frame.healthback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
-    frame.healthback:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -1);
-    frame.healthback:SetPoint("BOTTOMRIGHT", frame, "RIGHT", -1, -5);
-    frame.healthback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
-    frame.healthback:SetVertexColor(unpack(bgColor));
-    frame.health = frame:CreateTexture(nil, "BORDER");
-    frame.health:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
-    frame.health:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT");
-    frame.health:SetPoint("BOTTOMLEFT", frame.healthback, "BOTTOMLEFT");
-    frame.health:SetVertexColor(unpack(healthColor));
-    frame.health:SetWidth(width);
-    frame.health.max = UnitHealthMax(unit);
-    frame.healthText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge");
-    frame.healthText:SetPoint("RIGHT", frame.healthback, "RIGHT", -2, 0);
-    frame.healthText:Hide();
-    frame.manaback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
-    frame.manaback:SetPoint("TOPLEFT", frame, "LEFT", 1, -5);
-    frame.manaback:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
-    frame.manaback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
-    frame.manaback:SetVertexColor(unpack(bgColor));
-    frame.mana = frame:CreateTexture(nil, "BORDER");
-    frame.mana:SetPoint("TOPLEFT", frame.manaback, "TOPLEFT");
-    frame.mana:SetPoint("BOTTOMLEFT", frame.manaback, "BOTTOMLEFT");
-    frame.mana:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
-    frame.mana:SetWidth(width);
-    frame.mana.max = UnitPowerMax(unit);
-    frame.manaText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
-    frame.manaText:SetPoint("RIGHT", frame.manaback, "RIGHT", -2, 0);
-    frame.manaText:Hide();
-    frame.shield = frame:CreateTexture(nil, "BORDER");
-    frame.shield:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
-    frame.shield:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
-    frame.shield:SetTexture("Interface\\RaidFrame\\Shield-Fill");
-    frame.shield:SetVertexColor(unpack(shieldColor));
-    frame.shield:Hide();
-    frame.shieldhl = frame:CreateTexture(nil, "ARTWORK");
-    frame.shieldhl:SetPoint("TOPLEFT", frame.healthback, "TOPRIGHT", -1, 0);
-    frame.shieldhl:SetPoint("BOTTOMRIGHT", frame.healthback, "BOTTOMRIGHT", 1, 0);
-    frame.shieldhl:SetColorTexture(unpack(shieldhlColor));
-    frame.shieldhl:Hide();
-    frame.healpred = frame:CreateTexture(nil, "ARTWORK");
-    frame.healpred:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
-    frame.healpred:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
-    frame.healpred:SetColorTexture(unpack(healpredColor));
-    frame.healpred:Hide();
-    frame.healabsorb = frame:CreateTexture(nil, "ARTWORK");
-    frame.healabsorb:SetPoint("TOPRIGHT", frame.health, "TOPRIGHT");
-    frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT");
-    frame.healabsorb:SetColorTexture(unpack(healabsorbColor));
-    frame.healabsorb:Hide();
-    frame.role = frame:CreateTexture(nil, "OVERLAY");
-    frame.role:SetPoint("TOPLEFT", frame.healthback, "TOPRIGHT", -8, 8);
-    frame.role:SetPoint("BOTTOMRIGHT", frame.healthback, "TOPRIGHT", 8, -8);
-    frame.role:SetTexture("Interface\\LFGFRAME\\UI-LFG-ICON-PORTRAITROLES");
-    frame.role:Hide();
-    frame.status = frame:CreateTexture(nil, "OVERLAY");
-    frame.status:SetPoint("TOPLEFT", frame.manaback, "BOTTOMLEFT", -8, 8);
-    frame.status:SetPoint("BOTTOMRIGHT", frame.manaback, "BOTTOMLEFT", 8, -8);
-    frame.status:SetTexture("Interface\\CHARACTERFRAME\\UI-StateIcon");
-    frame.status:Hide();
-    frame.pvp = frame:CreateTexture(nil, "OVERLAY");
-    frame.pvp:SetPoint("TOPLEFT", frame.manaback, "BOTTOMLEFT", 8, 6);
-    frame.pvp:SetPoint("BOTTOMRIGHT", frame.manaback, "BOTTOMLEFT", 32, -18);
-    frame.pvp:SetTexture("Interface\\TARGETINGFRAME\\UI-PVP-Horde");
-    frame.pvp:Hide();
-    frame.leader = frame:CreateTexture(nil, "OVERLAY");
-    frame.leader:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT", -6, 6);
-    frame.leader:SetPoint("BOTTOMRIGHT", frame.healthback, "TOPLEFT", 6, -6);
-    frame.leader:Hide();
-    if unit ~= "pet" then
-        frame.name = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge");
-        frame.name:SetPoint("LEFT", frame.healthback, "LEFT", 2, 1);
-        frame.level = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
-        frame.level:SetPoint("LEFT", frame.manaback, "LEFT", 2, 1);
-    end
-    -- set scripts
-    frame:SetScript("OnShow", frameShow);
-    frame:SetScript("OnHide", frameHide);
-    frame:SetScript("OnEvent", unitEvent);
-    secure:SetScript("OnEnter", showTooltip);
-    secure:SetScript("OnLeave", hideTooltip);
-    -- set attributes
-    secure:RegisterForClicks("AnyDown");
-    for attr, val in pairs(attributes) do
-        secure:SetAttribute(attr, val);
-    end
-    -- rest give target and menu
-    secure:SetAttribute("*type1", "target");
-    secure:SetAttribute("*type2", "togglemenu");
-end
-
--- vehicle toggle from Shadowed Unit Frames
-local vehicletoggle = [=[
-    local unit = self:GetAttribute("unit");
-    if unit and newstate == "vehicle" and not UnitTargetsVehicleInRaidUI(unit) then
-        self:SetAttribute("toggleForVehicle", false);
-    else
-        self:SetAttribute("toggleForVehicle", true);
-    end
-]=]
-
-local function initializePlayer(parent)
-    local secure = CreateFrame("Button", "OmaPlayerSecure", parent, inheritedFrames);
-    local frame = CreateFrame("Frame", "OmaPlayer", parent);
-    local unit = "player";
-    secure:SetPoint("CENTER", parent, "CENTER", -300, -175);
-    frame:SetPoint("CENTER", parent, "CENTER", -300, -175);
-    setupFrame(frame, secure, unit, width, height);
-    RegisterUnitWatch(frame);
-    RegisterUnitWatch(secure);
-    --RegisterStateDriver(secure, "vehicleui", "[vehicleui] vehicle; no");
-    --secure:SetAttribute("_onstate-vehicleui", vehicletoggle);
-end
-
-local function initializePet(parent)
-    local secure = CreateFrame("Button", "OmaPetSecure", parent, inheritedFrames);
-    local frame = CreateFrame("Frame", "OmaPet", parent);
-    local unit = "pet";
-    secure:SetPoint("TOPRIGHT", parent, "TOPLEFT", -10, 0);
-    frame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -10, 0);
-    setupFrame(frame, secure, unit, width/2, height/2);
-    RegisterUnitWatch(frame);
-    RegisterUnitWatch(secure);
-end
-
-local function initializeTarget(parent)
-    local secure = CreateFrame("Button", "OmaTargetSecure", parent, inheritedFrames);
-    local frame = CreateFrame("Frame", "OmaTarget", parent);
-    local unit = "target";
-    secure:SetPoint("CENTER", parent, "CENTER", 300, -175);
-    frame:SetPoint("CENTER", parent, "CENTER", 300, -175);
-    setupFrame(frame, secure, unit, width, height);
-    createAuraFrame(frame, unit);
-    RegisterUnitWatch(frame);
-    RegisterUnitWatch(secure);
-end
-
-local function loadCharSettings()
-    anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY;
-    attributes = Settings.Character.Clickheal;
-end
-
 local function initialize()
-    loadCharSettings();
-    -- let other addons hook these to anchor tooltip elsewhere
-    GameTooltip = _G["GameTooltip"];
-    GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
-    initializePlayer(UIParent);
-    initializePet(_G["OmaPlayer"]);
-    initializeTarget(UIParent);
-    -- TODO boss frames, pet frame, (arena frames)
+    local player = M.InitializePlayer(UIParent);
+    --M.InitializePet(player);
+    local target = M.InitializeTarget(UIParent);
+    --M.InitializeToT(target);
+    -- TODO boss frames, (arena frames)
 end
 
 local hidden = false;