c33600a - Reorganise hook scripts to single function/file
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Mon, 25 Dec 2017 14:54:22 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Mon, 25 Dec 2017 14:54:22 +0000
LayoutFramesHook.lua [new file with mode: 0644]
RaidFrameColors.lua
RaidFrameCustomization.toc
RaidFrameHealth.lua [deleted file]
RaidFrameIndicators.lua
RaidFrameNames.lua [deleted file]
RaidFramePowerBars.lua [deleted file]
UnitFrameSetupHook.lua [new file with mode: 0644]
UpdateNameHook.lua [new file with mode: 0644]
UpdateStatusTextHook.lua [new file with mode: 0644]

diff --git a/LayoutFramesHook.lua b/LayoutFramesHook.lua
new file mode 100644 (file)
index 0000000..411a069
--- /dev/null
@@ -0,0 +1,25 @@
+local normalBarColor = CreateColor(0.3, 0.3, 0.3);
+local normalBackColor = {0.7, 0.7, 0.7};
+local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
+local CompactUnitFrame_UpdateHealthColor = CompactUnitFrame_UpdateHealthColor;
+local CompactRaidFrameContainer_ApplyToFrames = CompactRaidFrameContainer_ApplyToFrames;
+
+-- TODO remove 1px border
+hooksecurefunc("CompactRaidFrameContainer_LayoutFrames", function(frame)
+    if not frame then return end
+    CompactRaidFrameContainer_ApplyToFrames(frame, "normal", function(frame)
+        if frame then
+            -- Health bar color --
+            -- used in CompactUnitFrame_UpdateHealthColor, might not be set prior
+            frame.optionTable.healthBarColorOverride = normalBarColor;
+            frame.background:SetColorTexture(unpack(normalBackColor));
+            -- Power bar display --
+            local role = UnitGroupRolesAssigned(frame.unit);
+            local options = DefaultCompactUnitFrameSetupOptions;
+            if options.displayPowerBar and role ~= "HEALER" then
+                frame.healthBar:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
+                frame.powerBar:Hide();
+            end
+        end
+    end);
+end);
index 9be113c..590b824 100644 (file)
@@ -1,35 +1,20 @@
+-- TODO have colors in global addon object only in one place
 local normalBarColor = CreateColor(0.3, 0.3, 0.3);
 local dispelBarColor = CreateColor(1, 0.5, 0);
 local normalBackColor = {0.7, 0.7, 0.7};
 local dispelBackColor = {0.5, 0.2, 0};
 local UnitDebuff = UnitDebuff;
 local CompactUnitFrame_UpdateHealthColor = CompactUnitFrame_UpdateHealthColor;
 local normalBarColor = CreateColor(0.3, 0.3, 0.3);
 local dispelBarColor = CreateColor(1, 0.5, 0);
 local normalBackColor = {0.7, 0.7, 0.7};
 local dispelBackColor = {0.5, 0.2, 0};
 local UnitDebuff = UnitDebuff;
 local CompactUnitFrame_UpdateHealthColor = CompactUnitFrame_UpdateHealthColor;
