From dc3c89b3adac44f56aef420e137dbce6a52c00ad Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 30 Dec 2016 05:36:40 +0100 Subject: [PATCH] hunterbar: add range based auto paging --- env/locales_deDE.lua | 5 +++++ env/locales_enUS.lua | 5 +++++ env/locales_frFR.lua | 5 +++++ env/locales_ruRU.lua | 5 +++++ env/locales_zhCN.lua | 5 +++++ modules/config.lua | 1 + modules/gui.lua | 2 ++ modules/hunterbar.lua | 48 +++++++++++++++++++++++++++++++++++++++++++ pfUI.lua | 1 + pfUI.toc | 1 + 10 files changed, 78 insertions(+) create mode 100644 modules/hunterbar.lua diff --git a/env/locales_deDE.lua b/env/locales_deDE.lua index b8be198c2..f6e767505 100644 --- a/env/locales_deDE.lua +++ b/env/locales_deDE.lua @@ -52,6 +52,11 @@ pfLocaleSpellInterrupts["deDE"] = { ["Erdschock"] = true; } +pfLocaleHunterbars["deDE"] = { + ["MELEE"] = "Raptorstoß", + ["RANGED"] = "Arkaner Schuss", +} + pfLocaleSpells["deDE"] = { ['Eisenherz nimmt wieder Huhngestalt an'] = {t=1000, icon="Ability_Racial_BearForm" }; ['Monstrositätenspucke'] = {t=2500, icon="Spell_Nature_CorrosiveBreath" }; diff --git a/env/locales_enUS.lua b/env/locales_enUS.lua index 67e0a58fc..0b6eb71be 100644 --- a/env/locales_enUS.lua +++ b/env/locales_enUS.lua @@ -52,6 +52,11 @@ pfLocaleSpellInterrupts["enUS"] = { ["Earth Shock"] = true; } +pfLocaleHunterbars["enUS"] = { + ["MELEE"] = "Raptor Strike", + ["RANGED"] = "Arcane Shot", +} + pfLocaleSpells["enUS"] = { ['"Plucky" Resumes Chicken Form'] = {t=1000, icon="Ability_Racial_BearForm" }; ['Abomination Spit'] = {t=2500, icon="Spell_Nature_CorrosiveBreath" }; diff --git a/env/locales_frFR.lua b/env/locales_frFR.lua index 9c773cbd3..b35a21c39 100644 --- a/env/locales_frFR.lua +++ b/env/locales_frFR.lua @@ -52,6 +52,11 @@ pfLocaleSpellInterrupts["frFR"] = { ["Horion de terre"] = true; } +pfLocaleHunterbars["frFR"] = { + ["MELEE"] = "Attaque du raptor", + ["RANGED"] = "Tir des Arcanes", +} + pfLocaleSpells["frFR"] = { ['Le Brave reprend sa forme de poulet'] = {t=1000, icon="Ability_Racial_BearForm" }; ['Crachat d\'abomination'] = {t=2500, icon="Spell_Nature_CorrosiveBreath" }; diff --git a/env/locales_ruRU.lua b/env/locales_ruRU.lua index bd08025b9..7cca6566f 100644 --- a/env/locales_ruRU.lua +++ b/env/locales_ruRU.lua @@ -52,6 +52,11 @@ pfLocaleSpellInterrupts["ruRU"] = { ["Земной шок"] = true; } +pfLocaleHunterbars["ruRU"] = { + ["MELEE"] = "Удар ящера", + ["RANGED"] = "Чародейский выстрел", +} + pfLocaleSpells["ruRU"] = { ['"Отчаянный" снова принимает облик цыпленка"'] = {t=1000, icon="Ability_Racial_BearForm" }; ['Плевок мясника'] = {t=2500, icon="Spell_Nature_CorrosiveBreath" }; diff --git a/env/locales_zhCN.lua b/env/locales_zhCN.lua index bfdcc1647..5d3a46127 100644 --- a/env/locales_zhCN.lua +++ b/env/locales_zhCN.lua @@ -52,6 +52,11 @@ pfLocaleSpellInterrupts["zhCN"] = { ["地震术"] = true; } +pfLocaleHunterbars["zhCN"] = { + ["MELEE"] = "猛禽一击", + ["RANGED"] = "奥术射击", +} + pfLocaleSpells["zhCN"] = { ['"Plucky" Resumes Chicken Form'] = {t=1000, icon="Ability_Racial_BearForm" }; ['憎恶喷吐'] = {t=2500, icon="Spell_Nature_CorrosiveBreath" }; diff --git a/modules/config.lua b/modules/config.lua index e7ef978b6..5805f77e2 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -89,6 +89,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("bars", nil, "background", "1") pfUI:UpdateConfig("bars", nil, "glowrange", "1") pfUI:UpdateConfig("bars", nil, "rangecolor", "1,0.1,0.1,1") + pfUI:UpdateConfig("bars", nil, "hunterbar", "1") pfUI:UpdateConfig("bars", nil, "hide_time", "1") pfUI:UpdateConfig("bars", nil, "hide_actionmain", "0") pfUI:UpdateConfig("bars", nil, "hide_bottomleft", "0") diff --git a/modules/gui.lua b/modules/gui.lua index 020d88461..c2e83e7a3 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -934,6 +934,8 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.bar, "Show actionbar backgrounds", pfUI_config.bars, "background", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Use colored icon as range indicator", pfUI_config.bars, "glowrange", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Range indicator Color", pfUI_config.bars, "rangecolor", "color") + pfUI.gui:CreateConfig(pfUI.gui.bar, "Range based auto paging (Hunter)", pfUI_config.bars, "hunterbar", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.bar, "Seconds to wait until hide bars", pfUI_config.bars, "hide_time") pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide main actionbar", pfUI_config.bars, "hide_actionmain", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide bottomleft actionbar", pfUI_config.bars, "hide_bottomleft", "checkbox") diff --git a/modules/hunterbar.lua b/modules/hunterbar.lua new file mode 100644 index 000000000..908657750 --- /dev/null +++ b/modules/hunterbar.lua @@ -0,0 +1,48 @@ +pfUI:RegisterModule("hunterbar", function () + local _,class = UnitClass("player") + if class ~= "HUNTER" or pfUI_config.bars.hunterbar == "0" then return end + + pfUI.hunterbar = CreateFrame("Frame", "pfHunterBar", UIParent) + pfUI.hunterbar.scanner = CreateFrame("GameTooltip", "pfHunterBarScanner", UIParent, "GameTooltipTemplate") + pfUI.hunterbar.scanner:SetOwner(pfUI.hunterbar, "ANCHOR_NONE") + + pfUI.hunterbar.melee = nil + pfUI.hunterbar.ranged = nil + pfUI.hunterbar.current = 1 + + pfUI.hunterbar:RegisterEvent("ACTIONBAR_SLOT_CHANGED") + pfUI.hunterbar:RegisterEvent("PLAYER_ENTERING_WORLD") + pfUI.hunterbar:SetScript("OnEvent", function() + for i=1,120 do + if pfUI.hunterbar.melee and pfUI.hunterbar.ranged then return end + + pfUI.hunterbar.scanner:ClearLines() + pfUI.hunterbar.scanner:SetAction(i) + if pfHunterBarScannerTextLeft1 then + if pfHunterBarScannerTextLeft1:GetText() == pfLocaleHunterbars[pfUI.cache["locale"]]["MELEE"] then + pfUI.hunterbar.melee = i + elseif pfHunterBarScannerTextLeft1:GetText() == pfLocaleHunterbars[pfUI.cache["locale"]]["RANGED"] then + pfUI.hunterbar.ranged = i + end + end + end + end) + + pfUI.hunterbar:SetScript("OnUpdate", function() + if not pfUI.hunterbar.melee or not pfUI.hunterbar.ranged then return end + + if IsActionInRange(pfUI.hunterbar.melee) == 1 and IsActionInRange(pfUI.hunterbar.ranged) == 0 then + if pfUI.hunterbar.current ~= 0 then + CURRENT_ACTIONBAR_PAGE = 9 + ChangeActionBarPage() + pfUI.hunterbar.current = 0 + end + else + if pfUI.hunterbar.current ~= 1 then + CURRENT_ACTIONBAR_PAGE = 1 + ChangeActionBarPage() + pfUI.hunterbar.current = 1 + end + end + end) +end) diff --git a/pfUI.lua b/pfUI.lua index da904e663..7520a7ff1 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -34,6 +34,7 @@ pfLocaleShift = {} pfLocaleSpells = {} pfLocaleSpellEvents = {} pfLocaleSpellInterrupts = {} +pfLocaleHunterbars = {} pfUI:SetScript("OnEvent", function() if arg1 == "pfUI" then diff --git a/pfUI.toc b/pfUI.toc index aeb63762e..47ace3b72 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -28,6 +28,7 @@ modules\gui.lua modules\pixelperfect.lua modules\hoverbind.lua modules\actionbar.lua +modules\hunterbar.lua modules\chat.lua modules\font.lua modules\addons.lua