diff --git a/Roth_UI.toc b/Roth_UI.toc index 74426a2..0def225 100755 --- a/Roth_UI.toc +++ b/Roth_UI.toc @@ -1,4 +1,4 @@ -## Interface: 810000 +## Interface: 80205 ## Author: Galaxy ## Title: Roth UI ## Notes: Galaxy's oUF layout with Diablo flavor! diff --git a/config.lua b/config.lua index 062ee1e..81dbb45 100755 --- a/config.lua +++ b/config.lua @@ -5,7 +5,7 @@ -- A Diablo themed unitframe layout for oUF 1.6.x -- Galaxy119/Joker119 - 2016-2018 - -- Version 2.7.1 + -- Version 2.8.0 --------------------------------------------- --get the addon namespace @@ -629,29 +629,35 @@ texture = (mediapath.."statusbar3"), }, aurawatch = { - show = true, + show = false, }, auras = { --put every single spellid here that you want to be tracked, be it buff or debuff doesn't matter - --maximum number of icons displayed at a time = 1 - --this is for important boss mechanics only, this is not for tracking healing HOTs etc whitelist = { - + 223306, -- Bestow Faith + 53563, -- Beacon of Light + 6940, -- Blessing of Sacrifice + 287280, -- Glimmer of Light + 156910, -- Beacon of Faith + 200025, -- Beacon of Virtue + 313255, -- Slow }, blacklist = { - --these are abilities that should definetly now be shown + --these are abilities that should definetly not be shown 164545, 164547, + 54149, }, show = true, disableCooldown = false, showBuffType = true, showDebuffType = true, - doNotUseCustomFilter = true, + doNotUseCustomFilter = false, size = 13, num = 5, spacing = 3, - pos = { a1 = "CENTER", x = 0, y = -23}, + debuffPos = { a1 = "CENTER", x = 0, y = -23}, + buffPos = {a1 = "CENTER", x = 33, y = 0}, }, attributes = { visibility = "custom [nogroup:party,nogroup:raid] show; [group:party,nogroup:raid] show; [group:raid] show; hide", @@ -830,7 +836,7 @@ mouseover = { enable = true, fadeIn = {time = 0.4, alpha = 1}, - fadeOut = {time = 0.3, alpha = 0.2}, + fadeOut = {time = 0.3, alpha = 1}, }, }, bar6 = { @@ -1021,6 +1027,7 @@ cfg.tracker = { --rMinimap cfg.minimap = { scale = 1, + alpha = 0.5, point = {"TOPRIGHT", 0, -18}, } diff --git a/core/mainmenu.lua b/core/mainmenu.lua index 61901fa..cbd25d3 100755 --- a/core/mainmenu.lua +++ b/core/mainmenu.lua @@ -20,6 +20,6 @@ cfg.backdrop = { bgFile = mediapath.."Tooltip_Background", edgeFile = mediapath. local MenuSetup = function() end --Skin the Game Menu - GameMenuFrame:SetBackdrop(cfg.backdrop) +-- GameMenuFrame:SetBackdrop(cfg.backdrop) --Skin the Character Frame diff --git a/core/panel.lua b/core/panel.lua index 3115bf3..016acc9 100755 --- a/core/panel.lua +++ b/core/panel.lua @@ -237,9 +237,9 @@ --basic color picker func local createBasicColorPicker = function(parent, name, title, width, height) - local picker = CF("Button", name, parent) + local picker = CF("Button", name, parent, BackdropTemplateMixin and "BackdropTemplate") picker:SetSize(width, height) - picker:SetBackdrop(backdrop) + picker:SetBackdrop({backdrop}) picker:SetBackdropBorderColor(0.5,0.5,0.5) --texture local color = picker:CreateTexture(nil,"BACKGROUND",nil,-7) diff --git a/core/tags.lua b/core/tags.lua index 93400eb..51e9dda 100755 --- a/core/tags.lua +++ b/core/tags.lua @@ -195,7 +195,7 @@ end local val = oUF.Tags.Methods["perhp"](unit) return val or "" end - oUF.Tags.Events["diablo:bosshp"] = "UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_TARGETABLE_CHANGED" + oUF.Tags.Events["diablo:bosshp"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_TARGETABLE_CHANGED" --boss power value oUF.Tags.Methods["diablo:bosspp"] = function(unit) @@ -435,4 +435,4 @@ end end --oUF.Tags.Events["diablo:PowerOrbBottom"] = "UNIT_DISPLAYPOWER UNIT_POWER_UPDATE UNIT_MAXPOWER UNIT_CONNECTION" - --------------------------------------------- \ No newline at end of file + --------------------------------------------- diff --git a/embeds/Roth_ShinyBuffs/Roth_ShinyBuffs.lua b/embeds/Roth_ShinyBuffs/Roth_ShinyBuffs.lua index b699ec5..8907dd9 100755 --- a/embeds/Roth_ShinyBuffs/Roth_ShinyBuffs.lua +++ b/embeds/Roth_ShinyBuffs/Roth_ShinyBuffs.lua @@ -70,7 +70,7 @@ local function SkinningMachine(svtable, btn, dur, c, icon, bor, firstTime) bor:SetDrawLayer("OVERLAY", 1) end -- - btn.bar = CreateFrame("StatusBar", nil, btn.bg) + btn.bar = CreateFrame("StatusBar", nil, btn.bg, BackdropTemplateMixin and "BackdropTemplate") btn.bar:SetPoint("TOPLEFT", icon, "BOTTOMLEFT", 0, -1.5) btn.bar:SetPoint("TOPRIGHT", icon, "BOTTOMRIGHT", 0, -1.5) btn.bar:SetPoint("BOTTOM", btn.bg, "BOTTOM", 0, 5.5) @@ -99,21 +99,16 @@ local function SkinningMachine(svtable, btn, dur, c, icon, bor, firstTime) dur:SetFont(LSM:Fetch("font", db.font), db[svtable].dfsize, db.fstyle) c:SetFont(LSM:Fetch("font", db.font), db[svtable].cfsize, db.fstyle) btn.bg:SetPoint("BOTTOMRIGHT", btn, "BOTTOMRIGHT", 2, -max(db[svtable].size*.2, 5)) - btn.bg:SetBackdrop({ bgFile = LSM:Fetch("background", db.bg), - edgeFile = LSM:Fetch("border", db.border), - edgeSize = db.borderWidth, - insets = {left=3,right=3,top=3,bottom=3} - }) btn.bar:SetStatusBarTexture(LSM:Fetch("statusbar", db.sbar)) if db.classbg then - btn.bg:SetBackdropColor(classColor.r, classColor.g, classColor.b) + --btn.bg:SetBackdropColor(classColor.r, classColor.g, classColor.b) else - btn.bg:SetBackdropColor(db.bgColor.r, db.bgColor.g, db.bgColor.b) + --btn.bg:SetBackdropColor(db.bgColor.r, db.bgColor.g, db.bgColor.b) end if db.classbor then - btn.bg:SetBackdropBorderColor(classColor.r, classColor.g, classColor.b) + --btn.bg:SetBackdropBorderColor(classColor.r, classColor.g, classColor.b) else - btn.bg:SetBackdropBorderColor(db.borColor.r, db.borColor.g, db.borColor.b) + --btn.bg:SetBackdropBorderColor(db.borColor.r, db.borColor.g, db.borColor.b) end if db.classbar then btn.bar:SetStatusBarColor(classColor.r, classColor.g, classColor.b) @@ -923,4 +918,4 @@ LSM:Register("background", "Solid", "Interface\\AddOns\\Roth_UI\\media\\Solid.tg SB:SetScript("OnEvent", PEW) -SB:RegisterEvent("PLAYER_ENTERING_WORLD") \ No newline at end of file +SB:RegisterEvent("PLAYER_ENTERING_WORLD") diff --git a/embeds/oUF/elements/health.lua b/embeds/oUF/elements/health.lua index 231c1cd..7b2a254 100755 --- a/embeds/oUF/elements/health.lua +++ b/embeds/oUF/elements/health.lua @@ -167,7 +167,7 @@ local Enable = function(self, unit) health.ForceUpdate = ForceUpdate if(health.frequentUpdates) then - self:RegisterEvent('UNIT_HEALTH_FREQUENT', Path) + self:RegisterEvent('UNIT_HEALTH', Path) else self:RegisterEvent('UNIT_HEALTH', Path) end @@ -190,7 +190,7 @@ local Disable = function(self) local health = self.Health if(health) then health:Hide() - self:UnregisterEvent('UNIT_HEALTH_FREQUENT', Path) + self:UnregisterEvent('UNIT_HEALTH', Path) self:UnregisterEvent('UNIT_HEALTH', Path) self:UnregisterEvent('UNIT_MAXHEALTH', Path) self:UnregisterEvent('UNIT_CONNECTION', Path) diff --git a/embeds/rActionBarStyler/core/bar1.lua b/embeds/rActionBarStyler/core/bar1.lua index 9df9f03..2ccd176 100755 --- a/embeds/rActionBarStyler/core/bar1.lua +++ b/embeds/rActionBarStyler/core/bar1.lua @@ -21,7 +21,6 @@ if not gcfg.embeds.rActionBarStyler then return end --create the frame to hold the buttons local frame = CreateFrame("Frame", "rABS_MainMenuBar", UIParent, "SecureHandlerStateTemplate") - frame:ClearAllPoints(); if cfg.uselayout2x6 then frame:SetWidth(cfg.buttons.size*num/2 + (num/2-1)*cfg.buttons.margin + 2*cfg.padding) frame:SetHeight(cfg.buttons.size*num/6 + (num/6-1)*cfg.buttons.margin + 2*cfg.padding) @@ -37,9 +36,11 @@ if not gcfg.embeds.rActionBarStyler then return end frame:SetScale(cfg.scale) --move the buttons into position and reparent them + MainMenuBarArtFrame:ClearAllPoints() MainMenuBarArtFrame:SetParent(frame) MainMenuBarArtFrame:EnableMouse(false) MainMenuBar:EnableMouse(false) + MainMenuBar:ClearAllPoints() MainMenuBar:Hide() for i=1, num do diff --git a/embeds/rButtonTemplate/core.lua b/embeds/rButtonTemplate/core.lua index 598c81c..4013c35 100755 --- a/embeds/rButtonTemplate/core.lua +++ b/embeds/rButtonTemplate/core.lua @@ -120,10 +120,10 @@ end local function SetupBackdrop(button,backdrop) if not backdrop then return end - local bg = CreateFrame("Frame", nil, button) + local bg = CreateFrame("Frame", nil, button, BackdropTemplateMixin and "BackdropTemplate") ApplyPoints(bg, backdrop.points) bg:SetFrameLevel(button:GetFrameLevel()-1) - bg:SetBackdrop(backdrop) + bg:SetBackdrop({backdrop}) if backdrop.backgroundColor then bg:SetBackdropColor(unpack(backdrop.backgroundColor)) end @@ -359,4 +359,4 @@ function rButtonTemplate:StyleAllAuraButtons(cfg) rButtonTemplate:StyleBuffButtons(cfg) rButtonTemplate:StyleDebuffButtons(cfg) rButtonTemplate:StyleTempEnchants(cfg) -end \ No newline at end of file +end diff --git a/embeds/rInfostrings/core/core.lua b/embeds/rInfostrings/core/core.lua index 03389a4..86a7c4d 100755 --- a/embeds/rInfostrings/core/core.lua +++ b/embeds/rInfostrings/core/core.lua @@ -151,6 +151,7 @@ if not cfg.embeds.rInfoStrings then return end xp = "|c00FA58F4"..numformat(UnitXP("player")).."/"..numformat(UnitXPMax("player")).." |r|c00ffb400("..numformat(GetXPExhaustion() or 0)..")|r|c00FA58F4 | "..string.format("%.0f", (UnitXP("player")/UnitXPMax("player")*100)).."%|r" else local _, _, minimum, maximum, value = GetWatchedFactionInfo() + if ((value-minimum)==999) and ((maximum-minimum)==1000) then xp = "|c0000FF00MAXED OUT|r" else diff --git a/embeds/rMinimap/core.lua b/embeds/rMinimap/core.lua index a5b3111..841ccad 100755 --- a/embeds/rMinimap/core.lua +++ b/embeds/rMinimap/core.lua @@ -30,6 +30,12 @@ Minimap:SetMaskTexture(mediapath.."mask2") Minimap:ClearAllPoints() Minimap:SetPoint("CENTER") Minimap:SetSize(190,190) --correct the cluster offset +local function SetAlpha() + Minimap:SetAlpha(cfg.minimap.alpha) +end +C_Timer.After(5, SetAlpha) + + --hide regions MinimapBackdrop:Hide() @@ -156,9 +162,8 @@ Minimap:SetScript("OnLeave", SetTimer) rLib:RegisterCallback("PLAYER_ENTERING_WORLD", Hide) Hide(Minimap) - --drag frame rLib:CreateDragFrame(MinimapCluster, L.dragFrames, -2, true) --create slash commands -rLib:CreateSlashCmd(L.addonName, L.addonShortcut, L.dragFrames, L.addonColor) \ No newline at end of file +rLib:CreateSlashCmd(L.addonName, L.addonShortcut, L.dragFrames, L.addonColor) diff --git a/embeds/rNamePlates/rNamePlates.lua b/embeds/rNamePlates/rNamePlates.lua index a417465..8731040 100755 --- a/embeds/rNamePlates/rNamePlates.lua +++ b/embeds/rNamePlates/rNamePlates.lua @@ -180,7 +180,7 @@ hooksecurefunc("CompactUnitFrame_UpdateName", function (frame) frame.name:SetFont(cfg.font, 12) --explosiove orbs - if (name == "Explosives") then + if (string.match( name, "Explosives" )) then frame.healthBar:SetSize(384,48) frame.healthBar:SetScale(0.35) frame.healthBar:SetFrameStrata("TOOLTIP") @@ -188,8 +188,7 @@ hooksecurefunc("CompactUnitFrame_UpdateName", function (frame) frame.healthBar.re:SetSize(128,128) frame.healthBar.le:SetSize(128,128) else - frame.healthBar.re:SetSize(64,64) - frame.healthBar.le:SetSize(64,64) + frame.healthBar:SetSize(64,64) end end) diff --git a/embeds/rRaidManager/core.lua b/embeds/rRaidManager/core.lua index 66a364d..a53f579 100755 --- a/embeds/rRaidManager/core.lua +++ b/embeds/rRaidManager/core.lua @@ -70,12 +70,12 @@ --------------------------- --create manager frame - local manager = CF("Frame", addon, UIP, "SecureHandlerStateTemplate") + local manager = CF("Frame", addon, UIP, "SecureHandlerStateTemplate" and "BackdropTemplate") manager:SetFrameStrata("DIALOG") manager:SetSize(200,390) manager:SetPoint("LEFT", -190, 0) manager:SetAlpha(0.4) - manager:SetBackdrop(backdrop) + manager:SetBackdrop({backdrop}) manager:SetBackdropColor(0.1,0.1,0.1,0.9) manager:SetBackdropBorderColor(0.7,0.7,0.7) manager:RegisterEvent("PLAYER_LOGIN") diff --git a/embeds/tullaRange/LICENSE b/embeds/tullaRange/LICENSE old mode 100755 new mode 100644 index c2e0422..7bd2426 --- a/embeds/tullaRange/LICENSE +++ b/embeds/tullaRange/LICENSE @@ -1,19 +1,19 @@ -Copyright (c) 2010 Jason Greer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +Copyright (c) 2010 Jason Greer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/embeds/tullaRange/README.md b/embeds/tullaRange/README.md new file mode 100644 index 0000000..f64deea --- /dev/null +++ b/embeds/tullaRange/README.md @@ -0,0 +1,6 @@ +# tullaRange + +[![Travis (.org)](https://img.shields.io/travis/tullamods/tullarange?style=flat-square)](https://travis-ci.com/tullamods/tullaRange) +[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/tullamods/tullaRange?sort=semver&style=flat-square)](https://github.com/tullamods/tullaRange/releases/latest) + +An addon for World of Warcraft that makes buttons appear red when out of range diff --git a/embeds/tullaRange/changelog.md b/embeds/tullaRange/changelog.md new file mode 100644 index 0000000..27573ba --- /dev/null +++ b/embeds/tullaRange/changelog.md @@ -0,0 +1,45 @@ +# tullaRange release notes + +## 9.0.0 + +* Updated for World of Warcraft 9.0.1 - Shadowlands + +## 8.3.2 + +* Added support for pet action buttons. You can disable this via `/run tullaRange:SetEnablePetActions(false)` +* Replaced the attack flash animation with a smoother one. You can disable this via `/run tullaRange:SetEnableFlashAnimations(false)` + +## 8.3.1 + +* Increase performance a bit by only updating attack actions and actions with a range + +## 8.3.0 + +* Update for WoW 8.3.0 + +## 8.2.7 + +* Use a C_Timer.After handler for updates + +## 8.2.6 + +* Update classic TOC for 1.13.2 +* Update packager to use github actions + +## 8.2.5 + +* Updated TOC for 8.2.5 + +## 8.2.2 + +* Added classic build + +## 8.2.1 + +* Automated releases + +## 8.2.0 + +* Updated TOC for 8.2.0 +* Verified the addon works with classic +* Cleaned up code a tiny bit diff --git a/embeds/tullaRange/tullaRange.lua b/embeds/tullaRange/tullaRange.lua old mode 100755 new mode 100644 index b35ac2d..28ec7ac --- a/embeds/tullaRange/tullaRange.lua +++ b/embeds/tullaRange/tullaRange.lua @@ -1,332 +1,556 @@ ---[[ - tullaRange - Adds out of range coloring to action buttons - Derived from RedRange with negligable improvements to CPU usage ---]] - ---locals and speed -local AddonName, Addon, ns = ... -local addon, ns = ... -local cfg = ns.cfg -if not cfg.embeds.tullaRange then return end -local _G = _G -local next = next -local pairs = pairs +-------------------------------------------------------------------------------- +-- tullaRange +-- Adds out of range coloring to action buttons +-- Derived from RedRange with negligable improvements to CPU usage +-------------------------------------------------------------------------------- -local DB_KEY = 'TULLARANGE_COLORS' -local UPDATE_DELAY = 0.15 -local ATTACK_BUTTON_FLASH_TIME = _G['ATTACK_BUTTON_FLASH_TIME'] -local SPELL_POWER_HOLY_POWER = _G['SPELL_POWER_HOLY_POWER'] +local AddonName = ... -local ActionHasRange = _G['ActionHasRange'] -local IsActionInRange = _G['IsActionInRange'] -local IsUsableAction = _G['IsUsableAction'] -local HasAction = _G['HasAction'] +-- the addon event handler +local Addon = CreateFrame('Frame', AddonName, _G.InterfaceOptionsFrame) ---[[ - Helper Functions ---]] +-- how quickly attack actions flash +local ATTACK_BUTTON_FLASH_TIME = _G.ATTACK_BUTTON_FLASH_TIME -local function removeDefaults(tbl, defaults) - for k, v in pairs(defaults) do - if type(tbl[k]) == 'table' and type(v) == 'table' then - removeDefaults(tbl[k], v) - if next(tbl[k]) == nil then - tbl[k] = nil - end - elseif tbl[k] == v then - tbl[k] = nil - end - end +-- the name of the database +local DB_KEY = 'TULLARANGE_COLORS' - return tbl -end +-- how frequently we want to update colors, in seconds +local UPDATE_DELAY = 0.2 -local function copyDefaults(tbl, defaults) - for k, v in pairs(defaults) do - if type(v) == 'table' then - tbl[k] = copyDefaults(tbl[k] or {}, v) - elseif tbl[k] == nil then - tbl[k] = v - end - end +local ActionHasRange = _G.ActionHasRange +local After = _G.C_Timer.After +local GetTime = _G.GetTime +local IsActionInRange = _G.IsActionInRange +local IsUsableAction = _G.IsUsableAction +local GetPetActionInfo = _G.GetPetActionInfo +local GetPetActionSlotUsable = _G.GetPetActionSlotUsable - return tbl -end +-------------------------------------------------------------------------------- +-- Event Handlers +-------------------------------------------------------------------------------- +-- addon intially loaded +function Addon:OnLoad() + -- a table for the action buttons we want to periodically check the range of + self.watchedActions = {} ---[[ - The main thing ---]] + -- a table for the action buttons we want to periodically check the ranges of + self.watchedPetActions = {} -function Addon:Load() - self.buttonColors = {} - self.buttonsToUpdate = {} + -- a table for all of the known action button states + self.buttonStates = {} - -- create a frame for watching for the options menu to show up - -- when it does, load the options menu - do - local optionsWatcher = CreateFrame('Frame', nil, _G['InterfaceOptionsFrame']) + -- setup script handlers + self:SetScript('OnShow', self.OnShow) + self:SetScript('OnEvent', self.OnEvent) - optionsWatcher:SetScript('OnShow', function(watcher) - watcher:SetScript('OnShow', nil) - LoadAddOn(AddonName .. '_Config') - end) - end + -- register any events we need to watch + self:RegisterEvent('ADDON_LOADED') + self:RegisterEvent('PLAYER_LOGIN') + self:RegisterEvent('PLAYER_LOGOUT') + -- drop this method, as we won't need it again + self.OnLoad = nil +end - -- create a frame for handling events and throttling timer updates - do - local eventHandler = CreateFrame('Frame', nil); eventHandler:Hide() - - eventHandler.remain = UPDATE_DELAY +-- addon shown (which in this case means that InterfaceOptionsFrame was shown) +-- load the config addon and get rid of this method +function Addon:OnShow() + LoadAddOn(AddonName .. '_Config') - eventHandler:SetScript('OnEvent', function(handler, ...) - self:OnEvent(...) - end) + -- drop this method, as we won't need it again + self:SetScript('OnShow', nil) + self.OnShow = nil +end - eventHandler:SetScript('OnUpdate', function(handler, elapsed) - local remain = handler.remain - elapsed +function Addon:OnEvent(event, ...) + local func = self[event] - if remain > 0 then - handler.remain = remain - else - handler.remain = UPDATE_DELAY + if func then + func(self, event, ...) + end +end - if not self:UpdateButtons(UPDATE_DELAY - remain) then - handler:Hide() - end - end - end) +-- when the addon finishes loading... +function Addon:ADDON_LOADED(event, addonName) + if addonName ~= AddonName then + return + end - eventHandler:RegisterEvent('PLAYER_LOGIN') - eventHandler:RegisterEvent('PLAYER_LOGOUT') + -- setup our saved settings stuff + self:SetupDatabase() - self.updater = eventHandler - end + -- get rid of the handler, as we don't need it anymore + self:UnregisterEvent(event) + self[event] = nil +end - --make thyself global - _G[AddonName] = self +-- when the player first logs in... +function Addon:PLAYER_LOGIN(event) + local function button_StartFlash(button) + if button:IsVisible() then + self:StartButtonFlashing(button) + end + end + + local function actionButton_OnShowHide(button) + self:UpdateActionButtonWatched(button) + self:UpdateButtonFlashing(button) + end + + local function actionButton_Update(button) + self:UpdateActionButtonWatched(button) + end + + local function actionButton_UpdateUsable(button) + self:UpdateActionButtonState(button, true) + end + + + + -- register existing action buttons + -- the method varies between classic and shadowlands, as action buttons in + -- shadowlands use ActionBarActionButtonMixin + local ActionBarActionButtonMixin = _G.ActionBarActionButtonMixin + if ActionBarActionButtonMixin then + local function actionButton_OnLoad(button) + button:SetScript("OnUpdate", nil) + button:HookScript('OnShow', actionButton_OnShowHide) + button:HookScript('OnHide', actionButton_OnShowHide) + + -- Update is called whenever an action button changes, so we + -- check here to we if we need to pay attention to the button anymore + hooksecurefunc(button, 'Update', actionButton_Update) + + -- UpdateUsable is called when the button normally changes + -- color when unusuable, so we need to reapply our custom coloring + hooksecurefunc(button, 'UpdateUsable', actionButton_UpdateUsable) + + if self:EnableFlashAnimations() then + hooksecurefunc(button, 'StartFlash', button_StartFlash) + end + + self:UpdateActionButtonWatched(button) + end + + -- hook any existing frames that are derived from ActionBarActionButtonMixin + local mixin_OnLoad = ActionBarActionButtonMixin.OnLoad + local EnumerateFrames = _G.EnumerateFrames + local f = EnumerateFrames() + + while f do + if f.OnLoad == mixin_OnLoad then + actionButton_OnLoad(f) + end + + f = EnumerateFrames(f) + end + + -- grab later ones, too + hooksecurefunc(ActionBarActionButtonMixin, "OnLoad", actionButton_OnLoad) + else + local function actionButton_OnUpdate(button) + button:SetScript('OnUpdate', nil) + button:HookScript('OnShow', actionButton_OnShowHide) + button:HookScript('OnHide', actionButton_OnShowHide) + + self:UpdateActionButtonWatched(button) + end + + -- hook any action button events we need to take care of + -- register events on update initially, and wipe out their individual on + -- update handlers. This is why tullaRange has a negative performance + -- impact + hooksecurefunc('ActionButton_OnUpdate', actionButton_OnUpdate) + + -- ActionButton_UpdateUsable is called when the button normally changes + -- color when unusuable, so we need to reapply our custom coloring at this + -- point + hooksecurefunc('ActionButton_UpdateUsable', actionButton_UpdateUsable) + + -- ActionButton_Update is called whenever an action button changes, so we + -- check here to we if we need to pay attention to the button anymore or not + hooksecurefunc('ActionButton_Update', actionButton_Update) + + -- setup flash animations + if self:EnableFlashAnimations() then + hooksecurefunc('ActionButton_StartFlash', button_StartFlash) + end + end + + -- register pet actions, if we want to + if self:EnablePetActions() then + -- register all pet action slots + self.petActions = {} + + for i = 1, NUM_PET_ACTION_SLOTS do + tinsert(self.petActions, _G['PetActionButton' .. i]) + end + + local function petButton_OnShowHide(button) + self:UpdatePetActionButtonWatched(button) + self:UpdateButtonFlashing(button) + end + + local function petButton_OnUpdate(button) + button:SetScript('OnUpdate', nil) + button:HookScript('OnShow', petButton_OnShowHide) + button:HookScript('OnHide', petButton_OnShowHide) + self:UpdatePetActionButtonWatched(button) + end + + local function petActionBar_Update(bar) + -- reset the timer on update, so that we don't trigger the bar's + -- own range updater code + bar.rangeTimer = nil + + -- if we have a bar, update all the actions + if PetHasActionBar() then + for _, button in pairs(self.petActions) do + -- clear our current styling + self.buttonStates[button] = nil + self:UpdatePetActionButtonWatched(button) + end + -- if we don't, wipe any actions we currently are showing + else + wipe(self.watchedPetActions) + end + end + + -- hook any pet button events we need to take care of + -- register events on update initially, and wipe out their individual on + -- update handlers. + hooksecurefunc('PetActionButton_OnUpdate', petButton_OnUpdate) + hooksecurefunc('PetActionBar_Update', petActionBar_Update) + + if self:EnableFlashAnimations() then + hooksecurefunc('PetActionButton_StartFlash', button_StartFlash) + end + end + + -- get rid of the handler, as we don't need it anymore + self:UnregisterEvent(event) + self[event] = nil end +function Addon:PLAYER_LOGOUT() + self:CleanupDatabase() +end ---[[ - Frame Events ---]] +-------------------------------------------------------------------------------- +-- Update API +-------------------------------------------------------------------------------- + +local function handleUpdate() + if Addon:UpdateButtonStates() then + Addon.updating = GetTime() + After(UPDATE_DELAY, handleUpdate) + else + Addon.updating = nil + end +end -function Addon:OnEvent(event, ...) - local action = self[event] +function Addon:RequestUpdate() + if self.updating ~= nil then + return + end - if action then - action(self, event, ...) - end + self.updating = GetTime() + After(UPDATE_DELAY, handleUpdate) end -function Addon:PLAYER_LOGIN() - self:SetupDatabase() - self:HookActionEvents() -end +function Addon:SetButtonState(button, state, force) + if self.buttonStates[button] == state and not force then + return + end -function Addon:PLAYER_LOGOUT() - self:CleanupDatabase() -end + self.buttonStates[button] = state + local r, g, b, a = self:GetColor(state) ---[[ - Button Hooking ---]] + button.icon:SetVertexColor(r, g, b, a) +end -do - local function button_UpdateStatus(button) - Addon:UpdateButtonStatus(button) - end +function Addon:UpdateButtonStates(force) + local updatedButtons = false - local function button_UpdateUsable(button) - Addon:UpdateButtonUsable(button, true) - end + if next(self.watchedActions) then + for button in pairs(self.watchedActions) do + self:UpdateActionButtonState(button, force) + end - local function button_Register(button) - Addon:Register(button) - end + updatedButtons = true + end - function Addon:HookActionEvents() - hooksecurefunc('ActionButton_OnUpdate', button_Register) - hooksecurefunc('ActionButton_UpdateUsable', button_UpdateUsable) - hooksecurefunc('ActionButton_Update', button_UpdateStatus) - end + if next(self.watchedPetActions) then + for button in pairs(self.watchedPetActions) do + self:UpdatePetActionButtonState(button, force) + end - function Addon:Register(button) - button:HookScript('OnShow', button_UpdateStatus) - button:HookScript('OnHide', button_UpdateStatus) - button:SetScript('OnUpdate', nil) + updatedButtons = true + end - self:UpdateButtonStatus(button) - end + return updatedButtons end +-- action button specific methods + +-- gets the current state of the action button +function Addon:GetActionButtonState(button) + local action = button.action + local isUsable, notEnoughMana = IsUsableAction(action) + local inRange = IsActionInRange(action) + + -- usable (ignoring target information) + if isUsable then + -- but out of range + if inRange == false then + return 'oor' + else + return 'normal' + end + elseif notEnoughMana then + return 'oom' + else + return 'unusable' + end +end ---[[ - Actions ---]] - -function Addon:RequestUpdate() - if next(self.buttonsToUpdate) then - self.updater:Show() - end +function Addon:UpdateActionButtonState(button, force) + self:SetButtonState(button, self:GetActionButtonState(button), force) end -function Addon:UpdateButtons(elapsed) - if next(self.buttonsToUpdate) then - for button in pairs(self.buttonsToUpdate) do - self:UpdateButton(button, elapsed) - end +function Addon:UpdateActionButtonWatched(button) + local action = button.action - return true - end + if action and button:IsVisible() and ActionHasRange(action) then + self.watchedActions[button] = true + else + self.watchedActions[button] = nil + end - return false + self:RequestUpdate() end -function Addon:UpdateButton(button, elapsed) - self:UpdateButtonUsable(button) - self:UpdateButtonFlash(button, elapsed) +-- pet action button specific stuff +function Addon:GetPetActionButtonState(button) + local slot = button:GetID() or 0 + local _, _, _, _, _, _, _, checksRange, inRange = GetPetActionInfo(slot) + local isUsable, notEnoughMana = GetPetActionSlotUsable(slot) + + -- usable (ignoring target information) + if isUsable then + -- but out of range + if checksRange and not inRange then + return 'oor' + else + return 'normal' + end + elseif notEnoughMana then + return 'oom' + else + return 'unusable' + end end -function Addon:UpdateButtonUsable(button, force) - if force then - self.buttonColors[button] = nil - end +function Addon:UpdatePetActionButtonState(button, force) + self:SetButtonState(button, self:GetPetActionButtonState(button), force) +end - local action = button.action - local isUsable, notEnoughMana = IsUsableAction(action) +function Addon:UpdatePetActionButtonWatched(button) + local slot = button:GetID() or 0 + local _, _, _, _, _, _, _, checksRange = GetPetActionInfo(slot) - --usable (ignoring target information) - if isUsable then - local inRange = IsActionInRange(action) + if button:IsVisible() and checksRange then + self.watchedPetActions[button] = true + else + self.watchedPetActions[button] = nil + end - --but out of range - if inRange == false then - self:SetButtonColor(button, 'oor') - else - self:SetButtonColor(button, 'normal') - end - --out of mana - elseif notEnoughMana then - self:SetButtonColor(button, 'oom') - --unusable - else - self:SetButtonColor(button, 'unusable') - end + self:RequestUpdate() end -function Addon:UpdateButtonFlash(button, elapsed) - if button.flashing ~= 1 then return end +-------------------------------------------------------------------------------- +-- Flashing replacement +-------------------------------------------------------------------------------- - local flashtime = button.flashtime - elapsed +local function alpha_OnFinished(self) + local owner = self.owner - if flashtime <= 0 then - local overtime = -flashtime + if owner.flashing ~= 1 then + Addon:StopButtonFlashing(owner) + end +end - if overtime >= ATTACK_BUTTON_FLASH_TIME then - overtime = 0 - end +function Addon:StartButtonFlashing(button) + local animation = self.flashAnimations and self.flashAnimations[button] - flashtime = ATTACK_BUTTON_FLASH_TIME - overtime + if not animation then + animation = button.Flash:CreateAnimationGroup() + animation:SetLooping('BOUNCE') - local flashTexture = button.Flash - if flashTexture:IsShown() then - flashTexture:Hide() - else - flashTexture:Show() - end - end + local alpha = animation:CreateAnimation('ALPHA') - button.flashtime = flashtime -end + alpha:SetDuration(self:GetFlashDuration()) + alpha:SetFromAlpha(0) + alpha:SetToAlpha(1) + alpha:SetScript('OnFinished', alpha_OnFinished) -function Addon:UpdateButtonStatus(button) - local action = button.action + alpha.owner = button - if action and button:IsVisible() and HasAction(action) then - self.buttonsToUpdate[button] = true - else - self.buttonsToUpdate[button] = nil - end + if self.flashAnimations then + self.flashAnimations[button] = animation + else + self.flashAnimations = { [button] = animation } + end + end - self:RequestUpdate() + button.Flash:Show() + animation:Play() end -function Addon:SetButtonColor(button, colorIndex) - if self.buttonColors[button] == colorIndex then return end +function Addon:StopButtonFlashing(button) + local animation = self.flashAnimations and self.flashAnimations[button] - self.buttonColors[button] = colorIndex + if animation then + animation:Stop() + button.Flash:Hide() + end +end - local r, g, b = self:GetColor(colorIndex) - button.icon:SetVertexColor(r, g, b) +function Addon:UpdateButtonFlashing(button) + if button.flashing == 1 and button:IsVisible() then + self:StartButtonFlashing(button) + else + self:StopButtonFlashing(button) + end end +-------------------------------------------------------------------------------- +-- Saved settings setup stuff +-------------------------------------------------------------------------------- ---[[ - Configuration ---]] +local function removeDefaults(tbl, defaults) + for k, v in pairs(defaults) do + if type(tbl[k]) == 'table' and type(v) == 'table' then + removeDefaults(tbl[k], v) + if next(tbl[k]) == nil then + tbl[k] = nil + end + elseif tbl[k] == v then + tbl[k] = nil + end + end + + return tbl +end + +local function copyDefaults(tbl, defaults) + for k, v in pairs(defaults) do + if type(v) == 'table' then + tbl[k] = copyDefaults(tbl[k] or {}, v) + elseif tbl[k] == nil then + tbl[k] = v + end + end + + return tbl +end function Addon:SetupDatabase() - local sets = _G[DB_KEY] + local sets = _G[DB_KEY] - if not sets then - sets = {} - _G[DB_KEY] = sets - end + if not sets then + sets = {} + _G[DB_KEY] = sets + end - self.sets = copyDefaults(sets, self:GetDatabaseDefaults()) + self.sets = copyDefaults(sets, self:GetDatabaseDefaults()) end function Addon:CleanupDatabase() - local sets = self.sets + local sets = self.sets - if sets then - removeDefaults(sets, self:GetDatabaseDefaults()) - end + if sets then + removeDefaults(sets, self:GetDatabaseDefaults()) + end end function Addon:GetDatabaseDefaults() - return { - normal = {1, 1, 1}, - oor = {1, 0.3, 0.1}, - oom = {0.1, 0.3, 1}, - unusable = {0.4, 0.4, 0.4} - } + return { + -- enable range coloring on pet actions + petActions = true, + + -- enable flash animations, + flashAnimations = true, + flashDuration = ATTACK_BUTTON_FLASH_TIME * 1.5, + + -- default color (r, g, b, a) + normal = {1, 1, 1, 1}, + -- out of range + oor = {1, 0.3, 0.1, 1}, + -- out of mana + oom = {0.1, 0.3, 1, 1}, + -- unusable action + unusable = {0.4, 0.4, 0.4, 1} + } end function Addon:ResetDatabase() - _G[DB_KEY] = nil + _G[DB_KEY] = nil - self:SetupDatabase() - self:ForceColorUpdate() + self:SetupDatabase() + self:UpdateButtonStates(true) end -function Addon:SetColor(index, r, g, b) - local color = self.sets[index] +-------------------------------------------------------------------------------- +-- Configuration API +-------------------------------------------------------------------------------- - color[1] = r - color[2] = g - color[3] = b +function Addon:GetColor(state) + local color = self.sets[state] - self:ForceColorUpdate() + return color[1], color[2], color[3], color[4] end -function Addon:GetColor(index) - local color = self.sets[index] +function Addon:SetColor(state, r, g, b, a) + local color = self.sets[state] - return color[1], color[2], color[3] + color[1] = r + color[2] = g + color[3] = b + color[4] = a or 1 + + self:UpdateButtonStates(true) +end + +-- gets or sets enabling action button flashing +function Addon:EnableFlashAnimations() + return self.sets.flashAnimations +end + +function Addon:SetEnableFlashAnimations(enable) + self.sets.flashAnimations = enable end -function Addon:ForceColorUpdate() - for button in pairs(self.buttonsToUpdate) do - self:UpdateButtonUsable(button, true) - end +-- sets the flash animation speed +function Addon:GetFlashDuration() + return self.sets.flashDuration end +function Addon:SetFlashDuration(duration) + self.sets.flashDuration = tonumber(duration) +end + +-- gets or sets enabling out of range coloring on pet actions +function Addon:EnablePetActions() + return self.sets.petActions +end + +function Addon:SetEnablePetActions(enable) + self.sets.petActions = enable +end ---[[ Load The Thing ]]-- -Addon:Load() \ No newline at end of file +-- load the addon +Addon:OnLoad() diff --git a/embeds/tullaRange/tullaRange.toc b/embeds/tullaRange/tullaRange.toc new file mode 100644 index 0000000..334761d --- /dev/null +++ b/embeds/tullaRange/tullaRange.toc @@ -0,0 +1,7 @@ +## Interface: 90001 +## Title: tullaRange +## Author: Tuller +## Notes: Out of range coloring based on RedRange +## Version: v9.0.0-beta +## SavedVariables: TULLARANGE_COLORS +tullaRange.lua diff --git a/embeds/tullaRange_Config/colorOptions.lua b/embeds/tullaRange_Config/colorOptions.lua new file mode 100644 index 0000000..336915b --- /dev/null +++ b/embeds/tullaRange_Config/colorOptions.lua @@ -0,0 +1,111 @@ +--[[ + Frame.lua + General Bagnon settings +--]] + +local _, Addon = ... +local L = Addon.L + +local ColorOptions +do + ColorOptions = Addon.OptionsPanel:New( + 'tullaRange_ColorOptions', + nil, + 'tullaRange', + L.ColorSettingsTitle + ) + + -- ColorOptions:Hide() + + Addon.ColorOptions = ColorOptions +end + +local SPACING = 4 +local COLOR_TYPES = {'oor', 'oom', 'unusable'} + +--[[ + Startup +--]] + +function ColorOptions:Load() + self:SetScript('OnShow', self.OnShow) + self:AddWidgets() + self:UpdateWidgets() +end + + +--[[ + Frame Events +--]] + +function ColorOptions:OnShow() + self:UpdateWidgets() +end + + +--[[ + Components +--]] + +function ColorOptions:AddWidgets() + local lastSelector = nil + + for i, type in self:GetColorTypes() do + local selector = self:CreateColorSelector(type) + + selector:SetHeight(132) + + if i == 1 then + selector:SetPoint('TOPLEFT', 12, -84) + selector:SetPoint('TOPRIGHT', -12, -84) + else + selector:SetPoint('TOPLEFT', lastSelector, 'BOTTOMLEFT', 0, -(SPACING + 24)) + selector:SetPoint('TOPRIGHT', lastSelector, 'BOTTOMRIGHT', 0, -(SPACING + 24)) + end + + lastSelector = selector + end +end + +function ColorOptions:UpdateWidgets() + if not self:IsVisible() then + return + end + + if self.sliders then + for _, s in pairs(self.sliders) do + s:UpdateValue() + end + end + + for _, type in self:GetColorTypes() do + local selector = self:GetColorSelector(type) + selector:UpdateValues() + end +end + +function ColorOptions:GetColorTypes() + return pairs(COLOR_TYPES) +end + + +--[[ Color Pickers ]]-- + +--frame color +function ColorOptions:CreateColorSelector(type) + local selector = Addon.ColorSelector:New(type, self) + + local colorSelectors = self.colorSelectors or {} + colorSelectors[type] = selector + self.colorSelectors = colorSelectors + + return selector +end + +function ColorOptions:GetColorSelector(type) + return self.colorSelectors and self.colorSelectors[type] +end + +--[[ Load the thing ]]-- + +ColorOptions:Load() \ No newline at end of file diff --git a/embeds/tullaRange_Config/localization/localization.cn.lua b/embeds/tullaRange_Config/localization/localization.cn.lua new file mode 100644 index 0000000..b612109 --- /dev/null +++ b/embeds/tullaRange_Config/localization/localization.cn.lua @@ -0,0 +1,22 @@ +--[[tullaRange Config Localization - Simplified Chinese by Masini]] + +if GetLocale() ~= 'zhCN' then return end + +local AddonName, Addon = ... +local L = Addon.L + +L.ColorSettings = '颜色' + +L.ColorSettingsTitle = 'tullaRange颜色设置设定' + +L.oor = '超出距离' + +L.oom = '魔力不足' + +L.unusable = '不稳定' + +L.Red = '红' + +L.Green = '绿' + +L.Blue = '蓝' diff --git a/embeds/tullaRange_Config/localization/localization.de.lua b/embeds/tullaRange_Config/localization/localization.de.lua new file mode 100644 index 0000000..cc3e230 --- /dev/null +++ b/embeds/tullaRange_Config/localization/localization.de.lua @@ -0,0 +1,22 @@ +--[[tullaRange Config Localization - German]] + +if GetLocale() ~= 'deDE' then return end + +local AddonName, Addon = ... +local L = Addon.L + +L.ColorSettings = 'Farben' + +L.ColorSettingsTitle = 'Hier kannst du Farbeinstellungen vornehmen' + +L.oor = 'Außer Reichweite' + +L.oom = 'Nicht genug Mana' + +L.unusable = 'Nicht benutzbar' + +L.Red = 'Rot' + +L.Green = 'Grün' + +L.Blue = 'Blau' diff --git a/embeds/tullaRange_Config/localization/localization.it.lua b/embeds/tullaRange_Config/localization/localization.it.lua new file mode 100644 index 0000000..db681ec --- /dev/null +++ b/embeds/tullaRange_Config/localization/localization.it.lua @@ -0,0 +1,22 @@ +--[[tullaRange Config Localization - Italian]] + +if GetLocale() ~= 'itIT' then return end + +local AddonName, Addon = ... +local L = Addon.L + +L.ColorSettings = 'Colori' + +L.ColorSettingsTitle = 'Impostazioni per la configurazione del colore' + +L.oor = 'Bersaglio distante' + +L.oom = 'Mana scarso' + +L.unusable = 'Non utilizzabile' + +L.Red = 'Rosso' + +L.Green = 'Verde' + +L.Blue = 'Blu' diff --git a/embeds/tullaRange_Config/localization/localization.ko.lua b/embeds/tullaRange_Config/localization/localization.ko.lua new file mode 100644 index 0000000..12c5f14 --- /dev/null +++ b/embeds/tullaRange_Config/localization/localization.ko.lua @@ -0,0 +1,20 @@ +if GetLocale() ~= 'koKR' then return end + +local AddonName, Addon = ... +local L = Addon.L + +L.ColorSettings = '색상' + +L.ColorSettingsTitle = 'tullaRange 색상 구성 설정' + +L.oor = '사정거리 벗어남' + +L.oom = '마나 부족' + +L.unusable = '사용불가' + +L.Red = '빨강' + +L.Green = '녹색' + +L.Blue = '파랑' diff --git a/embeds/tullaRange_Config/localization/localization.lua b/embeds/tullaRange_Config/localization/localization.lua new file mode 100644 index 0000000..98cfabc --- /dev/null +++ b/embeds/tullaRange_Config/localization/localization.lua @@ -0,0 +1,25 @@ +--[[ + tullaRangeConfig localization +--]] + +local AddonName, Addon = ... + +local L = { + ColorSettings = 'Colors', + + ColorSettingsTitle = 'tullaRange color configuration settings', + + oor = 'Out of Range', + + oom = 'Out of Mana', + + unusable = 'Unusable', + + Red = 'Red', + + Green = 'Green', + + Blue = 'Blue' +} + +Addon.L = setmetatable(L, { __index = function(t, k) return k end }) \ No newline at end of file diff --git a/embeds/tullaRange_Config/localization/localization.tw.lua b/embeds/tullaRange_Config/localization/localization.tw.lua new file mode 100644 index 0000000..49a0f6e --- /dev/null +++ b/embeds/tullaRange_Config/localization/localization.tw.lua @@ -0,0 +1,22 @@ +--[[tullaRange Config Localization - Traditional Chinese by Masini]] + +if GetLocale() ~= 'zhTW' then return end + +local AddonName, Addon = ... +local L = Addon.L + +L.ColorSettings = '顏色' + +L.ColorSettingsTitle = 'tullaRange顏色設置設定' + +L.oor = '超出距離' + +L.oom = '魔力不足' + +L.unusable = '不穩定' + +L.Red = '紅' + +L.Green = '綠' + +L.Blue = '藍' diff --git a/embeds/tullaRange_Config/localization/localization.xml b/embeds/tullaRange_Config/localization/localization.xml new file mode 100644 index 0000000..f558235 --- /dev/null +++ b/embeds/tullaRange_Config/localization/localization.xml @@ -0,0 +1,8 @@ + +