PK ZI!OO 0 0 ! WeaponSwingTimer/localization.lualocal addon_name, addon_data = ... addon_data.localization_table = {} local L = addon_data.localization_table if GetLocale() == "deDE" then L["Thank you for installing WeaponSwingTimer Version"] = "Vielen Dank, dass Sie die WeaponSwingTimer-Version installiert haben" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "von LeftHandedGlove! Verwenden Sie |cFFFFC300/wst|r für weitere Optionen." end if GetLocale() == "enUS" then L["Thank you for installing WeaponSwingTimer Version"] = "Thank you for installing WeaponSwingTimer Version" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "by LeftHandedGlove! Use |cFFFFC300/wst|r for more options." end if GetLocale() == "esES" then L["Thank you for installing WeaponSwingTimer Version"] = "Gracias por instalar la versión WeaponSwingTimer" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "por LeftHandedGlove! Use |cFFFFC300/wst|r para más opciones." end if GetLocale() == "esMX" then L["Thank you for installing WeaponSwingTimer Version"] = "Gracias por instalar la versión WeaponSwingTimer" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "por LeftHandedGlove! Use |cFFFFC300/wst|r para más opciones." end if GetLocale() == "frFR" then L["Thank you for installing WeaponSwingTimer Version"] = "Merci d’avoir installé la version WeaponSwingTimer" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "par LeftHandedGlove! Utilisez |cFFFFC300/wst|r pour plus d'options." end if GetLocale() == "itIT" then L["Thank you for installing WeaponSwingTimer Version"] = "Grazie per aver installato la versione di WeaponSwingTimer" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "di LeftHandedGlove! Utilizzare |cFFFFC300/wst|r per ulteriori opzioni." end if GetLocale() == "koKR" then L["Thank you for installing WeaponSwingTimer Version"] = "WeaponSwingTimer 버전을 설치해 주셔서 감사합니다" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "LeftHandedGlove 제작 더 많은 옵션을 보려면 |cFFFFC300/wst|r을 사용하십시오." end if GetLocale() == "ptBR" then L["Thank you for installing WeaponSwingTimer Version"] = "Obrigado por instalar a versão WeaponSwingTimer" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "por LeftHandedGlove! Use |cFFFFC300/wst|r para obter mais opções." end if GetLocale() == "ruRU" then L["Thank you for installing WeaponSwingTimer Version"] = "Спасибо за установку версии WeaponSwingTimer" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "LeftHandedGlove! Используйте |cFFFFC300/wst|r для получения дополнительных опций." end if GetLocale() == "zhCN" then L["Thank you for installing WeaponSwingTimer Version"] = "感谢您安装WeaponSwingTimer版本" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "by LeftHandedGlove!使用|cFFFFC300/wst|r获取更多选项。" end if GetLocale() == "zhTW" then L["Thank you for installing WeaponSwingTimer Version"] = "感謝您安裝WeaponSwingTimer版本" L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] = "by LeftHandedGlove!使用|cFFFFC300/wst|r獲取更多選項。" end PK AO 9L L WeaponSwingTimer/README.md
# WeaponSwingTimer WeaponSwingTimer is an addon for WoW Classic that tracks your's and your target's swing timers. If you're a hunter, it also tracks Auto Shot timing and castable shots cast time. If you use a wand, it also tracks when your shot will go off. ## Latest Update Video https://www.youtube.com/watch?v=o_b7PZxIuls ## Visuals ### Melee Bars ![alt text](Images/MeleeBars.png) ### YaHT Style Shot Bar ![alt text](Images/YaHTShotBar.png) ### One Bar Style Shot Bar ![alt text](Images/OneBarShotBar.png) ## Melee Bars The melee bars track the player's and target's main-hand and off-hand swings. It resets on abilities that would reset a swing timer, such as Warrior's Slam, and also takes parry haste into account. Both frames can be moved around with the typical click-and-drag. A configuration window can be brought up with /wst /WeaponSwingTimer or /weaponswingtimer where more visual options are available. ![alt text](Images/MeleeBars.png) ![alt text](Images/MeleeConfigWindow.png) ## Hunter/Wand Bars The shot bars track the player's Auto Shot and Shoot timing and also track the cast time for Aimed Shot and Multi-Shot. The shot bar turns white when projectile leaves the player. While the bar is white, the player can move and cast freely without clipping their next Auto Shot or Shoot. When the white bar is depleted, the player should stand still while their Auto Shot or Shoot is 'casting'. ![alt text](Images/YaHTShotBar.png) ![alt text](Images/OneBarShotBar.png) ![alt text](Images/HunterConfigWindow.png) ## Installation ### CurseForge / WoW Interface 1. Download the latest version 2. Unzip the file into Interface\Addons. 3. It should look like Interface\Addons\WeaponSwingTimer\WeaponSwingTimer.toc ### GitHub 1. Click the download button on the repository's Github page, then select Download ZIP. 2. Wait for the zip file to download 3. Unzip the file into Interface\Addons. 4. It should look like Interface\Addons\WeaponSwingTimer\WeaponSwingTimer.toc ### Git Clone 1. Clone the repository into Interface\Addons. 2. It should look like Interface\Addons\WeaponSwingTimer\WeaponSwingTimer.toc PK hJ!OGe % WeaponSwingTimer/WeaponSwingTimer.toc## Interface: 11302 ## Title-deDE: WeaponSwingTimer (Deutsch) ## Title-enUS: WeaponSwingTimer (English) ## Title-esES: WeaponSwingTimer (Español) ## Title-esMX: WeaponSwingTimer (Español) ## Title-frFR: WeaponSwingTimer (Français) ## Title-itIT: WeaponSwingTimer (Italiano) ## Title-koKR: WeaponSwingTimer (한국어) ## Title-ptBR: WeaponSwingTimer (Português) ## Title-ruRU: WeaponSwingTimer (русский) ## Title-zhCN: WeaponSwingTimer (中文) ## Title-zhTW: WeaponSwingTimer (中文) ## Notes-deDE: Zeichnet die Schwungzeiten für Nahkampfwaffen auf. Hunters Auto Shot und Wands Shoot. ## Notes-enUS: Tracks swing times for melee weapons, Hunter's Auto Shot, and wand's Shoot. ## Notes-esES: Rastrea los tiempos de swing de las armas cuerpo a cuerpo Hunters Auto Shot y las varitas Shoot. ## Notes-esMX: Rastrea los tiempos de swing de las armas cuerpo a cuerpo Hunters Auto Shot y las varitas Shoot. ## Notes-frFR: Suit les temps de swing pour les armes de mêlée Hunters Auto Shot et les baguettes magiques Shoot. ## Notes-itIT: Tiene traccia dei tempi di oscillazione per le armi da mischia. Cacciatori Auto Shot e bacchette. ## Notes-koKR: 근접 무기 사냥꾼 자동 사격 및 지팡이 사격의 스윙 시간을 추적합니다. ## Notes-ptBR: Rastreia os tempos de balanço para armas corpo-a-corpo Caçadores Auto-tiro e varinhas Atire. ## Notes-ruRU: Отслеживает время прохождения оружия ближнего боя. Охотники с автоматическим выстрелом и палочки стреляют. ## Notes-zhCN: 跟踪近战武器的挥动时间猎人自动射击和魔杖射击。 ## Notes-zhTW: 跟踪近戰武器的揮動時間獵人自動射擊和魔杖射擊。 ## Author: LeftHandedGlove ## Version: 4.1.0 ## DefaultState: enabled ## OptionalDeps: ColorPickerPlus ## SavedVariablesPerCharacter: character_core_settings, character_player_settings, character_target_settings, character_hunter_settings localization.lua WeaponSwingTimer_Utils.lua WeaponSwingTimer_Player.lua WeaponSwingTimer_Target.lua WeaponSwingTimer_Hunter.lua WeaponSwingTimer_Config.lua WeaponSwingTimer_Core.luaPK ^O6}*# *# , WeaponSwingTimer/WeaponSwingTimer_Config.lualocal addon_name, addon_data = ... addon_data.config = {} addon_data.config.OnDefault = function() addon_data.core.RestoreAllDefaults() addon_data.config.UpdateConfigValues() end addon_data.config.InitializeVisuals = function() -- Add the parent panel addon_data.config.config_parent_panel = CreateFrame("Frame", "MyFrame", UIParent) local panel = addon_data.config.config_parent_panel panel:SetSize(1, 1) panel.global_panel = addon_data.config.CreateConfigPanel(panel) panel.global_panel:SetPoint('TOPLEFT', 10, -10) panel.global_panel:SetSize(1, 1) panel.logo = panel:CreateTexture(nil, 'ARTWORK') panel.logo:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/LandingPage') panel.logo:SetSize(1024, 1024) panel.logo:SetPoint('TOPLEFT', 5, -10) panel.name = "WeaponSwingTimer" panel.default = addon_data.config.OnDefault InterfaceOptions_AddCategory(panel) -- Add the melee panel panel.config_melee_panel = CreateFrame("Frame", nil, panel) panel.config_melee_panel:SetSize(1, 1) panel.config_melee_panel.player_panel = addon_data.player.CreateConfigPanel(panel.config_melee_panel) panel.config_melee_panel.player_panel:SetPoint('TOPLEFT', 0, 0) panel.config_melee_panel.player_panel:SetSize(1, 1) panel.config_melee_panel.target_panel = addon_data.target.CreateConfigPanel(panel.config_melee_panel) panel.config_melee_panel.target_panel:SetPoint('TOPLEFT', 0, -275) panel.config_melee_panel.target_panel:SetSize(1, 1) panel.config_melee_panel.name = 'Melee Settings' panel.config_melee_panel.parent = panel.name panel.config_melee_panel.default = addon_data.config.OnDefault InterfaceOptions_AddCategory(panel.config_melee_panel) -- Add the hunter panel panel.config_hunter_panel = CreateFrame("Frame", nil, panel) panel.config_hunter_panel:SetSize(1, 1) panel.config_hunter_panel.hunter_panel = addon_data.hunter.CreateConfigPanel(panel.config_hunter_panel) panel.config_hunter_panel.hunter_panel:SetPoint('TOPLEFT', 0, 0) panel.config_hunter_panel.hunter_panel:SetSize(1, 1) panel.config_hunter_panel.name = 'Hunter & Wand Settings' panel.config_hunter_panel.parent = panel.name panel.config_hunter_panel.default = addon_data.config.OnDefault InterfaceOptions_AddCategory(panel.config_hunter_panel) end addon_data.config.TextFactory = function(parent, text, size) local text_obj = parent:CreateFontString(nil, "ARTWORK") text_obj:SetFont("Fonts/FRIZQT__.ttf", size) text_obj:SetJustifyV("CENTER") text_obj:SetJustifyH("CENTER") text_obj:SetText(text) return text_obj end addon_data.config.CheckBoxFactory = function(g_name, parent, checkbtn_text, tooltip_text, on_click_func) local checkbox = CreateFrame("CheckButton", addon_name .. g_name, parent, "ChatConfigCheckButtonTemplate") getglobal(checkbox:GetName() .. 'Text'):SetText(checkbtn_text) checkbox.tooltip = tooltip_text checkbox:SetScript("OnClick", function(self) on_click_func(self) end) checkbox:SetScale(1.1) return checkbox end addon_data.config.EditBoxFactory = function(g_name, parent, title, w, h, enter_func) local edit_box_obj = CreateFrame("EditBox", addon_name .. g_name, parent) edit_box_obj.title_text = addon_data.config.TextFactory(edit_box_obj, title, 12) edit_box_obj.title_text:SetPoint("TOP", 0, 12) edit_box_obj:SetBackdrop({ bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "Interface/Tooltips/UI-Tooltip-Border", tile = true, tileSize = 26, edgeSize = 16, insets = { left = 4, right = 4, top = 4, bottom = 4} }) edit_box_obj:SetBackdropColor(0,0,0,1) edit_box_obj:SetSize(w, h) edit_box_obj:SetMultiLine(false) edit_box_obj:SetAutoFocus(false) edit_box_obj:SetMaxLetters(4) edit_box_obj:SetJustifyH("CENTER") edit_box_obj:SetJustifyV("CENTER") edit_box_obj:SetFontObject(GameFontNormal) edit_box_obj:SetScript("OnEnterPressed", function(self) enter_func(self) self:ClearFocus() end) edit_box_obj:SetScript("OnTextChanged", function(self) if self:GetText() ~= "" then enter_func(self) end end) edit_box_obj:SetScript("OnEscapePressed", function(self) self:ClearFocus() end) return edit_box_obj end addon_data.config.SliderFactory = function(g_name, parent, title, min_val, max_val, val_step, func) local slider = CreateFrame("Slider", addon_name .. g_name, parent, "OptionsSliderTemplate") local editbox = CreateFrame("EditBox", "$parentEditBox", slider, "InputBoxTemplate") slider:SetMinMaxValues(min_val, max_val) slider:SetValueStep(val_step) slider.text = _G[addon_name .. g_name .. "Text"] slider.text:SetText(title) slider.textLow = _G[addon_name .. g_name .. "Low"] slider.textHigh = _G[addon_name .. g_name .. "High"] slider.textLow:SetText(floor(min_val)) slider.textHigh:SetText(floor(max_val)) slider.textLow:SetTextColor(0.8,0.8,0.8) slider.textHigh:SetTextColor(0.8,0.8,0.8) slider:SetObeyStepOnDrag(true) editbox:SetSize(45,30) editbox:ClearAllPoints() editbox:SetPoint("LEFT", slider, "RIGHT", 15, 0) editbox:SetText(slider:GetValue()) editbox:SetAutoFocus(false) slider:SetScript("OnValueChanged", function(self) editbox:SetText(tostring(addon_data.utils.SimpleRound(self:GetValue(), val_step))) func(self) end) editbox:SetScript("OnTextChanged", function(self) local val = self:GetText() if tonumber(val) then self:GetParent():SetValue(val) end end) editbox:SetScript("OnEnterPressed", function(self) local val = self:GetText() if tonumber(val) then self:GetParent():SetValue(val) self:ClearFocus() end end) slider.editbox = editbox return slider end addon_data.config.color_picker_factory = function(g_name, parent, r, g, b, a, text, on_click_func) local color_picker = CreateFrame('Button', addon_name .. g_name, parent) color_picker:SetSize(15, 15) color_picker.normal = color_picker:CreateTexture(nil, 'BACKGROUND') color_picker.normal:SetColorTexture(1, 1, 1, 1) color_picker.normal:SetPoint('TOPLEFT', -1, 1) color_picker.normal:SetPoint('BOTTOMRIGHT', 1, -1) color_picker.foreground = color_picker:CreateTexture(nil, 'ARTWORK') color_picker.foreground:SetColorTexture(r, g, b, a) color_picker.foreground:SetAllPoints() color_picker:SetNormalTexture(color_picker.foreground) color_picker:SetScript('OnClick', on_click_func) color_picker.text = addon_data.config.TextFactory(color_picker, text, 12) color_picker.text:SetPoint('LEFT', 25, 0) return color_picker end addon_data.config.UpdateConfigValues = function() local panel = addon_data.config.config_frame local settings = character_player_settings panel.is_locked_checkbox:SetChecked(settings.is_locked) end addon_data.config.IsLockedCheckBoxOnClick = function(self) character_player_settings.is_locked = self:GetChecked() character_target_settings.is_locked = self:GetChecked() character_hunter_settings.is_locked = self:GetChecked() addon_data.player.frame:EnableMouse(not character_target_settings.is_locked) addon_data.target.frame:EnableMouse(not character_target_settings.is_locked) addon_data.hunter.frame:EnableMouse(not character_target_settings.is_locked) addon_data.core.UpdateAllVisualsOnSettingsChange() end addon_data.config.CreateConfigPanel = function(parent_panel) addon_data.config.config_frame = CreateFrame("Frame", addon_name .. "GlobalConfigPanel", parent_panel) local panel = addon_data.config.config_frame local settings = character_player_settings -- Title Text panel.title_text = addon_data.config.TextFactory(panel, "Global Bar Settings", 20) panel.title_text:SetPoint("TOPLEFT", 0, 0) panel.title_text:SetTextColor(1, 0.9, 0, 1) -- Is Locked Checkbox panel.is_locked_checkbox = addon_data.config.CheckBoxFactory( "IsLockedCheckBox", panel, " Lock All Bars", "Locks all of the swing bar frames, preventing them from being dragged.", addon_data.config.IsLockedCheckBoxOnClick) panel.is_locked_checkbox:SetPoint("TOPLEFT", 0, -30) -- Guidance Text panel.guidance_text = addon_data.config.TextFactory(panel, "<- Click the '+' on the left\nfor more options", 16) panel.guidance_text:SetPoint("TOPLEFT", 0, -100) panel.guidance_text:SetTextColor(1, 1, 1, 1) -- Return the final panel addon_data.config.UpdateConfigValues() return panel end PK hJ!OCG"{_ {_ * WeaponSwingTimer/WeaponSwingTimer_Core.lualocal addon_name, addon_data = ... local L = addon_data.localization_table addon_data.core = {} addon_data.core.core_frame = CreateFrame("Frame", addon_name .. "CoreFrame", UIParent) addon_data.core.core_frame:RegisterEvent("ADDON_LOADED") addon_data.core.all_timers = { addon_data.player, addon_data.target } local version = "4.1.0" local load_message = L["Thank you for installing WeaponSwingTimer Version"] .. " " .. version .. " " .. L["by LeftHandedGlove! Use |cFFFFC300/wst|r for more options."] addon_data.core.default_settings = { one_frame = false } addon_data.core.in_combat = false local swing_reset_spells = {} swing_reset_spells['DRUID'] = { -- --[[ Abolish Poison ]] 2893, -- --[[ Aquatic Form ]] 1066, -- --[[ Barkskin ]] 22812, -- --[[ Bash ]] 5211, 6798, 8983, -- --[[ Bear Form ]] 5487, -- --[[ Cat Form ]] 768, -- --[[ Challenging Roar ]] 5209, -- --[[ Claw ]] 1082, 3029, 5201, 9849, 9850, -- --[[ Cower ]] 8998, 9000, 9892, -- --[[ Cure Poison ]] 8946, -- --[[ Dash ]] 1850, 9821, -- --[[ Demoralizing Roar ]] 99, 1735, 9490, 9747, 9898, -- --[[ Dire Bear Form ]] 9634, -- --[[ Enrage ]] 5229, -- --[[ Entangling Roots ]] 339, 1062, 5195, 5196, 9852, 9853, -- --[[ Faerie Fire ]] 770, 778, 9749, 9907, -- --[[ Faerie Fire (Feral) ]] 16857, 17390, 17391, 17392, -- --[[ Feral Charge ]] 16979, -- --[[ Ferocious Bite ]] 22568, 22827, 22828, 22829, 31018, -- --[[ Frenzied Regeneration ]] -- --[[ Gift of the Wild ]] -- --[[ Growl ]] -- --[[ Healing Touch ]] -- --[[ Hibernate ]] -- --[[ Hurricane ]] -- --[[ Innervate ]] -- --[[ Insect Storm ]] -- --[[ Mark of the Wild ]] --[[ Maul ]] 6807, 6808, 6809, 8972, 9745, 9880, 9881 -- --[[ Moonfire ]] -- --[[ Moonkin Form ]] -- --[[ Nature's Grasp ]] -- --[[ Nature's Swiftness ]] -- --[[ Omen of Clarity ]] -- --[[ Pounce ]] -- --[[ Prowl ]] -- --[[ Rake ]] -- --[[ Ravage ]] -- --[[ Rebirth ]] -- --[[ Regrowth ]] -- --[[ Rejuvenation ]] -- --[[ Remove Curse ]] -- --[[ Rip ]] -- --[[ Shred ]] -- --[[ Soothe Animal ]] -- --[[ Starfire ]] -- --[[ Swiftmend ]] -- --[[ Swipe ]] -- --[[ Teleport: Moonglade ]] -- --[[ Thorns ]] -- --[[ Tiger's Fury ]] -- --[[ Track Humanoids ]] -- --[[ Tranquility ]] -- --[[ Travel Form ]] -- --[[ Wrath ]] } swing_reset_spells['HUNTER'] = { -- --[[ Aimed Shot ]] -- --[[ Arcane Shot ]] -- --[[ Aspect of the Beast ]] -- --[[ Aspect of the Cheetah ]] -- --[[ Aspect of the Hawk ]] -- --[[ Aspect of the Monkey ]] -- --[[ Aspect of the Pack ]] -- --[[ Aspect of the Wild ]] -- --[[ Auto Shot ]] -- --[[ Beast Lore ]] -- --[[ Bestial Wrath ]] -- --[[ Call Pet ]] -- --[[ Concussive Shot ]] -- --[[ Counterattack ]] -- --[[ Deterrence ]] -- --[[ Disengage ]] -- --[[ Dismiss Pet ]] -- --[[ Distracting Shot ]] -- --[[ Eagle Eye ]] -- --[[ Explosive Trap ]] -- --[[ Eyes of the Beast ]] -- --[[ Feed Pet ]] -- --[[ Feign Death ]] -- --[[ Flare ]] -- --[[ Freezing Trap ]] -- --[[ Frost Trap ]] -- --[[ Hunter's Mark ]] -- --[[ Immolation Trap ]] -- --[[ Intimidation ]] -- --[[ Mend Pet ]] -- --[[ Mongoose Bite ]] -- --[[ Multi-Shot ]] -- --[[ Rapid Fire ]] --[[ Raptor Strike ]] 2973, 14260, 14261, 14262, 14263, 14264, 14265, 14266, -- --[[ Readiness ]] -- --[[ Revive Pet ]] -- --[[ Scare Beast ]] -- --[[ Scatter Shot ]] -- --[[ Scorpid Sting ]] -- --[[ Serpent Sting ]] -- --[[ Tame Beast ]] -- --[[ Throw ]] -- --[[ Track Beast ]] -- --[[ Track Demons ]] -- --[[ Track Dragonkin ]] -- --[[ Track Elements ]] -- --[[ Track Giants ]] -- --[[ Track Hidden ]] -- --[[ Track Humanoids ]] -- --[[ Track Undead ]] -- --[[ Tranquilizing Shot ]] -- --[[ Trueshot Aura ]] -- --[[ Viper Sting ]] -- --[[ Volley ]] -- --[[ Wing Clip ]] -- --[[ Wyvern Sting ]] } swing_reset_spells['MAGE'] = { -- --[[ Amplify Magic ]] -- --[[ Arcane Brilliance ]] -- --[[ Arcane Explosion ]] -- --[[ Arcane Intellect ]] -- --[[ Arcane Missles ]] -- --[[ Arcane Power ]] -- --[[ Blast Wave ]] -- --[[ Blink ]] -- --[[ Blizzard ]] -- --[[ Cold Snap ]] -- --[[ Combustion ]] -- --[[ Cone of Cold ]] -- --[[ Counterspell ]] -- --[[ Dampen Magic ]] -- --[[ Detect Magic ]] -- --[[ Evocation ]] -- --[[ Fire Blast ]] -- --[[ Fire Ward ]] -- --[[ Fireball ]] -- --[[ Flamestrike ]] -- --[[ Frost Armor ]] -- --[[ Frost Nova ]] -- --[[ Frost Ward ]] -- --[[ Frostbolt ]] -- --[[ Ice Armor ]] -- --[[ Ice Barrier ]] -- --[[ Ice Block ]] -- --[[ Mage Armor ]] -- --[[ Mana Shield ]] -- --[[ Polymorph ]] -- --[[ Polymorph: Cow ]] -- --[[ Polymorph: Pig ]] -- --[[ Polymorph: Turtle ]] -- --[[ Portal: Darnassus ]] -- --[[ Portal: Ironforge ]] -- --[[ Portal: Orgimmar ]] -- --[[ Portal: Stormwind ]] -- --[[ Portal: Thunder Bluff ]] -- --[[ Portal: Undercity ]] -- --[[ Presence of Mind ]] -- --[[ Pyroblast ]] -- --[[ Remove Lesser Curse ]] -- --[[ Scorch ]] -- --[[ Shoot ]] -- --[[ Slow Fall ]] -- --[[ Teleport: Darnassus ]] -- --[[ Teleport: Ironforge ]] -- --[[ Teleport: Orgimmar ]] -- --[[ Teleport: Stormwind ]] -- --[[ Teleport: Thunder Bluff ]] -- --[[ Teleport: Undercity ]] -- --[[ Conjure Food ]] -- --[[ Conjure Mana Agate ]] -- --[[ Conjure Mana Citrine ]] -- --[[ Conjure Mana Jade ]] -- --[[ Conjure Mana Ruby ]] -- --[[ Conjure Water ]] } swing_reset_spells['PALADIN'] = { -- --[[ Blessing of Freedom ]] -- --[[ Blessing of Kings ]] -- --[[ Blessing of Light ]] -- --[[ Blessing of Might ]] -- --[[ Blessing of Protection ]] -- --[[ Blessing of Sacrifice ]] -- --[[ Blessing of Salvation ]] -- --[[ Blessing of Sanctuary ]] -- --[[ Blessing of Wisdom ]] -- --[[ Cleanse ]] -- --[[ Concentration Aura ]] -- --[[ Consecration ]] -- --[[ Devotion Aura ]] -- --[[ Divine Favor ]] -- --[[ Divine Intervention ]] -- --[[ Divine Protection ]] -- --[[ Divine Shield ]] -- --[[ Exorcism ]] -- --[[ Fire Resistance Aura ]] -- --[[ Flash of Light ]] -- --[[ Frost Resistance Aura ]] -- --[[ Greater Blessing of Kings ]] -- --[[ Greater Blessing of Light ]] -- --[[ Greater Blessing of Might ]] -- --[[ Greater Blessing of Salvation ]] -- --[[ Greater Blessing of Sanctuary ]] -- --[[ Greater Blessing of Wisdom ]] -- --[[ Hammer of Justice ]] -- --[[ Hammer of Wrath ]] -- --[[ Holy Light ]] -- --[[ Holy Shield ]] -- --[[ Holy Shock ]] -- --[[ Holy Wrath ]] -- --[[ Judgement ]] -- --[[ Lay on Hands ]] -- --[[ Purify ]] -- --[[ Redemption ]] -- --[[ Repentance ]] -- --[[ Retribution Aura ]] -- --[[ Righteous Fury ]] -- --[[ Sanctity Aura ]] -- --[[ Seal of Command ]] -- --[[ Seal of Justice ]] -- --[[ Seal of Light ]] -- --[[ Seal of Righteousness ]] -- --[[ Seal of the Crusader ]] -- --[[ Seal of Wisdom ]] -- --[[ Sense Undead ]] -- --[[ Shadow Resistance Aura ]] -- --[[ Summon Charger ]] -- --[[ Summon Warhorse ]] -- --[[ Turn Undead ]] } swing_reset_spells['PRIEST'] = { -- --[[ Abolish Disease ]] -- --[[ Cure Disease ]] -- --[[ Desperate Prayer ]] -- --[[ Devouring Plague ]] -- --[[ Dispel Magic ]] -- --[[ Divine Spirit ]] -- --[[ Fade ]] -- --[[ Fear Ward ]] -- --[[ Feedback ]] -- --[[ Flash Heal ]] -- --[[ Greater Heal ]] -- --[[ Heal ]] -- --[[ Hex of Weakness ]] -- --[[ Holy Fire ]] -- --[[ Holy Nova ]] -- --[[ Inner Fire ]] -- --[[ Inner Focus ]] -- --[[ Lesser Heal ]] -- --[[ Levitate ]] -- --[[ Lightwell ]] -- --[[ Mana Burn ]] -- --[[ Mind Blast ]] -- --[[ Mind Control ]] -- --[[ Mind Flay ]] -- --[[ Mind Soothe ]] -- --[[ Mind Vision ]] -- --[[ Power Infusion ]] -- --[[ Power Word: Fortitude ]] -- --[[ Power Word: Shield ]] -- --[[ Prayer of Fortitude ]] -- --[[ Prayer of Healing ]] -- --[[ Prayer of Shadow Protection ]] -- --[[ Prayer of Spirit ]] -- --[[ Psychic Scream ]] -- --[[ Renew ]] -- --[[ Resurrection ]] -- --[[ Shackle Undead ]] -- --[[ Shadow Protection ]] -- --[[ Shadow Word: Pain ]] -- --[[ Shadowform ]] -- --[[ Shadowguard ]] -- --[[ Shoot ]] -- --[[ Silence ]] -- --[[ Smite ]] -- --[[ Starshards ]] -- --[[ Touch of Weakness ]] -- --[[ Vampiric Embrace ]] } swing_reset_spells['ROGUE'] = { -- --[[ Adrenaline Rush ]] -- --[[ Ambush ]] -- --[[ Backstab ]] -- --[[ Blade Flurry ]] -- --[[ Blind ]] -- --[[ Cheap Shot ]] -- --[[ Cold Blood ]] -- --[[ Detect Traps ]] -- --[[ Disarm Trap ]] -- --[[ Distract ]] -- --[[ Evasion ]] -- --[[ Eviscerate ]] -- --[[ Expose Armor ]] -- --[[ Feint ]] -- --[[ Garrote ]] -- --[[ Ghostly Strike ]] -- --[[ Gouge ]] -- --[[ Hemorrhage ]] -- --[[ Kick ]] -- --[[ Kidney Shot ]] -- --[[ Pick Lock ]] -- --[[ Pick Pocket ]] -- --[[ Preparation ]] -- --[[ Riposte ]] -- --[[ Rupture ]] -- --[[ Sap ]] -- --[[ Shoot Bow ]] -- --[[ Shoot Crossbow ]] -- --[[ Shoot Gun ]] -- --[[ Sinister Strike ]] -- --[[ Slice and Dice ]] -- --[[ Sprint ]] -- --[[ Stealth ]] -- --[[ Throw ]] -- --[[ Vanish ]] -- --[[ Blinding Powder ]] -- --[[ Crippling Poison ]] -- --[[ Crippling Poison II ]] -- --[[ Deadly Poison ]] -- --[[ Deadly Poison II ]] -- --[[ Deadly Poison III ]] -- --[[ Deadly Poison IV ]] -- --[[ Deadly Poison V ]] -- --[[ Instant Poison ]] -- --[[ Instant Poison II ]] -- --[[ Instant Poison III ]] -- --[[ Instant Poison IV ]] -- --[[ Instant Poison V ]] -- --[[ Instant Poison VI ]] -- --[[ Mind-numbing Poison ]] -- --[[ Mind-numbing Poison II ]] -- --[[ Mind-numbing Poison III ]] -- --[[ Would Poison ]] -- --[[ Would Poison II ]] -- --[[ Would Poison III ]] -- --[[ Would Poison IV ]] } swing_reset_spells['SHAMAN'] = { -- --[[ Ancestral Spirit ]] -- --[[ Astral Recall ]] -- --[[ Chain Heal ]] -- --[[ Chain Lightning ]] -- --[[ Cure Disease ]] -- --[[ Cure Poison ]] -- --[[ Disease Cleansing Totem ]] -- --[[ Earth Shock ]] -- --[[ Earthbind Totem ]] -- --[[ Elemental Mastery ]] -- --[[ Farsight ]] -- --[[ Fire Nova Totem ]] -- --[[ Fire Resistance Totem ]] -- --[[ Flame Shock ]] -- --[[ Flametongue Totem ]] -- --[[ Flametongue Weapon ]] -- --[[ Frost Resistance Totem ]] -- --[[ Frost Shock ]] -- --[[ Frostbrand Weapon ]] -- --[[ Ghost Wolf ]] -- --[[ Grace of Air Totem ]] -- --[[ Grounding Totem ]] -- --[[ Healing Stream Totem ]] -- --[[ Healing Wave ]] -- --[[ Lesser Healing Wave ]] -- --[[ Lightning Bolt ]] -- --[[ Lightning Shield ]] -- --[[ Magma Totem ]] -- --[[ Mana Spring Totem ]] -- --[[ Mana Tide Totem ]] -- --[[ Nature Resistance Totem ]] -- --[[ Nature's Swiftness ]] -- --[[ Poison Cleansing Totem ]] -- --[[ Purge ]] -- --[[ Reincarnation ]] -- --[[ Rockbiter Weapon ]] -- --[[ Searing Totem ]] -- --[[ Sentry Totem ]] -- --[[ Stoneclaw Totem ]] -- --[[ Stoneskin Totem ]] -- --[[ Stormstrike ]] -- --[[ Strength of Earth Totem ]] -- --[[ Tranquil Air Totem ]] -- --[[ Tremor Totem ]] -- --[[ Water Breathing ]] -- --[[ Water Walking ]] -- --[[ Windfury Totem ]] -- --[[ Windfury Weapon ]] -- --[[ Windwall Totem ]] } swing_reset_spells['WARLOCK'] = { -- --[[ Amplify Curse ]] -- --[[ Banish ]] -- --[[ Conflagrate ]] -- --[[ Corruption ]] -- --[[ Create Healthstone ]] -- --[[ Create Healthstone (Greater) ]] -- --[[ Create Healthstone (Lesser) ]] -- --[[ Create Healthstone (Major) ]] -- --[[ Create Healthstone (Minor) ]] -- --[[ Curse of Agony ]] -- --[[ Curse of Doom ]] -- --[[ Curse of Exhaustion ]] -- --[[ Curse of Recklessness ]] -- --[[ Curse of Shadow ]] -- --[[ Curse of the Elements ]] -- --[[ Curse of Tongues ]] -- --[[ Curse of Weakness ]] -- --[[ Dark Pact ]] -- --[[ Death Coil ]] -- --[[ Demon Armor ]] -- --[[ Demon Skin ]] -- --[[ Demonic Sacrifice ]] -- --[[ Detect Greater Invisibility ]] -- --[[ Detect Invisibility ]] -- --[[ Detect Lesser Invisibility ]] -- --[[ Drain Life ]] -- --[[ Drain Mana ]] -- --[[ Drain Soul ]] -- --[[ Enslave Demon ]] -- --[[ Eye of Kilrogg ]] -- --[[ Fear ]] -- --[[ Fel Domination ]] -- --[[ Health Funnel ]] -- --[[ Hell Fire ]] -- --[[ Howl of Terror ]] -- --[[ Immolate ]] -- --[[ Inferno ]] -- --[[ Life Tap ]] -- --[[ Rain of Fire ]] -- --[[ Ritual of Doom ]] -- --[[ Ritual of Summoning ]] -- --[[ Searing Pain ]] -- --[[ Sense Demons ]] -- --[[ Shadow Bolt ]] -- --[[ Shadow Ward ]] -- --[[ Shadowburn ]] -- --[[ Shoot ]] -- --[[ Siphon Life ]] -- --[[ Soul Fire ]] -- --[[ Soul Link ]] -- --[[ Summon Dreadsteed ]] -- --[[ Summon Felhunter ]] -- --[[ Summon Felsteed ]] -- --[[ Summon Imp ]] -- --[[ Summon Succubus ]] -- --[[ Summon Voidwalker ]] -- --[[ Unending Breath ]] -- --[[ Create Firestone ]] -- --[[ Create Firestone (Greater) ]] -- --[[ Create Firestone (Lesser) ]] -- --[[ Create Firestone (Major) ]] -- --[[ Create Soulstone ]] -- --[[ Create Soulstone (Greater) ]] -- --[[ Create Soulstone (Lesser) ]] -- --[[ Create Soulstone (Major) ]] -- --[[ Create Spellstone ]] -- --[[ Create Spellstone (Greater) ]] -- --[[ Create Spellstone (Major) ]] } swing_reset_spells['WARRIOR'] = { -- --[[ Battle Shout ]] -- --[[ Battle Stance ]] -- --[[ Berserker Rage ]] -- --[[ Berserker Stance ]] -- --[[ Bloodrage ]] -- --[[ Bloodthirst ]] -- --[[ Challenging Shout ]] -- --[[ Charge ]] --[[ Cleave ]] 845, 7369, 11608, 11609, 20569, -- --[[ Death Wish ]] -- --[[ Defensive Stance ]] -- --[[ Demoralizing Shout ]] -- --[[ Disarm ]] -- --[[ Execute ]] -- --[[ Hamstring ]] --[[ Heroic Strike ]] 78, 284, 285, 1608, 11564, 11565, 11566, 11567, 25286, -- --[[ Intercept ]] -- --[[ Intimidating Shout ]] -- --[[ Last Stand ]] -- --[[ Mocking Blow ]] -- --[[ Mortal Strike ]] -- --[[ Overpower ]] -- --[[ Piercing Howl ]] -- --[[ Pummel ]] -- --[[ Recklessness ]] -- --[[ Rend ]] -- --[[ Retaliation ]] -- --[[ Revenge ]] -- --[[ Shield Bash ]] -- --[[ Shield Block ]] -- --[[ Shield Slam ]] -- --[[ Shield Wall ]] -- --[[ Shoot Bow ]] -- --[[ Shoot Crossbow ]] -- --[[ Shoot Gun ]] --[[ Slam ]] 1464, 8820, 11604, 11605 -- --[[ Sunder Armor ]] -- --[[ Sweeping Strikes ]] -- --[[ Taunt ]] -- --[[ Throw ]] -- --[[ Thunder Clap ]] -- --[[ Whirlwind ]] } local function LoadAllSettings() addon_data.core.LoadSettings() addon_data.player.LoadSettings() addon_data.target.LoadSettings() addon_data.hunter.LoadSettings() end addon_data.core.RestoreAllDefaults = function() addon_data.core.RestoreDefaults() addon_data.player.RestoreDefaults() addon_data.target.RestoreDefaults() addon_data.hunter.RestoreDefaults() end local function InitializeAllVisuals() addon_data.player.InitializeVisuals() addon_data.target.InitializeVisuals() addon_data.hunter.InitializeVisuals() addon_data.config.InitializeVisuals() end addon_data.core.UpdateAllVisualsOnSettingsChange = function() addon_data.player.UpdateVisualsOnSettingsChange() addon_data.target.UpdateVisualsOnSettingsChange() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.core.LoadSettings = function() -- If the carried over settings dont exist then make them if not character_core_settings then character_core_settings = {} end -- If the carried over settings aren't set then set them to the defaults for setting, value in pairs(addon_data.core.default_settings) do if character_core_settings[setting] == nil then character_core_settings[setting] = value end end end addon_data.core.RestoreDefaults = function() for setting, value in pairs(addon_data.core.default_settings) do character_core_settings[setting] = value end end local function CoreFrame_OnUpdate(self, elapsed) addon_data.player.OnUpdate(elapsed) addon_data.target.OnUpdate(elapsed) addon_data.hunter.OnUpdate(elapsed) end addon_data.core.MissHandler = function(unit, miss_type, is_offhand) if miss_type == "PARRY" then if unit == "player" then min_swing_time = addon_data.target.main_weapon_speed * 0.2 if addon_data.target.main_swing_timer > min_swing_time then addon_data.target.main_swing_timer = min_swing_time end if not is_offhand then addon_data.player.ResetMainSwingTimer() else addon_data.player.ResetOffSwingTimer() end elseif unit == "target" then min_swing_time = addon_data.player.main_weapon_speed * 0.2 if addon_data.player.main_swing_timer > min_swing_time then addon_data.player.main_swing_timer = min_swing_time end if not is_offhand then addon_data.target.ResetMainSwingTimer() else addon_data.target.ResetOffSwingTimer() end else addon_data.utils.PrintMsg("Unexpected Unit Type in MissHandler().") end else if unit == "player" then if not is_offhand then addon_data.player.ResetMainSwingTimer() else addon_data.player.ResetOffSwingTimer() end elseif unit == "target" then if not is_offhand then addon_data.target.ResetMainSwingTimer() else addon_data.target.ResetOffSwingTimer() end else addon_data.utils.PrintMsg("Unexpected Unit Type in MissHandler().") end end end addon_data.core.SpellHandler = function(unit, spell_id) local _, player_class, _ = UnitClass('player') for class, spell_table in pairs(swing_reset_spells) do if player_class == class then for spell_index, curr_spell_id in ipairs(spell_table) do if spell_id == curr_spell_id then if unit == "player" then addon_data.player.ResetMainSwingTimer() elseif unit == "target" then addon_data.target.ResetMainSwingTimer() else addon_data.utils.PrintMsg("Unexpected Unit Type in SpellHandler().") end end end end end end local function OnAddonLoaded(self) -- Attach the rest of the events and scripts to the core frame addon_data.core.core_frame:SetScript("OnUpdate", CoreFrame_OnUpdate) addon_data.core.core_frame:RegisterEvent("PLAYER_REGEN_ENABLED") addon_data.core.core_frame:RegisterEvent("PLAYER_REGEN_DISABLED") addon_data.core.core_frame:RegisterEvent("PLAYER_TARGET_CHANGED") addon_data.core.core_frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") addon_data.core.core_frame:RegisterEvent("UNIT_INVENTORY_CHANGED") addon_data.core.core_frame:RegisterEvent("START_AUTOREPEAT_SPELL") addon_data.core.core_frame:RegisterEvent("STOP_AUTOREPEAT_SPELL") addon_data.core.core_frame:RegisterEvent("UNIT_SPELLCAST_START") addon_data.core.core_frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") addon_data.core.core_frame:RegisterEvent("UNIT_SPELLCAST_DELAYED") addon_data.core.core_frame:RegisterEvent("UNIT_SPELLCAST_FAILED") addon_data.core.core_frame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED") addon_data.core.core_frame:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET") -- Load the settings for the core and all timers LoadAllSettings() InitializeAllVisuals() -- Any other misc operations that happen at the start addon_data.player.ZeroizeSwingTimers() addon_data.target.ZeroizeSwingTimers() addon_data.utils.PrintMsg(load_message) end local function CoreFrame_OnEvent(self, event, ...) local args = {...} if event == "ADDON_LOADED" then if args[1] == "WeaponSwingTimer" then OnAddonLoaded() end elseif event == "PLAYER_REGEN_ENABLED" then addon_data.core.in_combat = false elseif event == "PLAYER_REGEN_DISABLED" then addon_data.core.in_combat = true elseif event == "PLAYER_TARGET_CHANGED" then addon_data.target.OnPlayerTargetChanged() elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then local combat_info = {CombatLogGetCurrentEventInfo()} addon_data.player.OnCombatLogUnfiltered(combat_info) addon_data.target.OnCombatLogUnfiltered(combat_info) elseif event == "UNIT_INVENTORY_CHANGED" then addon_data.player.OnInventoryChange() addon_data.target.OnInventoryChange() elseif event == "START_AUTOREPEAT_SPELL" then addon_data.hunter.OnStartAutorepeatSpell() elseif event == "STOP_AUTOREPEAT_SPELL" then addon_data.hunter.OnStopAutorepeatSpell() elseif event == "UNIT_SPELLCAST_START" then addon_data.hunter.OnUnitSpellCastStart(args[1], args[3]) elseif event == "UNIT_SPELLCAST_STOP" then addon_data.hunter.OnUnitSpellCastStop(args[1], args[3]) elseif event == "UNIT_SPELLCAST_SUCCEEDED" then addon_data.hunter.OnUnitSpellCastSucceeded(args[1], args[3]) elseif event == "UNIT_SPELLCAST_DELAYED" then addon_data.hunter.OnUnitSpellCastDelayed(args[1], args[3]) elseif event == "UNIT_SPELLCAST_FAILED" then addon_data.hunter.OnUnitSpellCastFailed(args[1], args[3]) elseif event == "UNIT_SPELLCAST_INTERRUPTED" then addon_data.hunter.OnUnitSpellCastInterrupted(args[1], args[3]) elseif event == "UNIT_SPELLCAST_FAILED_QUIET" then addon_data.hunter.OnUnitSpellCastFailedQuiet(args[1], args[3]) end end -- Add a slash command to bring up the config window SLASH_WEAPONSWINGTIMER_CONFIG1 = "/WeaponSwingTimer" SLASH_WEAPONSWINGTIMER_CONFIG2 = "/weaponswingtimer" SLASH_WEAPONSWINGTIMER_CONFIG3 = "/wst" SlashCmdList["WEAPONSWINGTIMER_CONFIG"] = function(option) InterfaceOptionsFrame_OpenToCategory("WeaponSwingTimer") InterfaceOptionsFrame_OpenToCategory("WeaponSwingTimer") end -- Setup the core of the addon (This is like calling main in C) addon_data.core.core_frame:SetScript("OnEvent", CoreFrame_OnEvent) PK >!O , WeaponSwingTimer/WeaponSwingTimer_Hunter.lualocal addon_name, addon_data = ... addon_data.hunter = {} addon_data.hunter.shot_spell_ids = { [75] = {spell_name = 'Auto Shot', rank = nil, cast_time = nil, cooldown = nil}, [2643] = {spell_name = 'Multi-Shot', rank = 1, cast_time = 0.5, cooldown = 10}, [14288] = {spell_name = 'Multi-Shot', rank = 2, cast_time = 0.5, cooldown = 10}, [14289] = {spell_name = 'Multi-Shot', rank = 3, cast_time = 0.5, cooldown = 10}, [14290] = {spell_name = 'Multi-Shot', rank = 4, cast_time = 0.5, cooldown = 10}, [25294] = {spell_name = 'Multi-Shot', rank = 5, cast_time = 0.5, cooldown = 10}, [19434] = {spell_name = 'Aimed Shot', rank = 1, cast_time = 3, cooldown = 6}, [20900] = {spell_name = 'Aimed Shot', rank = 2, cast_time = 3, cooldown = 6}, [20901] = {spell_name = 'Aimed Shot', rank = 3, cast_time = 3, cooldown = 6}, [20902] = {spell_name = 'Aimed Shot', rank = 4, cast_time = 3, cooldown = 6}, [20903] = {spell_name = 'Aimed Shot', rank = 5, cast_time = 3, cooldown = 6}, [20904] = {spell_name = 'Aimed Shot', rank = 6, cast_time = 3, cooldown = 6}, [5019] = {spell_name = 'Shoot', rank = nil, cast_time = nil, cooldown = nil} } addon_data.hunter.is_spell_multi_shot = function(spell_id) if (spell_id == 2643) or (spell_id == 14288) or (spell_id == 14289) or (spell_id == 14290) or (spell_id == 25294) then return true else return false end end addon_data.hunter.is_spell_aimed_shot = function(spell_id) if (spell_id == 19434) or (spell_id == 20900) or (spell_id == 20901) or (spell_id == 20902) or (spell_id == 20903) or (spell_id == 20904) then return true else return false end end addon_data.hunter.is_spell_auto_shot = function(spell_id) return (spell_id == 75) end addon_data.hunter.is_spell_shoot = function(spell_id) return (spell_id == 5019) end addon_data.hunter.default_settings = { enabled = true, width = 300, height = 12, point = "CENTER", rel_point = "CENTER", x_offset = 0, y_offset = -260, in_combat_alpha = 1.0, ooc_alpha = 0.25, backplane_alpha = 0.5, is_locked = false, show_text = true, show_aimedshot_cast_bar = true, show_multishot_cast_bar = true, show_latency_bars = false, show_multishot_clip_bar = false, show_border = true, classic_bars = true, one_bar = false, cooldown_r = 0.95, cooldown_g = 0.95, cooldown_b = 0.95, cooldown_a = 1.0, auto_cast_r = 0.8, auto_cast_g = 0.0, auto_cast_b = 0.0, auto_cast_a = 1.0, clip_r = 1.0, clip_g = 0.0, clip_b = 0.0, clip_a = 0.7 } addon_data.hunter.shooting = false addon_data.hunter.range_speed = 3.0 addon_data.hunter.auto_cast_time = 0.7001 addon_data.hunter.shot_timer = 0.60 addon_data.hunter.last_shot_time = GetTime() addon_data.hunter.auto_shot_ready = true addon_data.hunter.casting = false addon_data.hunter.casting_shot = false addon_data.hunter.cast_timer = 0.1 addon_data.hunter.cast_time = 0.1 addon_data.hunter.last_failed_time = GetTime() addon_data.hunter.range_weapon_id = 0 addon_data.hunter.has_moved = false addon_data.hunter.berserk_haste = 0 addon_data.hunter.class = 0 addon_data.hunter.guid = 0 addon_data.hunter.OnUseAction = function(action_id) addon_data.hunter.scan_tip:SetAction(action_id) name, _, _, cast_time, _, _, real_spell_id = GetSpellInfo(WSTScanTipTextLeft1:GetText()) if not addon_data.hunter.casting and name then addon_data.hunter.StartCastingSpell(real_spell_id) end end addon_data.hunter.OnCastSpellByName = function(name, on_self) name, _, _, cast_time, _, _, real_spell_id = GetSpellInfo(name) if not addon_data.hunter.casting then addon_data.hunter.StartCastingSpell(real_spell_id) end end addon_data.hunter.OnCastSpell = function(spell_id, spell_book_type) name, _, _, cast_time, _, _, real_spell_id = GetSpellInfo(spell_id, spell_book_type) if not addon_data.hunter.casting then addon_data.hunter.StartCastingSpell(real_spell_id) end end addon_data.hunter.StartCastingSpell = function(spell_id) local settings = character_hunter_settings if (GetTime() - addon_data.hunter.last_failed_time) > 0 then if not addon_data.hunter.casting and UnitCanAttack('player', 'target') then spell_name, _, _, cast_time, _, _, _ = GetSpellInfo(spell_id) if cast_time == nil then return end if not addon_data.hunter.is_spell_auto_shot(spell_id) and not addon_data.hunter.is_spell_shoot(spell_id) and cast_time > 0 then addon_data.hunter.casting = true end local settings = character_hunter_settings for id, spell_table in pairs(addon_data.hunter.shot_spell_ids) do if spell_id == id then if (addon_data.hunter.is_spell_aimed_shot(spell_id) and settings.show_aimedshot_cast_bar) or (addon_data.hunter.is_spell_multi_shot(spell_id) and settings.show_multishot_cast_bar) then local base_cast_time = addon_data.hunter.shot_spell_ids[spell_id].cast_time addon_data.hunter.casting_shot = true addon_data.hunter.cast_timer = 0 addon_data.hunter.frame.spell_bar:SetVertexColor(0.7, 0.4, 0, 1) addon_data.hunter.UpdateRangeCastSpeedModifier() addon_data.hunter.cast_time = base_cast_time * addon_data.hunter.range_cast_speed_modifer if settings.show_latency_bars then _, _, _, latency = GetNetStats() addon_data.hunter.cast_time = addon_data.hunter.cast_time + (latency / 1000) end if character_hunter_settings.show_text then addon_data.hunter.frame.spell_text_center:SetText(spell_name) end end break end end end end end addon_data.hunter.LoadSettings = function() -- If the carried over settings dont exist then make them if not character_hunter_settings then character_hunter_settings = {} _, class, _ = UnitClass("player") character_hunter_settings.enabled = (class == "HUNTER" or class == "MAGE" or class == "PRIEST" or class == "WARLOCK") end -- If the carried over settings aren't set then set them to the defaults for setting, value in pairs(addon_data.hunter.default_settings) do if character_hunter_settings[setting] == nil then character_hunter_settings[setting] = value end end hooksecurefunc('UseAction', addon_data.hunter.OnUseAction) hooksecurefunc('CastSpellByName', addon_data.hunter.OnCastSpellByName) hooksecurefunc('CastSpell', addon_data.hunter.OnCastSpell) addon_data.hunter.scan_tip = CreateFrame("GameTooltip", "WSTScanTip", nil, "GameTooltipTemplate") addon_data.hunter.scan_tip:SetOwner(WorldFrame, "ANCHOR_NONE") end addon_data.hunter.RestoreDefaults = function() for setting, value in pairs(addon_data.hunter.default_settings) do character_hunter_settings[setting] = value end _, class, _ = UnitClass("player") character_hunter_settings.enabled = (class == "HUNTER" or class == "MAGE" or class == "PRIEST" or class == "WARLOCK") addon_data.hunter.UpdateVisualsOnSettingsChange() addon_data.hunter.UpdateConfigPanelValues() end addon_data.hunter.UpdateInfo = function() addon_data.hunter.range_weapon_id = GetInventoryItemID("player", 18) addon_data.hunter.class = UnitClass("player")[2] addon_data.hunter.guid = UnitGUID("player") end addon_data.hunter.UpdateRangeCastSpeedModifier = function() local speed = 1.0 for i=1, 40 do name, _ = UnitAura("player", i) if name == "Quick Shots" then speed = speed/1.3 end if name == "Rapid Shot" then speed = speed/1.4 end if name == "Berserking" then addon_data.hunter.UpdateBerserkHaste() speed = speed/ (1 + addon_data.hunter.berserk_haste) end if name == "Kiss of the Spider" then speed = speed/1.2 end if name == "Curse of Tongues" then speed = speed/0.5 end end addon_data.hunter.range_cast_speed_modifer = speed end addon_data.hunter.UpdateBerserkHaste = function() if((UnitHealth("player")/UnitHealthMax("player")) >= 0.40) then addon_data.hunter.berserk_haste = (1.30 - (UnitHealth("player")/UnitHealthMax("player")))/3 else addon_data.hunter.berserk_haste = 0.3 end end addon_data.hunter.ResetShotTimer = function() -- The timer is reset to either the auto cast time or the difference between the time since the last shot and the current time depending on which is larger local curr_time = GetTime() local range_speed = addon_data.hunter.range_speed if (curr_time + 0.01 - addon_data.hunter.last_shot_time) > (range_speed - addon_data.hunter.auto_cast_time) then addon_data.hunter.shot_timer = addon_data.hunter.auto_cast_time addon_data.hunter.auto_shot_ready = true elseif curr_time ~= addon_data.hunter.last_shot_time then addon_data.hunter.shot_timer = curr_time - addon_data.hunter.last_shot_time addon_data.hunter.auto_shot_ready = false else addon_data.hunter.shot_timer = range_speed addon_data.hunter.auto_shot_ready = false end end addon_data.hunter.UpdateAutoShotTimer = function(elapsed) local curr_time = GetTime() addon_data.hunter.shot_timer = addon_data.hunter.shot_timer - elapsed -- If the player moved then the timer resets if addon_data.hunter.has_moved or addon_data.hunter.casting then if addon_data.hunter.shot_timer <= addon_data.hunter.auto_cast_time then addon_data.hunter.ResetShotTimer() end end -- If the shot timer is less than the auto cast time then the auto shot is ready if addon_data.hunter.shot_timer <= addon_data.hunter.auto_cast_time then addon_data.hunter.auto_shot_ready = true -- If we are not shooting then the timer should be reset if not addon_data.hunter.shooting then addon_data.hunter.ResetShotTimer() end else addon_data.hunter.auto_shot_ready = false end end addon_data.hunter.UpdateCastTimer = function(elapsed) addon_data.hunter.cast_timer = addon_data.hunter.cast_timer + elapsed if addon_data.hunter.cast_timer > addon_data.hunter.cast_time + 0.1 then addon_data.hunter.OnUnitSpellCastFailed('player', 1) end end addon_data.hunter.OnUpdate = function(elapsed) if character_hunter_settings.enabled then -- Update the ranged attack speed new_range_speed, _, _, _, _, _ = UnitRangedDamage("player") -- FIXME: Temp fix until I can nail down the divide by zero error if addon_data.hunter.range_speed == 0 then addon_data.hunter.range_speed = 3 end -- Handling for getting haste buffs in combat if new_range_speed ~= addon_data.hunter.range_speed then if not addon_data.hunter.auto_shot_ready then addon_data.hunter.shot_timer = addon_data.hunter.shot_timer * (new_range_speed / addon_data.hunter.range_speed) end addon_data.hunter.range_speed = new_range_speed end -- Check to see if we have moved addon_data.hunter.has_moved = (GetUnitSpeed("player") > 0) -- Update the Auto Shot timer based on the updated settings addon_data.hunter.UpdateAutoShotTimer(elapsed) -- Update the cast bar timers if addon_data.hunter.casting_shot then addon_data.hunter.UpdateCastTimer(elapsed) end -- Update the visuals addon_data.hunter.UpdateVisualsOnUpdate() end end addon_data.hunter.OnStartAutorepeatSpell = function() addon_data.hunter.shooting = true addon_data.hunter.UpdateInfo() if addon_data.hunter.shot_timer <= addon_data.hunter.auto_cast_time then addon_data.hunter.ResetShotTimer() end end addon_data.hunter.OnStopAutorepeatSpell = function() addon_data.hunter.shooting = false addon_data.hunter.UpdateInfo() end addon_data.hunter.OnUnitSpellCastStart = function(unit, spell_id) --[[ if unit == 'player' then addon_data.hunter.casting = true local spell_name local settings = character_hunter_settings for id, spell_table in pairs(addon_data.hunter.shot_spell_ids) do if spell_id == id then spell_name = addon_data.hunter.shot_spell_ids[spell_id].spell_name if ((spell_name == 'Aimed Shot') and settings.show_aimedshot_cast_bar) or ((spell_name == 'Multi-Shot') and settings.show_multishot_cast_bar) then addon_data.hunter.casting_shot = true addon_data.hunter.cast_timer = 0 addon_data.hunter.frame.spell_bar:SetVertexColor(0.7, 0.4, 0, 1) local name, text, _, start_time, end_time, _, _, _ = UnitCastingInfo("player") addon_data.hunter.cast_time = (end_time - start_time) / 1000 if character_hunter_settings.show_text then addon_data.hunter.frame.spell_text_center:SetText(text) end end break end end end ]]-- end addon_data.hunter.OnUnitSpellCastSucceeded = function(unit, spell_id) if unit == 'player' then addon_data.hunter.casting = false -- If the spell is Auto Shot then reset the shot timer if addon_data.hunter.shot_spell_ids[spell_id] then spell_name = addon_data.hunter.shot_spell_ids[spell_id].spell_name if addon_data.hunter.is_spell_auto_shot(spell_id) or addon_data.hunter.is_spell_shoot(spell_id) then hunter_bw_shot_timer = GetTime() addon_data.hunter.last_shot_time = GetTime() addon_data.hunter.ResetShotTimer() end end -- Otherwise, set the cast bar to green if addon_data.hunter.shot_spell_ids[spell_id] then spell_name = addon_data.hunter.shot_spell_ids[spell_id].spell_name if not addon_data.hunter.is_spell_auto_shot(spell_id) and not addon_data.hunter.is_spell_shoot(spell_id) then addon_data.hunter.casting_shot = false addon_data.hunter.frame.spell_bar:SetVertexColor(0, 0.5, 0, 1) addon_data.hunter.frame.spell_bar:SetWidth(character_hunter_settings.width) addon_data.hunter.frame.spell_bar_text:SetText("0.0") end end end end addon_data.hunter.OnUnitSpellCastDelayed = function(unit, spell_id) if unit == 'player' then for id, spell_table in pairs(addon_data.hunter.shot_spell_ids) do if spell_id == id then local name, text, _, start_time, end_time, _, _, _ = UnitCastingInfo("player") local current_timer = (GetTime() - (start_time / 1000)) if current_timer < 0 then current_timer = 0 end addon_data.hunter.cast_timer = current_timer end end end end addon_data.hunter.OnUnitSpellCastFailed = function(unit, spell_id) local settings = character_hunter_settings local frame = addon_data.hunter.frame if unit == 'player' then if addon_data.hunter.casting and addon_data.hunter.casting_shot then addon_data.hunter.frame.spell_bar:SetVertexColor(0.7, 0, 0, 1) if character_hunter_settings.show_text then addon_data.hunter.frame.spell_text_center:SetText("Failed") end addon_data.hunter.frame.spell_bar:SetWidth(character_hunter_settings.width) end addon_data.hunter.casting_shot = false addon_data.hunter.last_failed_time = GetTime() end end addon_data.hunter.OnUnitSpellCastInterrupted = function(unit, spell_id) if unit == 'player' then if addon_data.hunter.shot_spell_ids[spell_id] then if not addon_data.hunter.is_spell_auto_shot(spell_id) and not addon_data.hunter.is_spell_shoot(spell_id) then addon_data.hunter.casting = false end end for id, spell_table in pairs(addon_data.hunter.shot_spell_ids) do if (spell_id == id) and not addon_data.hunter.is_spell_auto_shot(spell_id) and not addon_data.hunter.is_spell_shoot(spell_id) then addon_data.hunter.casting_shot = false addon_data.hunter.frame.spell_bar:SetVertexColor(0.7, 0, 0, 1) if character_hunter_settings.show_text then addon_data.hunter.frame.spell_text_center:SetText("Interrupted") end addon_data.hunter.frame.spell_bar:SetWidth(character_hunter_settings.width) end end end end addon_data.hunter.OnUnitSpellCastFailedQuiet = function(unit, spell_id) local settings = character_hunter_settings if settings.enabled and unit == "player" and addon_data.hunter.is_spell_auto_shot(spell_id) then -- addon_data.hunter.shot_timer = addon_data.hunter.auto_cast_time + 0.5 end end addon_data.hunter.UpdateVisualsOnUpdate = function() local settings = character_hunter_settings local frame = addon_data.hunter.frame local range_speed = addon_data.hunter.range_speed local shot_timer = addon_data.hunter.shot_timer local auto_cast_time = addon_data.hunter.auto_cast_time if settings.enabled then frame.shot_bar_text:SetText(tostring(addon_data.utils.SimpleRound(shot_timer, 0.1))) if addon_data.core.in_combat or addon_data.hunter.shooting or addon_data.hunter.casting_shot then frame:SetAlpha(settings.in_combat_alpha) else frame:SetAlpha(settings.ooc_alpha) end if not settings.one_bar then if addon_data.hunter.auto_shot_ready then frame.shot_bar:SetVertexColor(settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b, settings.auto_cast_a) new_width = settings.width * (auto_cast_time - shot_timer) / auto_cast_time frame.multishot_clip_bar:Hide() else frame.shot_bar:SetVertexColor(settings.cooldown_r, settings.cooldown_g, settings.cooldown_b, settings.cooldown_a) new_width = settings.width * ((shot_timer - auto_cast_time) / (range_speed - auto_cast_time)) if settings.show_multishot_clip_bar then frame.multishot_clip_bar:Show() multishot_clip_width = math.min((settings.width * 2) * (0.5 / (addon_data.hunter.range_speed - 0.5)), settings.width) frame.multishot_clip_bar:SetWidth(multishot_clip_width) end end if new_width < 2 then new_width = 2 end frame.shot_bar:SetWidth(math.min(new_width, settings.width)) else timer_width = settings.width * ((addon_data.hunter.range_speed - addon_data.hunter.shot_timer) / addon_data.hunter.range_speed) if addon_data.hunter.auto_shot_ready then auto_shot_cast_width = settings.width * (addon_data.hunter.shot_timer / addon_data.hunter.range_speed) else auto_shot_cast_width = settings.width * (addon_data.hunter.auto_cast_time / addon_data.hunter.range_speed) end if settings.show_multishot_clip_bar then frame.multishot_clip_bar:Show() multishot_clip_width = math.min(settings.width * (0.5 / (addon_data.hunter.range_speed - 0.5)), settings.width) frame.multishot_clip_bar:SetWidth(5) multi_offset = (settings.width * (addon_data.hunter.auto_cast_time / addon_data.hunter.range_speed)) + multishot_clip_width frame.multishot_clip_bar:SetPoint('TOPRIGHT', -multi_offset, 0) end frame.shot_bar:SetWidth(math.min(timer_width, settings.width)) frame.auto_shot_cast_bar:SetWidth(math.max(auto_shot_cast_width, 0.001)) end if addon_data.hunter.casting_shot then frame.spell_bar_text:SetText(tostring(addon_data.utils.SimpleRound(addon_data.hunter.cast_time - addon_data.hunter.cast_timer, 0.1))) frame:SetSize(settings.width, (settings.height * 2) + 2) frame.spell_bar:SetAlpha(1) new_width = settings.width * (addon_data.hunter.cast_timer / addon_data.hunter.cast_time) new_width = math.min(new_width, settings.width) frame.spell_bar:SetWidth(new_width) frame.spell_spark:SetPoint('BOTTOMLEFT', new_width - 8, 0) if new_width == settings.width or not settings.classic_bars then frame.spell_spark:Hide() else frame.spell_spark:Show() end else new_alpha = frame.spell_bar:GetAlpha() - 0.005 if new_alpha <= 0 then new_alpha = 0 frame:SetSize(settings.width, settings.height) frame.spell_text_center:SetText("") frame.spell_bar_text:SetText("") end frame.spell_bar:SetAlpha(new_alpha) frame.spell_spark:Hide() end if settings.show_latency_bars then if addon_data.hunter.casting_shot then frame.cast_latency:Show() _, _, _, latency = GetNetStats() lag_width = settings.width * ((latency / 1000) / addon_data.hunter.cast_time) frame.cast_latency:SetWidth(lag_width) else frame.cast_latency:Hide() end end end end addon_data.hunter.UpdateVisualsOnSettingsChange = function() local settings = character_hunter_settings local frame = addon_data.hunter.frame if settings.enabled then frame:Show() frame:ClearAllPoints() frame:SetPoint(settings.point, UIParent, settings.rel_point, settings.x_offset, settings.y_offset) if settings.show_border then frame.backplane:SetBackdrop({ bgFile = "Interface/AddOns/WeaponSwingTimer/Images/Background", edgeFile = "Interface/AddOns/WeaponSwingTimer/Images/Border", tile = true, tileSize = 16, edgeSize = 12, insets = { left = 8, right = 8, top = 8, bottom = 8}}) else frame.backplane:SetBackdrop({ bgFile = "Interface/AddOns/WeaponSwingTimer/Images/Background", edgeFile = nil, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 8, right = 8, top = 8, bottom = 8}}) end frame.backplane:SetBackdropColor(0,0,0,settings.backplane_alpha) frame.shot_bar:ClearAllPoints() if not settings.one_bar then frame.shot_bar:SetPoint("TOP", 0, 0) frame.auto_shot_cast_bar:Hide() else frame.shot_bar:SetPoint("TOPLEFT", 0, 0) frame.shot_bar:SetVertexColor(settings.cooldown_r, settings.cooldown_g, settings.cooldown_b, settings.cooldown_a) frame.auto_shot_cast_bar:Show() frame.auto_shot_cast_bar:SetPoint('TOPRIGHT', 0, 0) frame.auto_shot_cast_bar:SetHeight(settings.height) frame.auto_shot_cast_bar:SetVertexColor(settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b, settings.auto_cast_a) end frame.shot_bar_text:SetPoint("TOPRIGHT", -5, -(settings.height / 2) + 5) frame.shot_bar_text:SetTextColor(1.0, 1.0, 1.0, 1.0) frame.spell_bar_text:SetPoint("BOTTOMRIGHT", -5, (settings.height / 2) - 5) frame.spell_bar_text:SetTextColor(1.0, 1.0, 1.0, 1.0) frame.shot_bar:SetHeight(settings.height) if settings.classic_bars then frame.shot_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Bar') frame.auto_shot_cast_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Bar') else frame.shot_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Background') frame.auto_shot_cast_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Background') end frame.multishot_clip_bar:ClearAllPoints() if not settings.one_bar then frame.multishot_clip_bar:SetPoint("TOP", 0, 0) else frame.multishot_clip_bar:SetPoint("TOPRIGHT", 0, 0) end frame.multishot_clip_bar:SetHeight(settings.height) frame.multishot_clip_bar:SetColorTexture(settings.clip_r, settings.clip_g, settings.clip_b, settings.clip_a) frame.spell_bar:SetPoint("BOTTOMLEFT", 0, 0) frame.spell_bar:SetHeight(settings.height) if settings.classic_bars then frame.spell_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Bar') else frame.spell_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Background') end frame.spell_spark:SetSize(16, settings.height) frame.spell_text_center:SetPoint("CENTER", 2, -(settings.height / 2)) frame.cast_latency:SetHeight(settings.height) frame.cast_latency:SetPoint("BOTTOMLEFT", 0, 0) frame.cast_latency:SetColorTexture(1, 0, 0, 0.75) if settings.show_latency_bars then frame.cast_latency:Show() else frame.cast_latency:Hide() end if settings.show_multishot_clip_bar then frame.multishot_clip_bar:Show() else frame.multishot_clip_bar:Hide() end if settings.show_text then frame.spell_text_center:Show() frame.shot_bar_text:Show() frame.spell_bar_text:Show() else frame.spell_text_center:Hide() frame.shot_bar_text:Hide() frame.spell_bar_text:Hide() end else frame:Hide() end end addon_data.hunter.OnFrameDragStart = function() if not character_hunter_settings.is_locked then addon_data.hunter.frame:StartMoving() end end addon_data.hunter.OnFrameDragStop = function() local frame = addon_data.hunter.frame local settings = character_hunter_settings frame:StopMovingOrSizing() point, _, rel_point, x_offset, y_offset = frame:GetPoint() if x_offset < 20 and x_offset > -20 then x_offset = 0 end settings.point = point settings.rel_point = rel_point settings.x_offset = addon_data.utils.SimpleRound(x_offset, 1) settings.y_offset = addon_data.utils.SimpleRound(y_offset, 1) addon_data.hunter.UpdateVisualsOnSettingsChange() addon_data.hunter.UpdateConfigPanelValues() end addon_data.hunter.InitializeVisuals = function() local settings = character_hunter_settings -- Create the frame addon_data.hunter.frame = CreateFrame("Frame", addon_name .. "HunterAutoshotFrame", UIParent) local frame = addon_data.hunter.frame frame:SetMovable(true) frame:EnableMouse(not settings.is_locked) frame:RegisterForDrag("LeftButton") frame:SetScript("OnDragStart", addon_data.hunter.OnFrameDragStart) frame:SetScript("OnDragStop", addon_data.hunter.OnFrameDragStop) -- Create the backplane frame.backplane = CreateFrame("Frame", addon_name .. "HunterBackdropFrame", frame) frame.backplane:SetPoint('TOPLEFT', -9, 9) frame.backplane:SetPoint('BOTTOMRIGHT', 9, -9) frame.backplane:SetFrameStrata('BACKGROUND') -- Create the shot bar frame.shot_bar = frame:CreateTexture(nil, "ARTWORK") -- Create the shot bar text frame.shot_bar_text = frame:CreateFontString(nil, "OVERLAY") frame.shot_bar_text:SetFont("Fonts/FRIZQT__.ttf", 11) frame.shot_bar_text:SetJustifyV("CENTER") frame.shot_bar_text:SetJustifyH("CENTER") -- Create the multishot clip bar frame.multishot_clip_bar = frame:CreateTexture(nil, "OVERLAY") -- Create the auto shot cast bar indicator frame.auto_shot_cast_bar = frame:CreateTexture(nil, "OVERLAY") -- Create the range spell shot bar frame.spell_bar = frame:CreateTexture(nil, "ARTWORK") -- Create the spell bar text frame.spell_bar_text = frame:CreateFontString(nil, "OVERLAY") frame.spell_bar_text:SetFont("Fonts/FRIZQT__.ttf", 11) frame.spell_bar_text:SetJustifyV("CENTER") frame.spell_bar_text:SetJustifyH("CENTER") -- Create the spell spark frame.spell_spark = frame:CreateTexture(nil,"OVERLAY") frame.spell_spark:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Spark') -- Create the range spell shot bar center text frame.spell_text_center = frame:CreateFontString(nil, "OVERLAY") frame.spell_text_center:SetFont("Fonts/FRIZQT__.ttf", 11) frame.spell_text_center:SetTextColor(1, 1, 1, 1) frame.spell_text_center:SetJustifyV("CENTER") frame.spell_text_center:SetJustifyH("LEFT") -- Create the latency bar frame.cast_latency = frame:CreateTexture(nil,"OVERLAY") -- Show it off addon_data.hunter.UpdateVisualsOnSettingsChange() addon_data.hunter.UpdateVisualsOnUpdate() frame:Show() end addon_data.hunter.UpdateConfigPanelValues = function() local panel = addon_data.hunter.config_frame local settings = character_hunter_settings panel.enabled_checkbox:SetChecked(settings.enabled) panel.show_aimedshot_cast_bar_checkbox:SetChecked(settings.show_aimedshot_cast_bar) panel.show_multishot_cast_bar_checkbox:SetChecked(settings.show_multishot_cast_bar) panel.show_latency_bar_checkbox:SetChecked(settings.show_latency_bars) panel.show_multishot_clip_bar_checkbox:SetChecked(settings.show_multishot_clip_bar) panel.show_border_checkbox:SetChecked(settings.show_border) panel.classic_bars_checkbox:SetChecked(settings.classic_bars) panel.one_bar_checkbox:SetChecked(settings.one_bar) panel.show_text_checkbox:SetChecked(settings.show_text) panel.width_editbox:SetText(tostring(settings.width)) panel.width_editbox:SetCursorPosition(0) panel.height_editbox:SetText(tostring(settings.height)) panel.height_editbox:SetCursorPosition(0) panel.x_offset_editbox:SetText(tostring(settings.x_offset)) panel.x_offset_editbox:SetCursorPosition(0) panel.y_offset_editbox:SetText(tostring(settings.y_offset)) panel.y_offset_editbox:SetCursorPosition(0) panel.cooldown_color_picker.foreground:SetColorTexture( settings.cooldown_r, settings.cooldown_g, settings.cooldown_b, settings.cooldown_a) panel.autoshot_cast_color_picker.foreground:SetColorTexture( settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b, settings.auto_cast_a) panel.multi_clip_color_picker.foreground:SetColorTexture( settings.clip_r, settings.clip_g, settings.clip_b, settings.clip_a) if settings.one_bar then panel.explaination:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/HunterOneBarExplainedAlpha') panel.explaination:SetSize(350, 175) panel.explaination:SetPoint('TOPLEFT', -50, -385) else panel.explaination:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/HunterBarExplainedFullAlpha') panel.explaination:SetSize(700, 175) panel.explaination:SetPoint('TOPLEFT', -48, -410) end panel.in_combat_alpha_slider:SetValue(settings.in_combat_alpha) panel.in_combat_alpha_slider.editbox:SetCursorPosition(0) panel.ooc_alpha_slider:SetValue(settings.ooc_alpha) panel.ooc_alpha_slider.editbox:SetCursorPosition(0) panel.backplane_alpha_slider:SetValue(settings.backplane_alpha) panel.backplane_alpha_slider.editbox:SetCursorPosition(0) end addon_data.hunter.EnabledCheckBoxOnClick = function(self) character_hunter_settings.enabled = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.ShowAimedShotCastBarCheckBoxOnClick = function(self) character_hunter_settings.show_aimedshot_cast_bar = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.ShowMultiShotCastBarCheckBoxOnClick = function(self) character_hunter_settings.show_multishot_cast_bar = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.ShowLatencyBarsCheckBoxOnClick = function(self) character_hunter_settings.show_latency_bars = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.ShowMultiShotClipBarCheckBoxOnClick = function(self) character_hunter_settings.show_multishot_clip_bar = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.ShowBorderCheckBoxOnClick = function(self) character_hunter_settings.show_border = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.ClassicBarsCheckBoxOnClick = function(self) character_hunter_settings.classic_bars = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.OneBarCheckBoxOnClick = function(self) character_hunter_settings.one_bar = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() addon_data.hunter.UpdateConfigPanelValues() end addon_data.hunter.ShowTextCheckBoxOnClick = function(self) character_hunter_settings.show_text = self:GetChecked() addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.WidthEditBoxOnEnter = function(self) character_hunter_settings.width = tonumber(self:GetText()) addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.HeightEditBoxOnEnter = function(self) character_hunter_settings.height = tonumber(self:GetText()) addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.XOffsetEditBoxOnEnter = function(self) character_hunter_settings.x_offset = tonumber(self:GetText()) addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.YOffsetEditBoxOnEnter = function(self) character_hunter_settings.y_offset = tonumber(self:GetText()) addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.CooldownColorPickerOnClick = function() local settings = character_hunter_settings local function CooldownOnActionFunc(restore) local settings = character_hunter_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.cooldown_r, settings.cooldown_g, settings.cooldown_b, settings.cooldown_a = new_r, new_g, new_b, new_a addon_data.hunter.config_frame.cooldown_color_picker.foreground:SetColorTexture( settings.cooldown_r, settings.cooldown_g, settings.cooldown_b, settings.cooldown_a) addon_data.hunter.UpdateVisualsOnSettingsChange() end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = CooldownOnActionFunc, CooldownOnActionFunc, CooldownOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.cooldown_a ColorPickerFrame:SetColorRGB(settings.cooldown_r, settings.cooldown_g, settings.cooldown_b) ColorPickerFrame.previousValues = {settings.cooldown_r, settings.cooldown_g, settings.cooldown_b, settings.cooldown_a} ColorPickerFrame:Show() end addon_data.hunter.AutoShotCastColorPickerOnClick = function() local settings = character_hunter_settings local function AutoShotCastOnActionFunc(restore) local settings = character_hunter_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b, settings.auto_cast_a = new_r, new_g, new_b, new_a addon_data.hunter.config_frame.autoshot_cast_color_picker.foreground:SetColorTexture( settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b, settings.auto_cast_a) addon_data.hunter.UpdateVisualsOnSettingsChange() end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = AutoShotCastOnActionFunc, AutoShotCastOnActionFunc, AutoShotCastOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.auto_cast_a ColorPickerFrame:SetColorRGB(settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b) ColorPickerFrame.previousValues = {settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b, settings.auto_cast_a} ColorPickerFrame:Show() end addon_data.hunter.MultiClipColorPickerOnClick = function() local settings = character_hunter_settings local function MultiClipOnActionFunc(restore) local settings = character_hunter_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.clip_r, settings.clip_g, settings.clip_b, settings.clip_a = new_r, new_g, new_b, new_a addon_data.hunter.frame.multishot_clip_bar:SetColorTexture(settings.clip_r, settings.clip_g, settings.clip_b, settings.clip_a) addon_data.hunter.config_frame.multi_clip_color_picker.foreground:SetColorTexture( settings.clip_r, settings.clip_g, settings.clip_b, settings.clip_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = MultiClipOnActionFunc, MultiClipOnActionFunc, MultiClipOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.clip_a ColorPickerFrame:SetColorRGB(settings.clip_r, settings.clip_g, settings.clip_b) ColorPickerFrame.previousValues = {settings.clip_r, settings.clip_g, settings.clip_b, settings.clip_a} ColorPickerFrame:Show() end addon_data.hunter.CombatAlphaOnValChange = function(self) character_hunter_settings.in_combat_alpha = tonumber(self:GetValue()) addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.OOCAlphaOnValChange = function(self) character_hunter_settings.ooc_alpha = tonumber(self:GetValue()) addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.BackplaneAlphaOnValChange = function(self) character_hunter_settings.backplane_alpha = tonumber(self:GetValue()) addon_data.hunter.UpdateVisualsOnSettingsChange() end addon_data.hunter.CreateConfigPanel = function(parent_panel) addon_data.hunter.config_frame = CreateFrame("Frame", addon_name .. "HunterConfigPanel", parent_panel) local panel = addon_data.hunter.config_frame local settings = character_hunter_settings -- Title Text panel.title_text = addon_data.config.TextFactory(panel, "Hunter & Wand Shot Bar Settings", 20) panel.title_text:SetPoint("TOPLEFT", 10 , -10) panel.title_text:SetTextColor(1, 0.9, 0, 1) -- General Settings Text panel.general_text = addon_data.config.TextFactory(panel, "General Settings", 16) panel.general_text:SetPoint("TOPLEFT", 10 , -50) panel.general_text:SetTextColor(1, 0.9, 0, 1) -- Enabled Checkbox panel.enabled_checkbox = addon_data.config.CheckBoxFactory( "HunterEnabledCheckBox", panel, " Enable", "Enables the Autoshot/Shoot bars.", addon_data.hunter.EnabledCheckBoxOnClick) panel.enabled_checkbox:SetPoint("TOPLEFT", 10, -70) -- Show Border Checkbox panel.show_border_checkbox = addon_data.config.CheckBoxFactory( "HunterShowBorderCheckBox", panel, " Show border", "Enables the shot bar's border.", addon_data.hunter.ShowBorderCheckBoxOnClick) panel.show_border_checkbox:SetPoint("TOPLEFT", 10, -90) -- Show Classic Bars Checkbox panel.classic_bars_checkbox = addon_data.config.CheckBoxFactory( "HunterClassicBarsCheckBox", panel, " Classic bars", "Enables the classic texture for the shot bars.", addon_data.hunter.ClassicBarsCheckBoxOnClick) panel.classic_bars_checkbox:SetPoint("TOPLEFT", 10, -110) -- One bar Checkbox panel.one_bar_checkbox = addon_data.config.CheckBoxFactory( "HunterOneBarCheckBox", panel, " YaHT / One bar", "Changes the Auto Shot bar to a single bar that fills from left to right", addon_data.hunter.OneBarCheckBoxOnClick) panel.one_bar_checkbox:SetPoint("TOPLEFT", 10, -130) -- Show Text Checkbox panel.show_text_checkbox = addon_data.config.CheckBoxFactory( "HunterShowTextCheckBox", panel, " Show Text", "Enables the shot bar text.", addon_data.hunter.ShowTextCheckBoxOnClick) panel.show_text_checkbox:SetPoint("TOPLEFT", 10, -150) -- Width EditBox panel.width_editbox = addon_data.config.EditBoxFactory( "HunterWidthEditBox", panel, "Bar Width", 75, 25, addon_data.hunter.WidthEditBoxOnEnter) panel.width_editbox:SetPoint("TOPLEFT", 200, -90, "BOTTOMRIGHT", 275, -115) -- Height EditBox panel.height_editbox = addon_data.config.EditBoxFactory( "HunterHeightEditBox", panel, "Bar Height", 75, 25, addon_data.hunter.HeightEditBoxOnEnter) panel.height_editbox:SetPoint("TOPLEFT", 280, -90, "BOTTOMRIGHT", 225, -115) -- X Offset EditBox panel.x_offset_editbox = addon_data.config.EditBoxFactory( "HunterXOffsetEditBox", panel, "X Offset", 75, 25, addon_data.hunter.XOffsetEditBoxOnEnter) panel.x_offset_editbox:SetPoint("TOPLEFT", 200, -140, "BOTTOMRIGHT", 275, -165) -- Y Offset EditBox panel.y_offset_editbox = addon_data.config.EditBoxFactory( "HunterYOffsetEditBox", panel, "Y Offset", 75, 25, addon_data.hunter.YOffsetEditBoxOnEnter) panel.y_offset_editbox:SetPoint("TOPLEFT", 280, -140, "BOTTOMRIGHT", 225, -165) -- Cooldown color picker panel.cooldown_color_picker = addon_data.config.color_picker_factory( 'HunterCooldownColorPicker', panel, settings.cooldown_r, settings.cooldown_g, settings.cooldown_b, settings.cooldown_a, 'Auto Shot Cooldown Color', addon_data.hunter.CooldownColorPickerOnClick) panel.cooldown_color_picker:SetPoint('TOPLEFT', 205, -180) -- Autoshot cast color picker panel.autoshot_cast_color_picker = addon_data.config.color_picker_factory( 'HunterAutoShotCastColorPicker', panel, settings.auto_cast_r, settings.auto_cast_g, settings.auto_cast_b, settings.auto_cast_a, 'Auto Shot Cast Color', addon_data.hunter.AutoShotCastColorPickerOnClick) panel.autoshot_cast_color_picker:SetPoint('TOPLEFT', 205, -200) -- In Combat Alpha Slider panel.in_combat_alpha_slider = addon_data.config.SliderFactory( "HunterInCombatAlphaSlider", panel, "In Combat Alpha", 0, 1, 0.05, addon_data.hunter.CombatAlphaOnValChange) panel.in_combat_alpha_slider:SetPoint("TOPLEFT", 405, -90) -- Out Of Combat Alpha Slider panel.ooc_alpha_slider = addon_data.config.SliderFactory( "HunterOOCAlphaSlider", panel, "Out of Combat Alpha", 0, 1, 0.05, addon_data.hunter.OOCAlphaOnValChange) panel.ooc_alpha_slider:SetPoint("TOPLEFT", 405, -140) -- Backplane Alpha Slider panel.backplane_alpha_slider = addon_data.config.SliderFactory( "HunterBackplaneAlphaSlider", panel, "Backplane Alpha", 0, 1, 0.05, addon_data.hunter.BackplaneAlphaOnValChange) panel.backplane_alpha_slider:SetPoint("TOPLEFT", 405, -190) -- Hunter Specific Settings Text panel.hunter_text = addon_data.config.TextFactory(panel, "Hunter Specific Settings", 16) panel.hunter_text:SetPoint("TOPLEFT", 10 , -250) panel.hunter_text:SetTextColor(1, 0.9, 0, 1) -- Show Aimed Shot Cast Bar Checkbox panel.show_aimedshot_cast_bar_checkbox = addon_data.config.CheckBoxFactory( "HunterShowAimedShotCastBarCheckBox", panel, " Aimed Shot cast bar", "Allows the cast bar to show Aimed Shot casts.", addon_data.hunter.ShowAimedShotCastBarCheckBoxOnClick) panel.show_aimedshot_cast_bar_checkbox:SetPoint("TOPLEFT", 10, -250) -- Show Multi Shot Cast Bar Checkbox panel.show_multishot_cast_bar_checkbox = addon_data.config.CheckBoxFactory( "HunterShowMultiShotCastBarCheckBox", panel, " Multi-Shot cast bar", "Allows the cast bar to show Multi-Shot casts.", addon_data.hunter.ShowMultiShotCastBarCheckBoxOnClick) panel.show_multishot_cast_bar_checkbox:SetPoint("TOPLEFT", 10, -270) -- Show Latency Bar Checkbox panel.show_latency_bar_checkbox = addon_data.config.CheckBoxFactory( "HunterShowLatencyBarCheckBox", panel, " Latency bar", "Shows a bar that represents latency on cast bar.", addon_data.hunter.ShowLatencyBarsCheckBoxOnClick) panel.show_latency_bar_checkbox:SetPoint("TOPLEFT", 10, -290) -- Show Multi-Shot Clip Bar Checkbox panel.show_multishot_clip_bar_checkbox = addon_data.config.CheckBoxFactory( "HunterShowMultiShotClipBarCheckBox", panel, " Multi-Shot clip bar", "Shows a bar that represents when a Multi-Shot would clip an Auto Shot.", addon_data.hunter.ShowMultiShotClipBarCheckBoxOnClick) panel.show_multishot_clip_bar_checkbox:SetPoint("TOPLEFT", 10, -310) -- Multi-shot clip color picker panel.multi_clip_color_picker = addon_data.config.color_picker_factory( 'HunterMultiClipColorPicker', panel, settings.clip_r, settings.clip_g, settings.clip_b, settings.clip_a, 'Multi-Shot Clip Color', addon_data.hunter.MultiClipColorPickerOnClick) panel.multi_clip_color_picker:SetPoint('TOPLEFT', 205, -280) -- Add the explaination text panel.explaination_text = addon_data.config.TextFactory(panel, "Bar Explanation", 16) panel.explaination_text:SetPoint("TOPLEFT", 10 , -400) panel.explaination_text:SetTextColor(1, 0.9, 0, 1) -- Add the explaination panel.explaination = panel:CreateTexture(nil, 'ARTWORK') -- Return the final panel addon_data.hunter.UpdateConfigPanelValues() return panel end PK >!OƑRx , WeaponSwingTimer/WeaponSwingTimer_Player.lualocal addon_name, addon_data = ... addon_data.player = {} --[[============================================================================================]]-- --[[===================================== SETTINGS RELATED =====================================]]-- --[[============================================================================================]]-- addon_data.player.default_settings = { enabled = true, width = 200, height = 10, point = "CENTER", rel_point = "CENTER", x_offset = 0, y_offset = -200, in_combat_alpha = 1.0, ooc_alpha = 0.25, backplane_alpha = 0.5, is_locked = false, show_left_text = true, show_right_text = true, show_offhand = true, show_border = true, classic_bars = true, fill_empty = true, main_r = 0.1, main_g = 0.1, main_b = 0.9, main_a = 1.0, main_text_r = 1.0, main_text_g = 1.0, main_text_b = 1.0, main_text_a = 1.0, off_r = 0.1, off_g = 0.1, off_b = 0.9, off_a = 1.0, off_text_r = 1.0, off_text_g = 1.0, off_text_b = 1.0, off_text_a = 1.0, } addon_data.player.class = UnitClass("player")[2] addon_data.player.guid = UnitGUID("player") addon_data.player.main_swing_timer = 0.00001 addon_data.player.prev_main_weapon_speed = 2 addon_data.player.main_weapon_speed = 2 addon_data.player.main_weapon_id = GetInventoryItemID("player", 16) addon_data.player.main_speed_changed = false addon_data.player.off_swing_timer = 0.00001 addon_data.player.prev_off_weapon_speed = 2 addon_data.player.off_weapon_speed = 2 addon_data.player.off_weapon_id = GetInventoryItemID("player", 17) addon_data.player.has_offhand = false addon_data.player.off_speed_changed = false addon_data.player.LoadSettings = function() -- If the carried over settings dont exist then make them if not character_player_settings then character_player_settings = {} end -- If the carried over settings aren't set then set them to the defaults for setting, value in pairs(addon_data.player.default_settings) do if character_player_settings[setting] == nil then character_player_settings[setting] = value end end -- Update settings that dont change unless the interface is reloaded addon_data.player.class = UnitClass("player")[2] addon_data.player.guid = UnitGUID("player") end addon_data.player.RestoreDefaults = function() for setting, value in pairs(addon_data.player.default_settings) do character_player_settings[setting] = value end addon_data.player.UpdateVisualsOnSettingsChange() addon_data.player.UpdateConfigPanelValues() end --[[============================================================================================]]-- --[[====================================== LOGIC RELATED =======================================]]-- --[[============================================================================================]]-- addon_data.player.OnUpdate = function(elapsed) if character_player_settings.enabled then -- Update the weapon speed addon_data.player.UpdateMainWeaponSpeed() addon_data.player.UpdateOffWeaponSpeed() -- FIXME: Temp fix until I can nail down the divide by zero error if addon_data.player.main_weapon_speed == 0 then addon_data.player.main_weapon_speed = 2 end if addon_data.player.off_weapon_speed == 0 then addon_data.player.off_weapon_speed = 2 end -- If the weapon speed changed for either hand then a buff occured and we need to modify the timers if addon_data.player.main_speed_changed or addon_data.player.off_speed_changed then local main_multiplier = addon_data.player.main_weapon_speed / addon_data.player.prev_main_weapon_speed addon_data.player.main_swing_timer = addon_data.player.main_swing_timer * main_multiplier if addon_data.player.has_offhand then local off_multiplier = (addon_data.player.off_weapon_speed / addon_data.player.prev_off_weapon_speed) addon_data.player.off_swing_timer = addon_data.player.off_swing_timer * off_multiplier end end -- Update the main hand swing timer addon_data.player.UpdateMainSwingTimer(elapsed) -- Update the off hand swing timer addon_data.player.UpdateOffSwingTimer(elapsed) -- Update the visuals addon_data.player.UpdateVisualsOnUpdate() end end addon_data.player.OnInventoryChange = function() local new_main_guid = GetInventoryItemID("player", 16) local new_off_guid = GetInventoryItemID("player", 17) -- Check for a main hand weapon change if addon_data.player.main_weapon_id ~= new_main_guid then addon_data.player.UpdateMainWeaponSpeed() addon_data.player.ResetMainSwingTimer() end addon_data.player.main_weapon_id = new_main_guid -- Check for an off hand weapon change if addon_data.player.off_weapon_id ~= new_off_guid then addon_data.player.UpdateOffWeaponSpeed() addon_data.player.ResetOffSwingTimer() end addon_data.player.off_weapon_id = new_off_guid end addon_data.player.OnCombatLogUnfiltered = function(combat_info) local _, event, _, source_guid, _, _, _, dest_guid, _, _, _, _, spell_name, _ = unpack(combat_info) if (source_guid == addon_data.player.guid) then if (event == "SWING_DAMAGE") then local _, _, _, _, _, _, _, _, _, is_offhand = select(12, unpack(combat_info)) if is_offhand then addon_data.player.ResetOffSwingTimer() else addon_data.player.ResetMainSwingTimer() end elseif (event == "SWING_MISSED") then local miss_type, is_offhand = select(12, unpack(combat_info)) addon_data.core.MissHandler("player", miss_type, is_offhand) elseif (event == "SPELL_DAMAGE") or (event == "SPELL_MISSED") then local _, _, _, _, _, _, spell_id = GetSpellInfo(spell_name) addon_data.core.SpellHandler("player", spell_id) end end end addon_data.player.ResetMainSwingTimer = function() addon_data.player.main_swing_timer = addon_data.player.main_weapon_speed end addon_data.player.ResetOffSwingTimer = function() if addon_data.player.has_offhand then addon_data.player.off_swing_timer = addon_data.player.off_weapon_speed end end addon_data.player.ZeroizeSwingTimers = function() addon_data.player.main_swing_timer = 0.0001 addon_data.player.off_swing_timer = 0.0001 end addon_data.player.UpdateMainSwingTimer = function(elapsed) if character_player_settings.enabled then if addon_data.player.main_swing_timer > 0 then addon_data.player.main_swing_timer = addon_data.player.main_swing_timer - elapsed if addon_data.player.main_swing_timer < 0 then addon_data.player.main_swing_timer = 0 end end end end addon_data.player.UpdateOffSwingTimer = function(elapsed) if character_player_settings.enabled then if addon_data.player.has_offhand then if addon_data.player.off_swing_timer > 0 then addon_data.player.off_swing_timer = addon_data.player.off_swing_timer - elapsed if addon_data.player.off_swing_timer < 0 then addon_data.player.off_swing_timer = 0 end end end end end addon_data.player.UpdateMainWeaponSpeed = function() addon_data.player.prev_main_weapon_speed = addon_data.player.main_weapon_speed addon_data.player.main_weapon_speed, _ = UnitAttackSpeed("player") if addon_data.player.main_weapon_speed ~= addon_data.player.prev_main_weapon_speed then addon_data.player.main_speed_changed = true else addon_data.player.main_speed_changed = false end end addon_data.player.UpdateOffWeaponSpeed = function() addon_data.player.prev_off_weapon_speed = addon_data.player.off_weapon_speed _, addon_data.player.off_weapon_speed = UnitAttackSpeed("player") -- Check to see if we have an off-hand if (not addon_data.player.off_weapon_speed) or (addon_data.player.off_weapon_speed == 0) then addon_data.player.has_offhand = false else addon_data.player.has_offhand = true end if addon_data.player.off_weapon_speed ~= addon_data.player.prev_off_weapon_speed then addon_data.player.off_speed_changed = true else addon_data.player.off_speed_changed = false end end --[[============================================================================================]]-- --[[===================================== VISUALS RELATED ======================================]]-- --[[============================================================================================]]-- addon_data.player.UpdateVisualsOnUpdate = function() local settings = character_player_settings local frame = addon_data.player.frame if settings.enabled then local main_speed = addon_data.player.main_weapon_speed local main_timer = addon_data.player.main_swing_timer -- FIXME: Handle divide by 0 error if main_speed == 0 then main_speed = 2 end -- Update the main bars width main_width = math.min(settings.width - (settings.width * (main_timer / main_speed)), settings.width) if not settings.fill_empty then main_width = settings.width - main_width + 0.001 end frame.main_bar:SetWidth(main_width) frame.main_spark:SetPoint('TOPLEFT', main_width - 8, 0) if main_width == settings.width or not settings.classic_bars or main_width == 0.001 then frame.main_spark:Hide() else frame.main_spark:Show() end -- Update the main bars text frame.main_left_text:SetText("Main-Hand") frame.main_right_text:SetText(tostring(addon_data.utils.SimpleRound(main_timer, 0.1))) -- Update the off hand bar if addon_data.player.has_offhand and settings.show_offhand then frame.off_bar:Show() if settings.show_left_text then frame.off_left_text:Show() else frame.off_left_text:Hide() end if settings.show_right_text then frame.off_right_text:Show() else frame.off_right_text:Hide() end local off_speed = addon_data.player.off_weapon_speed local off_timer = addon_data.player.off_swing_timer -- FIXME: Handle divide by 0 error if off_speed == 0 then off_speed = 2 end -- Update the off-hand bar's width off_width = math.min(settings.width - (settings.width * (off_timer / off_speed)), settings.width) if not settings.fill_empty then off_width = settings.width - off_width + 0.001 end frame.off_bar:SetWidth(off_width) frame.off_spark:SetPoint('BOTTOMLEFT', off_width - 8, 0) if off_width == settings.width or not settings.classic_bars or off_width == 0.001 then frame.off_spark:Hide() else frame.off_spark:Show() end -- Update the off-hand bar's text frame.off_left_text:SetText("Off-Hand") frame.off_right_text:SetText(tostring(addon_data.utils.SimpleRound(off_timer, 0.1))) else frame.off_bar:Hide() frame.off_left_text:Hide() frame.off_right_text:Hide() end -- Update the frame's appearance based on settings if addon_data.player.has_offhand and character_player_settings.show_offhand then frame:SetHeight((settings.height * 2) + 2) else frame:SetHeight(settings.height) end -- Update the alpha if addon_data.core.in_combat then frame:SetAlpha(settings.in_combat_alpha) else frame:SetAlpha(settings.ooc_alpha) end end end addon_data.player.UpdateVisualsOnSettingsChange = function() local frame = addon_data.player.frame local settings = character_player_settings if settings.enabled then frame:Show() frame:ClearAllPoints() frame:SetPoint(settings.point, UIParent, settings.rel_point, settings.x_offset, settings.y_offset) frame:SetWidth(settings.width) if settings.show_border then frame.backplane:SetBackdrop({ bgFile = "Interface/AddOns/WeaponSwingTimer/Images/Background", edgeFile = "Interface/AddOns/WeaponSwingTimer/Images/Border", tile = true, tileSize = 16, edgeSize = 12, insets = { left = 8, right = 8, top = 8, bottom = 8}}) else frame.backplane:SetBackdrop({ bgFile = "Interface/AddOns/WeaponSwingTimer/Images/Background", edgeFile = nil, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 8, right = 8, top = 8, bottom = 8}}) end frame.backplane:SetBackdropColor(0,0,0,settings.backplane_alpha) frame.main_bar:SetPoint("TOPLEFT", 0, 0) frame.main_bar:SetHeight(settings.height) if settings.classic_bars then frame.main_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Bar') else frame.main_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Background') end frame.main_bar:SetVertexColor(settings.main_r, settings.main_g, settings.main_b, settings.main_a) frame.main_spark:SetSize(16, settings.height) frame.main_left_text:SetPoint("TOPLEFT", 2, -(settings.height / 2) + 5) frame.main_left_text:SetTextColor(settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) frame.main_right_text:SetPoint("TOPRIGHT", -5, -(settings.height / 2) + 5) frame.main_right_text:SetTextColor(settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) frame.off_bar:SetPoint("BOTTOMLEFT", 0, 0) frame.off_bar:SetHeight(settings.height) if settings.classic_bars then frame.off_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Bar') else frame.off_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Background') end frame.off_bar:SetVertexColor(settings.off_r, settings.off_g, settings.off_b, settings.off_a) frame.off_spark:SetSize(16, settings.height) frame.off_left_text:SetPoint("BOTTOMLEFT", 2, (settings.height / 2) - 5) frame.off_left_text:SetTextColor(settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) frame.off_right_text:SetPoint("BOTTOMRIGHT", -5, (settings.height / 2) - 5) frame.off_right_text:SetTextColor(settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) if settings.show_left_text then frame.main_left_text:Show() frame.off_left_text:Show() else frame.main_left_text:Hide() frame.off_left_text:Hide() end if settings.show_right_text then frame.main_right_text:Show() frame.off_right_text:Show() else frame.main_right_text:Hide() frame.off_right_text:Hide() end if settings.show_offhand and addon_data.player.has_offhand then frame.off_bar:Show() if settings.show_left_text then frame.off_left_text:Show() else frame.off_left_text:Hide() end if settings.show_right_text then frame.off_right_text:Show() else frame.off_right_text:Hide() end else frame.off_bar:Hide() frame.off_left_text:Hide() frame.off_right_text:Hide() end else frame:Hide() end end addon_data.player.OnFrameDragStart = function() if not character_player_settings.is_locked then addon_data.player.frame:StartMoving() end end addon_data.player.OnFrameDragStop = function() local frame = addon_data.player.frame local settings = character_player_settings frame:StopMovingOrSizing() point, _, rel_point, x_offset, y_offset = frame:GetPoint() if x_offset < 20 and x_offset > -20 then x_offset = 0 end settings.point = point settings.rel_point = rel_point settings.x_offset = addon_data.utils.SimpleRound(x_offset, 1) settings.y_offset = addon_data.utils.SimpleRound(y_offset, 1) addon_data.player.UpdateVisualsOnSettingsChange() addon_data.player.UpdateConfigPanelValues() end addon_data.player.InitializeVisuals = function() local settings = character_player_settings -- Create the frame addon_data.player.frame = CreateFrame("Frame", addon_name .. "PlayerFrame", UIParent) local frame = addon_data.player.frame frame:SetMovable(true) frame:EnableMouse(not settings.is_locked) frame:RegisterForDrag("LeftButton") frame:SetScript("OnDragStart", addon_data.player.OnFrameDragStart) frame:SetScript("OnDragStop", addon_data.player.OnFrameDragStop) -- Create the backplane and border frame.backplane = CreateFrame("Frame", addon_name .. "PlayerBackdropFrame", frame) frame.backplane:SetPoint('TOPLEFT', -9, 9) frame.backplane:SetPoint('BOTTOMRIGHT', 9, -9) frame.backplane:SetFrameStrata('BACKGROUND') -- Create the main hand bar frame.main_bar = frame:CreateTexture(nil,"ARTWORK") -- Create the main spark frame.main_spark = frame:CreateTexture(nil,"OVERLAY") frame.main_spark:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Spark') -- Create the main hand bar left text frame.main_left_text = frame:CreateFontString(nil, "OVERLAY") frame.main_left_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.main_left_text:SetJustifyV("CENTER") frame.main_left_text:SetJustifyH("LEFT") -- Create the main hand bar right text frame.main_right_text = frame:CreateFontString(nil, "OVERLAY") frame.main_right_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.main_right_text:SetJustifyV("CENTER") frame.main_right_text:SetJustifyH("RIGHT") -- Create the off hand bar frame.off_bar = frame:CreateTexture(nil,"ARTWORK") -- Create the off spark frame.off_spark = frame:CreateTexture(nil,"OVERLAY") frame.off_spark:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Spark') -- Create the off hand bar left text frame.off_left_text = frame:CreateFontString(nil, "OVERLAY") frame.off_left_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.off_left_text:SetJustifyV("CENTER") frame.off_left_text:SetJustifyH("LEFT") -- Create the off hand bar right text frame.off_right_text = frame:CreateFontString(nil, "OVERLAY") frame.off_right_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.off_right_text:SetJustifyV("CENTER") frame.off_right_text:SetJustifyH("RIGHT") -- Show it off addon_data.player.UpdateVisualsOnSettingsChange() addon_data.player.UpdateVisualsOnUpdate() frame:Show() end --[[============================================================================================]]-- --[[================================== CONFIG WINDOW RELATED ===================================]]-- --[[============================================================================================]]-- addon_data.player.UpdateConfigPanelValues = function() local panel = addon_data.player.config_frame local settings = character_player_settings panel.enabled_checkbox:SetChecked(settings.enabled) panel.show_offhand_checkbox:SetChecked(settings.show_offhand) panel.show_border_checkbox:SetChecked(settings.show_border) panel.classic_bars_checkbox:SetChecked(settings.classic_bars) panel.fill_empty_checkbox:SetChecked(settings.fill_empty) panel.show_left_text_checkbox:SetChecked(settings.show_left_text) panel.show_right_text_checkbox:SetChecked(settings.show_right_text) panel.width_editbox:SetText(tostring(settings.width)) panel.width_editbox:SetCursorPosition(0) panel.height_editbox:SetText(tostring(settings.height)) panel.height_editbox:SetCursorPosition(0) panel.x_offset_editbox:SetText(tostring(settings.x_offset)) panel.x_offset_editbox:SetCursorPosition(0) panel.y_offset_editbox:SetText(tostring(settings.y_offset)) panel.y_offset_editbox:SetCursorPosition(0) panel.main_color_picker.foreground:SetColorTexture( settings.main_r, settings.main_g, settings.main_b, settings.main_a) panel.main_text_color_picker.foreground:SetColorTexture( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) panel.off_color_picker.foreground:SetColorTexture( settings.off_r, settings.off_g, settings.off_b, settings.off_a) panel.off_text_color_picker.foreground:SetColorTexture( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) panel.in_combat_alpha_slider:SetValue(settings.in_combat_alpha) panel.in_combat_alpha_slider.editbox:SetCursorPosition(0) panel.ooc_alpha_slider:SetValue(settings.ooc_alpha) panel.ooc_alpha_slider.editbox:SetCursorPosition(0) panel.backplane_alpha_slider:SetValue(settings.backplane_alpha) panel.backplane_alpha_slider.editbox:SetCursorPosition(0) end addon_data.player.EnabledCheckBoxOnClick = function(self) character_player_settings.enabled = self:GetChecked() addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.ShowOffHandCheckBoxOnClick = function(self) character_player_settings.show_offhand = self:GetChecked() addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.ShowBorderCheckBoxOnClick = function(self) character_player_settings.show_border = self:GetChecked() addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.ClassicBarsCheckBoxOnClick = function(self) character_player_settings.classic_bars = self:GetChecked() addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.FillEmptyCheckBoxOnClick = function(self) character_player_settings.fill_empty = self:GetChecked() addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.ShowLeftTextCheckBoxOnClick = function(self) character_player_settings.show_left_text = self:GetChecked() addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.ShowRightTextCheckBoxOnClick = function(self) character_player_settings.show_right_text = self:GetChecked() addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.WidthEditBoxOnEnter = function(self) character_player_settings.width = tonumber(self:GetText()) addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.HeightEditBoxOnEnter = function(self) character_player_settings.height = tonumber(self:GetText()) addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.XOffsetEditBoxOnEnter = function(self) character_player_settings.x_offset = tonumber(self:GetText()) addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.YOffsetEditBoxOnEnter = function(self) character_player_settings.y_offset = tonumber(self:GetText()) addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.MainColorPickerOnClick = function() local settings = character_player_settings local function MainOnActionFunc(restore) local settings = character_player_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.main_r, settings.main_g, settings.main_b, settings.main_a = new_r, new_g, new_b, new_a addon_data.player.frame.main_bar:SetVertexColor( settings.main_r, settings.main_g, settings.main_b, settings.main_a) addon_data.player.config_frame.main_color_picker.foreground:SetColorTexture( settings.main_r, settings.main_g, settings.main_b, settings.main_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = MainOnActionFunc, MainOnActionFunc, MainOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.main_a ColorPickerFrame:SetColorRGB(settings.main_r, settings.main_g, settings.main_b) ColorPickerFrame.previousValues = {settings.main_r, settings.main_g, settings.main_b, settings.main_a} ColorPickerFrame:Show() end addon_data.player.MainTextColorPickerOnClick = function() local settings = character_player_settings local function MainTextOnActionFunc(restore) local settings = character_player_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a = new_r, new_g, new_b, new_a addon_data.player.frame.main_left_text:SetTextColor( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) addon_data.player.frame.main_right_text:SetTextColor( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) addon_data.player.config_frame.main_text_color_picker.foreground:SetColorTexture( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = MainTextOnActionFunc, MainTextOnActionFunc, MainTextOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.main_text_a ColorPickerFrame:SetColorRGB(settings.main_text_r, settings.main_text_g, settings.main_text_b) ColorPickerFrame.previousValues = {settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a} ColorPickerFrame:Show() end addon_data.player.OffColorPickerOnClick = function() local settings = character_player_settings local function OffOnActionFunc(restore) local settings = character_player_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.off_r, settings.off_g, settings.off_b, settings.off_a = new_r, new_g, new_b, new_a addon_data.player.frame.off_bar:SetVertexColor( settings.off_r, settings.off_g, settings.off_b, settings.off_a) addon_data.player.config_frame.off_color_picker.foreground:SetColorTexture( settings.off_r, settings.off_g, settings.off_b, settings.off_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = OffOnActionFunc, OffOnActionFunc, OffOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.off_a ColorPickerFrame:SetColorRGB(settings.off_r, settings.off_g, settings.off_b) ColorPickerFrame.previousValues = {settings.off_r, settings.off_g, settings.off_b, settings.off_a} ColorPickerFrame:Show() end addon_data.player.OffTextColorPickerOnClick = function() local settings = character_player_settings local function OffTextOnActionFunc(restore) local settings = character_player_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a = new_r, new_g, new_b, new_a addon_data.player.frame.off_left_text:SetTextColor( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) addon_data.player.frame.off_right_text:SetTextColor( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) addon_data.player.config_frame.off_text_color_picker.foreground:SetColorTexture( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = OffTextOnActionFunc, OffTextOnActionFunc, OffTextOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.off_text_a ColorPickerFrame:SetColorRGB(settings.off_text_r, settings.off_text_g, settings.off_text_b) ColorPickerFrame.previousValues = {settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a} ColorPickerFrame:Show() end addon_data.player.CombatAlphaOnValChange = function(self) character_player_settings.in_combat_alpha = tonumber(self:GetValue()) addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.OOCAlphaOnValChange = function(self) character_player_settings.ooc_alpha = tonumber(self:GetValue()) addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.BackplaneAlphaOnValChange = function(self) character_player_settings.backplane_alpha = tonumber(self:GetValue()) addon_data.player.UpdateVisualsOnSettingsChange() end addon_data.player.CreateConfigPanel = function(parent_panel) addon_data.player.config_frame = CreateFrame("Frame", addon_name .. "PlayerConfigPanel", parent_panel) local panel = addon_data.player.config_frame local settings = character_player_settings -- Title Text panel.title_text = addon_data.config.TextFactory(panel, "Player Swing Bar Settings", 20) panel.title_text:SetPoint("TOPLEFT", 10, -10) panel.title_text:SetTextColor(1, 0.82, 0, 1) -- Enabled Checkbox panel.enabled_checkbox = addon_data.config.CheckBoxFactory( "PlayerEnabledCheckBox", panel, " Enable", "Enables the player's swing bars.", addon_data.player.EnabledCheckBoxOnClick) panel.enabled_checkbox:SetPoint("TOPLEFT", 10, -40) -- Show Off-Hand Checkbox panel.show_offhand_checkbox = addon_data.config.CheckBoxFactory( "PlayerShowOffHandCheckBox", panel, " Show Off-Hand", "Enables the player's off-hand swing bar.", addon_data.player.ShowOffHandCheckBoxOnClick) panel.show_offhand_checkbox:SetPoint("TOPLEFT", 10, -60) -- Show Border Checkbox panel.show_border_checkbox = addon_data.config.CheckBoxFactory( "PlayerShowBorderCheckBox", panel, " Show border", "Enables the player bar's border.", addon_data.player.ShowBorderCheckBoxOnClick) panel.show_border_checkbox:SetPoint("TOPLEFT", 10, -80) -- Show Classic Bars Checkbox panel.classic_bars_checkbox = addon_data.config.CheckBoxFactory( "PlayerClassicBarsCheckBox", panel, " Classic bars", "Enables the classic texture for the player's bars.", addon_data.player.ClassicBarsCheckBoxOnClick) panel.classic_bars_checkbox:SetPoint("TOPLEFT", 10, -100) -- Fill/Empty Checkbox panel.fill_empty_checkbox = addon_data.config.CheckBoxFactory( "PlayerFillEmptyCheckBox", panel, " Fill / Empty", "Determines if the bar is full or empty when a swing is ready.", addon_data.player.FillEmptyCheckBoxOnClick) panel.fill_empty_checkbox:SetPoint("TOPLEFT", 10, -120) -- Show Left Text Checkbox panel.show_left_text_checkbox = addon_data.config.CheckBoxFactory( "PlayerShowLeftTextCheckBox", panel, " Show Left Text", "Enables the player's left side text.", addon_data.player.ShowLeftTextCheckBoxOnClick) panel.show_left_text_checkbox:SetPoint("TOPLEFT", 10, -140) -- Show Right Text Checkbox panel.show_right_text_checkbox = addon_data.config.CheckBoxFactory( "PlayerShowRightTextCheckBox", panel, " Show Right Text", "Enables the player's right side text.", addon_data.player.ShowRightTextCheckBoxOnClick) panel.show_right_text_checkbox:SetPoint("TOPLEFT", 10, -160) -- Width EditBox panel.width_editbox = addon_data.config.EditBoxFactory( "PlayerWidthEditBox", panel, "Bar Width", 75, 25, addon_data.player.WidthEditBoxOnEnter) panel.width_editbox:SetPoint("TOPLEFT", 200, -60, "BOTTOMRIGHT", 275, -85) -- Height EditBox panel.height_editbox = addon_data.config.EditBoxFactory( "PlayerHeightEditBox", panel, "Bar Height", 75, 25, addon_data.player.HeightEditBoxOnEnter) panel.height_editbox:SetPoint("TOPLEFT", 280, -60, "BOTTOMRIGHT", 355, -85) -- X Offset EditBox panel.x_offset_editbox = addon_data.config.EditBoxFactory( "PlayerXOffsetEditBox", panel, "X Offset", 75, 25, addon_data.player.XOffsetEditBoxOnEnter) panel.x_offset_editbox:SetPoint("TOPLEFT", 200, -110, "BOTTOMRIGHT", 275, -135) -- Y Offset EditBox panel.y_offset_editbox = addon_data.config.EditBoxFactory( "PlayerYOffsetEditBox", panel, "Y Offset", 75, 25, addon_data.player.YOffsetEditBoxOnEnter) panel.y_offset_editbox:SetPoint("TOPLEFT", 280, -110, "BOTTOMRIGHT", 355, -135) -- Main-hand color picker panel.main_color_picker = addon_data.config.color_picker_factory( 'PlayerMainColorPicker', panel, settings.main_r, settings.main_g, settings.main_b, settings.main_a, 'Main-hand Bar Color', addon_data.player.MainColorPickerOnClick) panel.main_color_picker:SetPoint('TOPLEFT', 205, -150) -- Main-hand color text picker panel.main_text_color_picker = addon_data.config.color_picker_factory( 'PlayerMainTextColorPicker', panel, settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a, 'Main-hand Bar Text Color', addon_data.player.MainTextColorPickerOnClick) panel.main_text_color_picker:SetPoint('TOPLEFT', 205, -170) -- Off-hand color picker panel.off_color_picker = addon_data.config.color_picker_factory( 'PlayerOffColorPicker', panel, settings.off_r, settings.off_g, settings.off_b, settings.off_a, 'Off-hand Bar Color', addon_data.player.OffColorPickerOnClick) panel.off_color_picker:SetPoint('TOPLEFT', 205, -200) -- Off-hand color text picker panel.off_text_color_picker = addon_data.config.color_picker_factory( 'PlayerOffTextColorPicker', panel, settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a, 'Off-hand Bar Text Color', addon_data.player.OffTextColorPickerOnClick) panel.off_text_color_picker:SetPoint('TOPLEFT', 205, -220) -- In Combat Alpha Slider panel.in_combat_alpha_slider = addon_data.config.SliderFactory( "PlayerInCombatAlphaSlider", panel, "In Combat Alpha", 0, 1, 0.05, addon_data.player.CombatAlphaOnValChange) panel.in_combat_alpha_slider:SetPoint("TOPLEFT", 405, -60) -- Out Of Combat Alpha Slider panel.ooc_alpha_slider = addon_data.config.SliderFactory( "PlayerOOCAlphaSlider", panel, "Out of Combat Alpha", 0, 1, 0.05, addon_data.player.OOCAlphaOnValChange) panel.ooc_alpha_slider:SetPoint("TOPLEFT", 405, -110) -- Backplane Alpha Slider panel.backplane_alpha_slider = addon_data.config.SliderFactory( "PlayerBackplaneAlphaSlider", panel, "Backplane Alpha", 0, 1, 0.05, addon_data.player.BackplaneAlphaOnValChange) panel.backplane_alpha_slider:SetPoint("TOPLEFT", 405, -160) -- Return the final panel addon_data.player.UpdateConfigPanelValues() return panel end PK >!OҖ Җ , WeaponSwingTimer/WeaponSwingTimer_Target.lualocal addon_name, addon_data = ... addon_data.target = {} --[[============================================================================================]]-- --[[===================================== SETTINGS RELATED =====================================]]-- --[[============================================================================================]]-- addon_data.target.default_settings = { enabled = true, width = 200, height = 10, point = "CENTER", rel_point = "CENTER", x_offset = 0, y_offset = -230, in_combat_alpha = 1.0, ooc_alpha = 0.25, backplane_alpha = 0.5, is_locked = false, show_left_text = true, show_right_text = true, show_offhand = true, show_border = true, classic_bars = true, fill_empty = true, main_r = 0.8, main_g = 0.1, main_b = 0.1, main_a = 1.0, main_text_r = 1.0, main_text_g = 1.0, main_text_b = 1.0, main_text_a = 1.0, off_r = 0.8, off_g = 0.1, off_b = 0.1, off_a = 1.0, off_text_r = 1.0, off_text_g = 1.0, off_text_b = 1.0, off_text_a = 1.0 } addon_data.target.class = 'WARRIOR' addon_data.target.guid = 0 addon_data.target.main_swing_timer = 0.00001 addon_data.target.prev_main_weapon_speed = 2 addon_data.target.main_weapon_speed = 2 addon_data.target.main_weapon_id = GetInventoryItemID("target", 16) addon_data.target.main_speed_changed = false addon_data.target.off_swing_timer = 0.00001 addon_data.target.prev_off_weapon_speed = 2 addon_data.target.off_weapon_speed = 2 addon_data.target.off_weapon_id = GetInventoryItemID("target", 17) addon_data.target.has_offhand = false addon_data.target.off_speed_changed = false addon_data.target.LoadSettings = function() -- If the carried over settings dont exist then make them if not character_target_settings then character_target_settings = {} end -- If the carried over settings aren't set then set them to the defaults for setting, value in pairs(addon_data.target.default_settings) do if character_target_settings[setting] == nil then character_target_settings[setting] = value end end end addon_data.target.RestoreDefaults = function() for setting, value in pairs(addon_data.target.default_settings) do character_target_settings[setting] = value end addon_data.target.UpdateVisualsOnSettingsChange() addon_data.target.UpdateConfigPanelValues() end --[[============================================================================================]]-- --[[====================================== LOGIC RELATED =======================================]]-- --[[============================================================================================]]-- addon_data.target.OnPlayerTargetChanged = function() if UnitExists("target") then addon_data.target.class = UnitClass("target")[2] addon_data.target.guid = UnitGUID("target") addon_data.target.ZeroizeSwingTimers() end end addon_data.target.OnInventoryChange = function() local new_main_guid = GetInventoryItemID("target", 16) local new_off_guid = GetInventoryItemID("target", 17) -- Check for a main hand weapon change if addon_data.target.main_weapon_id ~= new_main_guid then addon_data.target.UpdateMainWeaponSpeed() addon_data.target.ResetMainSwingTimer() end addon_data.target.main_weapon_id = new_main_guid -- Check for an off hand weapon change if addon_data.target.off_weapon_id ~= new_off_guid then addon_data.target.UpdateOffWeaponSpeed() addon_data.target.ResetOffSwingTimer() end addon_data.target.off_weapon_id = new_off_guid end addon_data.target.OnUpdate = function(elapsed) if character_target_settings.enabled and UnitExists("target") then -- Update the weapon speed addon_data.target.UpdateMainWeaponSpeed() addon_data.target.UpdateOffWeaponSpeed() -- FIXME: Temp fix until I can nail down the divide by zero error if addon_data.target.main_weapon_speed == 0 then addon_data.target.main_weapon_speed = 2 end if addon_data.target.off_weapon_speed == 0 then addon_data.target.off_weapon_speed = 2 end -- If the weapon speed changed for either hand then a buff occured and we need to modify the timers if addon_data.target.main_speed_changed or addon_data.target.off_speed_changed then local main_multiplier = addon_data.target.main_weapon_speed / addon_data.target.prev_main_weapon_speed addon_data.target.main_swing_timer = addon_data.target.main_swing_timer * main_multiplier if addon_data.target.has_offhand then local off_multiplier = (addon_data.target.off_weapon_speed / addon_data.target.prev_off_weapon_speed) addon_data.target.off_swing_timer = addon_data.target.off_swing_timer * off_multiplier end end -- Update the main hand swing timer addon_data.target.UpdateMainSwingTimer(elapsed) -- Update the off hand swing timer addon_data.target.UpdateOffSwingTimer(elapsed) end -- Update the visuals addon_data.target.UpdateVisualsOnUpdate() end addon_data.target.OnCombatLogUnfiltered = function(combat_info) local _, event, _, source_guid, _, _, _, dest_guid, _, _, _, _, spell_name, _ = unpack(combat_info) if (source_guid == addon_data.target.guid) then if (event == "SWING_DAMAGE") then local _, _, _, _, _, _, _, _, _, is_offhand = select(12, unpack(combat_info)) if is_offhand then addon_data.target.ResetOffSwingTimer() else addon_data.target.ResetMainSwingTimer() end elseif (event == "SWING_MISSED") then local miss_type, is_offhand = select(12, unpack(combat_info)) addon_data.core.MissHandler("target", miss_type, is_offhand) elseif (event == "SPELL_DAMAGE") or (event == "SPELL_MISSED") then local _, _, _, _, _, _, spell_id = GetSpellInfo(spell_name) addon_data.core.SpellHandler("target", spell_id) end end end addon_data.target.ResetMainSwingTimer = function() if UnitExists("target") then addon_data.target.main_swing_timer = addon_data.target.main_weapon_speed end end addon_data.target.ResetOffSwingTimer = function() if addon_data.target.has_offhand and UnitExists("target") then addon_data.target.off_swing_timer = addon_data.target.off_weapon_speed end end addon_data.target.ZeroizeSwingTimers = function() addon_data.target.main_swing_timer = 0.0001 addon_data.target.off_swing_timer = 0.0001 end addon_data.target.UpdateMainSwingTimer = function(elapsed) if character_target_settings.enabled and UnitExists("target") then if addon_data.target.main_swing_timer > 0 then addon_data.target.main_swing_timer = addon_data.target.main_swing_timer - elapsed if addon_data.target.main_swing_timer < 0 then addon_data.target.main_swing_timer = 0 end end end end addon_data.target.UpdateOffSwingTimer = function(elapsed) if character_target_settings.enabled and UnitExists("target") then if addon_data.target.has_offhand then if addon_data.target.off_swing_timer > 0 then addon_data.target.off_swing_timer = addon_data.target.off_swing_timer - elapsed if addon_data.target.off_swing_timer < 0 then addon_data.target.off_swing_timer = 0 end end end end end addon_data.target.UpdateMainWeaponSpeed = function() if UnitExists("target") then -- Handle the nil when first selecting target if addon_data.target.main_weapon_speed then addon_data.target.prev_main_weapon_speed = addon_data.target.main_weapon_speed else addon_data.target.prev_main_weapon_speed, _ = UnitAttackSpeed("target") end -- Update the weapon speed addon_data.target.main_weapon_speed, _ = UnitAttackSpeed("target") if addon_data.target.main_weapon_speed ~= addon_data.target.prev_main_weapon_speed then addon_data.target.main_speed_changed = true else addon_data.target.main_speed_changed = false end end end addon_data.target.UpdateOffWeaponSpeed = function() if UnitExists("target") then -- Handle the nil when first selecting target if addon_data.target.off_weapon_speed then addon_data.target.prev_off_weapon_speed = addon_data.target.off_weapon_speed else _, addon_data.target.prev_off_weapon_speed = UnitAttackSpeed("target") end -- Update the weapon speed _, addon_data.target.off_weapon_speed = UnitAttackSpeed("target") -- Check to see if we have an off-hand if (not addon_data.target.off_weapon_speed) or (addon_data.target.off_weapon_speed == 0) then addon_data.target.has_offhand = false else addon_data.target.has_offhand = true end if addon_data.target.off_weapon_speed ~= addon_data.target.prev_off_weapon_speed then addon_data.target.off_speed_changed = true else addon_data.target.off_speed_changed = false end end end --[[============================================================================================]]-- --[[===================================== VISUALS RELATED ======================================]]-- --[[============================================================================================]]-- addon_data.target.UpdateVisualsOnUpdate = function() local settings = character_target_settings local frame = addon_data.target.frame if settings.enabled and UnitExists("target") then frame:Show() local main_speed = addon_data.target.main_weapon_speed local main_timer = addon_data.target.main_swing_timer -- FIXME: Handle divide by 0 error if main_speed == 0 then main_speed = 2 end -- Update the main bars width main_width = math.min(settings.width - (settings.width * (main_timer / main_speed)), settings.width) if not settings.fill_empty then main_width = settings.width - main_width + 0.001 end frame.main_bar:SetWidth(main_width) frame.main_spark:SetPoint('TOPLEFT', main_width - 8, 0) if main_width == settings.width or not settings.classic_bars or main_width == 0.001 then frame.main_spark:Hide() else frame.main_spark:Show() end -- Update the main bars text frame.main_left_text:SetText("Main-Hand") frame.main_right_text:SetText(tostring(addon_data.utils.SimpleRound(main_timer, 0.1))) -- Update the off hand bar if addon_data.target.has_offhand and settings.show_offhand then frame.off_bar:Show() if settings.show_left_text then frame.off_left_text:Show() else frame.off_left_text:Hide() end if settings.show_right_text then frame.off_right_text:Show() else frame.off_right_text:Hide() end local off_speed = addon_data.target.off_weapon_speed local off_timer = addon_data.target.off_swing_timer -- FIXME: Handle divide by 0 error if off_speed == 0 then off_speed = 2 end -- Update the off-hand bar's width off_width = math.min(settings.width - (settings.width * (off_timer / off_speed)), settings.width) if not settings.fill_empty then off_width = settings.width - off_width + 0.001 end frame.off_bar:SetWidth(off_width) frame.off_spark:SetPoint('BOTTOMLEFT', off_width - 8, 0) if off_width == settings.width or not settings.classic_bars or off_width == 0.001 then frame.off_spark:Hide() else frame.off_spark:Show() end -- Update the off-hand bar's text frame.off_left_text:SetText("Off-Hand") frame.off_right_text:SetText(tostring(addon_data.utils.SimpleRound(off_timer, 0.1))) else frame.off_bar:Hide() frame.off_left_text:Hide() frame.off_right_text:Hide() end -- Update the frame's appearance based on settings if addon_data.target.has_offhand and character_target_settings.show_offhand then frame:SetHeight((settings.height * 2) + 2) else frame:SetHeight(settings.height) end -- Update the alpha if addon_data.core.in_combat then frame:SetAlpha(settings.in_combat_alpha) else frame:SetAlpha(settings.ooc_alpha) end else frame:Hide() end end addon_data.target.UpdateVisualsOnSettingsChange = function() local frame = addon_data.target.frame local settings = character_target_settings if settings.enabled then frame:Show() frame:ClearAllPoints() frame:SetPoint(settings.point, UIParent, settings.rel_point, settings.x_offset, settings.y_offset) frame:SetWidth(settings.width) if settings.show_border then frame.backplane:SetBackdrop({ bgFile = "Interface/AddOns/WeaponSwingTimer/Images/Background", edgeFile = "Interface/AddOns/WeaponSwingTimer/Images/Border", tile = true, tileSize = 16, edgeSize = 12, insets = { left = 8, right = 8, top = 8, bottom = 8}}) else frame.backplane:SetBackdrop({ bgFile = "Interface/AddOns/WeaponSwingTimer/Images/Background", edgeFile = nil, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 8, right = 8, top = 8, bottom = 8}}) end frame.backplane:SetBackdropColor(0, 0, 0, settings.backplane_alpha) frame.main_bar:SetPoint("TOPLEFT", 0, 0) frame.main_bar:SetHeight(settings.height) if settings.classic_bars then frame.main_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Bar') else frame.main_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Background') end frame.main_bar:SetVertexColor(settings.main_r, settings.main_g, settings.main_b, settings.main_a) frame.main_spark:SetSize(16, settings.height) frame.main_left_text:SetPoint("TOPLEFT", 2, -(settings.height / 2) + 5) frame.main_left_text:SetTextColor(settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) frame.main_right_text:SetPoint("TOPRIGHT", -5, -(settings.height / 2) + 5) frame.main_right_text:SetTextColor(settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) frame.off_bar:SetPoint("BOTTOMLEFT", 0, 0) frame.off_bar:SetHeight(settings.height) if settings.classic_bars then frame.off_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Bar') else frame.off_bar:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Background') end frame.off_bar:SetVertexColor(settings.off_r, settings.off_g, settings.off_b, settings.off_a) frame.off_spark:SetSize(16, settings.height) frame.off_left_text:SetPoint("BOTTOMLEFT", 2, (settings.height / 2) - 5) frame.off_left_text:SetTextColor(settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) frame.off_right_text:SetPoint("BOTTOMRIGHT", -5, (settings.height / 2) - 5) frame.off_right_text:SetTextColor(settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) if settings.show_left_text then frame.main_left_text:Show() frame.off_left_text:Show() else frame.main_left_text:Hide() frame.off_left_text:Hide() end if settings.show_right_text then frame.main_right_text:Show() frame.off_right_text:Show() else frame.main_right_text:Hide() frame.off_right_text:Hide() end if settings.show_offhand and addon_data.target.has_offhand then frame.off_bar:Show() if settings.show_left_text then frame.off_left_text:Show() else frame.off_left_text:Hide() end if settings.show_right_text then frame.off_right_text:Show() else frame.off_right_text:Hide() end else frame.off_bar:Hide() frame.off_left_text:Hide() frame.off_right_text:Hide() end else frame:Hide() end end addon_data.target.OnFrameDragStart = function() if not character_target_settings.is_locked then addon_data.target.frame:StartMoving() end end addon_data.target.OnFrameDragStop = function() local frame = addon_data.target.frame local settings = character_target_settings frame:StopMovingOrSizing() point, _, rel_point, x_offset, y_offset = frame:GetPoint() if x_offset < 20 and x_offset > -20 then x_offset = 0 end settings.point = point settings.rel_point = rel_point settings.x_offset = addon_data.utils.SimpleRound(x_offset, 1) settings.y_offset = addon_data.utils.SimpleRound(y_offset, 1) addon_data.target.UpdateVisualsOnSettingsChange() addon_data.target.UpdateConfigPanelValues() end addon_data.target.InitializeVisuals = function() local settings = character_target_settings -- Create the frame addon_data.target.frame = CreateFrame("Frame", addon_name .. "TargetFrame", UIParent) local frame = addon_data.target.frame frame:SetMovable(true) frame:EnableMouse(not settings.is_locked) frame:RegisterForDrag("LeftButton") frame:SetScript("OnDragStart", addon_data.target.OnFrameDragStart) frame:SetScript("OnDragStop", addon_data.target.OnFrameDragStop) -- Create the backplane frame.backplane = CreateFrame("Frame", addon_name .. "TargetBackdropFrame", frame) frame.backplane:SetPoint('TOPLEFT', -9, 9) frame.backplane:SetPoint('BOTTOMRIGHT', 9, -9) frame.backplane:SetFrameStrata('BACKGROUND') -- Create the main hand bar frame.main_bar = frame:CreateTexture(nil,"ARTWORK") -- Create the main spark frame.main_spark = frame:CreateTexture(nil,"OVERLAY") frame.main_spark:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Spark') -- Create the main hand bar left text frame.main_left_text = frame:CreateFontString(nil, "OVERLAY") frame.main_left_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.main_left_text:SetJustifyV("CENTER") frame.main_left_text:SetJustifyH("LEFT") -- Create the main hand bar right text frame.main_right_text = frame:CreateFontString(nil, "OVERLAY") frame.main_right_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.main_right_text:SetJustifyV("CENTER") frame.main_right_text:SetJustifyH("RIGHT") -- Create the off hand bar frame.off_bar = frame:CreateTexture(nil,"ARTWORK") -- Create the off spark frame.off_spark = frame:CreateTexture(nil,"OVERLAY") frame.off_spark:SetTexture('Interface/AddOns/WeaponSwingTimer/Images/Spark') -- Create the off hand bar left text frame.off_left_text = frame:CreateFontString(nil, "OVERLAY") frame.off_left_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.off_left_text:SetJustifyV("CENTER") frame.off_left_text:SetJustifyH("LEFT") -- Create the off hand bar right text frame.off_right_text = frame:CreateFontString(nil, "OVERLAY") frame.off_right_text:SetFont("Fonts/FRIZQT__.ttf", 10) frame.off_right_text:SetJustifyV("CENTER") frame.off_right_text:SetJustifyH("RIGHT") -- Show it off addon_data.target.UpdateVisualsOnSettingsChange() addon_data.target.UpdateVisualsOnUpdate() frame:Show() end --[[============================================================================================]]-- --[[================================== CONFIG WINDOW RELATED ===================================]]-- --[[============================================================================================]]-- addon_data.target.UpdateConfigPanelValues = function() local panel = addon_data.target.config_frame local settings = character_target_settings panel.enabled_checkbox:SetChecked(settings.enabled) panel.show_offhand_checkbox:SetChecked(settings.show_offhand) panel.show_border_checkbox:SetChecked(settings.show_border) panel.classic_bars_checkbox:SetChecked(settings.classic_bars) panel.fill_empty_checkbox:SetChecked(settings.fill_empty) panel.show_left_text_checkbox:SetChecked(settings.show_left_text) panel.show_right_text_checkbox:SetChecked(settings.show_right_text) panel.width_editbox:SetText(tostring(settings.width)) panel.width_editbox:SetCursorPosition(0) panel.height_editbox:SetText(tostring(settings.height)) panel.height_editbox:SetCursorPosition(0) panel.x_offset_editbox:SetText(tostring(settings.x_offset)) panel.x_offset_editbox:SetCursorPosition(0) panel.y_offset_editbox:SetText(tostring(settings.y_offset)) panel.y_offset_editbox:SetCursorPosition(0) panel.main_color_picker.foreground:SetColorTexture( settings.main_r, settings.main_g, settings.main_b, settings.main_a) panel.main_text_color_picker.foreground:SetColorTexture( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) panel.off_color_picker.foreground:SetColorTexture( settings.off_r, settings.off_g, settings.off_b, settings.off_a) panel.off_text_color_picker.foreground:SetColorTexture( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) panel.in_combat_alpha_slider:SetValue(settings.in_combat_alpha) panel.in_combat_alpha_slider.editbox:SetCursorPosition(0) panel.ooc_alpha_slider:SetValue(settings.ooc_alpha) panel.ooc_alpha_slider.editbox:SetCursorPosition(0) panel.backplane_alpha_slider:SetValue(settings.backplane_alpha) panel.backplane_alpha_slider.editbox:SetCursorPosition(0) end addon_data.target.EnabledCheckBoxOnClick = function(self) character_target_settings.enabled = self:GetChecked() addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.ShowOffHandCheckBoxOnClick = function(self) character_target_settings.show_offhand = self:GetChecked() addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.ShowBorderCheckBoxOnClick = function(self) character_target_settings.show_border = self:GetChecked() addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.ClassicBarsCheckBoxOnClick = function(self) character_target_settings.classic_bars = self:GetChecked() addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.FillEmptyCheckBoxOnClick = function(self) character_target_settings.fill_empty = self:GetChecked() addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.ShowLeftTextCheckBoxOnClick = function(self) character_target_settings.show_left_text = self:GetChecked() addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.ShowRightTextCheckBoxOnClick = function(self) character_target_settings.show_right_text = self:GetChecked() addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.WidthEditBoxOnEnter = function(self) character_target_settings.width = tonumber(self:GetText()) addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.HeightEditBoxOnEnter = function(self) character_target_settings.height = tonumber(self:GetText()) addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.XOffsetEditBoxOnEnter = function(self) character_target_settings.x_offset = tonumber(self:GetText()) addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.YOffsetEditBoxOnEnter = function(self) character_target_settings.y_offset = tonumber(self:GetText()) addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.MainColorPickerOnClick = function() local settings = character_target_settings local function MainOnActionFunc(restore) local settings = character_target_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.main_r, settings.main_g, settings.main_b, settings.main_a = new_r, new_g, new_b, new_a addon_data.target.frame.main_bar:SetVertexColor( settings.main_r, settings.main_g, settings.main_b, settings.main_a) addon_data.target.config_frame.main_color_picker.foreground:SetColorTexture( settings.main_r, settings.main_g, settings.main_b, settings.main_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = MainOnActionFunc, MainOnActionFunc, MainOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.main_a ColorPickerFrame:SetColorRGB(settings.main_r, settings.main_g, settings.main_b) ColorPickerFrame.previousValues = {settings.main_r, settings.main_g, settings.main_b, settings.main_a} ColorPickerFrame:Show() end addon_data.target.MainTextColorPickerOnClick = function() local settings = character_target_settings local function MainTextOnActionFunc(restore) local settings = character_target_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a = new_r, new_g, new_b, new_a addon_data.target.frame.main_left_text:SetTextColor( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) addon_data.target.frame.main_right_text:SetTextColor( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) addon_data.target.config_frame.main_text_color_picker.foreground:SetColorTexture( settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = MainTextOnActionFunc, MainTextOnActionFunc, MainTextOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.main_text_a ColorPickerFrame:SetColorRGB(settings.main_text_r, settings.main_text_g, settings.main_text_b) ColorPickerFrame.previousValues = {settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a} ColorPickerFrame:Show() end addon_data.target.OffColorPickerOnClick = function() local settings = character_target_settings local function OffOnActionFunc(restore) local settings = character_target_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.off_r, settings.off_g, settings.off_b, settings.off_a = new_r, new_g, new_b, new_a addon_data.target.frame.off_bar:SetVertexColor( settings.off_r, settings.off_g, settings.off_b, settings.off_a) addon_data.target.config_frame.off_color_picker.foreground:SetColorTexture( settings.off_r, settings.off_g, settings.off_b, settings.off_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = OffOnActionFunc, OffOnActionFunc, OffOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.off_a ColorPickerFrame:SetColorRGB(settings.off_r, settings.off_g, settings.off_b) ColorPickerFrame.previousValues = {settings.off_r, settings.off_g, settings.off_b, settings.off_a} ColorPickerFrame:Show() end addon_data.target.OffTextColorPickerOnClick = function() local settings = character_target_settings local function OffTextOnActionFunc(restore) local settings = character_target_settings local new_r, new_g, new_b, new_a if restore then new_r, new_g, new_b, new_a = unpack(restore) else new_a, new_r, new_g, new_b = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() end settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a = new_r, new_g, new_b, new_a addon_data.target.frame.off_left_text:SetTextColor( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) addon_data.target.frame.off_right_text:SetTextColor( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) addon_data.target.config_frame.off_text_color_picker.foreground:SetColorTexture( settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a) end ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = OffTextOnActionFunc, OffTextOnActionFunc, OffTextOnActionFunc ColorPickerFrame.hasOpacity = true ColorPickerFrame.opacity = 1 - settings.off_text_a ColorPickerFrame:SetColorRGB(settings.off_text_r, settings.off_text_g, settings.off_text_b) ColorPickerFrame.previousValues = {settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a} ColorPickerFrame:Show() end addon_data.target.CombatAlphaOnValChange = function(self) character_target_settings.in_combat_alpha = tonumber(self:GetValue()) addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.OOCAlphaOnValChange = function(self) character_target_settings.ooc_alpha = tonumber(self:GetValue()) addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.BackplaneAlphaOnValChange = function(self) character_target_settings.backplane_alpha = tonumber(self:GetValue()) addon_data.target.UpdateVisualsOnSettingsChange() end addon_data.target.CreateConfigPanel = function(parent_panel) addon_data.target.config_frame = CreateFrame("Frame", addon_name .. "TargetConfigPanel", parent_panel) local panel = addon_data.target.config_frame local settings = character_target_settings -- Title Text panel.title_text = addon_data.config.TextFactory(panel, "Target Swing Bar Settings", 20) panel.title_text:SetPoint("TOPLEFT", 10, -10) panel.title_text:SetTextColor(1, 0.82, 0, 1) -- Enabled Checkbox panel.enabled_checkbox = addon_data.config.CheckBoxFactory( "TargetEnabledCheckBox", panel, " Enable", "Enables the target's swing bars.", addon_data.target.EnabledCheckBoxOnClick) panel.enabled_checkbox:SetPoint("TOPLEFT", 10, -40) -- Show Off-Hand Checkbox panel.show_offhand_checkbox = addon_data.config.CheckBoxFactory( "TargetShowOffHandCheckBox", panel, " Show Off-Hand", "Enables the target's off-hand swing bar.", addon_data.target.ShowOffHandCheckBoxOnClick) panel.show_offhand_checkbox:SetPoint("TOPLEFT", 10, -60) -- Show Border Checkbox panel.show_border_checkbox = addon_data.config.CheckBoxFactory( "TargetShowBorderCheckBox", panel, " Show border", "Enables the target bar's border.", addon_data.target.ShowBorderCheckBoxOnClick) panel.show_border_checkbox:SetPoint("TOPLEFT", 10, -80) -- Show Classic Bars Checkbox panel.classic_bars_checkbox = addon_data.config.CheckBoxFactory( "TargetClassicBarsCheckBox", panel, " Classic bars", "Enables the classic texture for the target's bars.", addon_data.target.ClassicBarsCheckBoxOnClick) panel.classic_bars_checkbox:SetPoint("TOPLEFT", 10, -100) -- Fill/Empty Checkbox panel.fill_empty_checkbox = addon_data.config.CheckBoxFactory( "TargetFillEmptyCheckBox", panel, " Fill / Empty", "Determines if the bar is full or empty when a swing is ready.", addon_data.target.FillEmptyCheckBoxOnClick) panel.fill_empty_checkbox:SetPoint("TOPLEFT", 10, -120) -- Show Left Text Checkbox panel.show_left_text_checkbox = addon_data.config.CheckBoxFactory( "TargetShowLeftTextCheckBox", panel, " Show Left Text", "Enables the target's left side text.", addon_data.target.ShowLeftTextCheckBoxOnClick) panel.show_left_text_checkbox:SetPoint("TOPLEFT", 10, -140) -- Show Right Text Checkbox panel.show_right_text_checkbox = addon_data.config.CheckBoxFactory( "TargetShowRightTextCheckBox", panel, " Show Right Text", "Enables the target's right side text.", addon_data.target.ShowRightTextCheckBoxOnClick) panel.show_right_text_checkbox:SetPoint("TOPLEFT", 10, -160) -- Width EditBox panel.width_editbox = addon_data.config.EditBoxFactory( "TargetWidthEditBox", panel, "Bar Width", 75, 25, addon_data.target.WidthEditBoxOnEnter) panel.width_editbox:SetPoint("TOPLEFT", 200, -60, "BOTTOMRIGHT", 275, -85) -- Height EditBox panel.height_editbox = addon_data.config.EditBoxFactory( "TargetHeightEditBox", panel, "Bar Height", 75, 25, addon_data.target.HeightEditBoxOnEnter) panel.height_editbox:SetPoint("TOPLEFT", 280, -60, "BOTTOMRIGHT", 355, -85) -- X Offset EditBox panel.x_offset_editbox = addon_data.config.EditBoxFactory( "TargetXOffsetEditBox", panel, "X Offset", 75, 25, addon_data.target.XOffsetEditBoxOnEnter) panel.x_offset_editbox:SetPoint("TOPLEFT", 200, -110, "BOTTOMRIGHT", 275, -135) -- Y Offset EditBox panel.y_offset_editbox = addon_data.config.EditBoxFactory( "TargetYOffsetEditBox", panel, "Y Offset", 75, 25, addon_data.target.YOffsetEditBoxOnEnter) panel.y_offset_editbox:SetPoint("TOPLEFT", 280, -110, "BOTTOMRIGHT", 355, -135) -- Main-hand color picker panel.main_color_picker = addon_data.config.color_picker_factory( 'TargetMainColorPicker', panel, settings.main_r, settings.main_g, settings.main_b, settings.main_a, 'Main-hand Bar Color', addon_data.target.MainColorPickerOnClick) panel.main_color_picker:SetPoint('TOPLEFT', 205, -150) -- Main-hand color text picker panel.main_text_color_picker = addon_data.config.color_picker_factory( 'TargetMainTextColorPicker', panel, settings.main_text_r, settings.main_text_g, settings.main_text_b, settings.main_text_a, 'Main-hand Bar Text Color', addon_data.target.MainTextColorPickerOnClick) panel.main_text_color_picker:SetPoint('TOPLEFT', 205, -170) -- Off-hand color picker panel.off_color_picker = addon_data.config.color_picker_factory( 'TargetOffColorPicker', panel, settings.off_r, settings.off_g, settings.off_b, settings.off_a, 'Off-hand Bar Color', addon_data.target.OffColorPickerOnClick) panel.off_color_picker:SetPoint('TOPLEFT', 205, -200) -- Off-hand color text picker panel.off_text_color_picker = addon_data.config.color_picker_factory( 'TargetOffTextColorPicker', panel, settings.off_text_r, settings.off_text_g, settings.off_text_b, settings.off_text_a, 'Off-hand Bar Text Color', addon_data.target.OffTextColorPickerOnClick) panel.off_text_color_picker:SetPoint('TOPLEFT', 205, -220) -- In Combat Alpha Slider panel.in_combat_alpha_slider = addon_data.config.SliderFactory( "TargetInCombatAlphaSlider", panel, "In Combat Alpha", 0, 1, 0.05, addon_data.target.CombatAlphaOnValChange) panel.in_combat_alpha_slider:SetPoint("TOPLEFT", 405, -60) -- Out Of Combat Alpha Slider panel.ooc_alpha_slider = addon_data.config.SliderFactory( "TargetOOCAlphaSlider", panel, "Out of Combat Alpha", 0, 1, 0.05, addon_data.target.OOCAlphaOnValChange) panel.ooc_alpha_slider:SetPoint("TOPLEFT", 405, -110) -- Backplane Alpha Slider panel.backplane_alpha_slider = addon_data.config.SliderFactory( "TargetBackplaneAlphaSlider", panel, "Backplane Alpha", 0, 1, 0.05, addon_data.target.BackplaneAlphaOnValChange) panel.backplane_alpha_slider:SetPoint("TOPLEFT", 405, -160) -- Return the final panel addon_data.target.UpdateConfigPanelValues() return panel end PK NX + WeaponSwingTimer/WeaponSwingTimer_Utils.lualocal addon_name, addon_data = ... addon_data.utils = {} -- Sends the given message to the chat frame with the addon name in front. addon_data.utils.PrintMsg = function(msg) chat_msg = "|cFF00FFB0" .. addon_name .. ": |r" .. msg DEFAULT_CHAT_FRAME:AddMessage(chat_msg) end -- Rounds the given number to the given step. -- If num was 1.17 and step was 0.1 then this would return 1.1 addon_data.utils.SimpleRound = function(num, step) return floor(num / step) * step end PK N| &