5d20ef0 - Separate TellMeWhen component
[wowui.git] / OmaTMW / TellMeWhen.lua
similarity index 90%
rename from OmaAB/TellMeWhen.lua
rename to OmaTMW/TellMeWhen.lua
index a43d22d..b7ba1e8 100644 (file)
@@ -4,6 +4,7 @@ local pairs = pairs;
 local GetSpecialization = GetSpecialization;
 local UnitExists = UnitExists;
 local UnitAura = UnitAura;
+local GetTotemInfo = GetTotemInfo;
 
 -- character specific frames
 local chars = {
@@ -49,6 +50,15 @@ local chars = {
                 height = 80,
             },
         },
+        ["Gedren"] = {
+            {
+                totems = {1},
+                x = 570,
+                y = 440,
+                width = 80,
+                height = 80,
+            },
+        },
     },
 };
 
@@ -136,14 +146,22 @@ local function updateAuras(unit)
     end
 end
 
-local function updateTotemFrame(frame)
-    print("totem frame not implemented");
+local function updateTotemFrame(frame, slot)
+    local _, name, start, duration, icon = GetTotemInfo(slot);
+    if name ~= "" then
+        frame.cd:SetCooldown(start, duration);
+        frame.cd:Show();
+        frame.icon:SetTexture(icon);
+        frame:Show();
+    else
+        frame:Hide();
+    end
 end
 
 local function updateTotems(slot)
     if totems[slot] then
         for _, i in pairs(totems[slot]) do
-            updateTotemFrame(frames[i]);
+            updateTotemFrame(frames[i], slot);
         end
     end
 end
@@ -167,6 +185,7 @@ local function createTMW(name, config, parent)
     frame.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93);
     frame.stack = frame:CreateFontString(nil, "OVERLAY", "NumberFontNormalLarge");
     frame.stack:SetPoint("TOPLEFT");
+    frame.stack:Hide();
     frame.cd = CreateFrame("Cooldown", name.."CD", frame, "CooldownFrameTemplate");
     frame.cd:SetReverse(true);
     frame.cd:SetAllPoints();
@@ -201,7 +220,9 @@ local function initialize()
 
     for _, frame in pairs(frames) do
         if frame.auras then updateAuraFrame(frame) end
-        if frame.totems then updateTotemFrame(frame) end
+        if frame.totems then
+            for _, slot in pairs(frame.totems) do updateTotemFrame(frame, slot) end
+        end
     end
 end