From c1bf61696b6ff24c8bc6a216ad9dd33404453345 Mon Sep 17 00:00:00 2001 From: pigmonkey Date: Mon, 30 May 2011 14:14:00 -0400 Subject: [PATCH] rbs module --- modules/macros.lua | 18 +++++++++ modules/rbs.lua | 92 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 modules/rbs.lua diff --git a/modules/macros.lua b/modules/macros.lua index 48c9868..52ecc94 100644 --- a/modules/macros.lua +++ b/modules/macros.lua @@ -17,6 +17,7 @@ function mod:OnInitialize() core:RegisterSlashCommand("ClearMarks", "cm", "clearmarks") core:RegisterSlashCommand("MasterLoot", "ml", "masterloot") core:RegisterSlashCommand("RandomLoot", "rl", "randomloot") + core:RegisterSlashCommand("FlaskCheck", "fc", "flaskcheck") core:RegisterSlashCommand("Countdown", "cd", "countdown") core:RegisterSlashCommand("RosterCheck", "rc", "rostercheck") end @@ -91,6 +92,23 @@ function mod:RandomLoot() end end +function core:FlaskCheck() + local now = GetTime() + for i=1,GetNumRaidMembers() do + for j=1,32 do + local player = UnitName("raid"..i) + name, _, _, _, _, _, expires = UnitAura("raid"..i, j) + if name and name:find("Flask ") then + local time = expires - now + if time<990 and time>0 then + SendChatMessage(format("%s %d:%02d", player, floor(time/60), time%60), "raid") + -- SendChatMessage(format("Flask ending in %d:%02d", UnitName(r), floor(time/60), time%60), "whipser", nil, player) + end + end + end + end +end + local countDown = {"Pulling in 5", "4", "3", "2", "1", "Go"} -- used in /atlt cd function mod:Countdown() for i=5,0,-1 do diff --git a/modules/rbs.lua b/modules/rbs.lua new file mode 100644 index 0000000..138dab5 --- /dev/null +++ b/modules/rbs.lua @@ -0,0 +1,92 @@ +local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") +local mod = core:NewModule("RBS Mods", "AceEvent-3.0", "AceHook-3.0") +local db = core.db.profile[mod:GetName()] + +local defaults = { +} +local options = { +} + +function mod:OnInitialize() + self:RegisterEvent("ADDON_LOADED") +end + +function mod:ADDON_LOADED(_, name) + if name == "RaidBuffStatus" then + if RaidBuffStatus then + self:SecureHook(RaidBuffStatus, "SetupFrames", "SetupRBS") + end + self:UnregisterEvent("ADDON_LOADED") + end +end + +function mod:RunMacro(name) + local macros = core:GetModule("Macros") + if not macros or not macros[name] then return end + + macros[name]() +end + +local didSetup = false +function mod:SetupRBS() + if didSetup or not RaidBuffStatus or not RaidBuffStatus.frame then + return + end + didSetup = true + + -- register new buttons + self:NewRBSButton("Flask", function() + self:RunMacro("FlaskCheck") + end, 45, "TOPLEFT", "BOTTOMLEFT", 7, 5) + self:NewRBSButton("Count", function() + self:RunMacro("Countdown") + end, 45, "TOP", "BOTTOM", 0, 5) + self:NewRBSButton("Loot", function() + self:RunMacro("MasterLoot") + end, 45, "TOPRIGHT", "BOTTOMRIGHT", -7, 5) + + -- reposition old ones + RaidBuffStatus.readybutton:SetWidth(45) + RaidBuffStatus.readybutton:SetText("Ready") + + -- hook old show/hide + local rbShow = RaidBuffStatus.readybutton.Show + RaidBuffStatus.readybutton.Show = function(...) + RaidBuffStatus.FlaskButton:Show() + RaidBuffStatus.CountButton:Show() + RaidBuffStatus.LootButton:Show() + return rbShow(...) + end + local rbHide = RaidBuffStatus.readybutton.Hide + RaidBuffStatus.readybutton.Hide = function(...) + RaidBuffStatus.FlaskButton:Hide() + RaidBuffStatus.CountButton:Hide() + RaidBuffStatus.LootButton:Hide() + return rbHide(...) + end + + --[[ fix height + local heightFix = 25 + RaidBuffStatus.frame:SetHeight(RaidBuffStatus.frame:GetHeight() + heightFix) + + -- fix future height + RaidBuffStatus.frame:SetScript("OnSizeChanged", function(self, width, height) + -- since this will cause OnSizeChanged to fire again immediately, we use a flag to determine which call it was + if self.heightFlag then + self.heightFlag = nil + else + self.heightFlag = true + self:SetHeight(height + heightFix) + end + end)]] +end + +function mod:NewRBSButton(label, func, width, anchorFrom, anchorTo, anchorX, anchorY) + local button = CreateFrame("Button", "", RaidBuffStatus.frame, "OptionsButtonTemplate") + button:SetText(label) + button:SetWidth(width) + button:SetPoint(anchorFrom, RaidBuffStatus.frame, anchorTo, anchorX, anchorY) + button:SetScript("OnClick", func) + button:Show() + RaidBuffStatus[label.."Button"] = button +end