mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- shamelessly ripped off code from pitbull4 to replace "set focus" with instructions on how to do so. begone, focus error reports!
This commit is contained in:
119
IceHUD.lua
119
IceHUD.lua
@ -1296,3 +1296,122 @@ function IceHUD:CreateCustomModuleAndNotify(moduleKey, settings)
|
||||
StaticPopup_Show(popupMsg)
|
||||
end
|
||||
end
|
||||
|
||||
local BLACKLISTED_UNIT_MENU_OPTIONS = {
|
||||
SET_FOCUS = "ICEHUD_SET_FOCUS",
|
||||
CLEAR_FOCUS = "ICEHUD_CLEAR_FOCUS",
|
||||
LOCK_FOCUS_FRAME = true,
|
||||
UNLOCK_FOCUS_FRAME = true,
|
||||
}
|
||||
|
||||
UnitPopupButtons["ICEHUD_SET_FOCUS"] = {
|
||||
text = L["Type %s to set focus"]:format(SLASH_FOCUS1),
|
||||
tooltipText = L["Blizzard currently does not provide a proper way to right-click focus with custom unit frames."],
|
||||
dist = 0,
|
||||
}
|
||||
|
||||
UnitPopupButtons["ICEHUD_CLEAR_FOCUS"] = {
|
||||
text = L["Type %s to clear focus"]:format(SLASH_CLEARFOCUS1),
|
||||
tooltipText = L["Blizzard currently does not provide a proper way to right-click focus with custom unit frames."],
|
||||
dist = 0,
|
||||
}
|
||||
|
||||
local munged_unit_menus = {}
|
||||
local function munge_unit_menu(menu)
|
||||
local result = munged_unit_menus[menu]
|
||||
if result then
|
||||
return result
|
||||
end
|
||||
|
||||
if not UnitPopupMenus then
|
||||
munged_unit_menus[menu] = menu
|
||||
return menu
|
||||
end
|
||||
|
||||
local data = UnitPopupMenus[menu]
|
||||
if not data then
|
||||
munged_unit_menus[menu] = menu
|
||||
return menu
|
||||
end
|
||||
|
||||
local found = false
|
||||
for _, v in ipairs(data) do
|
||||
if BLACKLISTED_UNIT_MENU_OPTIONS[v] then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not found then
|
||||
-- nothing to remove or add, we're all fine here.
|
||||
munged_unit_menus[menu] = menu
|
||||
return menu
|
||||
end
|
||||
|
||||
local new_data = {}
|
||||
for _, v in ipairs(data) do
|
||||
local blacklisted = BLACKLISTED_UNIT_MENU_OPTIONS[v]
|
||||
if not blacklisted then
|
||||
new_data[#new_data+1] = v
|
||||
elseif blacklisted ~= true then
|
||||
new_data[#new_data+1] = blacklisted
|
||||
end
|
||||
end
|
||||
local new_menu_name = "ICEHUD_" .. menu
|
||||
|
||||
UnitPopupMenus[new_menu_name] = new_data
|
||||
munged_unit_menus[menu] = new_menu_name
|
||||
return new_menu_name
|
||||
end
|
||||
IceHUD.MungeUnitMenu = munge_unit_menu
|
||||
|
||||
local function figure_unit_menu(unit)
|
||||
if unit == "focus" then
|
||||
return "FOCUS"
|
||||
end
|
||||
|
||||
if UnitIsUnit(unit, "player") then
|
||||
return "SELF"
|
||||
end
|
||||
|
||||
if UnitIsUnit(unit, "vehicle") then
|
||||
-- NOTE: vehicle check must come before pet check for accuracy's sake because
|
||||
-- a vehicle may also be considered your pet
|
||||
return "VEHICLE"
|
||||
end
|
||||
|
||||
if UnitIsUnit(unit, "pet") then
|
||||
return "PET"
|
||||
end
|
||||
|
||||
if not UnitIsPlayer(unit) then
|
||||
return "TARGET"
|
||||
end
|
||||
|
||||
local id = UnitInRaid(unit)
|
||||
if id then
|
||||
return "RAID_PLAYER", id
|
||||
end
|
||||
|
||||
if UnitInParty(unit) then
|
||||
return "PARTY"
|
||||
end
|
||||
|
||||
return "PLAYER"
|
||||
end
|
||||
|
||||
local IceHUD_UnitFrame_DropDown = CreateFrame("Frame", "IceHUD_UnitFrame_DropDown", UIParent, "UIDropDownMenuTemplate")
|
||||
UnitPopupFrames[#UnitPopupFrames+1] = "IceHUD_UnitFrame_DropDown"
|
||||
|
||||
IceHUD.DropdownUnit = nil
|
||||
UIDropDownMenu_Initialize(IceHUD_UnitFrame_DropDown, function()
|
||||
if not IceHUD.DropdownUnit then
|
||||
return
|
||||
end
|
||||
|
||||
local menu, id = figure_unit_menu(IceHUD.DropdownUnit)
|
||||
if menu then
|
||||
menu = IceHUD.MungeUnitMenu(menu)
|
||||
UnitPopup_ShowMenu(IceHUD_UnitFrame_DropDown, menu, IceHUD.DropdownUnit, nil, id)
|
||||
end
|
||||
end, "MENU", nil)
|
||||
|
@ -16,17 +16,5 @@ function PetInfo.prototype:GetDefaultSettings()
|
||||
return settings
|
||||
end
|
||||
|
||||
local function IcePetDropdown()
|
||||
ToggleDropDownMenu(1, nil, PetFrameDropDown, "cursor")
|
||||
end
|
||||
|
||||
function PetInfo.prototype:CreateFrame(redraw)
|
||||
PetInfo.super.prototype.CreateFrame(self, redraw)
|
||||
|
||||
if not self.frame.menu or self.frame.menu ~= IcePetDropdown then
|
||||
self.frame.menu = IcePetDropdown
|
||||
end
|
||||
end
|
||||
|
||||
-- Load us up
|
||||
IceHUD.PetInfo = PetInfo:new()
|
||||
|
@ -855,7 +855,8 @@ function PlayerHealth.prototype:CreateBackground(redraw)
|
||||
end
|
||||
|
||||
self.frame.button.menu = function()
|
||||
ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "cursor")
|
||||
IceHUD.DropdownUnit = self.unit
|
||||
ToggleDropDownMenu(1, nil, IceHUD_UnitFrame_DropDown, "cursor")
|
||||
end
|
||||
|
||||
self:EnableClickTargeting(self.moduleSettings.allowMouseInteraction)
|
||||
|
@ -51,18 +51,6 @@ function PlayerInfo.prototype:GetOptions()
|
||||
return opts
|
||||
end
|
||||
|
||||
local function IcePlayerDropdown()
|
||||
ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "cursor")
|
||||
end
|
||||
|
||||
function PlayerInfo.prototype:CreateFrame(redraw)
|
||||
PlayerInfo.super.prototype.CreateFrame(self, redraw)
|
||||
|
||||
if not self.frame.menu or self.frame.menu ~= IcePlayerDropdown then
|
||||
self.frame.menu = IcePlayerDropdown
|
||||
end
|
||||
end
|
||||
|
||||
StaticPopupDialogs["ICEHUD_BUFF_DISMISS_UNAVAILABLE"] =
|
||||
{
|
||||
text = "Sorry, but there is currently no way for custom mods to cancel buffs. This will be fixed whenever Blizzard fixes the API.",
|
||||
|
@ -702,7 +702,8 @@ function IceTargetHealth.prototype:CreateBackground(redraw)
|
||||
end
|
||||
|
||||
self.frame.button.menu = function()
|
||||
ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor");
|
||||
IceHUD.DropdownUnit = self.unit
|
||||
ToggleDropDownMenu(1, nil, IceHUD_UnitFrame_DropDown, "cursor")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -959,7 +959,8 @@ do -- OVERRIDE: IceTargetInfo.prototype:CreateFrame(redraw)
|
||||
|
||||
if not self.frame.menu then
|
||||
self.frame.menu = function()
|
||||
ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor")
|
||||
IceHUD.DropdownUnit = self.unit
|
||||
ToggleDropDownMenu(1, nil, IceHUD_UnitFrame_DropDown, "cursor")
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user