-local CompactRaidFrameContainer_ApplyToFrames = CompactRaidFrameContainer_ApplyToFrames;
-
-hooksecurefunc("CompactRaidFrameContainer_LayoutFrames", function(frame)
-    if not frame then return end
-    CompactRaidFrameContainer_ApplyToFrames(frame, "normal", function(frame)
-        if frame then
-            -- used in CompactUnitFrame_UpdateHealthColor, might not be set prior
-            frame.optionTable.healthBarColorOverride = normalBarColor;
-            frame.background:SetColorTexture(unpack(normalBackColor));
-        end
-    end);
-end);
 
 hooksecurefunc("CompactUnitFrame_UpdateDispellableDebuffs", function(frame)
     if frame and not frame:IsForbidden() and frame:GetName():match("^CompactRaidFrame%d") then
         -- try to find dispellable debuff
         if UnitDebuff(frame.displayedUnit, 1, "RAID") ~= nil then
             frame.optionTable.healthBarColorOverride = dispelBarColor;
 
 hooksecurefunc("CompactUnitFrame_UpdateDispellableDebuffs", function(frame)
     if frame and not frame:IsForbidden() and frame:GetName():match("^CompactRaidFrame%d") then
         -- try to find dispellable debuff
         if UnitDebuff(frame.displayedUnit, 1, "RAID") ~= nil then
             frame.optionTable.healthBarColorOverride = dispelBarColor;
-            if frame.background then
-                frame.background:SetColorTexture(unpack(dispelBackColor));
-            end
+            frame.background:SetColorTexture(unpack(dispelBackColor));
         else
             frame.optionTable.healthBarColorOverride = normalBarColor;
         else
             frame.optionTable.healthBarColorOverride = normalBarColor;
-            if frame.background then
-                frame.background:SetColorTexture(unpack(normalBackColor));
-            end
+            frame.background:SetColorTexture(unpack(normalBackColor));
         end
         -- update color
         CompactUnitFrame_UpdateHealthColor(frame);
         end
         -- update color
         CompactUnitFrame_UpdateHealthColor(frame);
index 1a3101a..fe8158a 100644 (file)
@@ -1,8 +1,8 @@
 ## Interface: 70300
 ## Title: Raid Frame Customization
 
 ## Interface: 70300
 ## Title: Raid Frame Customization
 
-## Version: 1.13
-## Author: Szandos, Jack, schyrio
+## Version: 1.0
+## Author: schyrio
 ## Notes: Customization to the standard raid frames
 ## SavedVariables: IndicatorsDB
 
 ## Notes: Customization to the standard raid frames
 ## SavedVariables: IndicatorsDB
 
@@ -10,7 +10,8 @@ embeds.xml
 
 RaidFrameIndicators.lua
 RaidFrameIndicatorsConfig.lua
 
 RaidFrameIndicators.lua
 RaidFrameIndicatorsConfig.lua
-RaidFrameNames.lua
-RaidFrameHealth.lua
 RaidFrameColors.lua
 RaidFrameColors.lua
-RaidFramePowerBars.lua
+UnitFrameSetupHook.lua
+UpdateNameHook.lua
+UpdateStatusTextHook.lua
+LayoutFramesHook.lua
diff --git a/RaidFrameHealth.lua b/RaidFrameHealth.lua
deleted file mode 100644 (file)
index 3ed8555..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-local UnitIsConnected = UnitIsConnected;
-local UnitIsDeadOrGhost = UnitIsDeadOrGhost;
-local UnitHealthMax = UnitHealthMax;
-local UnitHealth = UnitHealth;
-
-hooksecurefunc("CompactUnitFrame_UpdateStatusText", function(frame)
-    if frame and not frame:IsForbidden() then
-        local frameName = frame:GetName();
-        if frameName and frameName:match("^CompactRaidFrame%d") and frame.unit then
-            -- conditions taken from CompactUnitFrame.lua
-            if not UnitIsConnected(frame.unit) or UnitIsDeadOrGhost(frame.displayedUnit) then
-                return;
-            elseif (frame.optionTable.healthText == "losthealth") then
-                -- only losthealth option is condensed
-                local healthLost = UnitHealthMax(frame.displayedUnit) - UnitHealth(frame.displayedUnit);
-                if healthLost <= 0 then return end
-
-                local prettyHealth;
-                if healthLost > 1200000000 then -- 1.2B
-                    local h1b = healthLost / 1000000000;
-                    local h100m = (healthLost % 1000000000) / 100000000;
-                    prettyHealth = string.format("-%d.%dB", h1b, h100m);
-                elseif healthLost > 1200000 then -- 1.2M
-                    prettyHealth = string.format("-%dM", healthLost / 1000000);
-                elseif healthLost > 1000 then -- 1K
-                    prettyHealth = string.format("-%dK", healthLost / 1000);
-                else
-                    prettyHealth = string.format("-%d", healthLost)
-                end
-
-                frame.statusText:SetText(prettyHealth);
-            end
-        end
-    end
-end);
index e672284..8bb26ef 100644 (file)
@@ -24,22 +24,6 @@ local function dPrint(s)
     DEFAULT_CHAT_FRAME:AddMessage("Indicators: ".. tostring(s));
 end
 
     DEFAULT_CHAT_FRAME:AddMessage("Indicators: ".. tostring(s));
 end
 
--- Hide buff/debuff icons
-local function hideBlizzardBuffs(frame)
-    -- used in CompactUnitFrame_UpdateAuras (Buffs, Debuffs, DispellableDebuffs)
-    if frame.optionTable.displayBuffs then
-        frame.optionTable.displayBuffs = false
-    end
-    if frame.optionTable.displayDebuffs then
-        frame.optionTable.displayDebuffs = false
-    end
-    -- TODO
-    if frame.optionTable.displayDispelDebuffs then
-        frame.optionTable.displayDispelDebuffs = false
-    end
-end
-hooksecurefunc("DefaultCompactUnitFrameSetup", hideBlizzardBuffs);
-
 -- Set the appearance of the FontStrings
 local function setupIndicatorAppearance(frame)
     local frameName = frame:GetName();
 -- Set the appearance of the FontStrings
 local function setupIndicatorAppearance(frame)
     local frameName = frame:GetName();
diff --git a/RaidFrameNames.lua b/RaidFrameNames.lua
deleted file mode 100644 (file)
index 58795b2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-local UnitName = UnitName;
-
-hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
-    if frame and not frame:IsForbidden() then
-        local frameName = frame:GetName();
-        if frameName and frameName:match("^CompactRaidFrame%d") and frame.unit and frame.name then
-            local name, _;
-            name, _ = UnitName(frame.unit)
-            if name then
-                frame.name:SetFont(STANDARD_TEXT_FONT, 12, "")
-                frame.name:SetText(name)
-            end
-        end
-    end
-end);
diff --git a/RaidFramePowerBars.lua b/RaidFramePowerBars.lua
deleted file mode 100644 (file)
index df057e7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
-local CompactRaidFrameContainer_ApplyToFrames = CompactRaidFrameContainer_ApplyToFrames;
-
--- TODO remove 1px border
-hooksecurefunc("CompactRaidFrameContainer_LayoutFrames", function(frame)
-    if not frame then return end
-    CompactRaidFrameContainer_ApplyToFrames(frame, "normal", function(frame)
-        if not frame or not frame.unit then return end
-        local role = UnitGroupRolesAssigned(frame.unit);
-        local options = DefaultCompactUnitFrameSetupOptions;
-        if options.displayPowerBar and role ~= "HEALER" then
-            -- Fix healthbar size
-            frame.healthBar:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
-            frame.powerBar:Hide();
-            -- Fix borders
-            if options.displayBorder then
-                frame.horizDivider:Hide();
-            end
-        end
-    end);
-end);
diff --git a/UnitFrameSetupHook.lua b/UnitFrameSetupHook.lua
new file mode 100644 (file)
index 0000000..2919599
--- /dev/null
@@ -0,0 +1,8 @@
+hooksecurefunc("DefaultCompactUnitFrameSetup", function(frame)
+    -- used in CompactUnitFrame_UpdateAuras (Buffs, Debuffs, DispellableDebuffs)
+    frame.optionTable.displayBuffs = false;
+    frame.optionTable.displayDebuffs = false;
+    frame.optionTable.displayDispelDebuffs = false;
+    -- Unit name font
+    frame.name:SetFont(STANDARD_TEXT_FONT, 12, "");
+end);
diff --git a/UpdateNameHook.lua b/UpdateNameHook.lua
new file mode 100644 (file)
index 0000000..f75dacb
--- /dev/null
@@ -0,0 +1,11 @@
+local UnitName = UnitName;
+
+hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
+    if frame and not frame:IsForbidden() and frame:GetName():match("^CompactRaidFrame%d") then
+        local name, _;
+        name, _ = UnitName(frame.unit);
+        if name then
+            frame.name:SetText(name);
+        end
+    end
+end);
diff --git a/UpdateStatusTextHook.lua b/UpdateStatusTextHook.lua
new file mode 100644 (file)
index 0000000..6fdf535
--- /dev/null
@@ -0,0 +1,33 @@
+local UnitIsConnected = UnitIsConnected;
+local UnitIsDeadOrGhost = UnitIsDeadOrGhost;
+local UnitHealthMax = UnitHealthMax;
+local UnitHealth = UnitHealth;
+local format = string.format
+
+hooksecurefunc("CompactUnitFrame_UpdateStatusText", function(frame)
+    if frame and not frame:IsForbidden() and frame:GetName():match("^CompactRaidFrame%d") then
+        -- conditions taken from CompactUnitFrame.lua
+        if not UnitIsConnected(frame.unit) or UnitIsDeadOrGhost(frame.displayedUnit) then
+            return;
+        elseif (frame.optionTable.healthText == "losthealth") then
+            -- only losthealth option is condensed
+            local healthLost = UnitHealthMax(frame.displayedUnit) - UnitHealth(frame.displayedUnit);
+            if healthLost <= 0 then return end
+
+            local prettyHealth;
+            if healthLost > 1200000000 then -- 1.2B
+                local h1b = healthLost / 1000000000;
+                local h100m = (healthLost % 1000000000) / 100000000;
+                prettyHealth = format("-%d.%dB", h1b, h100m);
+            elseif healthLost > 1200000 then -- 1.2M
+                prettyHealth = format("-%dM", healthLost / 1000000);
+            elseif healthLost > 1000 then -- 1K
+                prettyHealth = format("-%dK", healthLost / 1000);
+            else
+                prettyHealth = format("-%d", healthLost)
+            end
+
+            frame.statusText:SetText(prettyHealth);
+        end
+    end
+end);