Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/GroupHeader.lua b/GroupHeader.lua
- index 502728e..9d75c86 100755
- --- a/GroupHeader.lua
- +++ b/GroupHeader.lua
- @@ -1,6 +1,5 @@
- local _G = _G
- local PitBull4 = _G.PitBull4
- -local mop_520 = select(4, GetBuildInfo()) >= 50200
- local DEBUG = PitBull4.DEBUG
- local expect = PitBull4.expect
- @@ -21,13 +20,16 @@ function PitBull4:MakeGroupHeader(group)
- if DEBUG then
- expect(group, 'typeof', 'string')
- end
- -
- +
- local group_db = PitBull4.db.profile.groups[group]
- - local pet_based = not not group_db.unit_group:match("pet") -- this feels dirty
- + local pet_based = group_db.unit_group:match("pet") and true
- + local group_based = group_db.unit_group:match("^party") or group_db.unit_group:match("^raid")
- local use_pet_header = pet_based and group_db.use_pet_header
- local header_name
- -
- - if use_pet_header then
- +
- + if not group_based then
- + header_name = "PitBull4_EnemyGroups_"..group
- + elseif use_pet_header then
- header_name = "PitBull4_PetGroups_" .. group
- else
- header_name = "PitBull4_Groups_" .. group
- @@ -36,18 +38,16 @@ function PitBull4:MakeGroupHeader(group)
- local header = _G[header_name]
- if not header then
- local template
- - if use_pet_header then
- - template = "SecureGroupPetHeaderTemplate"
- - else
- - template = "SecureGroupHeaderTemplate"
- + if group_based then
- + template = use_pet_header and "SecureGroupPetHeaderTemplate" or "SecureGroupHeaderTemplate"
- end
- header = CreateFrame("Frame", header_name, UIParent, template)
- header:Hide() -- it will be shown later and attributes being set won't cause lag
- -
- +
- header.name = group
- -
- header.group_db = group_db
- -
- + header.group_based = group_based
- +
- self:ConvertIntoGroupHeader(header)
- elseif header.group_db ~= group_db then
- -- If the frame already exists and the group_db doesn't already match the one
- @@ -73,6 +73,7 @@ function PitBull4:SwapGroupTemplate(group)
- local old_header = self.name_to_header[group]
- local group_db = PitBull4.db.profile.groups[group]
- + local group_based = group_db.unit_group:match("^party") or group_db.unit_group:match("^raid")
- if not group_db.enabled then
- return
- @@ -83,9 +84,11 @@ function PitBull4:SwapGroupTemplate(group)
- old_header:RefreshGroup()
- old_header:UpdateShownState()
- old_header:RecheckConfigMode()
- -
- +
- local new_name
- - if group_db.use_pet_header then
- + if not group_based then
- + new_name = "PitBull4_EnemyGroups_"..group
- + elseif group_db.use_pet_header then
- new_name = "PitBull4_PetGroups_"..group
- else
- new_name = "PitBull4_Groups_"..group
- @@ -270,6 +273,10 @@ function GroupHeader:RefixSizeAndPosition()
- self:Update()
- end
- + if not self.group_based then
- + -- reposition frames on the fake header
- + self:PositionMembers()
- + end
- self:ClearAllPoints()
- self:SetPoint(anchor, UIParent, "CENTER", group_db.position_x / scale + x_diff, group_db.position_y / scale + y_diff)
- @@ -347,9 +354,13 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
- local enabled = group_db.enabled
- local unit_group = group_db.unit_group
- local party_based = unit_group:sub(1, 5) == "party"
- + local group_based = party_based or unit_group:sub(1, 4) == "raid"
- local include_player = party_based and group_db.include_player
- local show_when = group_db.show_when
- - local show_solo = include_player and show_when.solo
- + local show_solo = show_when.solo
- + if group_based then
- + show_solo = include_player and show_solo
- + end
- local group_filter = not party_based and group_db.group_filter or nil
- local sort_direction = group_db.sort_direction
- local sort_method = group_db.sort_method
- @@ -359,13 +370,14 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
- if group_filter == "MAINTANK" then
- name_list = get_main_tank_name_list()
- end
- -
- - local changed_units = self.unit_group ~= unit_group or self.include_player ~= include_player or self.show_solo ~= show_solo or self.group_filter ~= group_filter or self.sort_direction ~= sort_direction or self.sort_method ~= sort_method or self.group_by ~= group_by or self.name_list ~= name_list
- -
- +
- + local changed_units = self.unit_group ~= unit_group or self.include_player ~= include_player or self.show_solo ~= show_solo or self.group_filter ~= group_filter or self.sort_direction ~= sort_direction or self.sort_method ~= sort_method or self.group_by ~= group_by or self.name_list ~= name_list or self.group_based ~= group_based
- +
- if changed_units then
- local old_unit_group = self.unit_group
- local old_super_unit_group = self.super_unit_group
- self.unit_group = unit_group
- + self.group_based = group_based
- self.include_player = include_player
- self.show_solo = show_solo
- self.group_filter = group_filter
- @@ -374,11 +386,9 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
- self.group_by = group_db.group_by
- self.name_list = name_list
- if DEBUG then
- - if not party_based then
- - expect(unit_group:sub(1, 4), '==', "raid")
- - end
- + expect(unit_group, 'typeof', 'string')
- end
- -
- +
- if party_based then
- self.super_unit_group = "party"
- self.unitsuffix = unit_group:sub(6)
- @@ -387,6 +397,14 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
- self:SetAttribute("showPlayer", include_player and true or nil)
- self:SetAttribute("showSolo", show_solo and true or nil)
- self:SetAttribute("groupFilter", nil)
- + elseif not group_based then
- + if unit_group:sub(1, 4) == "boss" then
- + self.super_unit_group = "boss"
- + self.unitsuffix = unit_group:sub(5)
- + elseif unit_group:sub(1, 5) == "arena" then
- + self.super_unit_group = "arena"
- + self.unitsuffix = unit_group:sub(6)
- + end
- else
- self.super_unit_group = "raid"
- self.unitsuffix = unit_group:sub(5)
- @@ -454,21 +472,23 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
- self:SetAttribute("startingIndex", 1)
- self:SetAttribute("columnAnchorPoint", DIRECTION_TO_COLUMN_ANCHOR_POINT[direction])
- self:SetAttribute("useOwnerUnit", 1)
- -
- - -- Set the attributes for the StateHeader to know when to show and hide this
- +
- + -- Set the attributes for the StateHeader to know when to show and hide this
- -- group
- for k,v in pairs(show_when) do
- - if k == "solo" then
- - self:SetAttribute(k, enabled and show_solo and party_based)
- - elseif k == "party" then
- - self:SetAttribute(k, enabled and v and party_based)
- - else
- - self:SetAttribute(k, enabled and v)
- + local value = enabled and v
- + if group_based then
- + if k == "solo" then
- + value = enabled and show_solo and party_based
- + elseif k == "party" then
- + value = value and party_based
- + end
- end
- + self:SetAttribute(k, value)
- end
- self:RefixSizeAndPosition()
- -
- +
- if is_shown then
- self:Show()
- end
- @@ -548,15 +568,15 @@ local function should_show_header(config_mode, header)
- if not config_mode then
- return false
- end
- -
- +
- if config_mode == "solo" then
- return header.show_solo
- end
- -
- - if config_mode == "party" and header.super_unit_group ~= "party" then
- +
- + if header.group_based and config_mode == "party" and header.super_unit_group ~= "party" then
- return false
- end
- -
- +
- return true
- end
- @@ -650,10 +670,27 @@ end
- -- utility function for ApplyConfigModeState, it doctors
- -- up some data so don't reuse this elsewhere
- local function get_group_roster_info(super_unit_group, index)
- - local unit, name, subgroup, class_name, role, _
- + local unit, name, subgroup, class_name, role, server, _
- if super_unit_group == "raid" then
- unit = "raid"..index
- name, _, subgroup, _, _, class_name, _, _, _, role = GetRaidRosterInfo(index)
- + elseif super_unit_group == "boss" then
- + unit = "boss"..index
- + if UnitExists(unit) then
- + name = UnitName(unit)
- + _, class_name = UnitClassBase(unit)
- + subgroup = 1
- + end
- + elseif super_unit_group == "arena" then
- + unit = "arena"..index
- + if UnitExists(unit) then
- + name, server = UnitName(unit)
- + if (server and server ~= "") then
- + name = name.."-"..server
- + end
- + _, class_name = UnitClass(unit)
- + subgroup = 1
- + end
- else
- if index > 0 then
- unit = "party"..index
- @@ -790,10 +827,11 @@ function GroupHeader:ApplyConfigModeState()
- return
- end
- - self:SetAttribute("_ignore",true)
- + local oldIgnore = self:SetAttribute("_ignore")
- + self:SetAttribute("_ignore", "applyConfigModeState")
- wipe(sorting_table)
- -
- +
- local super_unit_group = self.super_unit_group
- local config_mode = PitBull4.config_mode
- local start, finish, step = 1, self:GetMaxUnits(true), 1
- @@ -822,7 +860,7 @@ function GroupHeader:ApplyConfigModeState()
- -- filter by a list of group numbers and/or classes
- fill_table(wipe(token_table), strsplit(",", group_filter))
- - local strict_filter = self:GetAttribute("strictFiltering")
- + local strict_filtering = self:GetAttribute("strictFiltering")
- for i = start, finish, 1 do
- local unit, name, subgroup, class_name, role = get_group_roster_info(super_unit_group, i)
- @@ -875,7 +913,7 @@ function GroupHeader:ApplyConfigModeState()
- if sort_method == "NAME" then
- table.sort(sorting_table, sort_on_names)
- elseif sort_method == "NAMELIST" then
- - table.sort(sorting_table, sort_on_namelist)
- + table.sort(sorting_table, sort_on_name_list)
- end
- end
- @@ -951,7 +989,8 @@ function GroupHeader:ApplyConfigModeState()
- frame:SetPoint(column_anchor_point, current_anchor, column_anchor_point, 0, 0)
- end
- elseif column_unit_count == 1 then
- - local column_anchor = self:GetAttribute("child"..(frame_num - units_per_column))
- + local child_num = frame_num - units_per_column
- + local column_anchor = self[child_num]
- frame:SetPoint(column_anchor_point, column_anchor, column_rel_point, colx_multi * column_spacing, coly_multi * column_spacing)
- else
- frame:SetPoint(point, current_anchor, relative_point, x_multiplier * x_offset, y_multiplier * y_offset)
- @@ -967,7 +1006,7 @@ function GroupHeader:ApplyConfigModeState()
- current_anchor = frame
- end
- - self:SetAttribute("_ignore",nil)
- + self:SetAttribute("_ignore", oldIgnore)
- end
- GroupHeader.ApplyConfigModeState = PitBull4:OutOfCombatWrapper(GroupHeader.ApplyConfigModeState)
- @@ -1021,6 +1060,10 @@ function GroupHeader:GetMaxUnits(ignore_filters)
- -- Everything else we're gonna have to go by max.
- return MAX_RAID_MEMBERS
- + elseif self.super_unit_group == "boss" then
- + return MAX_BOSS_FRAMES
- + elseif self.super_unit_group == "arena" then
- + return MAX_PARTY_MEMBERS_WITH_PLAYER
- else
- if self.include_player then
- return MAX_PARTY_MEMBERS_WITH_PLAYER
- @@ -1049,7 +1092,9 @@ function GroupHeader:IterateMembers(guess_num)
- local num
- if guess_num then
- local config_mode = PitBull4.config_mode
- - if config_mode == "solo" then
- + if config_mode and not self.group_based then
- + num = 5
- + elseif config_mode == "solo" then
- num = self.include_player and 1 or 0
- elseif config_mode == "party" then
- num = self.include_player and MAX_PARTY_MEMBERS_WITH_PLAYER or MAX_PARTY_MEMBERS
- @@ -1141,13 +1186,21 @@ function GroupHeader:Rename(name)
- if self.name == name then
- return
- end
- -
- +
- local use_pet_header = self.group_db.use_pet_header
- - local prefix = use_pet_header and "PitBull4_PetGroups_" or "PitBull4_Groups_"
- + local group_based = self.group_db.group_based
- + local prefix
- + if not group_based then
- + prefix = "PitBull4_EnemyGroups_"
- + elseif use_pet_header then
- + prefix = "PitBull4_PetGroups_"
- + else
- + prefix = "PitBull4_Groups_"
- + end
- local old_header_name = prefix .. self.name
- local new_header_name = prefix .. name
- -
- +
- PitBull4.name_to_header[self.name] = nil
- PitBull4.name_to_header[name] = self
- _G[old_header_name] = nil
- @@ -1378,9 +1431,7 @@ local initialConfigFunction = [[
- header:CallMethod("InitialConfigFunction")
- end
- ]]
- -if not mop_520 then
- - initialConfigFunction = initialConfigFunction:gsub("togglemenu", "menu")
- -end
- +
- --- Add the proper functions and scripts to a SecureGroupHeaderTemplate or SecureGroupPetHeaderTemplate, as well as some initialization.
- -- @param frame a Frame which inherits from SecureGroupHeaderTemplate or SecureGroupPetHeaderTemplate
- @@ -1390,45 +1441,237 @@ function PitBull4:ConvertIntoGroupHeader(header)
- expect(header, 'typeof', 'frame')
- expect(header, 'frametype', 'Frame')
- end
- -
- - -- Stop the group header from listening to UNIT_NAME_UPDATE.
- - -- Allowing it to do so is a huge performance drain since the
- - -- GroupHeader's OnEvent updates the header regardless of the unit
- - -- passed in the argument. Many UNIT_NAME_UPDATE events can be
- - -- generated when zoning into battlegrounds, spirit rezes in
- - -- battlegrounds, pet rezes, etc. This should prevent some
- - -- stuttering isseus with BGs. See this post for more details:
- - -- http://forums.wowace.com/showthread.php?p=111494#post111494
- - self:UnregisterEvent("UNIT_NAME_UPDATE")
- self.all_headers[header] = true
- self.name_to_header[header.name] = header
- -
- +
- for k, v in pairs(GroupHeader__scripts) do
- header:HookScript(k, v)
- end
- -
- +
- for k, v in pairs(GroupHeader) do
- header[k] = v
- end
- - if ClickCastHeader then
- - SecureHandler_OnLoad(header)
- - header:SetFrameRef("clickcast_header", ClickCastHeader)
- - end
- -
- - -- this is done to pass self in properly
- - function header.initialConfigFunction(...)
- - return header:InitialConfigFunction(...)
- - end
- + if header.group_based then
- + -- Stop the group header from listening to UNIT_NAME_UPDATE.
- + -- Allowing it to do so is a huge performance drain since the
- + -- GroupHeader's OnEvent updates the header regardless of the unit
- + -- passed in the argument. Many UNIT_NAME_UPDATE events can be
- + -- generated when zoning into battlegrounds, spirit rezes in
- + -- battlegrounds, pet rezes, etc. This should prevent some
- + -- stuttering isseus with BGs. See this post for more details:
- + -- http://forums.wowace.com/showthread.php?p=111494#post111494
- + header:UnregisterEvent("UNIT_NAME_UPDATE")
- +
- + if ClickCastHeader then
- + SecureHandler_OnLoad(header)
- + header:SetFrameRef("clickcast_header", ClickCastHeader)
- + end
- +
- + -- this is done to pass self in properly
- + function header.initialConfigFunction(...)
- + return header:InitialConfigFunction(...)
- + end
- +
- + if header.group_db.unit_group:sub(1, 4) == "raid" then
- + header:SetAttribute("initialConfigFunction", initialConfigFunction:gsub("togglemenu", "menu"))
- + else
- + header:SetAttribute("initialConfigFunction", initialConfigFunction)
- + end
- - if header.group_db.unit_group:sub(1, 4) == "raid" then
- - header:SetAttribute("initialConfigFunction", initialConfigFunction:gsub("togglemenu", "menu"))
- else
- - header:SetAttribute("initialConfigFunction", initialConfigFunction)
- + -- set up our fake header for non party/raid group frames
- +
- + -- allow events to force an update
- + header:SetScript("OnEvent", function(self, event, arg1, ...)
- + if not self:IsVisible() or not self.group_db.enabled then return end
- +
- + if event == "UPDATE_BATTLEFIELD_STATUS" and GetBattlefieldStatus(arg1) ~= "active" then
- + return
- + elseif event == "UNIT_TARGETABLE_CHANGED" and not arg1:match(self.super_unit_group) then
- + return
- + end
- +
- + self:UpdateMembers()
- + end)
- +
- + -- set up the unit/unitsuffix and register update events
- + local unit_group = header.group_db.unit_group
- + if unit_group:sub(1, 4) == "boss" then
- + header.super_unit_group = "boss"
- + header.unitsuffix = unit_group:sub(5)
- +
- + header:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT")
- + header:RegisterEvent("UNIT_TARGETABLE_CHANGED")
- + elseif unit_group:sub(1, 5) == "arena" then
- + header.super_unit_group = "arena"
- + header.unitsuffix = unit_group:sub(6)
- +
- + header:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
- + end
- +
- + if header.unitsuffix == "" then
- + header.unitsuffix = nil
- + end
- + local unitsuffix = header.unitsuffix
- +
- + local frame_OnEvent = function(self, event, ...)
- + self:Update()
- + end
- +
- + for index = 1, header:GetMaxUnits(true) do
- + local unit = header.super_unit_group .. index -- want the base unit as "unit" before getting wacky in "unitsuffix" (seemed awkward to me)
- +
- + -- make a singleton unit frame and tack it onto our header
- + local frame_name = header:GetName() .. "UnitButton" .. index
- + local frame = _G[frame_name]
- + if not frame then
- + frame = CreateFrame("Button", frame_name, header, "SecureUnitButtonTemplate,SecureHandlerBaseTemplate,PitBull4_UnitTemplate_Clique")
- + frame:Hide()
- +
- + header[index] = frame
- + header:InitialConfigFunction()
- + frame:SetAttribute("*type1", "target")
- + frame:SetAttribute("*type2", "togglemenu")
- +
- + frame:SetAttribute("unit", unit)
- + frame:SetAttribute("unitsuffix", unitsuffix)
- +
- + frame:SetScript("OnEvent", frame_OnEvent)
- + frame:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
- + frame:RegisterUnitEvent("ARENA_OPPONENT_UPDATE", unit)
- +
- + frame:WrapScript(frame, "OnAttributeChanged", [[
- + if name == "config_mode" and self:GetAttribute("config_mode") then
- + self:Show()
- + end
- + ]])
- + end
- +
- + RegisterUnitWatch(frame)
- +
- + frame:RefreshLayout()
- +
- + frame:UpdateGUID(UnitGUID(frame.unit))
- + end
- end
- -
- +
- header:RefreshGroup(true)
- -
- +
- header:SetMovable(true)
- end
- +
- +
- +--- Position all the children of a fake group header.
- +-- duplicate code from SecureGroupHeader_Update IN TWO PLACES!
- +-- @usage header:PositionMembers()
- +function GroupHeader:PositionMembers()
- + if not self[1] then return end -- frames not set up (:SwapGroupTemplate from a disabled header)
- +
- + local oldIgnore = self:GetAttribute("_ignore")
- + self:SetAttribute("_ignore", "configureChildren")
- +
- + wipe(sorting_table)
- +
- + local start, finish, step = 1, self:GetMaxUnits(), 1
- + local super_unit_group = self.super_unit_group
- + for i = start, finish, step do
- + sorting_table[#sorting_table + 1] = super_unit_group .. i
- + end
- +
- + local point = self:GetAttribute("point") or "TOP"
- + local relative_point, x_offset_mult, y_offset_mult = get_relative_point_anchor(point)
- + local x_multiplier, y_multiplier = abs(x_offset_mult), abs(y_offset_mult)
- + local x_offset = self:GetAttribute("xOffset") or 0
- + local y_offset = self:GetAttribute("yOffset") or 0
- + local sort_dir = self:GetAttribute("sortDir") or "ASC"
- + local column_spacing = self:GetAttribute("columnSpacing") or 0
- + local units_per_column = self:GetAttribute("unitsPerColumn")
- + local num_displayed = #sorting_table
- + local num_columns
- + if units_per_column and num_displayed > units_per_column then
- + num_columns = min( ceil(num_displayed / units_per_column), (self:GetAttribute("maxColumns") or 1) )
- + else
- + units_per_column = num_displayed
- + num_columns = 1
- + end
- +
- + if sort_dir == "DESC" then
- + start, finish, step = finish, start, -1
- + end
- +
- + local column_anchor_point, column_rel_point, colx_multi, coly_multi
- + if num_columns > 1 then
- + column_anchor_point = self:GetAttribute("columnAnchorPoint")
- + column_rel_point, colx_multi, coly_multi = get_relative_point_anchor(column_anchor_point)
- + end
- +
- + local frame_num = 0
- + local column_num = 1
- + local column_unit_count = 0
- + local current_anchor = self
- + for i = start, finish, step do
- + frame_num = frame_num + 1
- + column_unit_count = column_unit_count + 1
- + if column_unit_count > units_per_column then
- + column_unit_count = 1
- + column_num = column_num + 1
- + end
- +
- + local frame = self[frame_num]
- + if not frame then
- + break
- + end
- + if frame_num == 1 then
- + frame:SetPoint(point, current_anchor, point, 0, 0)
- + if column_anchor_point then
- + frame:SetPoint(column_anchor_point, current_anchor, column_anchor_point, 0, 0)
- + end
- + elseif column_unit_count == 1 then
- + local column_anchor = self[frame_num - units_per_column]
- + frame:SetPoint(column_anchor_point, column_anchor, column_rel_point, colx_multi * column_spacing, coly_multi * column_spacing)
- + else
- + frame:SetPoint(point, current_anchor, relative_point, x_multiplier * x_offset, y_multiplier * y_offset)
- + end
- +
- + local old_unit = frame:GetAttribute("unit")
- + local unit = sorting_table[i]
- + frame:SetAttribute("unit", unit)
- + if old_unit ~= unit then
- + -- update our unit event references
- + frame:UnregisterEvent("UNIT_NAME_UPDATE")
- + frame:UnregisterEvent("ARENA_OPPONENT_UPDATE")
- + frame:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
- + frame:RegisterUnitEvent("ARENA_OPPONENT_UPDATE", unit)
- +
- + frame:Update()
- + end
- +
- + current_anchor = frame
- + end
- +
- + local frame_width = self[1]:GetWidth()
- + local frame_height = self[1]:GetHeight()
- + if num_displayed > 0 then
- + local width = x_multiplier * (units_per_column - 1) * frame_width + ( (units_per_column - 1) * (x_offset * x_offset_mult) ) + frame_width
- + local height = y_multiplier * (units_per_column - 1) * frame_height + ( (units_per_column - 1) * (y_offset * y_offset_mult) ) + frame_height
- +
- + if column_num > 1 then
- + width = width + ( (column_num - 1) * abs(colx_multi) * (width + column_spacing) )
- + height = height + ( (column_num - 1) * abs(coly_multi) * (height + column_spacing) )
- + end
- +
- + self:SetWidth(width)
- + self:SetHeight(height)
- + else
- + local min_width = self:GetAttribute("minWidth") or (y_multiplier * frame_width)
- + local min_height = self:GetAttribute("minHeight") or (x_multiplier * frame_height)
- + self:SetWidth( max(min_width, 0.1) )
- + self:SetHeight( max(min_height, 0.1) )
- + end
- +
- + self:SetAttribute("_ignore", oldIgnore)
- +end
- +GroupHeader.PositionMembers = PitBull4:OutOfCombatWrapper(GroupHeader.PositionMembers)
- +
- diff --git a/Main.lua b/Main.lua
- index 5bae7dd..5700893 100755
- --- a/Main.lua
- +++ b/Main.lua
- @@ -20,12 +20,21 @@ local UNIT_GROUPS = {
- "partypet",
- "partypettarget",
- "partypettargettarget",
- + "arena",
- + "arenatarget",
- + "arenatargettarget",
- + "arenapet",
- + "arenapettarget",
- + "arenapettargettarget",
- "raid",
- "raidtarget",
- "raidtargettarget",
- "raidpet",
- "raidpettarget",
- "raidpettargettarget",
- + "boss",
- + "bosstarget",
- + "bosstargettarget",
- }
- local NORMAL_UNITS = {
- @@ -39,9 +48,16 @@ for i = 1, MAX_PARTY_MEMBERS do
- NORMAL_UNITS[#NORMAL_UNITS+1] = "party" .. i
- NORMAL_UNITS[#NORMAL_UNITS+1] = "partypet" .. i
- end
- +for i = 1, 5 do
- + NORMAL_UNITS[#NORMAL_UNITS+1] = "arena" .. i
- + NORMAL_UNITS[#NORMAL_UNITS+1] = "arenapet" .. i
- +end
- for i = 1, MAX_RAID_MEMBERS do
- NORMAL_UNITS[#NORMAL_UNITS+1] = "raid" .. i
- end
- +for i = 1, MAX_BOSS_FRAMES do
- + NORMAL_UNITS[#NORMAL_UNITS+1] = "boss" .. i
- +end
- do
- local tmp = NORMAL_UNITS
- @@ -274,7 +290,6 @@ do
- end
- local wipe = _G.wipe
- -
- --- Delete a table, clearing it and putting it back into the queue
- -- @usage local t = PitBull4.new()
- -- t = del(t)
- @@ -863,7 +878,7 @@ end
- function PitBull4:IterateHeadersForSuperUnitGroup(super_unit_group)
- if DEBUG then
- expect(super_unit_group, 'typeof', 'string')
- - expect(super_unit_group, 'inset', 'party;raid')
- + expect(super_unit_group, 'inset', 'party;raid;boss;arena')
- end
- local headers = rawget(super_unit_group_to_headers, super_unit_group)
- @@ -1154,7 +1169,6 @@ do
- end
- local name = GetAddOnInfo(i)
- -
- -- must start with PitBull4_
- local module_name = name:match("^PitBull4_(.*)$")
- if not module_name then
- @@ -1279,7 +1293,7 @@ function PitBull4:OnProfileChanged()
- self.ClassOrder[#self.ClassOrder + 1] = v
- end
- end
- -
- +
- -- Notify modules that the profile has changed.
- for _, module in PitBull4:IterateEnabledModules() do
- if module.OnProfileChanged then
- diff --git a/Modules/HideBlizzard/HideBlizzard.lua b/Modules/HideBlizzard/HideBlizzard.lua
- index cdb3443..8f1a773 100755
- --- a/Modules/HideBlizzard/HideBlizzard.lua
- +++ b/Modules/HideBlizzard/HideBlizzard.lua
- @@ -21,6 +21,7 @@ PitBull4_HideBlizzard:SetDefaults({}, {
- aura = false,
- runebar = true,
- altpower = false,
- + boss = true,
- })
- function PitBull4_HideBlizzard:OnEnable()
- @@ -232,6 +233,26 @@ function showers:altpower()
- UnitPowerBarAlt_UpdateAll(PlayerPowerBarAlt)
- end
- +function hiders:boss()
- + for i=1, MAX_BOSS_FRAMES do
- + local frame = _G["Boss"..i.."TargetFrame"]
- + frame:UnregisterAllEvents()
- + frame:Hide()
- + end
- +end
- +
- +function showers:boss()
- + for i=1, MAX_BOSS_FRAMES do
- + local frame = _G["Boss"..i.."TargetFrame"]
- + if i == 1 then
- + BossTargetFrame_OnLoad(frame, "boss1", "INSTANCE_ENCOUNTER_ENGAGE_UNIT")
- + else
- + BossTargetFrame_OnLoad(frame, "boss"..i)
- + end
- + Target_Spellbar_OnEvent(frame.spellbar, "INSTANCE_ENCOUNTER_ENGAGE_UNIT")
- + end
- +end
- +
- for k, v in pairs(hiders) do
- hiders[k] = PitBull4:OutOfCombatWrapper(v)
- end
- @@ -323,5 +344,12 @@ PitBull4_HideBlizzard:SetGlobalOptionsFunction(function(self)
- get = get,
- set = set,
- hidden = hidden,
- + }, 'boss', {
- + type = 'toggle',
- + name = L["Boss"],
- + desc = L["Hides the standard boss frames."],
- + get = get,
- + set = set,
- + hidden = hidden,
- }
- end)
- diff --git a/Modules/LuaTexts/ScriptEnv.lua b/Modules/LuaTexts/ScriptEnv.lua
- index d6dd5e6..916b3ae 100755
- --- a/Modules/LuaTexts/ScriptEnv.lua
- +++ b/Modules/LuaTexts/ScriptEnv.lua
- @@ -53,6 +53,14 @@ setmetatable(UnitToLocale, {__index=function(self, unit)
- local num = unit:match("^party(%d)$")
- self[unit] = L["Party member #%d"]:format(num)
- return self[unit]
- + elseif unit:find("^arena%d$") then
- + local num = unit:match("^arena(%d)$")
- + self[unit] = L["Arena enemy #%d"]:format(num)
- + return self[unit]
- + elseif unit:find("^boss%d$") then
- + local num = unit:match("^boss(%d)$")
- + self[unit] = L["Boss #%d"]:format(num)
- + return self[unit]
- elseif unit:find("^raid%d%d?$") then
- local num = unit:match("^raid(%d%d?)$")
- self[unit] = L["Raid member #%d"]:format(num)
- @@ -61,6 +69,10 @@ setmetatable(UnitToLocale, {__index=function(self, unit)
- local num = unit:match("^partypet(%d)$")
- self[unit] = UnitToLocale["party" .. num .. "pet"]
- return self[unit]
- + elseif unit:find("^arenapet%d$") then
- + local num = unit:match("^arenapet(%d)$")
- + self[unit] = UnitToLocale["arena" .. num .. "pet"]
- + return self[unit]
- elseif unit:find("^raidpet%d%d?$") then
- local num = unit:match("^raidpet(%d%d?)$")
- self[unit] = UnitToLocale["raid" .. num .. "pet"]
- diff --git a/Options/Units.lua b/Options/Units.lua
- index 87267db..c69eb82 100755
- --- a/Options/Units.lua
- +++ b/Options/Units.lua
- @@ -367,7 +367,11 @@ function PitBull4.Options.get_unit_options()
- return t
- end,
- get = get,
- - set = set_with_refresh_group_shown,
- + set = function(info,value)
- + if set(info, value) then
- + PitBull4:SwapGroupTemplate(CURRENT_GROUP)
- + end
- + end,
- disabled = disabled,
- width = 'double',
- }
- @@ -615,6 +619,10 @@ function PitBull4.Options.get_unit_options()
- GROUP = L["By group"],
- }
- + local other_values = {
- + INDEX = L["By index"],
- + }
- +
- group_layout_args.sort_method = {
- name = L["Sort method"],
- desc = L["How to sort the frames within the group."],
- @@ -622,15 +630,17 @@ function PitBull4.Options.get_unit_options()
- order = next_order(),
- values = function(info)
- local unit_group = get_group_db().unit_group
- - if unit_group:sub(1, 5) == "party" then
- + if unit_group:sub(1, 4) == "raid" then
- + return raid_values
- + elseif unit_group:sub(1, 5) == "party" then
- return party_values
- else
- - return raid_values
- + return other_values
- end
- end,
- get = function(info)
- local db = get_group_db()
- - if db.unit_group:sub(1, 5) ~= "party" then
- + if db.unit_group:sub(1, 4) == "raid" then
- local group_by = db.group_by
- if group_by == "CLASS" or group_by == "GROUP" then
- return group_by
- @@ -774,7 +784,8 @@ function PitBull4.Options.get_unit_options()
- end,
- disabled = disabled,
- hidden = function(info)
- - return not get_group_db().unit_group:match("pet")
- + local unit_group = get_group_db().unit_group
- + return not unit_group:match("pet") or unit_group:match("^arena")
- end,
- }
- @@ -860,6 +871,7 @@ function PitBull4.Options.get_unit_options()
- type = 'multiselect',
- values = function(info)
- local unit_group = get_group_db().unit_group
- + local group_based = get_group_db().group_based
- local party_based = unit_group:sub(1, 5) == "party"
- @@ -871,6 +883,12 @@ function PitBull4.Options.get_unit_options()
- end
- t.party = L["Party"]
- end
- + if not group_based then
- + if unit_group:sub(1, 5) ~= "arena" then
- + t.solo = L["Solo"]
- + end
- + t.party = L["Party"]
- + end
- t.raid = L["5-man raid"]
- t.raid10 = L["10-man raid"]
- @@ -891,8 +909,8 @@ function PitBull4.Options.get_unit_options()
- db.show_when[key] = value
- - refresh_group('groups')
- for header in PitBull4:IterateHeadersForName(CURRENT_GROUP) do
- + header:RefreshGroup(true)
- header:UpdateShownState()
- end
- end,
- @@ -970,9 +988,9 @@ function PitBull4.Options.get_unit_options()
- local db = get_group_db()
- local unit_group = db.unit_group
- - local party_based = unit_group:sub(1, 5) == "party"
- + local raid_based = unit_group:sub(1, 4) == "raid"
- - return party_based -- only show in raid
- + return not raid_based -- only show in raid
- end
- }
- diff --git a/UnitFrame.lua b/UnitFrame.lua
- index 8177050..de0eabc 100755
- --- a/UnitFrame.lua
- +++ b/UnitFrame.lua
- @@ -5,8 +5,6 @@ local L = PitBull4.L
- local DEBUG = PitBull4.DEBUG
- local expect = PitBull4.expect
- -local mop_520 = select(4,GetBuildInfo()) >= 50200
- -
- -- CONSTANTS ----------------------------------------------------------------
- local MODULE_UPDATE_ORDER = {
- @@ -48,7 +46,7 @@ local Singleton_OnAttributeChanged = [[
- --- Make a singleton unit frame.
- -- @param unit the UnitID of the frame in question
- --- @usage local frame = PitBull4:MakeSingletonFrame("player")
- +-- @usage PitBull4:MakeSingletonFrame("player")
- function PitBull4:MakeSingletonFrame(unit)
- if DEBUG then
- expect(unit, 'typeof', 'string')
- @@ -199,40 +197,48 @@ end)
- local PitBull4_UnitFrame_DropDown = CreateFrame("Frame", "PitBull4_UnitFrame_DropDown", UIParent, "UIDropDownMenuTemplate")
- UnitPopupFrames[#UnitPopupFrames+1] = "PitBull4_UnitFrame_DropDown"
- --- from a unit, figure out the proper menu and, if appropriate, the corresponding ID
- +-- from a unit, figure out the proper menu and, if appropriate, the corresponding ID (updated from SECURE_ACTIONS.togglemenu)
- 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"
- + local unitType = string.match(unit, "^([a-z]+)[0-9]+$") or unit
- +
- + -- Mimic the default UI and prefer the relevant units menu when possible
- + local menu, id = "PLAYER", nil
- + if unitType == "raid" then
- + menu = "RAID"
- + elseif unitType == "party" then
- + menu = "PARTY"
- + elseif unitType == "boss" then
- + menu = "BOSS"
- + elseif unitType == "focus" then
- + menu = "FOCUS"
- + elseif unitType == "arenapet" or unitType == "arena" then
- + menu = "ARENAENEMY"
- + -- Then try and detect the unit type and show the most relevant menu we can find
- + elseif UnitIsUnit(unit, "player") then
- + menu = "SELF"
- + elseif UnitIsUnit(unit, "vehicle") then
- + menu = "VEHICLE"
- + elseif UnitIsUnit(unit, "pet") then
- + menu = "PET"
- + elseif UnitIsOtherPlayersBattlePet(unit) then
- + menu = "OTHERBATTLEPET"
- + elseif UnitIsOtherPlayersPet(unit) then
- + menu = "OTHERPET"
- + -- Last ditch checks
- + elseif UnitIsPlayer(unit) then
- + id = UnitInRaid(unit)
- + if ( id ) then
- + menu = "RAID_PLAYER"
- + elseif UnitInParty(unit) then
- + menu = "PARTY"
- + else
- + menu = "PLAYER"
- + end
- + elseif UnitIsUnit(unit, "target") then
- + menu = "TARGET"
- end
- - return "PLAYER"
- + return menu, id
- end
- local munged_unit_menus = {}
- @@ -565,7 +571,7 @@ function PitBull4:ConvertIntoUnitFrame(frame, isExampleFrame)
- if frame.is_singleton then
- frame:SetMovable(true)
- frame:SetAttribute("*type1", "target")
- - frame:SetAttribute("*type2", mop_520 and "togglemenu" or "menu")
- + frame:SetAttribute("*type2", "togglemenu")
- end
- frame:RegisterForDrag("LeftButton")
- frame:RegisterForClicks("AnyUp")
- @@ -802,7 +808,6 @@ function UnitFrame:Update(same_guid, update_layout)
- end
- local changed = update_layout
- -
- for _, module_type in ipairs(MODULE_UPDATE_ORDER) do
- for _, module in PitBull4:IterateModulesOfType(module_type) do
- changed = module:Update(self, true, same_guid) or changed
- diff --git a/Utils.lua b/Utils.lua
- index 6dd7148..00731e8 100755
- --- a/Utils.lua
- +++ b/Utils.lua
- @@ -89,6 +89,13 @@ do
- focus = true,
- target = true,
- }
- + for i = 1, 5 do
- + valid_singleton_unit_ids["arena" .. i] = true
- + valid_singleton_unit_ids["arenapet" .. i] = true
- + end
- + for i = 1, MAX_BOSS_FRAMES do
- + valid_singleton_unit_ids["boss" .. i] = true
- + end
- setmetatable(valid_singleton_unit_ids, target_same_mt)
- --- Return whether the UnitID provided is a singleton
- @@ -110,6 +117,11 @@ do
- partypet = true,
- raid = true,
- raidpet = true,
- + boss = true,
- + arena = true,
- + arenapet = true,
- + battleground = true,
- + battlegroundpet = true,
- }
- setmetatable(valid_classifications, target_same_mt)
- @@ -135,6 +147,11 @@ do
- partypet = true,
- raid = true,
- raidpet = true,
- + boss = true,
- + arena = true,
- + arenapet = true,
- + battleground = true,
- + battlegroundpet = true,
- }
- --- Return whether the classification provided is considered "wacky"
- @@ -157,10 +174,16 @@ do
- party_sing = L["Party"],
- partypet = L["Party pets"],
- partypet_sing = L["Party pet"],
- + arena = L["Arena"],
- + arena_sing = L["Arena"],
- + arenapet = L["Arena pets"],
- + arenapet_sing = L["Arena pet"],
- raid = L["Raid"],
- raid_sing = L["Raid"],
- raidpet = L["Raid pets"],
- raidpet_sing = L["Raid pet"],
- + boss = L["Boss"],
- + boss_sing = L["Boss"],
- mouseover = L["Mouse-over"],
- focus = L["Focus"],
- maintank = L["Main tanks"],
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement