-local min = math.min;
-local CreateFrame, IsResting = CreateFrame, IsResting;
-local UnitXP, UnitXPMax, GetXPExhaustion = UnitXP, UnitXPMax, GetXPExhaustion;
-local CTimerAfter = C_Timer.After;
-local ExhaustionToolTipText = ExhaustionToolTipText;
-local GameTooltip = nil;
-
-local width = 300;
-local running = false;
-
-local ActionBars = CreateFrame("Frame", "OmaActionBars");
-
-local function expBar(parent)
- local frame = CreateFrame("Frame", "OmaExpBar", parent);
- frame:SetPoint("BOTTOM");
- frame:SetWidth(width);
- frame:SetHeight(10);
- frame.base = frame:CreateTexture(nil, "BACKGROUND");
- frame.base:SetAllPoints();
- frame.base:SetColorTexture(0, 0, 0, 0.5);
- frame.bar = frame:CreateTexture(nil, "BORDER");
- frame.bar:SetPoint("TOPLEFT", frame.base, "TOPLEFT");
- frame.bar:SetPoint("BOTTOMLEFT", frame.base, "BOTTOMLEFT");
- frame.bar:SetColorTexture(1, 1, 1);
- frame.rest = frame:CreateTexture(nil, "BORDER");
- frame.rest:SetPoint("TOPLEFT", frame.bar, "TOPRIGHT");
- frame.rest:SetPoint("BOTTOMLEFT", frame.bar, "BOTTOMRIGHT");
- frame.rest:SetColorTexture(0, 0.3, 1, 0.7);
- frame.text = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
- frame.text:SetPoint("BOTTOM");
- frame.text:Hide();
-
- local function updateXP()
- local xp, xpmax = UnitXP("player"), UnitXPMax("player");
- local rested = GetXPExhaustion();
- local current = xp/xpmax*width;
- local space = width - current;
- frame.bar:SetWidth(current);
- if rested then
- local restw = rested/xpmax*width;
- frame.rest:SetWidth(min(space, restw));
- frame.rest:Show();
- frame.text:SetFormattedText("%d / %d (+%d)", xp, xpmax, rested/2);
- frame.bar:SetVertexColor(0, 0.5, 1, 0.9);
+local pairs = pairs;
+local format = string.format;
+local ssub = string.sub;
+local GetActionInfo, GetActionTexture = GetActionInfo, GetActionTexture;
+local GetActionLossOfControlCooldown = GetActionLossOfControlCooldown;
+local GetActionCooldown, GetActionCharges = GetActionCooldown, GetActionCharges;
+local GetActionText, GetBindingKey = GetActionText, GetBindingKey;
+local IsConsumableAction, IsStackableAction = IsConsumableAction, IsStackableAction;
+local IsItemAction, GetActionCount = IsItemAction, GetActionCount;
+local IsSpellOverlayed, GetMacroSpell = IsSpellOverlayed, GetMacroSpell;
+local IsMounted = IsMounted;
+local HasAction, IsUsableAction = HasAction, IsUsableAction;
+local IsCurrentAction, IsAutoRepeatAction = IsCurrentAction, IsAutoRepeatAction;
+local CreateFrame = CreateFrame;
+local RegisterStateDriver = RegisterStateDriver;
+local CooldownFrame_Set, CooldownFrame_Clear = CooldownFrame_Set, CooldownFrame_Clear;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
+local COOLDOWN_TYPE_LOSS_OF_CONTROL = COOLDOWN_TYPE_LOSS_OF_CONTROL;
+local COOLDOWN_TYPE_NORMAL = COOLDOWN_TYPE_NORMAL;
+local CDTexture = "Interface\\Cooldown\\edge";
+local locCDTexture = "Interface\\Cooldown\\edge-LoC";
+
+local BUTTONLOCK = true; -- change to lock button dragging
+
+local settings = {
+ ["Oma1"] = {
+ bar = 1,
+ start = 1,
+ length = 12,
+ columns = 4,
+ size = 40,
+ x = 580,
+ y = 300,
+ nomouse = true,
+ },
+ ["Oma2"] = {
+ bar = 2,
+ start = 13,
+ length = 12,
+ columns = 4,
+ size = 40,
+ x = 580,
+ y = 180,
+ nomouse = true,
+ },
+ ["Oma3"] = {
+ bar = 3,
+ start = 25,
+ length = 12,
+ columns = 3,
+ x = 1824,
+ y = 128,
+ flyout = "LEFT",
+ },
+ ["Oma4"] = {
+ bar = 4,
+ start = 37,
+ length = 12,
+ columns = 3,
+ x = 1824,
+ y = 256,
+ },
+ ["Oma5"] = {
+ bar = 5,
+ start = 49,
+ length = 12,
+ columns = 3,
+ x = 1000,
+ y = 840,
+ },
+ ["Oma6"] = {
+ bar = 6,
+ start = 61,
+ length = 12,
+ x = 1000,
+ y = 600,
+ },
+ -- used as bonus bars for some classes
+ ["Oma7"] = {
+ bar = 7,
+ start = 73,
+ length = 12,
+ x = 1000,
+ y = 760,
+ },
+ ["Oma8"] = {
+ bar = 8,
+ start = 85,
+ length = 12,
+ x = 1000,
+ y = 720,
+ },
+ ["Oma9"] = {
+ bar = 9,
+ start = 97,
+ length = 12,
+ x = 1000,
+ y = 680,
+ },
+ ["Oma10"] = {
+ bar = 10,
+ start = 109,
+ length = 12,
+ x = 1000,
+ y = 640,
+ },
+};
+
+local usingBonusbars = {
+ --["WARRIOR"] = {[7]=true, [8]=true, [9]=true}, -- not using stance separated actionbars
+ ["DRUID"] = {[7]=true, [8]=true, [9]=true}, -- moonkin form page is usable anyway
+ --["DRUID"] = {[7]=true, [8]=true, [9]=true,[10]=true},
+ ["ROGUE"] = {[7]=true},
+ --["PRIEST"] = {[7]=true}, -- shadowform doesn't change abilities
+};
+
+local chars = {
+ ["Stormreaver"] = {
+ ["Vildan"] = {1, 2, 3, 4,},
+ ["Gedren"] = {1, 2, 3, 4,},
+ ["Gazden"] = {1, 2, 3, 4,},
+ ["Gedran"] = {1, 2, 3, 4,},
+ ["Iled"] = {1, 2, 3, 4,},
+ },
+};
+
+local buttons = {};
+local activeButtons = {};
+
+local ActionBars = CreateFrame("Frame", "OmaActionBars", UIParent);
+local inheritedFrames =
+"SecureActionButtonTemplate,SecureHandlerDragTemplate,SecureHandlerStateTemplate";
+
+local function showTooltip(secure)
+ GameTooltip_SetDefaultAnchor(GameTooltip, secure);
+ GameTooltip:SetAction(secure:GetAttribute("action"));
+end
+
+local function hideTooltip()
+ GameTooltip:Hide();
+end
+
+local numChargeCDs = 0;
+local function createChargeCD(parent)
+ numChargeCDs = numChargeCDs + 1;
+ local frame = CreateFrame("Cooldown", "OmaChargeCD"..numChargeCDs, parent, "CooldownFrameTemplate");
+ frame:SetHideCountdownNumbers(false);
+ frame:SetDrawSwipe(false);
+ frame:SetAllPoints(parent);
+ frame:SetFrameStrata("TOOLTIP");
+ return frame;
+end
+
+local function clearChargeCD(parent)
+ if parent.chargecd then CooldownFrame_Clear(parent.chargecd) end
+end
+
+local function startChargeCD(parent, start, duration, modrate)
+ if start == 0 then
+ return clearChargeCD(parent);
+ end
+ parent.chargecd = parent.chargecd or createChargeCD(parent);
+ CooldownFrame_Set(parent.chargecd, start, duration, true, true, modrate);
+end
+
+local redoCooldown;
+
+local function updateCooldown(button, slot)
+ -- CD update from FrameXML/ActionButton.lua
+ local locstart, locduration = GetActionLossOfControlCooldown(slot);
+ local start, duration, enable, modrate = GetActionCooldown(slot);
+ local charges, maxcharges, chargestart, chargeduration, chargemodrate = GetActionCharges(slot);
+ -- avoid as many updates as possible by checking if there's changes first
+ if button.prev and
+ button.prev[1] == locstart and button.prev[2] == locduration and
+ button.prev[3] == start and button.prev[4] == duration and
+ button.prev[5] == enable and button.prev[6] == modrate and
+ button.prev[7] == charges and button.prev[8] == maxcharges and
+ button.prev[9] == chargestart and button.prev[10] == chargeduration and
+ button.prev[11] == chargemodrate then
+ return;
+ end
+ button.prev = { locstart, locduration, start, duration, enable, modrate,
+ charges, maxcharges, chargestart, chargeduration, chargemodrate };
+ if (locstart + locduration) > (start + duration) then
+ if button.cd.currentCooldownType ~= COOLDOWN_TYPE_LOSS_OF_CONTROL then
+ button.cd:SetEdgeTexture(locCDTexture);
+ button.cd:SetSwipeColor(0.17, 0, 0);
+ button.cd:SetHideCountdownNumbers(true);
+ button.cd.currentCooldownType = COOLDOWN_TYPE_LOSS_OF_CONTROL;
+ end
+
+ CooldownFrame_Set(button.cd, locstart, locduration, true, true, modrate);
+ clearChargeCD(button);
+ else
+ if button.cd.currentCooldownType ~= COOLDOWN_TYPE_NORMAL then
+ button.cd:SetEdgeTexture(CDTexture);
+ button.cd:SetSwipeColor(0, 0, 0);
+ button.cd:SetHideCountdownNumbers(false);
+ button.cd.currentCooldownType = COOLDOWN_TYPE_NORMAL;
+ end
+
+ if locstart > 0 then
+ button.cd:SetScript("OnCooldownDone", redoCooldown);
+ end
+ if charges and maxcharges and maxcharges > 1 and charges < maxcharges then
+ startChargeCD(button, chargestart, chargeduration, chargemodrate);
+ else
+ clearChargeCD(button);
+ end
+ CooldownFrame_Set(button.cd, start, duration, enable, false, modrate);
+ end
+end
+
+local function redoCooldown(cd)
+ local button = cd:GetParent();
+ cd:SetScript("OnCooldownDone", nil);
+ updateCooldown(button, button.slot);
+end
+
+local function updateCount(button, slot)
+ if IsConsumableAction(slot) or IsStackableAction(slot) or
+ (not IsItemAction(slot) and GetActionCount(slot) > 0) then
+ local count = GetActionCount(slot);
+ if count > 99 then
+ button.count:SetText("*");
+ else
+ button.count:SetText(count);
+ end
+ button.count:Show();
+ else
+ local charges, maxcharges = GetActionCharges(slot);
+ if maxcharges > 1 then
+ button.count:SetText(charges);
+ button.count:Show();