mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-28 10:26:02 +00:00
unitframes: add 40y-rangecheck
This commit is contained in:
+43
@@ -1,6 +1,7 @@
|
||||
pfUI.api = { }
|
||||
pfUI.api._G = getfenv(0)
|
||||
local _G = getfenv(0)
|
||||
|
||||
-- [ strsplit ]
|
||||
-- Splits a string using a delimiter.
|
||||
-- 'delimiter' [string] characters that will be interpreted as delimiter
|
||||
@@ -14,6 +15,48 @@ function pfUI.api.strsplit(delimiter, subject)
|
||||
return unpack(fields)
|
||||
end
|
||||
|
||||
-- [ UnitInRange ]
|
||||
-- Returns whether a party/raid member is nearby. It uses spells with a distance of around 40 yards.
|
||||
-- unit [string] A unit to query (string, unitID)
|
||||
-- return: [bool] "1" if in range otherwise "nil"
|
||||
local RangeCache = {}
|
||||
function pfUI.api.UnitInRange(unit)
|
||||
if not UnitExists(unit) or not UnitIsVisible(unit) then
|
||||
return nil
|
||||
end
|
||||
|
||||
if CheckInteractDistance(unit, 4) then
|
||||
return 1
|
||||
else if not pfUI.rangecheck or not pfUI.rangecheck.slot then
|
||||
return nil
|
||||
else
|
||||
-- Extended Range Check
|
||||
if not RangeCache[unit] or RangeCache[unit].time + pfUI.rangecheck.interval < GetTime() then
|
||||
RangeCache[unit] = {}
|
||||
RangeCache[unit].time = GetTime()
|
||||
|
||||
local noswitch = true
|
||||
if not UnitIsUnit("target", unit) then
|
||||
TargetUnit(unit)
|
||||
noswitch = false
|
||||
end
|
||||
|
||||
if IsActionInRange(pfUI.rangecheck.slot) == 1 then
|
||||
RangeCache[unit].range = 1
|
||||
else
|
||||
RangeCache[unit].range = nil
|
||||
end
|
||||
|
||||
if not noswitch then
|
||||
TargetLastTarget()
|
||||
end
|
||||
end
|
||||
|
||||
return RangeCache[unit].range
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [ strvertical ]
|
||||
-- Creates vertical text using linebreaks. Multibyte char friendly.
|
||||
-- 'str' [string] String to columnize.
|
||||
|
||||
@@ -77,6 +77,8 @@ function pfUI:LoadConfig()
|
||||
pfUI:UpdateConfig("unitframes", nil, "portraitalpha", "0.1")
|
||||
pfUI:UpdateConfig("unitframes", nil, "portraittexture", "1")
|
||||
pfUI:UpdateConfig("unitframes", nil, "layout", "default")
|
||||
pfUI:UpdateConfig("unitframes", nil, "rangecheck", "0")
|
||||
pfUI:UpdateConfig("unitframes", nil, "rangechecki", ".5")
|
||||
|
||||
-- pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") -- TODO migrate, deprecated
|
||||
-- pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") -- TODO migrate, deprecated
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick)
|
||||
end
|
||||
|
||||
if this.config.faderange == "1" then
|
||||
if CheckInteractDistance(this.label .. this.id, 4) or not UnitName(this.label .. this.id) then
|
||||
if pfUI.api.UnitInRange(this.label .. this.id, 4) or not UnitName(this.label .. this.id) then
|
||||
if this:GetAlpha() ~= 1 then
|
||||
this:SetAlpha(1)
|
||||
if this.config.portrait == "bar" then
|
||||
|
||||
Vendored
+7
@@ -27,6 +27,13 @@ pfUI_locale["deDE"]["itemtypes"] = {
|
||||
["INVTYPE_THROWN"] = "Wurfwaffe",
|
||||
}
|
||||
|
||||
pfUI_locale["deDE"]["rangecheck"] = {
|
||||
['PALADIN'] = "Heiliges Licht",
|
||||
['PRIEST'] = "Blitzheilung",
|
||||
['DRUID'] = "Heilende Berührung",
|
||||
['SHAMAN'] = "Welle der Heilung",
|
||||
}
|
||||
|
||||
pfUI_locale["deDE"]["interrupts"] = {
|
||||
["Schildhieb"] = true;
|
||||
["Zuschlagen"] = true;
|
||||
|
||||
Vendored
+7
@@ -27,6 +27,13 @@ pfUI_locale["enUS"]["itemtypes"] = {
|
||||
["INVTYPE_THROWN"] = "Thrown",
|
||||
}
|
||||
|
||||
pfUI_locale["enUS"]["rangecheck"] = {
|
||||
['PALADIN'] = "Holy Light",
|
||||
['PRIEST'] = "Flash Heal",
|
||||
['DRUID'] = "Healing Touch",
|
||||
['SHAMAN'] = "Healing Wave",
|
||||
}
|
||||
|
||||
pfUI_locale["enUS"]["interrupts"] = {
|
||||
["Shield Bash"] = true;
|
||||
["Pummel"] = true;
|
||||
|
||||
Vendored
+7
@@ -27,6 +27,13 @@ pfUI_locale["frFR"]["itemtypes"] = {
|
||||
["INVTYPE_THROWN"] = "Arme de jet",
|
||||
}
|
||||
|
||||
pfUI_locale["frFR"]["rangecheck"] = {
|
||||
['PALADIN'] = "Lumière sacrée",
|
||||
['PRIEST'] = "Soins rapides",
|
||||
['DRUID'] = "Toucher guérisseur",
|
||||
['SHAMAN'] = "Vague de soins",
|
||||
}
|
||||
|
||||
pfUI_locale["frFR"]["interrupts"] = {
|
||||
["Coup de bouclier"] = true;
|
||||
["Volée de coups"] = true;
|
||||
|
||||
Vendored
+7
@@ -27,6 +27,13 @@ pfUI_locale["ruRU"]["itemtypes"] = {
|
||||
["INVTYPE_THROWN"] = "Метательное",
|
||||
}
|
||||
|
||||
pfUI_locale["ruRU"]["rangecheck"] = {
|
||||
['PALADIN'] = "Свет небес",
|
||||
['PRIEST'] = "Быстрое исцеление",
|
||||
['DRUID'] = "Целительное прикосновение",
|
||||
['SHAMAN'] = "Волна исцеления",
|
||||
}
|
||||
|
||||
pfUI_locale["ruRU"]["interrupts"] = {
|
||||
["Удар щитом"] = true;
|
||||
["Зуботычина"] = true;
|
||||
|
||||
Vendored
+7
@@ -27,6 +27,13 @@ pfUI_locale["zhCN"]["itemtypes"] = {
|
||||
["INVTYPE_THROWN"] = "投掷武器",
|
||||
}
|
||||
|
||||
pfUI_locale["zhCN"]["rangecheck"] = {
|
||||
['PALADIN'] = "圣光术",
|
||||
['PRIEST'] = "快速治疗",
|
||||
['DRUID'] = "治疗之触",
|
||||
['SHAMAN'] = "治疗波",
|
||||
}
|
||||
|
||||
pfUI_locale["zhCN"]["interrupts"] = {
|
||||
["盾击"] = true;
|
||||
["拳击"] = true;
|
||||
|
||||
@@ -864,6 +864,8 @@ pfUI:RegisterModule("gui", function ()
|
||||
pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Alpha", C.unitframes, "portraitalpha")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable 2D Portraits As Fallback", C.unitframes, "portraittexture", "checkbox")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.uf, "Unit Frame Layout", C.unitframes, "layout", "dropdown", { "default", "tukui" })
|
||||
pfUI.gui:CreateConfig(pfUI.gui.uf, "Aggressive 40y-Range Check (Will break stuff)", C.unitframes, "rangecheck", "checkbox")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.uf, "40y-Range Check Interval", C.unitframes, "rangechecki")
|
||||
|
||||
pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff- And Debuff Indicators", nil, nil, "header")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Hots as Buff Indicators", C.unitframes, "show_hots", "checkbox")
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
pfUI:RegisterModule("rangecheck", function ()
|
||||
local _,class = UnitClass("player")
|
||||
|
||||
if C.unitframes.rangecheck == "0" then return end
|
||||
|
||||
pfUI.rangecheck = CreateFrame("Frame", "pfRangecheck", UIParent)
|
||||
pfUI.rangecheck.scanner = CreateFrame("GameTooltip", "pfRangecheckScanner", UIParent, "GameTooltipTemplate")
|
||||
pfUI.rangecheck.scanner:SetOwner(pfUI.rangecheck, "ANCHOR_NONE")
|
||||
|
||||
pfUI.rangecheck.slot = nil
|
||||
pfUI.rangecheck.interval = C.unitframes.rangechecki
|
||||
|
||||
pfUI.rangecheck:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
|
||||
pfUI.rangecheck:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
pfUI.rangecheck:SetScript("OnEvent", function()
|
||||
pfUI.rangecheck.slot = nil
|
||||
|
||||
for i=1,120 do
|
||||
if pfUI.rangecheck.slot then return end
|
||||
|
||||
pfUI.rangecheck.scanner:ClearLines()
|
||||
pfUI.rangecheck.scanner:SetAction(i)
|
||||
|
||||
if pfRangecheckScannerTextLeft1 and pfRangecheckScannerTextLeft1:GetText() then
|
||||
if pfRangecheckScannerTextLeft1:GetText() == L["rangecheck"][class] then
|
||||
pfUI.rangecheck.slot = i
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user